DNFs by Truth Table

advertisement
MAT 1348: Normal Forms–DNF and CNF by Truth-Table
Professor P. J. Scott
Winter, 2016
Note: This year we will only present DNF’s (Disjunctive Normal Forms). You are not
responsible for the dual notion CNF’s (Conjunctive Normal Forms), but it’s here in case you
need it for other courses. There are three common methods for obtaining DNF’s: using truthtables, using Boolean Algebra formal manipulation, and using Truth Trees. Below we describe
the truth-table method. It is mechanical, and the output DNF is uniquely determined.
When we work out DNF’s and CNF’s we make the following assumptions:
• For ease of reading, we use associativity of disjunction and conjunction to write a disjunction as (C1 ∨ C2 ∨ · · · Ck ), without writing further parentheses and similarly for conjunction
(D1 ∧ D2 ∧ · · · ∧ Dk ). For example, ((C1 ∨ C2 ) ∨ C3 ) ≡ (C1 ∨ (C2 ∨ C3 )), and we write them
both in abbreviated form as (C1 ∨ C2 ∨ C3 ). 1
• A literal ` is either an atom (e.g. p, q, etc.) or the negation of an atom, (¬p, ¬q, etc).
Definition 0.1 A DNF (disjunctive normal form) of a formula ϕ is a formula
(C1 ∨ C2 ∨ · · · ∨ Ck ) where the main connectives are disjunction and
(i) ϕ ≡ (C1 ∨ C2 ∨ · · · ∨ Ck )
(ii) Each Ci is of the form (`1 ∧ `2 ∧ · · · ∧ `r ) for literals `i .
(iii) We say a DNF is degenerate if k = 1 and there is just one clause C1 = (`1 ∧ `2 ∧ · · · ∧ `r )
Remark 0.2 (Non-uniqueness of DNFs ) Many times it is possible to greatly simplify a
DNF: for example, if a conjunct Ci ≡ F in a DNF, you can throw it away. This will be explained
in class, using the unit laws of Boolean Algebras. So in general DNF’s (especially given by
Boolean algebra) are not unique: you can often simplify them or expand them adding redundant
T’s or F’s as appropriate. But if we use the algorithm below for truth-tables, the output will give
a unique DNF for each formula ϕ (depending on the specific formatting of your truth-tables).
Truth-table algorithm for DNF. To find a DNF of a formula ϕ by truth-tables, do the
following:
• Write the truth table, for ϕ.
• Note the rows with value T.
• For each row with value T make a conjunction of literals Ci = (`1 ∧ · · · ∧ `r ) as follows: if
the atoms are p1 , · · · , pr and the atom pi has value T, the literal `i is pi . But if the atom
pi has value F, the literal `i is ¬pi .
• Take the disjunction (C1 ∨ · · · ∨ Ck ) of all the clauses Ci = (`1 ∧ · · · ∧ `r ) corresponding to
all rows of the truth table with value T. Ignore the rows with value F.
Definition 0.3 A CNF (conjunctive normal form) of a formula ϕ is a formula2
(D1 ∧ D2 ∧ · · · ∧ Dk ) where the main connectives are conjunction and
(i) ϕ ≡ (D1 ∧ D2 ∧ · · · ∧ Dk )
(ii) Each Di is of the form (`1 ∨ `2 ∨ · · · ∨ `r ) for literals `i .
(iii) We say the CNF is degenerate if k = 1 and there is just one clause D1 = (`1 ∨ `2 ∨ · · · ∨ `r )
1
If I do put in all parentheses, I prefer to associate to the left; for example, I would write (C1 ∨ C2 ∨ C3 ) as
((C1 ∨ C2 ) ∨ C3 ). But it is usually not necessary for DNF’s and CNF’s.
2
Similarly to the previous remark, CNF’s in general are not unique. But those given by the truth-table
algorithms are unique, only depending on the specific formatting of the truth-table.
1
Truth-table algorithm for CNF. To find a CNF of a formula ϕ do the following: dualize the
algorithm above for DNF by interchanging T and F, and interchanging ∨ with ∧ and vice versa.
This gives the following:
• Write the truth table, for ϕ.
• Note the rows with value F.
• For each row with value F make a disjunction of literals Di = (`1 ∨ · · · ∨ `r ) as follows: if
the atoms are p1 , · · · , pr and the atom pi has value F, the literal `i is pi . But if the atom
pi has value T, the literal `i is ¬pi .
• Take the conjunction (D1 ∧ · · · ∧ Dk ) of all the clauses Di = (`1 ∨ · · · ∨ `r ) corresponding
to all of the rows of the truth table with value F. Ignore the rows with value T.
Example: Suppose you calculate the truth table for ϕ and you get the following (in our format):
p
T
T
T
T
F
F
F
F
q
T
T
F
F
T
T
F
F
r
T
F
T
F
T
F
T
F
ϕ
T
T
F
T
F
T
F
T
DNF of ϕ:
(p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q ∧ ¬r) ∨ (¬p ∧ q ∧ ¬r) ∨ (¬p ∧ ¬q ∧ ¬r)
CNF of ϕ:
(¬p ∨ q ∨ ¬r) ∧ (p ∨ ¬q ∨ ¬r) ∧ (p ∨ q ∨ ¬r)
Theorem 0.4 (Theorem on DNF’s and CNF’s) For every formula ϕ of propositional calculus, there are DNF and CNF formulas ϕDN F and ϕCN F such that ϕ ≡ ϕDN F and ϕ ≡ ϕCN F . If
we use the truth-table algorithms above, the results are unique, up to presentation of truth-tables.
Remark 0.5 (Full DNFs and CNFs) DNFs (resp. CNFs) obtained by the truth-table
method above are special. We call them Full DNFs (resp. Full CNFs). This is because each
conjunctive clause Ci in the DNF (resp., each disjunctive clause Dj in the CNF) has the property
that every propositional variable occurs exactly once (either negated or not). That is, the truthtable algorithm above generates clauses Ci (resp. Dj ) such that every variable occurs exactly
once, either negated or not, in each clause. This is sometimes useful in practice.
The DNFs and CNFs obtained directly by a truth-table are fine. But sometimes they can be
quite long formulas. In some cases directly using laws of Boolean Algebras gives simpler DNFs
(and CNFs) , as shown in class. We will always say on tests or homework if we want you to
simplify.
2
Download