CSE 260
BRAC University, Fall’06
             Binary Logic
• Binary logic consists of binary variables
  and logical operations.
• Variables are designated by letters
  such as A, B, C, x, y, z etc. with only 2
  possible values: 1 and 0.
• Logic operations: and, or, not etc.
             Logic Gates
• The most basic digital devices are
  called gates.
• A gate has one or more inputs and
  produces an output that is a function of
  the current input values.
  Most Important logic gates
• AND
• OR
• NOT
2-input AND gate
A                   A   &
            A.B             A.B
B                   B
    A   B     A.B
    0   0      0
    0   1      0
    1   0      0
    1   1      1
    2- input OR gate
A                 A
           A+B         A+B
B                 B
       A   B     A+B
       0   0      0
       0   1      1
       1   0      1
       1   1      1
NOT gate (Inverter)
A     A'       A   A'
      A A'
      0    1
      1    0
         Some Other Gates
•   NAND
•   NOR
•   XOR
•   XNOR (equivalence)
            2-input NAND gate
A
             (A.B)'   ≡   A
                               (A.B)'
                                        A        &
                                                        (A.B)'
B                         B             B
    A   B      (A.B)'
    0   0        1
                                            ≡
    0   1        1
    1   0        1            NAND              Negative-OR
    1   1        0
        2-input NOR gate
A
         (A+B)'   ≡   A
                            (A+B)'
                                     A
                                                   (A+B)'
B                     B              B
A   B   (A+B)'
0   0     1
0   1     0                          ≡
1   0     0               NOR            Negative-AND
1   1     0
    2-input XOR gate
A                 A   =1
            A⊕B            A⊕B
B                 B
    A   B     A⊕B
    0   0      0
    0   1      1
    1   0      1
    1   1      0
           Boolean Algebra
• Like any other deductive mathematical
  system, defined with a set of elements, a set
  of operators and a number of axioms or
  postulates.
• In Boolean algebra, set consists at least 2
  variables say x & y, with 2 binary operations
  {+} and {.} and 1 unary operation {‘}
  Boolean algebra Postulates
 Closure: For every x, y in B [let, B is the set],
    x + y is in B
    x . y is in B
 Commutative laws: For every x, y in B,
   x+y=y+x
   x.y=y.x
 Complement: For every x in B, there exists an
  element x' in B such that
    x + x' = 1
    x . x' = 0
  Boolean algebra Postulates
 Associative laws: For every x, y, z in B,
   (x + y) + z = x + (y + z) = x + y + z
   (x . y) . z = x .( y . z ) = x . y . z
 Identities (0 and 1):
  0 + x = x + 0 = x       for every x in B
  1 . x = x . 1 = x       for every x in B
 Distributive laws: For every x, y, z in B,
   x . (y + z) = (x . y) + (x . z)
   x + (y . z) = (x + y) . (x + z)
             Truth Table
 Provides a listing of every possible
 combination of inputs and its
 corresponding outputs.
                 INPUTS   OUTPUTS
                   …         …
                   …         …
 Example (2 inputs, 2 outputs):
             x    y   x.y      x+y
             0    0    0        0
             0    1    0        1
             1    0    0        1
             1    1    1        1
       Proof using Truth Table
 Prove that: x . (y + z) = (x . y) + (x . z)
(i) Construct truth table for LHS & RHS of above equality.
           x   y   z y + z x.(y + z) x.y x.z (x.y)+(x.z)
           0   0   0   0       0      0   0       0
           0   0   1   1       0      0   0       0
           0   1   0   1       0      0   0       0
           0   1   1   1       0      0   0       0
           1   0   0   0       0      0   0       0
           1   0   1   1       1      0   1       1
           1   1   0   1       1      1   0       1
           1   1   1   1       1      1   1       1
(ii) Check that LHS = RHS
    Postulate is SATISFIED because output column 2 & 5 (for
    LHS & RHS expressions) are equal for all cases.
                    Duality
 Duality Principle – every valid Boolean
    expression (equality) remains valid if the
    operators and identity elements are
    interchanged, as follows:
        +↔.
        1↔0
   Example: Given the expression
               a + (b.c) = (a+b).(a+c)
     then its dual expression is
               a . (b+c) = (a.b) + (a.c)
                    Duality
 Duality gives free theorems – “two for the
  price of one”. You prove one theorem and
  the other comes for free!
 If (x+y+z)' = x'.y.'z' is valid, then its dual is
  also valid:
      (x.y.z)' = x'+y'+z’
 If x + 1 = 1 is valid, then its dual is also valid:
      x.0=0
Basic Theorems of Boolean Algebra
  •   Postulate 5 (a) x+0=x (b) x.1=x
  •   Postulate 3 (a) x+x’=1 (b) x.x’=0
  •   Th 1         (a) x+x=x (b) x.x=x
  •   Th 2         (a) x+1=1 (b) x.0=0
  •   Th 3, involution (x’)’=x
  •   Pos 2        (a) x+y=y+x (b) xy=yx
  •   Th 4         (a) x(yz)=(xy)z (b)x+(y+z)=(x+y)+z
  •   Pos 6        (a) x(y+z)=xy+xz (b) x+yz=(x+y)(x+z)
  •   Th 5, DeMorgan (a) (x+y)’=x’y’ (b) (xy)’=x’+y’
  •   Th 6, Absorption (a) x+xy=x (b) x(x+y)=x
Basic Theorems of Boolean Algebra
Proof of 1(a):
       x+x       = (x + x).1          (identity)
                 = (x + x).(x + x')   (complementarity)
                 = x + x.x'           (distributivity)
                 =x+0                 (complementarity)
                 =x                   (identity)
Basic Theorems of Boolean Algebra
  Theorems can be proved using the truth
  table method. (Exercise: Prove De-
  Morgan’s theorem using the truth table.)
  They can also be proved by algebraic
  manipulation using axioms/postulates
  or other basic theorems.
Basic Theorems of Boolean Algebra
  Theorem 6a (absorption) can be proved by:
               x + x.y = x.1 + x.y (identity)
                       = x.(1 + y) (distributivity)
                       = x.(y + 1) (commutativity)
                       = x.1       (Theorem 2a)
                       =x          (identity)
    By duality, theorem 6b:
                       x.(x+y) = x
    Try prove this by algebraic manipulation.
     Precedence of Operators
 To lessen the brackets used in writing boolean expressions,
    operator precedence can be used.
   Precedence (highest to lowest): ' . +
   Examples:
       a . b + c = (a . b) + c
       b' + c = (b') + c
       a + b' . c = a + ((b') . c)
   Use brackets to overwrite precedence.
   Examples:
       a . (b + c)
       (a + b)' . c
         Boolean Functions
                             x   y   z   F1   F2   F3   F4
 Examples:                  0   0   0   0    0    0    0
                             0   0   1   0    1    1    1
   F1= xyz'
                             0   1   0   0    0    0    0
   F2= x + y'z               0   1   1   0    0    1    1
                             1   0   0   0    1    1    1
   F3=(x'y'z)+(x'yz)+(xy')   1   0   1   0    1    1    1
   F4=xy'+x'z                1   1   0   1    1    0    0
                             1   1   1   0    1    0    0
 From the truth table, F3=F4.
 Can you also prove by algebraic manipulation
 that F3=F4?
 Graphical presentation = ??
            Assignment
• 2-5,2-6,2-11