0% found this document useful (0 votes)
77 views34 pages

Soundness Completeness Conjuctive Normal Form Horn Clauses

The document discusses soundness and completeness in propositional logic. It defines soundness as proving that if a formula is provable then it is logically valid. It involves using induction on proof lengths. Completeness means that if a formula is logically valid, then there exists a proof of it. The proof of completeness involves 3 steps: 1) transforming the formula into conjunctive normal form, 2) using the Lindenbaum-Tarski algebra, and 3) constructing a proof. Normal forms like conjunctive normal form and Horn clauses are also mentioned.

Uploaded by

rchimombe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views34 pages

Soundness Completeness Conjuctive Normal Form Horn Clauses

The document discusses soundness and completeness in propositional logic. It defines soundness as proving that if a formula is provable then it is logically valid. It involves using induction on proof lengths. Completeness means that if a formula is logically valid, then there exists a proof of it. The proof of completeness involves 3 steps: 1) transforming the formula into conjunctive normal form, 2) using the Lindenbaum-Tarski algebra, and 3) constructing a proof. Normal forms like conjunctive normal form and Horn clauses are also mentioned.

Uploaded by

rchimombe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Propositional Logic, continued: Soundness, Completeness, & Special Forms

Soundness

Completeness

Conjuctive Normal Form

Horn Clauses

Slide 1 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Soundness (1)


Suppose Φ1  Φn Ψ holds.

Hence, there is a proof of Ψ having Φ1  Φn as premises.

We proceed by induction on the length of these proofs. We need to reformu-


late the soundness statement such that it is amenable to induction.

M  k  : For all sequents Φ1  Φn Ψ that have a proof of
length k, it is the case that Φ1  Φn
Ψ

We intend to use course-of-values induction on k.

Technical problem:

– Chopping a proof may nod lead to correct sub-proofs, since some boxes
may still be open.
– However, a chopped proof (a prefix of the sequence of formulas rep-
resenting a proof) may form a correct proof if the assumptions of the
open boxes are added to the premises.
Slide 2 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04
Soundness (2)

To solve our technical problem, we change the structure of the proof as


in the following example. Consider the following sequent:

p q  r p   q  r

1 p q  r premise 1 0/ p q  r premise
2 p assumption 2  2  p assumption
3 q assumption 3  2 3  q assumption
4 p q i 2,3 4  2 3  p q i 2,3
5 r  e 1,4 5  2 3  r  e 1,4
6 q  r  i 3–5 6  2  q  r  i 3–5
7 p   q  r  i 2–6 7 0/ p   q  r  i 2–6

Note: The set at the right of a formula in a proof line grows and shrinks
as a stack, reflecting the way boxes are opened and closed.

Slide 3 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Soundness (3)

Just for the purpose of proving soundness, we formally change the defi-
nition of the proof as follows.

Definition: A proof of the sequent Γ Ψ is a sequence of pairs
 d1  χ1    dk  χk  where:
(1) d1
0; /
(2) each di is a subset of 1  i ;
 

(3) for each i, χi is either


– a premise (i.e., χi  Γ), or
– an assumption (i.e. χi  di ), or
– χi follows from previous lines by applying deduction rules;
(4) for each i, di is equal to
– di  1 if no box was closed/opened at line i;
– di  1  i if a box is opened on line i;
– di  1  ρ if a box with assumption at line rho was closed
 

 

The length of such a proof is k.

Slide 4 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Soundness (4)

Our inductive statement now becomes:

For any proof of length k  d1  χ1     dk  χk  ,


and any assignment of truth values that makes the
premises in Γ and the assumptions in dk true, it is
the case that χk evaluates to T .

When there is a chopping with no open boxes, this hypothesis precisely


covers the semantic entailment.

Slide 5 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Soundness (5)

We now proceed with the proof.

Base case k
1: the proof has length 1, hence it is of the form

1 0/ χ premise

The statement is obviously true, any assignment of truth values


that makes all the premises true, shall make this premise true as
well.

Induction case k 1: Suppose we have a proof

