Boolean Functions#
Definition: Boolean Function
A Boolean function is a function which takes a tuple whose elements come from a set of two elements and outputs one of the elements of the same set.
Notation
Most commonly, the elements of such a set are denoted by \(0\) and \(1\). This means that Boolean functions are usually written in the following way:
Sometimes, the labels \(\mathrm{F}\) and \(\mathrm{T}\) may be used instead of \(0\) and \(1\) because Boolean algebra is used ubiquitously in propositional logic.
Definition: Off-Set
The off-set of \(f\) is the set of all inputs for which \(f\) outputs \(0\):
Definition: On-Set
The on-set of \(f\) is the set of all inputs for which \(f\) outputs \(1\):
Definition: Shannon Cofactors
The positive Shannon cofactor of \(f\) with respect to the \(i\)-th variable is the restriction of \(f\) to \(\{(x_1, \dotsc, x_{i-1}, 1, x_{i+1}, \dotsc, x_n) \mid x_k \in \{0,1\}\}\).
Notation
The negative Shannon cofactor of \(f\) with respect to the \(i\)-th variable is the restriction of \(f\) to \(\{(x_1, \dotsc, x_{i-1}, 0, x_{i+1}, \dotsc, x_n) \mid x_k \in \{0,1\}\}\).
Notation
Definition: Contradiction
A Boolean function \(f: \{0,1\}^n \to \{0,1\}\) is a contradiction or contradictory when \(f(x) = 0\) for all \(x \in \{0, 1\}^n\).
Definition: Tautology
A Boolean function \(f: \{0,1\}^n \to \{0,1\}\) is a tautology or tautological when \(f(x) = 1\) for all \(x \in \{0, 1\}^n\).
Definition: Dependence and Independence
Let \(f: \{0,1\}^n \to \{0,1\}\) be a Boolean function.
We say that \(f\) is:
- dependent on \(x_i\) if \(f(x_1, \dotsc, x_i, \dotsc, x_n) \ne f(x_1, \dotsc, \neg x_i, \dotsc, x_n)\);
- independent of \(x_i\) if \(f(x_1, \dotsc, x_i, \dotsc, x_n) = f(x_1, \dotsc, \neg x_i, \dotsc, x_n)\).
Definition: Boolean Vector Function
A Boolean vector function is a function which takes and outputs tuples whose elements come from the same set of two elements:
Tip
Every Boolean vector function \(f: \{0,1\}^m \to \{0,1\}^n\) is equivalent to \(n\) Boolean functions \(f_1, \dotsc, f_n: \{0,1\}^m \to \{0,1\}\).
Theorem: Cofactor Substitution
The Shannon cofactors of a Boolean function \(f: \{0,1\}^n \to \{0,1\}\) obey the following rules:
Proof
We need to prove four things:
- (1) \(x_i \land f = x_i \land f_{x_i}\).
- (2) \(\overline{x_i} \land f = \overline{x_i} \land f_{\overline{x_i}}\).
- (3) \(x_i \lor f = x_i \lor f_{\overline{x_i}}\).
- (4) \(\overline{x_i} \lor f = \overline{x_i} \lor f_{x_i}\).
Proof of (1):
If \(x_i = 0\), then the left-hand side is \(x_i \land f = 0 \land f = 0\). Similarly, the right-hand side is \(x_i \land f_{x_i} = 0 \land f_{x_i} = 0\). The left-hand side and right-hand side are therefore equal when \(x_i = 0\).
If \(x_i = 1\), then the left-hand side is \(x_i \land f = 1 \land f = f\). Similarly, the right-hand side is \(x_i \land f_{x_i} = 1 \land f_{x_i} = f_{x_i}\). However, in this case, \(f\) and \(f_{x_i}\) are the same by definition. The left-hand side and right-hand side are therefore equal when \(x_i = 1\).
We have thus shown that the law holds for all possible values of \(x_i\), i.e. it holds in general.
Proof of (2):
If \(x_i = 0\), then the left-hand side is \(\overline{x_i} \land f = 1 \land f = f\). Similarly, the right-hand side is \(\overline{x_i} \land f_{\overline{x_i}} = \overline{0} \land f_{\overline{x_i}} = 1 \land f_{\overline{x_i}} = f_{\overline{x_i}}\). However, in this case, \(f\) and \(f_{\overline{x_i}}\) are the same by definition. The left-hand side and right-hand side are therefore equal when \(x_i = 1\). The left-hand side and right-hand side are therefore equal when \(x_i = 0\).
If \(x_i = 1\), then the left-hand side is \(\overline{x_i} \land f = \overline{1} \land f = 0 \land f = 0\). Similarly, the right-hand side is \(\overline{x_i} \land f_{\overline{x_i}} = \overline{1} \land f_{\overline{x_i}} = 0 \land f_{\overline{x_i}} = 0\). The left-hand side and right-hand side are therefore equal when \(x_i = 1\).
We have thus shown that the law holds for all possible values of \(x_i\), i.e. it holds in general.
Proof of (3):
Analogous.
Proof of (4):
Analogous.
Boole's Expansion Theorem
If \(f_{x_i}\) and \(f_{\overline{x_i}}\) are the Shannon cofactors of a logical connective \(f: \{0,1\}^n \to \{0, 1\}\) with respect to the \(i\)-th variable, then:
Proof
We need to prove two things:
- (1) \(f = (x_i \land f_{x_i}) \lor (\overline{x_i} \land f_{\overline{x_i}})\).
- (2) \(f = (x_i \lor f_{\overline{x_i}}) \land (\overline{x_i} \lor f_{x_i})\).
Proof of (1): The following proof was generated by AI and has not been human-verified. As such, it may contain mistakes.
If \(x_i = 1\):
- The LHS becomes \(f(x_1, \dots, 1, \dots, x_n)\), which by definition is the cofactor \(f_{x_i}\).
- The RHS becomes \((1 \land f_{x_i}) \lor (\overline{1} \land f_{\overline{x_i}})\).
- Since \(\overline{1} = 0\), this simplifies to \((1 \land f_{x_i}) \lor (0 \land f_{\overline{x_i}})\).
- Using the identities \(1 \land A = A\) and \(0 \land B = 0\), we get \(f_{x_i} \lor 0\).
- Using the identity \(A \lor 0 = A\), the RHS simplifies to \(f_{x_i}\).
- Thus, for \(x_i=1\), LHS = RHS.
If \(x_i = 0\):
- The LHS becomes \(f(x_1, \dots, 0, \dots, x_n)\), which by definition is the cofactor \(f_{\overline{x_i}}\).
- The RHS becomes \((0 \land f_{x_i}) \lor (\overline{0} \land f_{\overline{x_i}})\).
- Since \(\overline{0} = 1\), this simplifies to \((0 \land f_{x_i}) \lor (1 \land f_{\overline{x_i}})\).
- Using the identities \(0 \land A = 0\) and \(1 \land B = B\), we get \(0 \lor f_{\overline{x_i}}\).
- Using the identity \(0 \lor B = B\), the RHS simplifies to \(f_{\overline{x_i}}\).
- Thus, for \(x_i=0\), LHS = RHS.
Since the equality holds for both possible values of \(x_i\), the identity is proven true for all inputs.
Proof of (2): The following proof was generated by AI and has not been human-verified. As such, it may contain mistakes..
If \(x_i = 1\):
- The LHS is again \(f(x_1, \dots, 1, \dots, x_n) = f_{x_i}\).
- The RHS becomes \((1 \lor f_{\overline{x_i}}) \land (\overline{1} \lor f_{x_i})\).
- Since \(\overline{1} = 0\), this simplifies to \((1 \lor f_{\overline{x_i}}) \land (0 \lor f_{x_i})\).
- Using the identities \(1 \lor A = 1\) and \(0 \lor B = B\), we get \(1 \land f_{x_i}\).
- Using the identity \(1 \land A = A\), the RHS simplifies to \(f_{x_i}\).
- Thus, for \(x_i=1\), LHS = RHS.
If \(x_i = 0\):
- The LHS is again \(f(x_1, \dots, 0, \dots, x_n) = f_{\overline{x_i}}\).
- The RHS becomes \((0 \lor f_{\overline{x_i}}) \land (\overline{0} \lor f_{x_i})\).
- Since \(\overline{0} = 1\), this simplifies to \((0 \lor f_{\overline{x_i}}) \land (1 \lor f_{x_i})\).
- Using the identities \(0 \lor A = A\) and \(1 \lor B = 1\), we get \(f_{\overline{x_i}} \land 1\).
- Using the identity \(A \land 1 = A\), the RHS simplifies to \(f_{\overline{x_i}}\).
- Thus, for \(x_i=0\), LHS = RHS.
Theorem: Function Equivalence
Two Boolean functions \(f, g: \{0,1\}^n \to \{0,1\}\) are the same if and only if the function
is tautological.
Proof
TODO
Canonical Conjunctive Normal Form#
Theorem: Canonical Conjunctive Normal Form
Every non-tautological Boolean function can be expressed as a conjunctive normal form of \(p\) maxterms, where \(p\) is the cardinality of \(f\)'s off-set.
Definition: Canonical Conjunctive Normal Form (CCNF)
Such an expression is known as a canonical conjunctive normal form (CCNF) of \(f\).
Proof
TODO
Algorithm: Finding CCNFs
We are given a Boolean function \(f: \{0,1\}^n \to \{0,1\}\):
-
Identify the off-set \(\overline{F}\) of \(f\).
-
For each \((x_1^{\ast}, \dotsc, x_n^{\ast}) \in \overline{F}\) construct the maxterm \(\mathop{\operatorname{OR}}(x_1', \dotsc, x_n')\), where
- \(x_k' = x_k\) if \(x_k^{\ast} = 0\);
- \(x_k' = \neg x_k\) if \(x_k^{\ast} = 1\).
- The conjunctive normal form of \(f\) is the conjunction of all the maxterms from step 2.
Example
The easiest way is to use the truth table of \(f\). Suppose \(f(x_1, x_2, x_3)\) has the following truth table:
| \(x_1\) | \(x_2\) | \(x_3\) | \(f(x_1, x_2, x_3)\) |
|---|---|---|---|
| \(0\) | \(0\) | \(0\) | \(0\) |
| \(0\) | \(0\) | \(1\) | \(1\) |
| \(0\) | \(1\) | \(0\) | \(1\) |
| \(0\) | \(1\) | \(1\) | \(1\) |
| \(1\) | \(0\) | \(0\) | \(0\) |
| \(1\) | \(0\) | \(1\) | \(0\) |
| \(1\) | \(1\) | \(0\) | \(1\) |
| \(1\) | \(1\) | \(1\) | \(0\) |
The off-set of \(f\) is easily determined by looking at the rows which contain \(0\) in the column for \(f(x_1, x_2, x_3)\). In this example, these rows are \(1\), \(5\), \(6\), and \(8\).
On row \(1\) we see that \(x_1\), \(x_2\) and \(x_3\) are all \(0\). We therefore construct the maxterm \(x_1 \lor x_2 \lor x_3\).
On row \(5\) we see that \(x_1\) is \(1\), while \(x_2\) and \(x_3\) are both \(0\). We therefore construct the maxterm \(\neg x_1 \lor x_2 \lor x_3\).
On row \(6\) we see that \(x_1\) and \(x_3\) are both \(1\), while \(x_2\) is \(0\). We therefore construct the maxterm \(\neg x_1 \lor x_2 \lor \neg x_3\).
On row \(6\) we see that \(x_1\), \(x_2\) and \(x_3\) are all \(1\). We therefore construct the maxterm \(\neg x_1 \lor \neg x_2 \neg \lor x_3\).
Finally, we build the conjunction of all maxterms:
Algorithm: CCNF to DNF
We are given the CNF of a Boolean function \(f: \{0,1\}^n \to \{0,1\}\) and want to find its DNF:
- Apply the distributive law for conjunction recursively, starting left to right.
- It may be possible to further simplify the resulting conjunctions in the DNF.
Example
TODO
Algorithm: CNF to CCNF
We are given a CNF of a Boolean function \(f: \{0,1\}^n \to \{0,1\}\) and want to find a CCNF:
- For each clause \(C_i\) and each variable \(x_j\):
- If \(C_i\) contains \(x_j\) or \(\overline{x}_j\), then do nothing.
- If \(C_i\) does not contain \(x_j\) or \(\overline{x}_j\), then replace it by the product \((C_i + x_j)(C_i + \overline{x_j})\).
- Recursively repeat the same process for each of the newly generated clauses, until you only have maxterms.
Canonical Disjunctive Normal Form#
Theorem: Canonical Disjunctive Normal Form (CDNF)
Every non-contradictory Boolean function \(f: \{0, 1\}^n \to \{0,1\}\) can be expressed as a disjunctive normal form of \(p\) minterms, where \(p\) is the cardinality of \(f\)'s on-set.
Definition: Canonical Disjunctive Normal Form
Such an expression is known as a canonical disjunctive normal form (CDNF) of \(f\).
Proof
TODO
Algorithm: Finding CDNFs
We are given a Boolean operator \(f: \{0,1\}^n \to \{0,1\}\):
-
Identify the on-set \(F\) of \(f\).
-
For each \((x_1^{\ast}, \dotsc, x_n^{\ast}) \in F\) construct the minterm \(\mathop{\operatorname{AND}}(x_1', \dotsc, x_n')\), where
- \(x_k' = x_k\) if \(x_k^{\ast} = 1\);
- \(x_k' = \neg x_k\) if \(x_k^{\ast} = 0\).
- The disjunctive normal form of \(f\) is the disjunction of all the minterms from step 2.
Example
The easiest way is to use the truth table of \(f\). Suppose \(f(x_1, x_2, x_3)\) has the following truth table:
| \(x_1\) | \(x_2\) | \(x_3\) | \(f(x_1, x_2, x_3)\) |
|---|---|---|---|
| \(0\) | \(0\) | \(0\) | \(0\) |
| \(0\) | \(0\) | \(1\) | \(1\) |
| \(0\) | \(1\) | \(0\) | \(1\) |
| \(0\) | \(1\) | \(1\) | \(1\) |
| \(1\) | \(0\) | \(0\) | \(0\) |
| \(1\) | \(0\) | \(1\) | \(0\) |
| \(1\) | \(1\) | \(0\) | \(1\) |
| \(1\) | \(1\) | \(1\) | \(0\) |
The on-set of \(f\) is easily determined by looking at the rows which contain \(1\) in the column for \(f(x_1, x_2, x_3)\). In this example, these rows are \(2\), \(3\), \(4\), and \(7\).
On row \(2\) we see that \(x_1\) and \(x_2\) are both \(0\), while \(x_3\) is \(1\). We therefore construct the minterm \(\neg x_1 \land \neg x_2 \land x_3\).
On row \(3\) we see that \(x_1\) and \(x_3\) are both \(0\), while \(x_2\) is \(1\). We therefore construct the minterm \(\neg x_1 \land x_2 \land \neg x_3\).
On row \(4\) we see that \(x_1\) is \(0\), while \(x_2\) and \(x_3\) are both \(1\). We therefore construct the minterm \(\neg x_1 \land x_2 \land x_3\).
On row \(7\), we see that \(x_1\) and \(x_2\) are both \(1\), while \(x_3\) is \(0\). We therefore construct the minterm \(x_1 \land x_2 \land \neg x_3\).
Finally, we build the disjunction of all minterms:
Algorithm: DNF to CNF
We are given a CCNF of a Boolean function \(f: \{0,1\}^n \to \{0,1\}\) and want to find its CNF:
- Apply the distributive law for disjunction recursively, starting left to right.
- It may be possible to further simplify the resulting disjunctions in the CNF.
Example
TODO
Algorithm: DNF to CDNF
We are given are given a DNF of a Boolean function \(f: \{0,1\}^n \to \{0,1\}\) and want to find a CDNF:
- For each product term \(P_i\) and each variable \(x_j\):
- If \(P_i\) contains \(x_j\) or \(\overline{x}_j\), then do nothing.
- If \(P_i\) does not contain \(x_j\) or \(\overline{x}_j\), then replace it with \(P_i x_j + P_i \overline{x_j}\).
- Recursively repeat the same process for the newly generated product terms until you have only minterms.
- If you have multiple identical minterms, then merge them into a single one.
- The result from step 2 is a CDNF of \(f\).
Example
Consider \(f(A, B, C) = A + \overline{B}C\).
The first is \(A\). We need to perform two expansions on it:
We also need to expand the each of the newly generated terms once:
We thus generated the following minterms: \(ABC\), \(AB\overline{C}\), \(A\overline{B}C\), \(A\overline{B}\overline{C}\).
Now, we do the same for the other original product term \(\overline{B}C\). We only need to expand it once:
We thus generated the following minterms: \(\overline{B}CA\) and \(\overline{B}C\overline{A}\).
To obtain a CDNF of \(f\), we sum all generated minterms:
We see that \(A\overline{B}C\) and \(\overline{B}CA\) are the same, so we just leave \(A\overline{B}C\):