Program: Truth Tables Version 2.0
Platform: HP48G, G+, or GX
Programmer: MacDonald R. Phillips
Email: mrp100@erols.com 
       phillipsm.ggd@gao.gov 

This program is designed to construct and display or print truth tables for 1 to 9 variables and any logical expression based on those variables.

What's New - Version 2.0

I added the ability to use material implication and material equivalence directly with the logical functions P->Q and P<->Q.  The truth tables are now displayed or printed with Ts and Fs for true and false instead of 1s and 0s.

What's New - Version 1.1

I corrected a programming error in the use of variables.  Using the letters V or N as logical variables caused conflicts with other variables, also named V and N by the stupid programmer, causing the program to "blow up."  I also added an error checking routine to be sure that all variables used in a logical expression are also in the variables list.  If not, an "Uninitiated variables" message appears.

Using the Program

Load the program TRTBL to your calculator in binary mode.  A directory will be created called TRTBL.  Enter the directory and press TRTBL to set up the custom menu.

To construct truth tables you need a list of variables and a logical expression.  The first soft key, VARS, is for entering a list of variables.  (I find it best to use single, capital letters for the variables so there will be no conflict with the variables the program routines are stored in.)  Press VARS and you will be prompted to enter the variables in the list on the command line.  The calculator is automatically put in alpha mode, so just enter the letters one by one with a space between them.  When the list is complete, press ENTER and the table will be constructed.  You may use up to 9 different variables.  This will produce, however, a truth table of 512 lines (2^9).

After the table is constructed, enter a logical expression to be evaluated.  Press EXPR and you will be prompted to enter an expression.  The logic keys (AND, OR, XOR, NOT, P->Q, and P<->Q) are available to aid in entering the expression.  Since the calculator is not in alpha mode, the alpha key must be pressed before entering each variable.  When you are done entering the expression, press ENTER and it will be stored.

Logical expressions can be of any length and complexity; however, they must be constructed of _only_ the variables entered in the variables list, although not all the variables need be used.  The logical expression can be changed without changing the variables list as long as the new expression is made from _only_ the variables in the list.  In this way logical arguments as well as expressions can be evaluated.

The truth table can be displayed, six lines at a time, by pressing TRTBL.  If there are more than six lines in the table, press CONT to display them.  To stop the display of additional lines and return to the menu, press KILL.
Press PRINT to print the entire truth table, if you have an HP infrared printer.  A date and time stamp will be printed for each truth table.  Your name will also be printed, if you enter your name, as a string, and press NAME, which is next to the TRTBL key. This stores it permanently for future printing.

Example:

Press VARS
In the empty list { } that appears on the stack, enter P Q and then press ENTER.  You do not have to put the calculator in alpha mode; just press the appropriate letters followed by the SPC key (for space).  By pressing left-shift (LS) VARS, the current list of variables is recalled to the stack.

Press EXPR
In the empty quotes ' ' that appear on the stack, enter NOT P OR Q and press ENTER.  Since the calculator is _not_ in alpha mode here, the alpha key must be hit before hitting the P or Q keys.  By pressing LS EXPR, the current expression is recalled to the stack.

Press TRTBL to display the output.

 P Q             EXP
 T T              T
 T F              F
 F T              T
 F F              T


The expression just evaluated, NOT P OR Q, represents material implication which is expressed in logic textbooks as P -> Q and has the meaning, IF P, THEN Q.  You may also use the P->Q function in the list of logical functions.  This is entered as 'P->Q(P,Q)'.  Press LS (left-shift) ( ) to enter the brackets.

Material equivalence, P <-> Q, which has the meaning, P IF AND ONLY IF Q, can be expressed as NOT(P XOR Q) on the HP48 or the function 'P<->Q(P,Q)'.

Logical arguments can also be evaluated with truth tables.  For example:

P -> Q
Q -> R  /:. P -> R

This argument is composed of two premises and a conclusion.  It has three variables.

Press VARS and enter the variables { P Q R }.

Enter the premises and conclusion one at a time and press TRTBL.

1. NOT P OR Q
2. NOT Q OR R
3. NOT P OR R

All of the truth tables, when put together, will look like this.

  P Q R    |  P -> Q   Q -> R   P -> R
  T T T    |    T       T        T
  T T F    |    T       F        F
  T F T    |    F       T        T
  T F F    |    F       T        F
  F T T    |    T       T        T
  F T F    |    T       F        T
  F F T    |    T       T        T
  F F F    |    T       T        T

An argument is valid if for those cases where the conclusion is false, all of the premises are not true.  That is, for this case, where P -> R is F, not both P -> Q and Q -> R are T.  In plain English, an argument is valid when true premises do not yield a false conclusion.  The above argument is therefore valid.

Since an argument is basically an IF THEN statement, the preceding argument can be expressed as 'P->Q(P->Q(P,Q)AND P->Q(Q,R),P->Q(P,R))'.  In English, if(if p then q and if q then r) then (if p then r).  When this single expression is evaluated, all the values under EXP will be T, which means that the argument is a tautology, i.e., it is always a true and valid argument.

If you like this program, please sent me an email message.  It's nice to hear from people who find your work useful.