1 0/ χ1 premise
..
.
k d k χk justi f ication k 

Slide 6 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Soundness (6)

justification-k is a natural deduction rule, hence we proceed by case


analysis.
Φ Ψ Φ Ψ Φ Ψ 
i e1 e2  e
Φ Ψ Φ Ψ Φ

Φ Ψ  Φ
Φ Ψ
. .  e
. .
. .
Φ Ψ χ χ Φ
 i1  i2  e
Φ Ψ Φ Ψ χ

Φ
.
.
.
Ψ Φ Φ Ψ
 i  e
Φ Ψ Ψ

Φ
.
.

.
 Φ
 i  e
 Φ Φ

Slide 7 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Soundness (7)

i: It must be the case that χ


χ1 χ2 , with χi appearing at line ki
k, with i  1  2 . The formulas χ1 , χ2 have shorter proofs, and
 

therefore, using the induction hypothesis, they have the truth value
T . Using the truth table for , we conclude that the truth value of
χ is T .

e: It must be the case that some formula χ1 χ2 appears in in the


 

proof, and that we have two boxes with assumptions χ1 and χ2 and
conclusion χ. The proof of χ1 χ2 is shorter hence, according to


the induction hypothesis, it has a truth value of T . According to the


truth table of , either χ1 or χ2 have the truth value T . Assume it


is χ2 (the case when χ1 has a truth value of T is similar). Then, the


assumption χ2 of the second box is true, and using the induction
hypothesis, its conclusion χ has the truth value T .

The other cases are similar.

Slide 8 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (1)

Theorem: Whenever Φ1  Φn


Ψ holds, there exists a natural de-

duction proof for the sequent Φ1  Φn Ψ.

The proof consists of three steps:

Step 1:
Φ1   Φ2    Φn  Ψ  

Step 2: Φ1   Φ2    Φn  Ψ  

Step 3: Φ1  Φn Ψ

Definition: A formula of propositional logic is a tautology if it is true


for all assignments of truth values to its propositional atoms, i.e. if
Φ.

Slide 9 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (2)

Step 1:
Φ1   Φ2     Φn  Ψ  

This step is easy. Suppose Φ1  Φn


Ψ holds. The implication truth table shows
that the only possiblity for
Φ1  Φ2   Φn Ψ    to fail is to have an
  

assignment of truth values to its atoms that results in all Φ1  Φn having the truth
value T and Ψ having the truth value F; — but this is impossible, as it contradicts
the hypothesis.

Step 3: Φ1  Φn Ψ

This step is also easy. Suppose Φ1 

Φ1
 Φ2   Φn Ψ   holds, i.e.


..
.
has a natural deduction proof Π. Then
Φn
we augment this proof by adding the ..
premises Φ1  Φn to the front, and then Π   
.
  
Φ1 Φ2 Φn Ψ  
using the rule e at the end to produce


Ψ

e
Ψ. In other words, we produce the proof:

Slide 10 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (3)

The core of the completeness proof is Step 2, which requires to show the
following:

If
Φ holds, then Φ holds. In other words, if
Phi is a tautology, then Φ is a theorem.

The idea of the proof is the following:

Suppose
Φ holds.

If formula Ψ has n atoms p1  pn , then Φ has truth value T for


all the 2n lines in its truth table.

Then, we ”encode” each line in the truth table of Φ as a sequent


and assemble them into a proof of Φ using the disjunction rules.

Slide 11 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (4)

The first part of the proof is based on the following lemma.

Lemma: Let Φ be a formula containing the propositional atoms


p1   pn , and l a line of Φ’s truth table. Let p̂i be pi if the entry in
line l of pi is T , otherwise p̂i is pi . Then,

p̂1  p̂n Φ is provable if the entry for Φ in line l is T ;

p̂1  p̂n Φ is provable if the entry for Φ in line l is F.

Slide 12 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (5)

The proof of the lemma is by course of values induction on the height of


the syntax tree of Ψ.

Base case: If Φ is an atom (i.e. a formula of height 1), then we have to


 
show that p p and p p hold. This is immediate.

Slide 13 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (6)

