Tuesday, January 12, 2015 The two boolean values are T and F. The two binary digits are 0 and 1. We use the two binary digits to form binary numbers. We can use the two boolean values to represent the two binary digits. Then counting in binary looks like this. 0 000 FFF 1 001 FFT 2 010 FTF 3 011 FTT 4 100 TFF 5 101 TFT 6 110 TTF 7 111 TTT Modern digital computers use binary numbers. But the binary digits are not really 0 and 1. In the computer the two binary digits must be represented by some physical quantity. For example, a zero voltage vs a positive voltage, or a positive current vs a negative current, or a laser light that is on or off. 0 1 - + off on low high F T In an actual computer, we can't really use F and T as binary digits, but if we analyze arithmetic operations on binary numbers using boolean digits, we will see that we can implement arithmetic operators using boolean operators. This idea is the basis for designing all modern digital computer circuits. A "boolean operator" takes as its input two boolean values and it returns a boolean value. If we let p and q represent an operator's two boolean input values, then there are four possible input pairs to a boolean operator. There are 16 possible outputs that can be associated with the four input pairs. Here is a "truth table" of all 16 possible boolean operators. Notice how we are "counting" in binary down the left two columns, and we are "counting" in binary from left to right in the output columns. 0 1 2 3 4 5 6 7 8 9 A B C D E F p q | ----+--------------------------------- 0 F F | F T F T F T F T F T F T F T F T 1 F T | F F T T F F T T F F T T F F T T 2 T F | F F F F T T T T F F F F T T T T 3 T T | F F F F F F F F T T T T T T T T Here is the same table but with symbolic names given to most of the boolean operators. p q | F nor !p !q xor nand and == q --> p <-- or T ----+--------------------------------------------------------------- F F | F T F T F T F T F T F T F T F T F T | F F T T F F T T F F T T F F T T T F | F F F F T T T T F F F F T T T T T T | F F F F F F F F T T T T T T T T Note that we can build a similar table for boolean operators with only one input (unary boolean operators). There are only two possible inputs, and we have four possible outputs that can be associated with the two inputs. p | F not p T --+-------------- F | F T F T T | F F T T Notice that only one of these operators is at all useful, the not operator, which flips its input Boolean operators are used by many scientific disciplines, but they don't all use the same boolean operators. Programming languages use: not, and, or, ==, xor Digital logic uses: not, and, or, nand, nor Mathematical logic uses: not, and, or, <-->, -->, <-- (equivalence, implication, converse) In programming languages like C, C++, Java, etc, the six "relational operators" <, >, <=, >=, ==, != are boolean operators with numeric inputs. These operators return a boolean value, but their inputs are numeric values. Notice that the == operator is overloaded so that it is a boolean operator of both boolean values and numeric values. Notice that the relational operator != is in fact the boolean operator "exclusive or" (xor)! The == relational operator is sometimes called the "inclusive and" boolean operator. Problem: Which of the 16 boolean operators is this one? X Y ? ----+--- r r | s r s | s s r | r s s | s We have to choose a way to associate X and Y with p and q, and we have to choose a way to associate r and s with F and T. p q --> p q p q <-- p q ----+--- ----+--- ----+--- ----+--- F F | T F F | F F F | T F F | F F T | T F T | T F T | F F T | F T F | F T F | F T F | T T F | T T T | T T T | F T T | T T T | F X=p X=p X=q X=q Y=q Y=q Y=p Y=p r=F r=T r=F r=T s=T s=F s=T s=F Problem: Show that the boolean expression not(p and q) always has the same boolean value as the expression (not q) or (not q) This is called De Morgan's law. Use a "truth table". p q | p and q | not(p and q) | not p | not q | (not p) or (not q) ----+---------+--------------+-------+-------+-------------------- F F | F | T | T | T | T F T | F | T | T | F | T T F | F | T | F | T | T T T | T | F | F | F | F