Boolean functions and expressions
We consider Boolean functions and expressions. Circuits realizing boolean functions are the hardware basis
of modern computers. The next segment of the course introduces the ideas of computer hardware and
architecture.
Boolean functions
Boolean values in Scheme are #t and #f for true and false. In hardware, it is customary to use 1 for true
and 0 for false, so we will shift to that convention for this topic. A Boolean function is a function that takes
some fixed number of arguments, each of which may be 0 or 1, and returns a 0 or a 1 as its value.
For concreteness, we consider Boolean functions of two arguments. The domain of such a function is all
ordered pairs in which each element is either 0 or 1. Listed as a set, the domain is
{(0, 0), (0, 1), (1, 0), (1, 1)}.
We will display Boolean functions in truth tables giving every domain element and the value of the function
for that domain element. We’ll use (x * y) to denote the “and” function, true when both of its arguments
are true, and false otherwise. Its truth table is as follows.
x y | (x * y)
---------------
0 0 | 0
0 1 | 0
1 0 | 0
1 1 | 1
The “or” function, true when either or both of its arguments are true will be denoted (x + y), and has the
following truth table.
x y | (x + y)
---------------
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1
We’ll use the notation x’ for the “not” function, which has only one argument and is true when that argument
is false and false when that argument is true. Its truth table is as follows.
x | x’
---------------
0 | 1
1 | 0
Note that this truth table has only two lines because it displays the values of a function with only one
argument. Here is another truth table
x y | (x XOR y)
---------------
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 0
This function is the “exclusive or”, which is true when exactly one of its two arguments is true and the other
is false. Note that it differs from (x + y) when both x and y are 1.
How many two-argument Boolean functions are there? If we consider the possible tables of values, we
have:
x y | (x OP y)
---------------
0 0 | ?
0 1 | ?
1 0 | ?
1 1 | ?
Boolean expressions
We may combine constants, variables, and operators to get more complicated Boolean expressions.
We may combine constants, variables, and operators to get more complicated Boolean expressions.
Our definition of Boolean expressions is inductive.
1. 0 and 1 are Boolean expressions
2. Variables x, y, z, x1, y1, z1, . . . are Boolean expressions
3. If E is a Boolean expression, then (E)0
is a Boolean expression, the negation of E.
4. If E1 and E2 are Boolean expressions, then (E1 · E2) is a Boolean expression, the conjunction of E1
and E2.
5. If E1 and E2 are Boolean expressions, then (E1 + E2) is a Boolean expression, the disjunction of E1
and E2.
1. 0 and 1 are Boolean expressions
2. Variables x, y, z, x1, y1, z1, . . . are Boolean expressions
3. If E is a Boolean expression, then (E)0
is a Boolean expression, the negation of E.
4. If E1 and E2 are Boolean expressions, then (E1 · E2) is a Boolean expression, the conjunction of E1
and E2.
5. If E1 and E2 are Boolean expressions, then (E1 + E2) is a Boolean expression, the disjunction of E1
and E2.