Induction case: The height of Φ is greater than 1. Then, we have the following cases.

Φ is of the form Φ1 .

– If Φ evaluates to T , then Φ1 evaluates to F; Φ1 has the same atoms as Φ,



but a lower height, hence by induction hypothesis p̂1  p̂n Φ1 ; finally
Φ1 is Φ, hence we are done.
– If Φ evaluates to F, then Φ1 evaluates to T ; by induction hypothesis we
 
get p̂1  p̂n Φ1 , which can be extended to p̂1   p̂n Φ1 using the
i rule; but Φ1 is Φ1 , hence we are done.

Φ is of the form Φ1 Φ2 , where  . Let q1  ql be the atoms of Φ1




   

and r1   rk the atoms of Φ2 , where q1  ql  r1  rk

   p1  pn .
  

We are left with proving that


 
q̂1  q̂l Ψ1 and r̂1  r̂k Ψ2

implies p̂1   p̂n Ψ1 Ψ2

for appropriate formulas Ψ1 and Ψ2 .


Slide 14 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04
Completeness (7)

We show the proof for


, that is, we consider the case when Φ
Φ1 Φ2 .

If both Φ1 and Φ2 evaluate to T , then by the induction hypothesis


  
q̂1  q̂l Φ1 and r̂1  r̂k Φ2 , hence p̂1  p̂n Φ1 Φ2 , and we are
done.

If Φ1 evaluates to F and Φ2 evaluates to T , then we have q̂1  q̂l Φ1
 
and r̂1   r̂k Φ2 , hence p̂1  p̂n Φ1 Φ2 We are left with proving
 
p̂1  p̂n Φ1 Φ2 implies p̂1  p̂n  Φ1 Φ2 

(left as an exercise)

The other two cases are similar, requiring the following proofs:

Φ1 Φ2  Φ1 Φ2 

Φ1 Φ2  Φ1 Φ2 

Slide 15 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (8)

If Φ is of the form Φ1 Φ2 , we can reduce the proof to the search for the


following proofs.

Φ1 Φ2 Φ1 Φ2



Φ1 Φ2 Φ1 Φ2



Φ1 Φ2 Φ1 Φ2



Φ1 Φ2  Φ1 Φ2 


If Φ is of the form Φ1  Φ2 , we can reduce the proof to the search for


the following proofs.

Φ1 Φ2 Φ1 Φ2



Φ1 Φ2  Φ1 Φ2 



Φ1 Φ2 Φ1 Φ2



Φ1 Φ2 Φ1 Φ2


Slide 16 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (9)

The last piece of the puzzle is to assemble these proofs of the form

p̂1  p̂n Φ

each representing a line in the truth table, into a proof of Φ, without
premises.

We use the disjunction rules to generate the lines of the truth table, then
we appropriately insert the above proofs.

We exemplify this procedure for the case of two atoms, for the tautology

p q p.

Slide 17 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Completeness (10)

Assembling the proof for the tautology p q  p.
1 p p LEM


2 p ass p ass

3 q q LEM q q LEM
 

4 q ass q ass q ass q ass


.... .... .... ....
5 .. .. .. ..

7 p q  p p q  p p q  p p q  p

8 p q p e p q p e
 

 

9 p q p e


Slide 18 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Semantic Equivalence & Validity

Definitions:

Let Φ and Ψ be propositional logic formulas. They are semantically


equivalent iff Φ
Ψ and Ψ
Φ. We denote this by Φ Ψ.

Φ is valid iff
Φ.

Remarks:

Two formulas Φ and Ψ are semantically equivalent iff


 Φ  Ψ
Ψ  Φ .

Because of soundness and completeness of propositional logic, se-



mantic equivalence is identical with provable equivalence Φ 

Ψ   Ψ Φ  . (This is a fortunate case, most logics are not complete).




Our aim is to transform formulas into equivalent ones for which check-
ing validity is easier.

Slide 19 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Conjunctive Normal Form

Definitions:

A literal is either an atom p, or the negation of an atom p.

A formula Φ is in conjunctive normal form (CNF) if it is of the


