Copyright © Curt Hill Truth Tables A way to show Boolean Operations
Copyright © Curt Hill Definition A table that contains the output of a function for every possible input A unary function may only have two possible inputs so needs only two rows A binary function has four
Copyright © Curt Hill Example p q T T T T F F F F p q T T T FF F F T p qp q T T T F ¬p q T F F F
Copyright © Curt Hill Uses We use truth tables to define our functions –Then they have one column for each input and one column for output We also use them to construct our complicated functions
Copyright © Curt Hill Construction of Complicated Truth Tables For the most part we can write down simple conjunction and disjunction functions Larger functions turn out to be harder We just create separate columns for the smaller parts Thus our table is created left to right
Copyright © Curt Hill Consider p ¬(q p) First write the table of inputs Next write q p Then ¬(q p) –Use the previous column as input Finally the whole expression –Use the last column and the p as inputs
Copyright © Curt Hill Table of Inputs p q T T T T F F F F
Copyright © Curt Hill (q p) p q T T T T F F F FF F F T q p
Copyright © Curt Hill ¬(q p) p q T T T T F F F FF F F T q p¬(q p) F T T T
Copyright © Curt Hill p ¬(q p) p q T T T T F F F FF F F T q p¬(q p) F T T T p ¬(q p) T T T T
Copyright © Curt Hill Discussion A truth table column with all True is called a tautology A truth table column with all False is a contradiction The problem with truth tables is the size: –3 variables 8 rows –4 variables 16 rows –5 variables 32 rows
Example Lets try a big one on the board (p r ¬s) ¬(q r) Copyright © Curt Hill
Generation Generating a truth table from an expression may be tedious but certainly possible What about the reverse? Suppose we have a truth table and we would like the logical expression: how is this done? Copyright © Curt Hill
Finding the expression Look only at rows that have a true for the expression Create an expression for each variable in the row –The expression is just the variable if the variable is true –The expression is negated if false –All of these are ANDed together Or the resulting expressions Copyright © Curt Hill
Example Two rows have trues First row needs q p Last row needs ¬q ¬p Final expression is (q p) (¬q ¬p) This could be simplified, but it is a start Copyright © Curt Hill p q T T T T F F F FT F F T
One more Lets try this on a four variable On the board Copyright © Curt Hill
Proofs The truth table may be the basis of a proof It is often quite cumbersome One column for sub-expressions An equivalence should end up with two columns the same Let try the converse p q q p What we want are two different columns Copyright © Curt Hill