### Module 5 Section 1- Basic Logic Operations and Truth Tables

Recall that one of the uses for a bit is to represent whether a condition is FALSE (0) or TRUE (1). When used in this manner, the bit is said to represent a Boolean (BOO-lee-uhn) or logical value.

The word Boolean comes from the name George Boole (1815-1864), a famous British mathematician. Boole reduced logic to a simple algebra. He also worked on differential equations, the calculus of finite differences and general methods in probability. We will be studying Boolean algebra in this module.

Suppose we have a bit which is TRUE if the floor is painted green and FALSE if the floor is not painted green. We could give this bit a name, such as the letter G. We could also have a bit, Y, which is true if the sofa is yellow. Finally, we could have a bit named B which is true if someone decorates in bad taste. The values of G and Y are dictated by the actual colors of the floor and the sofa. The value for B could be determined by the values of G and Y. Let us say that a person has "bad taste" if they put a yellow sofa on a green floor. Then we could define B as follows:

B is TRUE if G is TRUE and if Y is TRUE

In Boolean notation, we would write

B=GY

The above is not a mathematical equality as much as it is a statement of computation: "B is TRUE if G is TRUE and Y is TRUE."  It is actually more correct to write the above as

B GY

which would be read as "B is implied by GY" or "GY implies B." However, computer scientists usually use the notation B=GY with the understanding that it is a one-way right-to-left implication.  This convention arises from the use of programming languages such as C, BASIC, and FORTRAN in which the '=' symbol is an assignment operator which assigns the value of the expression on the right side of the '=' to the variable on the left side of the '='.

The letters B, G, and Y are called variables because we don't know their values when we look at an expression like the one above. We know that they can take on the values of FALSE and TRUE. We also know that B's value will be determined once we know the values for G and Y. The variables G and Y are free or independent because their values are unknown. The variable B is computed or dependent because, once the free variables are given values, B's will then be known (computed). In other words, B is dependent on G and Y.

Boolean variables can be combined in several ways to form interesting statements which relate known facts. For example, the expression above combines G and Y to determine if someone has good or bad taste. The particular combination GY is called conjunction or and. The conjunction of two Boolean values written AB (read A and B) is TRUE if and only if both A and B are TRUE.

Another common way to combine two Boolean values is called disjunction or or. The disjunction of two values, written as A+B (read A or B) is TRUE if and only if at least one of the values is TRUE. So, G+Y would be true if the floor is green, or if the sofa is yellow, or both.

The third and last of the basic Boolean operations is complementation or not. Unlike conjunction and disjunction which are applied to two Boolean values, complementation is applied to a single Boolean value, reversing its value. Written as , (read not A) is TRUE if and only if A is FALSE.

A convenient and unambiguous way to represent how the operators and, or and not work in all possible cases is to give a table which shows, for all possible value assignments of free variables, what the computed variables' values will be. Such a table is called a truth table. Below are the truth tables for conjunction (and), disjunction (or), and complementation (not). Each column of the table represents the Boolean value for the expression shown at the top of the column. To make them stick out in this example (and in other examples you will see) the free variable columns are shown in red. (You would normally not make the columns a different color - we're doing it to help you see which columns are the free variables.) The truth table should have one row in it for each possible combination of assignments to the free variables. In this table, since there are 2 free variabls (A and B), there will be 22, or 4 rows in the truth table (not counting the column headers). You can think of A and B as being the two bits in a 2-bit field. Then, to be sure you cover all possible combinations, you would count in binary from the top of the table to the bottom, using the free variable columns are your 'bits'. In this example, the columns A and B together form a 2-bit field which we count 00, 01, 10, 11. After filling in the free variables, you fill in the computed variable columns for each row, using the value of the free variables on that row. This shows us, for any combination of assignments of the free variables, what the computed variables' values will be.

 A B AB A+B 0 0 1 0 0 0 1 1 0 1 1 0 0 0 1 1 1 0 1 1

### Homework Questions

1. Let H be a Boolean variable which is TRUE if Aunt Ethel's favorite begonia is healthy. Let I be TRUE if Aunt Ethel has sprayed her begonia with insecticide recently. Let S be TRUE if the begonia is in the shade for most of the day. Given the information "Aunt Ethel's begonia will be healthy if she sprays it regularly with insecticide and keeps it in the shade," form a Boolean expression which computes H.
2. Continuing with number 1, now let M be TRUE if Aunt Ethel is spending too much of her retirement money on insecticide to spray the begonia and let J be TRUE if Aunt Ethel derives joy and happiness from growing her begonia. Given the information "Aunt Ethel is happy when her begonia is healthy and it doesn't cost her much to keep it that way," draw a truth table which has columns for I, S, M, H and J and fill it in for all possible combinations of I, S, and M.

Previous Module: Computer Floating-point Arithmetic
Next Section: Boolean Expressions and Truth Tables