form Ψ1 Ψ2  Ψn , for some n 1, where each Ψi is a dis-
junction of literals, for all i  1  n .  

Note: Sometimes we include the case n


0, in which case, by conven-
tion, the term is . 

Examples of CNFs:
 q p r  p r q
  

 p r  p r  p r
  

Not in CNF:
  q p r  p r q
  

Slide 20 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Validity of a Disjunction of Literals

Lemma: A disjunction of literals L1 L2  Ln is valid iff there exist i, j, with


  

1 i  j n, such that Li is L j .

Proof:

If there exist i, j such that Li is L j , then clearly L1 L2  Ln evaluates


  

to T for all assignments.

For the converse, if no literal has a matching negation, then:

– For each positive literal we assign F to the corresponding atom.


– For each negative literal we assign T to the corresponding atom.
– This assignment falsifies the disjunction, which is impossiible. (Ex-
ample: for q p r, take p and r to be true, and q to be false and q
 

to be true.)
– Hence, there exist i, j such that Li is L j .

Slide 21 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Satisfiability

Definition: A formula Ψ is satisfiable if there exists an assignment of


truth values to its propositional atoms such that Φ is true.

Proposition: A propositional logic formula Φ is satisfiable iff Φ is not


valid.

Proof:

If Φ is satisfiable, then there exists a valuation (assignment of truth


values to its atoms) which makes Φ true. For this valuation Φ has
the truth value F, hence Φ cannot be valid.

Conversely, if Φ is not valid, then there exists a valuation for


which Φ has the truth value F. This valuation makes Φ have the
truth value T , hence Φ is satisfiable.

This is a simple, but very useful result.

Slide 22 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Useful Identities (Boolean Algebra)

and are idempotent and are distributive


 

Φ Φ Φ Φ  Ψ η  Φ Ψ  Φ η
 

Φ Φ Φ Φ  Ψ η  Φ Ψ  Φ η
   

and are commutative Rules for T and F




Φ Ψ Ψ Φ F Φ F Φ Φ F
Φ Ψ Ψ Φ T Φ T Φ Φ T
   

and are associative The de Morgan rules




Φ  Ψ η  Φ Ψ η  Φ Ψ Φ Ψ


Φ  Ψ η  Φ Ψ η  Φ Ψ Φ Ψ
    

and are absorbative Double negation rules




Φ  Φ η Φ Φ Φ


Φ  Φ η Φ


Slide 23 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


A Procedure to Compute CNFs

We present an algorithm to compute a CNF formula equivalent to a given


arbitrary formula Φ. The algorithm is deterministic and computes a
unique CNF for any formula.
The algorithm is described as:

CNF(NNF(IMPL FREE(Φ)))

for a given formula Φ. The CNF, NNF, and IMPL FREE functions shall
be discussed shortly.

Slide 24 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


IMPL FREE

function IMPL FREE(Φ) :


/* precondition: Φ is an arbitrary formula */
/* postcondition: returns an implication free formula equivalent to Φ */
begin function
case
Φ is a literal: return Φ
Φ is Φ1 : return  IMPL FREE  Φ1 
Φ is Φ1 Φ2 : return IMPL FREE  Φ1  IMPL FREE  Φ2 
Φ is Φ1 Φ2 : return IMPL FREE  Φ1  IMPL FREE  Φ2 
 

Φ is Φ1 Φ2 : return IMPL FREE  Φ1  IMPL FREE  Φ2 




end case
end function

Slide 25 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


IMPL FREE Example

Let Φ
p q  p  r  q .

IMPL FREE  Φ 
IMPL FREE  p q  IMPL FREE  p  r q 


 IMPL FREE  p  IMPL FREE  q  IMPL FREE  p  r q 


 p  IMPL FREE  q  IMPL FREE  p  r q 




 p  q  IMPL FREE  p  r q 




 p  q   p  IMPL FREE  r  IMPL FREE  q 


 

 p  q   p  r IMPL FREE  q 


 

 p  q   p  r q 
 

Slide 26 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


NNF

