IST 210: Boot Camp Ritendra Datta LECTURE 2 An Introduction to Boolean Algebra 2.1. Outline of Lecture Fundamentals Negation, Conjunction, and Disjunction Laws of Boolean Algebra Constructing Truth Tables Things You Should Know 2.2. Fundamentals Boolean algebra is a mathematical way to represent logical statements we make. At the end of this lecture, you should be able to construct boolean algebra statements out of logical statements such as The temperature is low and it is not snowing. Definition 2.1. Boolean algebra is the algebra of propositions. Propositions (or statements) are denoted by letters and referred to as Boolean variables. A proposition can have only two possible values: T (meaning T rue) and F (meaning F alse). Suppose A is Boolean variable denoting The earth is not flat. Then most people (I agree, not all) will treat this as a fact, hence the value of A will be T. Boolean algebra, however, really does not care about facts, reality etc. You define the facts, and boolean algebra helps draw conclusions from those facts. This means that boolean algebra is 1
2 RITENDRA DATTA, IST 210: BOOT CAMP a kind of math which, when told that the moon is square is T rue, will deduce that the moon is not square is F alse. 2.3. Negation, Conjunction, and Disjunction In order to make more sense out of the concept of Boolean variables, we must introduce some operations that can be performed on them. We can think of the addition 5 + 4 as a + operation on the numbers 5 and 4. Similar operations can be performed on Boolean variables. Definition 2.2. Negation (NOT) is an operation on a Boolean variable which changes its value from T rue to F alse and vice-versa. We denote the negation of a variable A as A. For example, if A = T, then A = F, and if B = F, then B = T. In order to summarize such Boolean operations, we use what is known as a truth table: Negation: A T F A F T Exercise 1. Show that ( A) = A. If ( C) = F, what is C? Remember that when you do math such as 2 + (5-3), you first do the (5-3) part. The same logic holds here as well. Definition 2.3. Conjunction (AND) is an operation on two Boolean variables which produces a T rue value only when both variables are T rue, and F alse in all other cases. Disjunction (OR) is an an operation on two Boolean variables which produces a T rue value when at least one variable is T rue, and F alse only when both are F alse. Given variables A and B, we denote their conjunction as A.B, and disjunction as A+B. For all possible values of any two variables A and B = F, the following truth tables summarize these operations: Conjunction: A B A.B T T T T F F F T F F F F Disjunction: A B A+B T T T T F T F T T F F F Exercise 2. Without knowing the value of A, can you find the value of (or simplify) the following? (a) (i) A.T (ii) A.F (iii) A+T (iv) A+F (b) (i) A.A (ii) A+A (c) (i) A. A (ii) A+ A
LECTURE 2. AN INTRODUCTION TO BOOLEAN ALGEBRA 3 2.4. Laws of Boolean Algebra The following laws hold true for Boolean variables. While proofs are not required for this course, it may be a good practise to construct truth tables for each of them in order to convince yourself that they do hold true. We will get more into proving with truth tables in the following section. (a) A.B = B.A (b) A+B = B+A (Commutative Laws) (c) A.(B.C) = (A.B).C (d) A+(B+C) = (A+B)+C (Associative Laws) (e) A.(B+C) = (A.B)+(A.C) (f) A+(B.C) = (A+B).(A+C) (Distributive Laws) (g) A.(A+B) = A (h) A+(A.B) = A (Redundancy Laws) (i) (A.B) = A+ B (j) (A+B) = A. B (De Morgan s Laws) In addition to these laws, once you have figured out the answers to Exercise 2, you can consider those as laws too. In case you are wondering, the A and B used here are just placeholders for any Boolean variable. So do not be hesitant to apply these laws on a Boolean expression involving X, Y, and Z, for example. Remember that when using these laws on a given expression, you should go from left to right. When calculating values of the expressions, you should first work on what s inside brackets (), then any NOT ( ) operations, then any AND (.) operations, and finally any OR (+) operations. Exercise 3. Use the laws of Boolean algebra to simplify the following expressions: (a) F +(X.Y) (b) F +(X. X) (c) X.( X+Y) (d) X.( X+Y)+Y (e) X.Z + Z. ( X+ X.Y) (Optional)
4 RITENDRA DATTA, IST 210: BOOT CAMP 2.5. Constructing Truth Tables Besides using laws, one way to find the values of Boolean expressions or prove the validity of simplifications is by using truth tables. The basic ides is to create a list of all possible values that the different Boolean variables can take, and figure out what the corresponding values of the entire expression are. Let us start with a simple example. Suppose we want to find the values of E for all possible values of A and B, where E = (A+B). We construct a truth table as follows: A B A+B E = (A+B) T T T F T F T F F T T F F F F T Exercise 4. Extend this truth table, by including three additional columns, in order to show that the De Morgan s law holds true. Let us now take a more elaborate example. Suppose we want to find the values of E for all possible values of X and Y, where E = ( X.( X+Y) ) +Y. We construct a truth table as follows: X Y X X+Y X.( X+Y) E = ( X.( X+Y) ) +Y T T F T T T T F F F F F F T T T F T F F T T F F Incidentally, also note that the values in the Y column and the final E column are exactly the same. This therefore proves that E can be simply represented by Y. Exercise 3.(d) asked you to simplify this expression using laws alone. The answer turns out to be Y in both cases, as expected. This shows that you can prove things or simplify expressions using either ways. Exercise 5. Use truth tables to prove that the following hold true: (a) ( A) = A (b) A.(A+B) = A (c) X.(Y + Z) = X.Y + X.Z (d) X.Y + X. Y = X
LECTURE 2. AN INTRODUCTION TO BOOLEAN ALGEBRA 5 2.6. Things You Should Know Although you will not be asked to define anything, an understanding of the concepts most certainly will help to solve problems. Concepts: Purpose of Boolean Algebra Boolean variables, values of Boolean variables Negation, Conjunction, Disjunction, and their truth tables Application of Laws of Boolean algebra Truth tables and their application to proofs Problems: Application of the above concepts. Close variants of problems in the Exercises of this lecture. Proving the laws of Boolean algebra using truth tables.