Computer Science 210 Computer Organization Introduction to Boolean Algebra
George Boole English mathematician (1815-1864) Boolean algebra Logic Set Theory Digital circuits Programming: Conditions in while and if statements
Boolean Constants In Boolean algebra, there are only two constants, true and false Boolean constant Binary digit State of a switch Voltage level true 1 On +5V false Off 0V
Boolean Variables Boolean variables are variables that store values that are Boolean constants. Let A be true Let B be false Etc.
Boolean Operator AND If A and B are Boolean variables (or expressions) then A AND B is true if and only if both A and B are true.
Boolean Operator AND If A and B are Boolean variables (or expressions) then A AND B is false if and only if either A or B are false or they’re both false.
Boolean Operator AND We denote the AND operation like multiplication in ordinary algebra: AB or A.B
Boolean Operator OR If A and B are Boolean variables (or expressions) then A OR B is true if and only if at least one of A and B is true.
Boolean Operator OR If A and B are Boolean variables (or expressions) then A OR B is false if and only if both A and B are false.
Boolean Operator OR We denote the OR operation like addition in ordinary algebra: A+B
Boolean Operator NOT If A is a Boolean variable (or expression) then NOT A has the opposite value from A.
Boolean Operator NOT We denote the NOT operation by putting a bar over the variable (or expression) _ A Or use tilde (~) when bar is not available: ~A
Boolean Expressions As with ordinary algebra, a Boolean expression is a well-formed expression made from Boolean constants Boolean variables Operators AND, OR and NOT Parentheses Example: __ ____ AB + (A+C)B
Evaluating a Boolean expression At any time, the value of a BE can be computed using the current values of the variables. __ AB + (CD) Let A = true Let B = false Let C = true Let D = false Then the resulting value is true
Operator precedence NOT comes first, then AND, and finally OR (Like arithmetic negation, product, and addition) A + BC is not the same as (A + B)C
Evaluating a Boolean expression Unlike ordinary algebra, for a BE, there are only finitely many possible assignments of values to the variables; so, theoretically, we can make a table, called a truth table, that shows the value of the BE for every possible set of values of the variables. For convenience, use 0 = false 1 = true
Truth Table for AND A B AB 1
Truth Table for OR A B A+B 1
Truth Table for NOT A _ 1
Filling in a Truth Table If there are N variables, there are 2N possible combinations of values Thus, there are 2N rows in the truth table Fill in the values by counting up from 0 in binary
Example Construct a truth table for _ ___ E = AB + (A+C)B
_ ___ E = AB + (A+C)B A B C 1 Assign the values of the variables first
_ ___ E = AB + (A+C)B Then add columns for each operation A B C 1 _ B 1 _ B 1 Then add columns for each operation
_ ___ E = AB + (A+C)B A B C 1 _ B 1 _ AB 1
_ ___ E = AB + (A+C)B A B C 1 _ B 1 _ AB 1 A+C 1
_ ___ E = AB + (A+C)B A B C 1 _ B 1 _ AB 1 A+C 1 ___ (A+C) 1
_ ___ E = AB + (A+C)B A B C 1 _ B 1 _ AB 1 A+C 1 ___ (A+C) 1 ___ 1 _ B 1 _ AB 1 A+C 1 ___ (A+C) 1 ___ (A+C)B 1
_ ___ E = AB + (A+C)B A B C 1 _ B 1 _ AB 1 A+C 1 ___ (A+C) 1 ___ 1 _ B 1 _ AB 1 A+C 1 ___ (A+C) 1 ___ (A+C)B 1 E 1
Designing a Circuit from a Truth Table The problem reduces to this: Given a truth table with all values for inputs. And given a column of values for the output. Find a Boolean expression that gives the column. If we can do this, we can get the circuit from the Boolean expression. The Sum of Products algorithm finds the expression.
Sum of Products Algorithm Identify each row of the output that has a 1. For each such row Make a product of all the input variables. Put bar over each variable with a 0 in this row. Make a sum of all of these product terms. Then, simplify the expression if possible.