function NNF(Φ) :
/* precondition: Φ is implication free */
/* postcondition: returns an NNF formula equivalent to Φ */
begin function
case
Φ is a literal: return Φ
Φ is Φ1 : return NNF  Φ1 
Φ is Φ1 Φ2 : return NNF  Φ1  NNF  Φ2 
Φ is Φ1 Φ2 : return NNF  Φ1  NNF  Φ2 
 

Φ is  Φ1 Φ2  : return NNF  Φ1 Φ2 


Φ is  Φ1 Φ2  : return NNF  Φ1 Φ2 


end case
end function

Slide 27 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


NNF Example

Let Φ
 p q  p  r q  .
 

NNF  Φ 
NNF   p  q  NNF  p  r q 
 

NNF   p  q  NNF  p  r q 


  

 NNF  p   NNF  q  NNF  p  r q 


  

p  NNF  q  NNF  p  r q 


  

p q NNF  p  r q 
  

p q  NNF  p  NNF  r q 


  

p q  p NNF  r q 
  

p q  p  NNF  r  NNF  q 


  

p q  p  r NNF  q 
  

p q  p  r q 
  

Slide 28 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


CNF

function CNF(Φ) :
/* precondition: Φ is implication and in NNF */
/* postcondition: returns an CNF formula equivalent to Φ */
begin function
case
Φ is a literal: return Φ
Φ is Φ1 Φ2 : return CNF  Φ1  CNF  Φ2 
Φ is Φ1 Φ2 : return DISTR  CNF  Φ1   CNF  Φ2 


end case
end function

Slide 29 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


DISTR

function DISTR(Φ1 ,Φ2 ) :


/* precondition: Φ1 , Φ2 are in CNF */
/* postcondition: returns an CNF formula equivalent to Φ1 Φ2 */


begin function
case
Φ1 is Φ11 Φ12 : return DISTR  Φ11  Φ2  DISTR  Φ12  Φ2 
Φ2 is Φ21 Φ22 : return DISTR  Φ1  Φ21  DISTR  Φ1  Φ22 
otherwise: return Φ1 Φ2


end case
end function

Slide 30 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


CNF Example

Let Φ
p q  p  r q  .
  

CNF  Φ 
CNF  p q  p  r q 
  

DISTR  CNF  p q   CNF  p  r q 


 

DISTR  p q  CNF  p  r q 


 

DISTR  p q  p  r q 
 

DISTR  p q  p  DISTR  p q  r q
  

 p q p  p q r q
    

Slide 31 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Horn Clauses

Definitions:

A Horn clause is a formula of the form p1 p2  pk  q,


where k 1, and p1  p2  pk  q are atoms, , or  .

A Horn formula is a conjunction of Horn clauses, i.e. a formula


Φ of the form Ψ1 Ψ2  Ψn , (n 1), such that each Ψi is a
Horn clause, i  1  n .
 

Horn clauses have an efficient procedure to decide their satisfiability, and


are the basis for logic programming.

Slide 32 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


Horn Clauses Examples

Examples (yes)

 p q s p  q r
  p  p s  s
 p q s   q r  p    s
 p1 p3 p5 p13  
   p5   p5 p11  

Examples (no)

 p q s p  q r
  p  p s  s
 p q s   q r
  p    s
 p1 p3 p5 p13 p27      p5   p5 p11  

Slide 33 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04


HORN
function HORN(Φ) :
/* precondition: Φ is a Horn formula*/
/* postcondition: decides the satisfiability of Φ*/
begin function
if Φ contains a clause   then return unsatisfiable
else mark all atoms p where   p is a clause of Φ
while there is a Horn clause p1  pki  qi of Φ
such that all p j are marked, but qi isn’t do
if qi then return ’unsatisfiable’
else mark qi for all Horn clauses of Φ
end while
return ’satisfiable’
end function

Theorem: The HORN algorithm is correct: it always terminates and its


answer is ’satisfiable’ iff the given Horn formula is satisfiable.

Slide 34 CS4231 — Logic and Formal Systems — Lecture 02 — 19/08/04

You might also like