# Logic for Computer Scientists/Propositional Logic/Equivalence and Normal Forms

## Equivalence and Normal Forms

Until now, we only discussed single formulae and their semantical properties. In this section we start investigating whether formulae can be transformed into another form, without changing their semantics. For this we introduce the concept of logical equivalence, which can be used to investigate the transformation of a given formula into its normal form.

## Definition 6

The formulae ${\displaystyle F}$  and ${\displaystyle G}$  are called (semantically) equivalent, iff for all assignments ${\displaystyle {\mathcal {A}}}$  for ${\displaystyle F}$  and ${\displaystyle G}$ , ${\displaystyle {\mathcal {A}}(F)={\mathcal {A}}(G)}$ . We write ${\displaystyle F\equiv G}$ .

Formulae containing different subformulae can be equivalent, e.g. all tautologies are equivalent. More interesting is the following theorem:

## Theorem 3 (Substituitivity)

Let ${\displaystyle F\equiv G}$  and ${\displaystyle H}$  a formula which contains at least one occurrence of the subformula ${\displaystyle F}$ . Then it holds ${\displaystyle H\equiv H'}$ , where ${\displaystyle H'}$  is obtained from ${\displaystyle H}$  by substituting any occurrence of ${\displaystyle F}$  by ${\displaystyle G}$ .

Proof: The proof is by induction over the structure of the subformula ${\displaystyle H}$ :

Assume for the induction start, that ${\displaystyle H}$  is atomic, hence ${\displaystyle H=F}$  holds, and the result of substituting the only occurrence of ${\displaystyle F}$  by ${\displaystyle G}$  results in ${\displaystyle H'=G}$  and because ${\displaystyle F\equiv G}$ , we have ${\displaystyle H\equiv H'}$ . Assume the theorem holds for all proper subformulae of ${\displaystyle H}$ : If ${\displaystyle F=H}$  we have the same argumentation as above in the start of the induction. If ${\displaystyle F\neq H}$  we have three cases:

• ${\displaystyle H=\lnot h_{1}}$ : Because ${\displaystyle h_{1}}$  is a subformula of ${\displaystyle H}$  we can conclude that ${\displaystyle h_{1}\equiv h_{1}'}$ , where ${\displaystyle h_{1}'}$  is constructed by substituting any occurrence of ${\displaystyle F}$  by ${\displaystyle G}$ . From the definition of the semantics of ${\displaystyle \lnot }$  we conclude that ${\displaystyle \lnot h_{1}\equiv \lnot h_{1}'}$  and hence ${\displaystyle H\equiv H_{1}'}$ . Where H_1 is equivalent formula constructed by replacing F in H by G, resulting in H_1
• ${\displaystyle H=(h_{1}\lor h_{2})}$ : Assume without loss of generality, that ${\displaystyle F}$  occurs in ${\displaystyle h_{1}}$ . Then, again we can conclude from the induction assumption, that ${\displaystyle h_{1}\equiv h_{1}'}$  and from the definition of the semantics of ${\displaystyle \lor }$  we conclude, that ${\displaystyle (h_{1}\lor h_{2})=(h_{1}'\lor h_{2})}$ .
• ${\displaystyle H=(h_{1}\land h_{2})}$  is similar.

## Theorem 4

The following equivalences hold:

${\displaystyle (F\land F)}$  ${\displaystyle \equiv }$  ${\displaystyle F}$

${\displaystyle (F\lor F)}$  ${\displaystyle \equiv }$  ${\displaystyle F}$  (Idempotence)

${\displaystyle (F\land G)}$  ${\displaystyle \equiv }$  ${\displaystyle (G\land F)}$

${\displaystyle (F\lor G)}$  ${\displaystyle \equiv }$  ${\displaystyle (G\lor F)}$  (Commutativity)

${\displaystyle ((F\land G)\land H)}$  ${\displaystyle \equiv }$  ${\displaystyle (F\land (G\land H))}$

