B A R G Informatics 1 Computation and Logic Karnaugh Maps Michael Fourman InfPals web.inf.ed.ac.uk/infweb/student-services/ito/students/year1/student-support/infpals Action : Make a commitment and sign up ASAP and before 5pm on Wednesday the 4th of October, using your First Name and your Student Number at tinyurl.com/infpals2017 1
R A G R ⋏ A 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 2
R A G ?? 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 3
R A G ?? 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 4
( ¬ R ∧ ¬ A ∧ ¬ G ) ∨ R A G ?? ( ¬ R ∧ A ∧ ¬ G ) 0 0 0 1 0 0 1 0 ∨ 0 1 0 1 ( ¬ R ∧ A ∧ G ) 0 1 1 1 1 0 0 1 ∨ 1 0 1 0 ( R ∧ ¬ A ∧ ¬ G ) 1 1 0 0 1 1 1 1 ∨ ( R ∧ A ∧ G ) disjunctive normal form DNF engineers write + for ∨ , × for ∧ , A ʹ for ¬A and call this a sum of products SOP R ʹ A ʹ G ʹ + R ʹ AG ʹ + R ʹ AG + RA ʹ G ʹ + RAG 5
we can also look at the states that do not satisfy the property R A G ?? ( ¬ R ∧ ¬ A ∧ G ) 0 0 0 1 0 0 1 0 ∨ 0 1 0 1 ( R ∧ ¬ A ∧ G ) 0 1 1 1 ¬ 1 0 0 1 ∨ 1 0 1 0 ( R ∧ A ∧ ¬ G ) 1 1 0 0 1 1 1 1 Then we apply de Morgan… 6
R A G ?? ( ¬ R ∧ ¬ A ∧ G ) 0 0 0 1 0 0 1 0 ∨ 0 1 0 1 ( R ∧ ¬ A ∧ G ) 0 1 1 1 ¬ 1 0 0 1 ∨ 1 0 1 0 ( R ∧ A ∧ ¬ G ) 1 1 0 0 1 1 1 1 ¬ ( ¬ R ∧ ¬ A ∧ G ) ( R ∨ A ∨ ¬ G ) ∧ ∧ ∧ = ¬ ( R ∧ ¬ A ∧ G ) = ( ¬ R ∨ A ∨ ¬ G ) = ∧ ∧ ∧ ¬ ( R ∧ A ∧ ¬ G ) ( ¬ R ∨ ¬ A ∨ G ) 7
R A G ?? ( ¬ R ∧ ¬ A ∧ G ) 0 0 0 1 0 0 1 0 ∨ 0 1 0 1 ( R ∧ ¬ A ∧ G ) 0 1 1 1 ¬ 1 0 0 1 ∨ 1 0 1 0 ( R ∧ A ∧ ¬ G ) 1 1 0 0 1 1 1 1 ( R ∨ A ∨ ¬ G ) ∧ ∧ ( A ∨ ¬ G ) ( ¬ R ∨ A ∨ ¬ G ) = = = ∧ = ∧ ∧ ∧ ( ¬ R ∨ ¬ A ∨ G ) ( ¬ R ∨ ¬ A ∨ G ) = 8
conjunctive normal form CNF ( A ∨ ¬ G ) ∧ = ( ¬ R ∨ ¬ A ∨ G ) engineers write this as (A + G ʹ ).(R ʹ + A ʹ + G) a product of sums POS
¬ ( R ∧ A ) = ¬ R ∨ ¬ A
¬ ( G ∧ ¬ A ) = ¬ G ∨ A
Boolean Algebra x ∨ ( y ∨ z ) = ( x ∨ y ) ∨ z x ∧ ( y ∧ z ) = ( x ∧ y ) ∧ z associative x ∨ ( y ∧ z ) = ( x ∨ y ) ∧ ( x ∨ z ) x ∧ ( y ∨ z ) = ( x ∧ y ) ∨ ( x ∧ z ) distributive x ∨ y = y ∨ x x ∧ y = y ∧ x commutative x ∨ 0 = x x ∧ 1 = x identity x ∨ 1 = 1 x ∧ 0 = 0 annihilation x ∨ x = x x ∧ x = x idempotent x ∨ ¬ x = 1 ¬ x ∧ x = 0 complements x ∨ ( x ∧ y ) = x x ∧ ( x ∨ y ) = x absorbtion ¬ ( x ∨ y ) = ¬ x ∧ ¬ y ¬ ( x ∧ y ) = ¬ x ∨ ¬ y de Morgan ¬¬ x = x x → y = ¬ x ← ¬ y 12
Lewis Carroll (The Rev. C.L. Dodgson) R A G { x | G ( x ) ↔ R ( x ) ↔ A ( x ) } 13
AG { x | G ( x ) ↔ R ( x ) ↔ A ( x ) } 00 01 11 10 0 R 1 14
AG 00 01 11 10 0 R 1 ( ¬ A ∧ ¬ G ) ∨ ( A ∧ G ) ∨ ( A ∧ ¬ R ) 15
AG 00 01 11 10 0 R 1 0 0 0 ∧ ¬ ∨ ∧ ∨ ∧ ¬ ¬ ( ¬ G ∨ A ) ∧ ( ¬ R ∨ G ∨ ¬ A ) 16
Karnaugh Maps B A AG 00 01 11 10 00 01 RB 11 10 R G 4 atoms:16 states: 64K subsets 17
Karnaugh Maps B A AG 00 01 11 10 00 0 0 0 0 01 0 1 1 0 RB 11 0 1 1 0 10 0 0 0 0 G ∧ B R G 4 atoms:16 states: 64K subsets 18
Karnaugh Maps B A AG 00 01 11 10 00 0 0 0 0 01 1 1 0 0 RB 11 1 1 0 0 10 0 0 0 0 ¬ A ∧ B R G 4 atoms:16 states: 64K subsets 19
Karnaugh Maps B A AG 00 01 11 10 00 1 1 0 0 01 1 1 0 0 RB 11 0 0 0 0 10 0 0 0 0 ¬ A ∧ ¬ R R G 4 atoms:16 states: 64K subsets 20
Karnaugh Maps B A AG 00 01 11 10 00 1 1 1 1 01 0 0 0 0 RB 11 0 0 0 0 10 0 0 0 0 ¬ B ∧ ¬ R R G 4 atoms:16 states: 64K subsets 21
Karnaugh Maps B A AG 00 01 11 10 00 1 0 0 1 01 1 0 0 1 RB 11 0 0 0 0 10 0 0 0 0 ¬ G ∧ ¬ R R G 22
Karnaugh Maps B A AG 00 01 11 10 00 1 0 0 1 01 0 0 0 0 RB 11 0 0 0 0 10 1 0 0 1 ¬ G ∧ ¬ B R G 23
Karnaugh Maps B A AG 00 01 11 10 00 0 0 0 0 01 0 1 1 0 RB 11 0 1 1 0 10 0 0 0 0 G ∧ B R G 4 atoms:16 states: 64K subsets 24
Karnaugh Maps B A AG 00 01 11 10 00 1 1 1 1 01 1 0 0 1 RB 11 1 0 0 1 10 1 1 1 1 ¬ B ∨ ¬ G R G 4 atoms:16 states: 64K subsets 25
Karnaugh Maps B A AG 00 01 11 10 00 1 1 0 0 01 1 1 0 0 RB 11 0 0 1 1 10 0 0 1 1 ( ¬ A ∧ ¬ R ) ∨ ( A ∧ R ) R G 4 atoms:16 states: 64K subsets 26
Karnaugh Maps B A AG 00 01 11 10 00 1 1 0 0 01 1 1 0 0 RB 11 0 0 1 1 10 0 0 1 1 ( ¬ R ∨ A ) ∧ ( ¬ A ∨ R ) R G 4 atoms:16 states: 64K subsets 27
Karnaugh Maps to produce a DNF / SOP identify blocks of 1s and write a product for each AG 00 01 11 10 00 1 0 0 0 01 1 1 0 0 RB 11 0 1 1 1 10 0 0 1 1 B A 4 atoms:16 states: 64K subsets R G 28
Karnaugh Maps to produce a DNF / SOP identify blocks of 1s and write a product for each AG 00 01 11 10 00 1 0 0 0 01 1 1 0 0 RB 11 0 1 1 1 RA + BA ʹ G + R ʹ A ʹ G ʹ 10 0 0 1 1 ( R ∧ A ) ∨ ( B ∧ ¬ A ∧ G ) ∨ ( ¬ R ∧ ¬ A ∧ ¬ G ) B A 4 atoms:16 states: 64K subsets R G 29
Karnaugh Maps to produce a CNF / POS identify blocks of 0s and write a sum for each AG 00 01 11 10 00 1 0 0 0 01 1 1 0 0 RB 11 0 1 1 1 10 0 0 1 1 B A R G 30
Karnaugh Maps to produce a CNF / POS identify blocks of 0s and write a sum for each AG 00 01 11 10 00 1 0 0 0 01 1 1 0 0 RB 11 0 1 1 1 (R ʹ +A+G)(B+A+G ʹ )(R+A ʹ ) 10 0 0 1 1 ( ¬ R ∨ A ∨ G ) ∧ ( B ∨ A ∨ ¬ G ) ∧ ( R ∨ ¬ A ) B A 4 atoms:16 states: 64K subsets R G 31
Recommend
More recommend