This means that whenever we have a formula, we can always think of it as a function. This connection is really important. One immediate result is this: we have already discussed that a boolean function can be competely described by a table (we called it the "truth table" for the function), since there are only a finite number of input combinations. So if we have a formula $F$, that motivates us to consider the truth table for $F$, i.e. the truth table for the boolean function $F$ defines. Here are some examples:
| $F_1 := \neg(a \vee b)$ | Truth table for $F_1$ | $F_2 := a\wedge b \vee \neg a \wedge \neg b$ | Truth table for $F_2$ |
|---|---|---|---|
| $F_3 := a \oplus b \Rightarrow a$ | Truth table for $F_3$ | $F_4 := a \oplus b \Rightarrow (a\vee c)$ | Truth table for $F_4$ |
|---|---|---|---|
ACTIVITY
Important: Truth tables are kind of a big deal!
Every propositional formula defines a boolean function, and every boolean function is defined by a propositional formula.We shouldn't take this for granted! In other contexts, analogous statements are not true. For example, what about functions that take a single real number as input and produce a single real number as output? Is it true that each of these is defined by a formula? Perhaps we are given a function $f$ and it is indeed defined by a formula, like: $$ f(x) = 3x^2 - \sin(x -1) + e^{-x} $$ But do all functions with a single real input and a single real output have such formulas? The answer is "no"! So we should be excited that for boolean functions and propositional functions, the answer is "yes"!
How could we go about convincing someone that for any boolean function, no matter how weird, there is always a propositional formula that defines that function? Well ... if I had a specific function in mind (like G1 from the previous activity), how would you prove to me that there is propositional formula that defines that function? You would produce such a formula, of course! What about G2? Same thing. So:
| helper function $l(\cdot,\cdot)$ | helper function $c(\cdot)$ |
|
If $i$ is a number in the range $1,\ldots,n$, where the function $f$ we are interested in has $n$ inputs, and $b$ is a boolean value: $l(i,b) = \left\{ \begin{array}{c,l} x_i & \mbox{if $b =$ true}\\ \neg x_i & \mbox{if $b =$ false}\\ \end{array} \right.$ |
If $r$ is row
$\begin{array}{cccccc}
x_1 & x_2 & \ldots & x_n & f &\\
\hline
\vdots &\vdots & \vdots & \vdots &\\
b_1 & b_2 & \ldots & b_n & b
\end{array}
$
in the
truth table for $f$ then:
$c(r) = l(1,b_1) \wedge l(2,b_2) \wedge \cdots \wedge l(n,b_n)$ |
Algorithm
Input: the truth table $T$ for boolean function $f$ with $n$ inputs
Output: a propositional formula $F$ in $x_1,\ldots,x_n$ that defines function
$f$
Step 1 doesn't apply, so we go on to Step 2. The rows of $T$ that have output value true are row 1, row 3 and row 4. So ...
and, finally, the output $c(r_{i_1}) \vee c(r_{i_2}) \vee \cdots \vee c(r_{i_k})$ is $F := (\neg x_1 \wedge \neg x_2) \vee (x_1 \wedge \neg x_2) \vee (x_1 \wedge x_2)$.
Hopefully what you see is that the formula literally says that the variable assignments have to match one of the truth table rows with a true output value.
It's important to note that formula produced by the algorithm from the Theorem is not the only formula defining the input function. There are many such formulas. In fact, the formula produced by the algorithm is seldom a very concise, simple or interesting defining formula. However, it's enough to show that a formula exists!
ACTIVITY
write down the formula the algorithm from the proof would produce for $f$.
a=false, b=false ... E1 is true, E2 is true ✓
a=false, b=true ... E1 is true, E2 is true ✓
a=true, b=false ... E1 is true, E2 is true ✓
a=true, b=false ... E1 is true, E2 is true ✓
a=true, b=true ... E1 is true, E2 is true ✓
This approach (i.e. explicitly & separately checking all possible cases of something) is
called proof by exhaustion. Presumably you won't need
me to explain why!
Of course, another way of looking at this is to say that $F_1$
and $F_2$ are equivalent if their truth tables are the same.