${\displaystyle ((F\lor G)\lor H)}$  ${\displaystyle \equiv }$  ${\displaystyle (F\lor (G\lor H))}$  (Associativity)

${\displaystyle (F\land (F\lor G))}$  ${\displaystyle \equiv }$  ${\displaystyle F}$

${\displaystyle (F\lor (F\land G))}$  ${\displaystyle \equiv }$  ${\displaystyle F}$  (Absorption)

${\displaystyle (F\land (G\lor H))}$  ${\displaystyle \equiv }$  ${\displaystyle ((F\land G)\lor (F\land H))}$

${\displaystyle (F\lor (G\land H))}$  ${\displaystyle \equiv }$  ${\displaystyle ((F\lor G)\land (F\lor H))}$  (Distributivity)

${\displaystyle \lnot ~\lnot F}$  ${\displaystyle \equiv }$  ${\displaystyle F}$  (Double negation)

${\displaystyle \lnot (F\land G)}$  ${\displaystyle \equiv }$  ${\displaystyle (\lnot F\lor \lnot G)}$

${\displaystyle \lnot (F\lor G)}$  ${\displaystyle \equiv }$  ${\displaystyle (\lnot F\land \lnot G)}$  (deMorgan's rule)

${\displaystyle (F\lor G)}$  ${\displaystyle \equiv }$  ${\displaystyle F}$ , if ${\displaystyle F}$  is a tautology

${\displaystyle (F\land G)}$  ${\displaystyle \equiv }$  ${\displaystyle G}$ , if ${\displaystyle F}$  is a tautology (Rule of Tautology)

${\displaystyle (F\lor G)}$  ${\displaystyle \equiv }$  ${\displaystyle G}$ , if ${\displaystyle F}$  is unsatisfiable

${\displaystyle (F\land G)}$  ${\displaystyle \equiv }$  ${\displaystyle F}$ , if ${\displaystyle F}$  is unsatisfiable (Rule of Unsatisfiability)

Proof: All equivalences can be proved by truth tables. This is done here for the second rule of absorption:

${\displaystyle F}$  ${\displaystyle G}$  (${\displaystyle F\land G}$ ) (${\displaystyle F\lor (F\land G}$ ))
false false
false
false
false true
false
false
true false
false
true
true true
true
true

Let us now use these equivalences together with the theorem of substituitivity (TS) to prove the following equivalence:

${\displaystyle ((A\lor (B\lor C))\land (C\lor \lnot A))\equiv ((B\land \lnot A)\lor C)}$

${\displaystyle ((A\lor (B\lor C))\land (C\lor \lnot A))}$

${\displaystyle \equiv }$  ${\displaystyle ((A\lor B)\lor C)\land (C\lor \lnot A))}$  Associativity and TS

${\displaystyle \equiv }$  ${\displaystyle ((C\lor (A\lor B))\land ((C\lor \lnot A))}$  Commutativity and TS

${\displaystyle \equiv }$  ${\displaystyle (C\lor ((A\lor B)\land \lnot A))}$  Distributivity

${\displaystyle \equiv }$  ${\displaystyle (C\lor (\lnot A\land (A\lor B)))}$  Commutativity and TS

${\displaystyle \equiv }$  ${\displaystyle (C\lor ((\lnot A\land A)\lor (\lnot A\land B))}$  Distributivity and TS

${\displaystyle \equiv }$  ${\displaystyle (C\lor (\lnot A\land B))}$  Unsatisfiability and TS

${\displaystyle \equiv }$  ${\displaystyle (C\lor (B\land \lnot A))}$  Commutativity and TS

${\displaystyle \equiv }$  ${\displaystyle ((B\land \lnot A)\lor C)}$  Commutativity and TS

## Problems

#### Problem 9 (Propositional)

The binary junctor ${\displaystyle {\stackrel {\cdot }{\vee }}}$  for exclusive disjunction is defined by ${\displaystyle F{\stackrel {\cdot }{\vee }}G=F\leftrightarrow (\lnot G)}$ . Show that the following holds for propositional logic formulae ${\displaystyle F}$ , ${\displaystyle G}$  and ${\displaystyle H}$ :

1. ${\displaystyle F{\stackrel {\cdot }{\vee }}G\equiv G{\stackrel {\cdot }{\vee }}F}$  (Commutativity).

2. ${\displaystyle (F{\stackrel {\cdot }{\vee }}G){\stackrel {\cdot }{\vee }}H\equiv F{\stackrel {\cdot }{\vee }}(G{\stackrel {\cdot }{\vee }}H)}$  (Associativity)

${\displaystyle \Box }$

#### Problem 10 (Propositional)

Show the following by equivalence transformation. Give to all remodelling steps the used rules!

1. ${\displaystyle (A\to (B\lor C))\equiv (A\to B)\lor (A\to C)}$
2. ${\displaystyle (A\to B)\to A\equiv (B\to A)\land (B\lor A)}$
3. ${\displaystyle A\leftrightarrow \lnot B\equiv \lnot (A\leftrightarrow B)}$
4. ${\displaystyle (A\to (B\land C))\equiv (A\to B)\land (A\to C)}$
5. ${\displaystyle (A\to B)\to (B\to A)\equiv B\to A}$
6. ${\displaystyle (A\lor \lnot B)\lor ((\lnot A\land \lnot C)\land B)\equiv (A\lor \lnot C)\lor \lnot B}$

${\displaystyle \Box }$

#### Problem 11 (Propositional)

Prove with equivalences:

1. ${\displaystyle p\lor \lnot (p\land q)}$  is a tautology.
2. ${\displaystyle (p\lor \lnot q)\land (\lnot p\land q)}$  is unsatisfiable.

${\displaystyle \Box }$

#### Problem 12 (Propositional)

The binary junctor ${\displaystyle \downarrow }$  with the meaning neither-nor is defined by ${\displaystyle F\downarrow G=\lnot (F\lor G)}$ . Let ${\displaystyle F}$  be a propositional logic formula, which contains only the operators ${\displaystyle \land }$  ${\displaystyle \lor }$  and ${\displaystyle \lnot }$ . Prove that for every formula ${\displaystyle F}$  a formula ${\displaystyle {\mathcal {T}}(F)}$  exists, such that ${\displaystyle F\equiv {\mathcal {T}}(F)}$  and ${\displaystyle {\mathcal {T}}(F)}$  is built by using only the junctor ${\displaystyle \downarrow }$ .

${\displaystyle \Box }$

#### Problem 13 (Propositional)

Let ${\displaystyle F}$  be a propositional logic formula, which contains only the operators ${\displaystyle \land }$ , ${\displaystyle \lor }$  and ${\displaystyle \lnot }$ . Prove that for every formula ${\displaystyle F}$  a formula ${\displaystyle {\mathcal {T}}(F)}$  exists, such that ${\displaystyle F\equiv {\mathcal {T}}(F)}$  and ${\displaystyle {\mathcal {T}}(F)}$  is built by using only the junctors ${\displaystyle \to }$  and ${\displaystyle {\stackrel {\cdot }{\vee }}}$ .

${\displaystyle \Box }$

#### Problem 14 (Propositional)

The following formulae are given:

• ${\displaystyle A\equiv D\lor B}$
• ${\displaystyle B\equiv \lnot B\lor \lnot D\lor \lnot S}$
• ${\displaystyle C\equiv (\lnot S\land D)\lor \lnot B}$

1. Simplify ${\displaystyle A\land B\land C}$  by using ${\displaystyle B\land C\equiv C}$ .
2. Simplify ${\displaystyle A\land B\land C}$  by using equivalences but not ${\displaystyle B\land C\equiv C}$ .

${\displaystyle \Box }$

## Definition 7 (Normal Forms)

A literal is an atomic formula or the negation of an atomic formula (positive or negative, resp.) A formula ${\displaystyle F}$  is in conjunctive normalform (CNF) iff

${\displaystyle F=(\bigwedge _{i=1}^{n}(\bigvee _{j=1}^{m_{i}}L_{i,j}))}$

where ${\displaystyle L_{ij}}$  is a literal.

A formula ${\displaystyle F}$  is in disjunctive normalform (DNF) iff

${\displaystyle F=(\bigvee _{i=1}^{n}(\bigwedge _{j=1}^{m_{i}}L_{i,j}))}$

where ${\displaystyle L_{ij}}$  is a literal

## Theorem 5

For every formula ${\displaystyle F}$  there is an equivalent formula which is in DNF and an equivalent formula which is in CNF.

Let us formulate an algorithm to transform a given formula F into an equivalent normalform:

Given: A formula ${\displaystyle F}$

1. Substitute in ${\displaystyle F}$  every subformula of the form

${\displaystyle \lnot ~\lnot ~G{\text{ by }}G}$
${\displaystyle \lnot ~(G~\land ~H){\text{ by }}(\lnot ~G~\lor ~\lnot ~H)}$
${\displaystyle \lnot ~(G~\lor ~H){\text{ by }}(\lnot ~G~\land ~\lnot ~H)}$

until there is no subformula of this kind.

2. Substitute in the result from the above step every subformula of the form

${\displaystyle (F~\lor ~(G~\land ~H)){\text{ by }}((F~\lor ~G)~\land ~(F~\lor ~H))}$
${\displaystyle ((F~\land ~G)~\lor ~H){\text{ by }}((F~\lor ~H)~\land ~(G~\lor ~H))}$

until there is no subformula of this kind.

Result: An equivalent formula in CNF

Until now, we investigate the transformation of a propositional formula into an equivalent normal form. Another problem in the context of normal forms is, to construct a normal form formula from a given truth table; i.e. the formula itself is not known, but its behaviour is given by a truth table. Let's read a normalform formula from a truth table: Assume a formula ${\displaystyle F}$ , which is given by the following truthtable.

A B C F
false false false true
false false true false
false true false false
false true true false
true false false true
true false true true
true true false false
true true true false

In order to construct a formula in DNF, which is equivalent to ${\displaystyle F}$ , we have to take into account, that every line of the table which yields the truthvalue ${\displaystyle true}$  gives one conjunction: if the assignment of the literal ${\displaystyle A_{i}}$  is ${\displaystyle true}$  it is included as ${\displaystyle \ldots \land A_{i}\land \ldots }$ , if is ${\displaystyle false}$  we include ${\displaystyle \ldots \land \lnot A_{i}\ldots \land \ldots }$ . For the above example we get as a DNF:

${\displaystyle (\lnot A\land \lnot B\land \lnot C)\lor }$

${\displaystyle (A\land \lnot B\land \lnot C)\lor }$

${\displaystyle (A\land \lnot B\land C)}$

If we change in the above procedure the roles of ${\displaystyle true}$  and ${\displaystyle false}$  and ${\displaystyle \lor }$  and ${\displaystyle \land }$  we arrive at a CNF:

${\displaystyle (A\lor B\lor \lnot C)\land }$

${\displaystyle (A\lor \lnot B\lor C)\land }$

${\displaystyle (A\lor \lnot B\lor \lnot C)\land }$

${\displaystyle (\lnot A\lor \lnot B\lor C)\land }$

${\displaystyle (\lnot A\lor \lnot B\lor \lnot C)}$

We introduce a special representation for formulae in normalform. In our circuit-example (circuit) from the introduction we already used a very special form of normalforms, namely the implication form for formulae in CNF: every subformula ${\displaystyle F_{i}}$  of a conjunction ${\displaystyle F_{1},\cdots ,F_{l}}$  is written as:

${\displaystyle A_{1}\land \cdots \land A_{n}\to B_{1}\lor \cdots \lor B_{m}}$

It is easy to see, that this implication is logically equivalent to a disjunction ${\displaystyle \lnot A_{1}\lor \cdots \lor \lnot A_{n}\lor B_{1}\lor \cdots \lor B_{m}}$ . Sometimes the implication is written as

${\displaystyle A_{1},\cdots ,A_{n}\to B_{1};\cdots ;B_{m}}$

Even the following ambiguous notation is used in some cases, where the comma in the premiss stands for a conjunction and the comma in the conclusion for a disjunction:

${\displaystyle A_{1},\cdots ,A_{n}\to B_{1},\cdots ,B_{m}}$

For some important procedures for logical reasoning it is mandatory to represent the formulae not only in one of the above notations for a normalform, moreover, it is necessary to use the so-called clause-form from the following definition.

## Definition 8

If ${\displaystyle F}$  is a formula in CNF, i.e.

${\displaystyle F=(L_{1,1}\lor \ldots \lor L_{1,{n_{1}}})\land \ldots \land (L_{k,1}\lor \ldots \lor L_{k,{n_{k}}})}$

then its corresponding representation in clause form is given as

${\displaystyle F=\{\{L_{1,1},\ldots ,L_{1,{n_{1}}}\},\ldots ,\{L_{k,1},\ldots ,L_{k,{n_{k}}}\}\}}$

The sets ${\displaystyle \{L_{i,1},\ldots ,L_{i,{n_{i}}}\}}$  are called clauses.

This representation as sets of literals has the advantage that literals occur in no special order and that multiple occurrences of a literal in a disjunction are "merged" in its clause form. Note that as a consequence we have built in associativity, commutativity and Idempotence into the representation.

${\displaystyle ((A_{1}\lor \lnot A_{2})\land (A_{3}\land A_{3}))}$              ${\displaystyle \{\{A_{1},\lnot A_{2}\},\{A_{3}\}\}}$

${\displaystyle (A_{3}\land (\lnot A_{2}\lor A_{1}))}$

## Problems

#### Problem 15 (Propositional)

Create formulae in (a) conjunctive or (b) disjuncive normal form which are equivalent to:

${\displaystyle A{\stackrel {\cdot }{\vee }}B{\stackrel {\cdot }{\vee }}C}$

where ${\displaystyle {\stackrel {\cdot }{\vee }}}$  denotes exclusive or.

${\displaystyle \Box }$

#### Problem 16 (Propositional)

The theorem prover OTTER uses the following optimization rules for clause sets:

Subsumption: If the literals of a clause ${\displaystyle K}$  are a subset of an another clause ${\displaystyle K'}$  remove ${\displaystyle K'}$  from the set of clauses.
Deleting by unit clause: If the set of clauses contains a unit clause ${\displaystyle L}$  -here ${\displaystyle L}$  is single literal unit-clause- every occurrence of a complementary literal ${\displaystyle {\overline {L}}}$  in a clause is deleted.

Which laws of the logic justify these procedures?

${\displaystyle \Box }$

#### Problem 17 (Propositional)

Generate truth tables for the following formulae. Give the conjunctive and disjunctive normal forms of the formulae. Which one of the relations ${\displaystyle F\models G}$ , ${\displaystyle G\models F}$ , ${\displaystyle F\equiv G}$  and ${\displaystyle F=G}$  holds?

1. ${\displaystyle F=(A\land \lnot (B\lor C)){\stackrel {\cdot }{\vee }}((A\to B)\lor (A\to C),)}$  whereas ${\displaystyle F{\stackrel {\cdot }{\vee }}G=F\leftrightarrow (\lnot G)}$  applies.
2. ${\displaystyle G=((A\lor (B\land A))\to \lnot A)\lor C}$

${\displaystyle \Box }$

#### Problem 18 (Propositional)

Generate a CNF and a DNF form the following truth table for the formula ${\displaystyle F}$ .

A B C F
0 0 0 0
1 0 0 1
0 1 0 0
1 0 0 1
1 1 0 1
1 0 1 0
0 1 1 1
1 1 1 0

${\displaystyle \Box }$

#### Problem 19 (Propositional)

Generate a CNF from the formula ${\displaystyle (P\land (Q\to R)\to S)}$

${\displaystyle \Box }$