Informatics 1
Computation and Logic
Boolean Algebra CNF DNF Michael Fourman
1
Informatics 1 Computation and Logic Boolean Algebra CNF DNF - - PDF document
Informatics 1 Computation and Logic Boolean Algebra CNF DNF Michael Fourman 1 To determine whether to { x | G ( x ) R ( x ) A ( x ) } expressions are equivalent, we The meaning of an expression is the set of states in which it is
Computation and Logic
Boolean Algebra CNF DNF Michael Fourman
1
✔ ✔ ✔ ✔
The meaning of an expression is the set of states in which it is true.
2
To determine whether to expressions are equivalent, we can check whether they give the same values for all 2^n states of the system. The meaning of an expression is the set of states in which it is true.
✔ ✔ ✔ ✔
R(x) ∧ A(x) ∧ G(x) ∨ R(x) ∧ ¬A(x) ∧ ¬G(x) ∨ ¬R(x) ∧ ¬A(x) ∧ G(x) ∨ ¬R(x) ∧ A(x) ∧ ¬G(x)
Disjunctive Normal Form (DNF)
3
A boolean function of three variables is given by a truth table with eight entries We can easily write down a disjunction of terms, each one
single state in which the function is true. This is called a Disjunctive Normal Form (DNF)
¬ ✓ R(x) ∧ ¬A(x) ∧ G(x) ∨ ¬R(x) ∧ A(x) ∧ G(x) ∨ ¬R(x) ∧ ¬A(x) ∧ ¬G(x) ∨ R(x) ∧ A(x) ∧ ¬G(x) ◆
✔ ✔ ✔ ✔
4
We can do things differently. Here we say that we are not in a state where the function is false
✔ ✔ ✔ ✔
¬
¬
¬
¬
Using de Morgan, this becomes a conjunction of negated conjunctions.
✔ ✔ ✔ ✔
6
Using de Morgan again, this becomes a conjunction of disjunctions. We will return to CNF later. CNF
Exercise 2.2 Generate CNF for this subset
7
Exercise 2.3 Generate CNF for this subset
8
To produce conjunctive normal form (CNF) eliminate ——— push negations in push ⋁ inside ⋀
9
¬(a → b) = a ∧ ¬b a ↔ b = (a → b) ∧ (b → a) a → b = ¬a ∨ b ¬(a ∨ b) = ¬a ∧ ¬b ¬(a ∨ b) = ¬a ∧ ¬b ¬0 = 1 ¬¬a = a ¬1 = 0 a ∨ 1 = 1 a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c) a ∧ 0 = 0 a ∨ 0 = a a ∨ ¬a = 1 a ∧ ¬a = 0 a ∧ 1 = a
We can transform any Boolean expression algebraically to create an equivalent CNF
10
R ↔ A = (R → A) ∧ (A → R) = (¬R ∨ A) ∧ (¬A ∨ R)
In this case, once we have eliminated implications, we have CNF . Clauses with only two literals correspond to implications.
11
R ↔ A = (R → A) ∧ (A → R) = (¬R ∨ A) ∧ (¬A ∨ R) G ↔ (R ↔ A) =
Here, we use the previous result to re-write the part in parentheses.
12
G ↔ (R ↔ A) =
13
G ↔ (R ↔ A) =
14
G ↔ (R ↔ A) =
15
G ↔ (R ↔ A) = (¬G ∨ ¬R ∨ A) ∧ (¬G ∨ ¬A ∨ R) ∧
∧
16
G ↔ (R ↔ A) = (¬G ∨ ¬R ∨ A) ∧ (¬G ∨ ¬A ∨ R) ∧
∧
R _ ¬R = > x ^ > = x
17
G ↔ (R ↔ A) = (¬G ∨ ¬R ∨ A) ∧ (¬G ∨ ¬A ∨ R) ∧
∧ (R ∨ A ∨ G) ∧ (¬A ∨ ¬R ∨ G)
18
✔ ✔ ✔ ✔
G ↔ (R ↔ A) = (¬G ∨ ¬R ∨ A) ∧ (¬G ∨ ¬A ∨ R) ∧ (R ∨ A ∨ G) ∧ (¬A ∨ ¬R ∨ G)
19
20