W1013 Boolean Algebra
The branch of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0 respectively. It is a formal description of logical relations. It was introduced by George Boole in his first book The Mathematical Analysis of Logic in 1847.
Alternative names for true and false:
There are three basic operations, all of which have two inputs and one output.
- AND, formally termed conjunction and denoted by . The output is true iff (iff means if and only if) both inputs are true.
- OR, formally termed disjunction and denoted by . The output is true if either of the inputs are true. This is sometimes also referred to as inclusive disjunction. This is because the output is true if either of the inputs are true, including the case where both inputs are true.
- NOT, formally termed negation, and denoted by . The output is simply the opposite of the input.
There are also several "shortcut" notations that we can use for more succinct expressions:
- conjunction may be written as multiplication, i.e. or, more simply,
- disjunction may be written as addition, i.e.
- negation may be written with a bar above the variable, i.e.
All Boolean operations can be expressed through a composition of these basic operations.
- NAND is denoted by and is equivalent to the negation of the result of , i.e. . The output is true in all cases except when both A and B are true.
- NOR is denoted by and is equivalent to the negation of the result of , i.e. . The output is true only if both A and B are false.
- EQUAL, formally termed equivalence and denoted by . The output is true iff both inputs have the same value.
- XOR, formally termed exclusive disjunction and denoted by , , , . The output is true if either of the inputs are true but both are not true. Compare this to inclusive disjunction.
- IMPLY, formally termed material implication and denoted by . This is sometimes read as "if A then B" or "A implies B". The output is true in all cases except the case where A is true and B is false.
- CONVERSE IMPLY, formally termed converse implication and denoted by . This is sometimes read as "if B then A" or "B implies A". The output is true in all cases except the case where B is true and A is false.
- BIDIRECTIONAL IMPLY, formally termed material biconditional and denoted by . This is sometimes read as "A if and only if B" and abbreviated as "A iff B". It is logically equivalent to . The output is true if both A and B are true or if both A and B are false.
Order of Operations
Expressions with multiple operators are evaluated from left to right, respecting the operator precedence as follows:
- (NOT) has the highest priority, followed by
- (AND), (NAND)
- (OR), (NOR)
- (IMPLY), (CONVERSE IMPLY)
- , , , (XOR), , (EQUIV)
As always, parentheses may be used to both emphasize and override the order of operations.
For clarification, here are several examples of equivalent expressions:
|Without Parentheses||With Parentheses|
Truth tables provide us with a straightforward means to specify the required output(s) for the specified input(s), in table form. On the left-hand side of the table we enumerate the input(s) and on the right-hand side of the table we specify the output(s). Assuming that we have inputs we may label each input as . The value of the inputs on any given row, may be referred to as an input tuple. Likewise, assuming that we have outputs we may label each output as , and the value of these outputs on any given row may be referred to as an output tuple. The number of rows in any such table is given by the formula . When there is a single output, we can formalize the relationship as
Note that for convenience we sometimes label inputs as A, B, C, etc. rather than etc. and do the same for outputs, often beginning with the letter Q.
There are possible single-output Boolean functions that can be defined over inputs. These are enumerated, with explanations, in the following table.
|Function Name||Boolean Algebraic Formula||Truth Table||Explanation|
|AND||0||0||0||1||x and y are true|
|AND NOT||0||0||1||0||x is true and y is false|
|0||0||1||1||x is true, y is irrelevant|
|NOT AND||0||1||0||0||x is false and y is true|
|0||1||0||1||y is true, x is irrelevant|
|XOR||0||1||1||0||x is true or y is true but both are not true|
x is different than y
|OR||0||1||1||1||Either x or y is true|
|NOR||1||0||0||0||Neither x nor y is true|
|EQUIVALENCE||1||0||0||1||x is the same as y|
|NOT||1||0||1||0||y is false, x is irrelevant|
|IMPLYs||1||0||1||1||x is true or y is false|
|NOT||1||1||0||0||x is false, y is irrelevant|
|IMPLYs||1||1||0||1||y is true or x is false|
|NAND||1||1||1||0||x and y are not both true|
As discussed above, regardless of the function being implemented, each input and output combination can be represented by a single row in a truth table. Therefore, if we correctly represent each row, and then join those representations together, we'll be able to accurately recreate the function. There's a very straightforward means of doing so:
- For each output, we consider only those rows where the output value is true. We then form an expression representing all of the inputs for that same row, either the value of the input itself (if true) or its negation (if false), so that the result is true.
- We join each of the above expressions using disjunction.
Let's consider some examples:
The first step is to scan through each row and note each case where the output is true. In the case of conjunction, there is only one such row, row #4:
The expression representing the inputs for this row is simply , that is, the conjunction of and . Because there are no other rows for which the output is true, we're done. Thus, the canonical representation of is simply . Let's consider a slightly more challenging example:
Again, the first step is to scan through each row and note each case where the output is true. In the case of exclusive disjunction, there are two such rows: row #2 and row #3. The expression representing the inputs for these rows are for row #2 and for row #3. To complete the canonical representation, we combine the expression for each row with disjunction. Thus, the canonical representation of is .
Let's consider one final example, function f:
We note those rows in which the output is true: row #2, row #6, and row #7. The expressions representing the inputs for these rows are:
Combining these expressions with disjunction yields our canonical representation: .
De Morgan's Laws
De Morgan's Laws provide a helpful formula to obtain the same truth table of:
- an AND operation by using negation and an OR operation, or
- an OR operation by using negation and an AND operation
The Laws are: