Truth Tables A way to show Boolean Operations
Truth Tables A way to show Boolean Operations Creative Commons License - 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 Creative Commons License - Curt Hill
Example p q p q T T T F T F F T T F F F F T F p q Creative Commons License - Curt Hill ¬p q
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 Creative Commons License - 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 Creative Commons License - 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 Creative Commons License - Curt Hill
Table of Inputs p q T T T F F Creative Commons License - Curt Hill
(q p) p q q p T T F F F T F F Creative Commons License - Curt Hill
¬(q p) p q q p ¬(q p) T T T F F T F T F F F T Creative Commons License - Curt Hill
p ¬(q p) p q q p ¬(q p) p ¬(q p) T T T F F T T F F F T T Creative Commons License - Curt Hill
Discussion • A truth table column with all True is called a tautology • A truth table column with all False is called a contradiction • The problem with truth tables is the size: – 3 variables 8 rows – 4 variables 16 rows – 5 variables 32 rows Creative Commons License - Curt Hill
Example • Lets try a big one • (p r ¬s) ¬(q r) • How many rows should four variables have? Creative Commons License - 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? Creative Commons License - 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 Creative Commons License - Curt Hill
Example p q T T F F F T • 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 Creative Commons License - Curt Hill
Proofs • The truth table may be the basis of a proof • However, it is often quite cumbersome • One column for sub-expressions • An equivalence should end up with two columns the same • We will see this one in the next presentation p q q p Creative Commons License - Curt Hill
Finally • Most often we use truth tables to show a simple operation – Or a couple of operations • Most proofs require something more flexible – We will consider these later Creative Commons License - Curt Hill
- Slides: 17