l9 logic concepts

72
Propositional Logic Concepts  Logic is a study of methods and principles used to distinguish correct from incorrect reasoning.  Formally it deals with the notion of truth in an abstract sense and is concerned with the principles of valid inferencing.  A proposition in logic is a declarative statements such as “Jack is a male”, "Jack loves Mary" etc. which are either true or false (but not both) in a given context.

Upload: abhishek-katyal

Post on 07-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 1/72

Propositional Logic Concepts•  Logic is a study of methods and principles

used to distinguish correct from incorrect

reasoning.•  Formally it deals with the notion of truth in an

abstract sense and is concerned with the

principles of valid inferencing.•  A proposition in logic is a declarative

statements such as “Jack is a male”, "Jack 

loves Mary" etc. which are either true or false(but not both) in a given context.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 2/72

 If we are given some propositions to be true in

a given context, then logic helps in inferencingnew proposition, which is also true in thesame context.

•  For example, if we are given a set of propositions such as “It is hot today" and “If it is hot it will rain", then we can infer that“It will rain today".

•  Propositional Calculus (PC) is a language of propositions basically refers to set of rulesused to combine the propositions to form

compound propositions using logical operatorsoften called connectives such as Λ, V, ~,→, ↔

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 3/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 4/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 5/72

Equivalence LawsCommutation

1. P Λ

 Q ≅

 Q Λ

 P

2. P V Q ≅

 Q V P

Association

1. P Λ

 (Q Λ

 R) ≅

 (P Λ

 Q) Λ

 R

2. P V (Q V R) ≅

 (P V Q) V R

Double Negation

~ (~ P) ≅

 P

Distributive Laws

1. P Λ

 ( Q V R) ≅

 (P Λ

 Q) V (P Λ

 R)

2. P V ( Q Λ

 R) ≅

 (P V Q) Λ

 (P V R)

De Morgan’s Laws

1. ~ (P Λ  Q) ≅   ~ P V ~ Q2. ~ (P V Q) ≅

 ~ P Λ

 ~ Q

Law of Excluded Middle

P V ~ P ≅

 T (true)

Law of ContradictionP Λ

 ~ P ≅

 F (false)

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 6/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 7/72

• These laws can be verified using truth table approach.

• Let us verify A V (A Λ

 B) ≅

 A using truth table approach.

Showing A V (A Λ B) ≅ A 

A B A Λ B A V A Λ B

T T T T

T F F T

F T F F

F F F F

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 8/72

Propositional Logic

• It basically deals with the validity,satisfiability and unsatisfiability of a

formula and derivation of a new formulausing equivalence laws.

• Each row of a truth table for a given formula

is called its interpretation under which aformula can be true or false.

• A formula α  is called tautology if and onlyif α  is true for all interpretations.

• A formula α

 is also called valid if and only

if it is a tautology.

E  d i   t   e d  b  y 

F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t  

 (   C  )   b  y F  ox i   t   S  of   t  w ar  e C  om p an y  ,2  0  0  5 -2 

 0  0  8 

F  or E v  al   u

 a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 9/72

• Let α  be a formula and if there exist at leastone interpretation for which α  is true, then α  issaid to be consistent (satisfiable) i.e., if  ∃

 a

model for α, then α  is said to be consistent .• A formula α  is said to be inconsistent

(unsatisfiable), if and only if α

 is always false

under all interpretations.• We can translate simple declarative and

conditional (if .. then) sentences of naturallanguage into its corresponding propositionalformulae.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 10/72

Example: Show that "If it is humid then it will rain and itis humid today then it will rain" is a valid argument.

Solution: Let us symbolize English sentences by

propositional atoms as follows:

A : It is humid

B : It will rain

Formula corresponding to a text:

α

 : ((A →

 B) Λ

 A) → B

Using truth table approach, one can see that α

 is true

under all four interpretations and hence is valid

argument.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 11/72

 

Truth Table for ((A → B) Λ A)→ B 

A B A → B = X X Λ A = Y Y→ B

T T T T T

T F F F T

F T T F T

F F T F T

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 12/72

Natural Deduction Systems in PL• Truth table method for problem solving is simple

and straightforward and is very good at presenting

a survey of all the truth possibilities in a givensituation.

• It is an easy method of evaluating a consistency,

inconsistency or validity of a formula, but the size

of truth table grows exponentially.

• If a formula contains n atoms, then the truth tablewill contain 2n entries. Truth table method is good

for small values of n.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 13/72

Example: If we have to show that a formula α

 : (P Λ

 Q Λ

 R) →  ( Q V S) is valid using truth table, then we have toconstruct a table of 16 rows for which the truth values of α

 are to be computed.

• If we carefully analyze α, we realize that if P Λ

 Q Λ

 R is

false, then α  is bound to be true because of the definitionof →. Since P Λ

 Q Λ

 R is false for 14 entries out of 16, we

are left only with two entries to be tested for whichP Λ

 Q Λ

 R.

• Therefore, we may find that in order to prove the validityof a formula, all the entries in the truth table are notrelevant in this case.

• There are other methods where we will be concerned withproofs and deductions of logical formula.  Natural Deductive System

 Axiomatic System

Semantic Tableaux Method 

 Resolution Refutation Method 

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 14/72

Natural deduction method

• It is based on the set of few deductive inference rules.

• The name natural deductive system is given because itmimics the pattern of natural reasoning.

• It has about 10 deductive inference rules.

Conventions:•

 E for Elimination.

 P, Pk  , (1 ≤

 k  ≤

 n) are atoms.

• αk , (1 ≤

 k  ≤

 n) and β

 are formulae.

Rule 1: I-Λ

 (Introducing Λ)

I-Λ  : If P1, P2, …, Pn then P1 Λ  P2 Λ  …Λ  Pn

 Interpretation: If we have hypothesized or proved P1, P2, …and Pn , then their conjunction P1 Λ

 P2 Λ

 …Λ

 Pn is also

proved or derived.

E  d i   t   e d  b  y 

F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e C  om p an y  ,2  0  0  5 -2 

 0  0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 15/72

Rule 2: E-Λ

 ( Eliminating Λ)

E-Λ

 : If P1 Λ

 P2 Λ

 …Λ

 Pn then Pi ( 1 ≤

 i ≤

 n)

 Interpretation: If we have proved P1 Λ

 P2 Λ

 …Λ

 Pn , then

any Pi is also proved or derived. This rule shows that Λ

 can

be eliminated to yield one of its conjuncts.

Rule 3: I-V (Introducing V)

I-V : If Pi ( 1 ≤

 i ≤

 n) then P1V P2 V …V Pn

 Interpretation: If any Pi (1≤

 i ≤

 n) is proved, then P1 V …

V Pn is also proved.

Rule 4: E-V ( Eliminating V)E-V : If P1 V … V Pn, P1 → P, … , Pn → P then P

 Interpretation: If P1 V…V Pn , P1 →

 P, P2 →

 P …and Pn →

P are proved, then P is proved.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 16/72

Rule 5: I-→

 (Introducing→ )

I- →  : If from

α1, …,

αninfer

β  is proved

then α1 Λ  …

Λαn → β is proved

 Interpretation: If given α1, α2, …and αn to be proved and fromthese we deduce β

 then α1 Λ α2 Λ… Λαn → β

 is also

proved.

Rule 6: E-→

 (Eliminating→ ) - Modus Ponen

E- →

 : If P1 → P, P1 then P

Rule 7: I-↔ (Introducing ↔ )

I- ↔  : If P1 → P2, P2 → P1 then P1 ↔ P2

Rule 8: E-↔ (Elimination ↔ )

E- ↔

 : If P1 ↔ P2 then P1 → P2 , P2 →

 P1

Rule 9: I- ~ (Introducing ~)I- ~ : If from P infer P1 Λ  ~ P1 is proved then ~P is

proved

Rule 10: E- ~ (Eliminating ~)

E- ~ : If from ~ P infer P1 Λ  ~ P1 is proved then P isproved

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 17/72

NDS Rules Table

Rule Name Symbol Rule Description

 Introduce Λ  (I:Λ) If A1, A2, …, An then

A1 Λ A2 Λ …Λ An

If A1, A2, … and An are true,

then their conjunction A1 Λ A2 Λ 

…Λ An is also true.

 Eliminate Λ  (E:Λ) If A1 Λ A2 Λ …Λ An then

Ai ( 1 ≤ i ≤ n)

If A1 Λ A2 Λ …Λ An is true,

then any Ai is also true.

 Introducing V  (I:V) If Ai ( 1 ≤ i ≤ n) then

A1V A2 V …V An

If any Ai (1≤ i ≤ n) is true, then

A1 V …V An is also true. 

 Eliminating V  (E:V) If A1 V … V An, A1 → A,… , An → A then A

If A1 V…V An , A1 → A, A2 → A …and An→ A are proved to be

true, then A is proved to be true. 

 Introducing →   (I : →) If from α1, …, αn infer β  

is proved then α1 Λ … αΛn

→  β  is proved

If given that α1, α2, …and αn are

true and from these we deduce β 

then α1 Λ α2 Λ… αΛn → β  is

also proved to be true.

 Eliminating →   (E: → ) If A1 → A, A1 then A If A1 → A and A1 are true then A

is also true. This is called  Modus

Ponen rule

 Introducing ↔   (I: ↔) If A1 → A2, A2 → A1

then A1 ↔ A2

If A1 → A2 and A2 → A1 are

true then A1 ↔ A2 is also true.

 Elimination ↔   (E: ↔) If A1 ↔ A2 thenA1 → A2 , A2 → A1

If A1 ↔ A2 is true thenA1 → A2 and A2 → A1 are

true

  Introducing ~ (I: ~ ) If  from A infer

A1 Λ~ A1 is proved then ~A

is proved

If from A, a contradiction is

proved then truth of ~A is also

proved

  Eliminating ~ (E: ~) If from ~ A inferA1 Λ~A1 is proved then A is

proved 

If from ~A, a contradiction isproved then truth of A is also

proved

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 18/72

•  If a formula β  is derived / proved from a setof premises / hypotheses { α1,…, αn }, thenone can write it as from α1, …, αn infer β.

•  In natural deductive system, a theorem to beproved should have a form from α1, …, αninfer β

•  If we write infer β, then it means that thereare no premises and β

 is true under all

interpretations i.e., β  is a tautology or valid .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 19/72

Example: Prove that P Λ

 (Q V R) follows from P Λ

 Q .

Solution: This problem is restated in natural deductive system as "from

P ΛQ infer P Λ

 (Q V R)". The formal proof is given as follows:

{Theorem} from P ΛQ infer P Λ

 (Q V R)

{ premise} P Λ  Q (1){ E-Λ

 , (1)} P (2)

{ E-Λ

 , (1)} Q (3)

{ I-V , (3) } Q V R (4)

{ I-Λ, ( 2, 4)} P Λ

 (Q V R) Conclusion

• If we assume that α → β

 is a premise, then we conclude

that β

 is proved if α

 is given i.e., if ‘from α

 infer β’ is a

theorem then α → β is concluded. The converse of thisis also true.

Deduction Theorem:

To prove a formula α1 Λ α2 Λ… Λ αn → β, it is sufficient

to prove a theorem from α1, α2, …, αn infer β.

E  d i   t   e d  b  y 

F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar 

 e C  om p an y  ,2  0  0  5 -2 

 0  0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 20/72

Example: Prove the following theorem:

infer ((Q → P) Λ  (Q → R)) → (Q → (P Λ  R))Solution: In order to prove infer ((Q →

 P) Λ(Q →

 R)) →

 (Q → (P

Λ

 R)), we prove a theorem from {Q →

 P, Q →

 R} infer Q → (P

Λ

 R). Further, for proving Q→ (P Λ

 R), we have to prove a sub

theorem from Q infer PΛ  R{Theorem} from Q→ P, Q→ R infer Q→ (P Λ

 R)

{ premise 1} Q → P (1)

{ premise 2} Q → R (2){ sub theorem} from Q infer P Λ

 R (3)

{ premise } Q (3.1)

{ E- → , (1, 3.1) } P (3.2)

{E- →, (2, 3.1) } R (3.3)

{ I-Λ, (3.2,3.3) } P Λ

 R (3.4)

{ I-→, ( 3 )} Q → (P Λ

 R) Conclusion

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 21/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 22/72

Example: Establish the following:

1. {Q} |- (P → Q) i.e., P →

 Q is a deductive consequence of {Q}.

{Hypothesis} Q (1)

{Axiom A1} Q →

 (P →

 Q) (2)

{MP, (1,2)} P→

 Q proved

2. { P →

 Q, Q →

 R } |- ( P →

 R ) i.e., P →

 R is a deductive

consequence of { P →

 Q, Q →

 R }.

{Hypothesis} P →

 Q (1)

{Hypothesis} Q → R (2){Axiom A1} (Q→

 R) → (P →

 (Q →

 R)) (3)

{MP, (2, 3)} P →

 (Q →

 R) (4)

{Axiom A2} (P →

 (Q →

 R)) →

((P → Q) →

 (P → R)) (5)

{MP , (4, 5)} (P → Q) →

 (P → R) (6)

{MP, (1, 6)} P → R proved

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 23/72

1. Useful tip

Given α, we can easily prove β →  α for any well-formedformulae α

 and β.

Deduction Theorem:

If  ∑

 is a set of hypotheses and α

 and β

 are well-formed

formulae , then {∑ ∪ α } |- β

 implies ∑

 |- (α → β ).

Converse of deduction theorem:

Given ∑

 |- (α → β ), we can prove { ∑ ∪ α } |- β.

2. Useful tipIf  α → β is to be proved, then include α

 in the set of 

hypotheses ∑

 and derive β

 from the set {∑ ∪ α}. Then

using deduction theorem, we conclude α → β.

Example: Prove ~ P → (P → Q) using deduction theorem.

Proof: We prove {~ P} |- (P →

 Q) and |- ~ P →

 (P →

 Q)

follows from deduction theorem.

E  d i   t   e d  b  y 

F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar 

 e C  om p an y  ,2  0  0  5 -2  0  0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 24/72

Semantic Tableaux System in PL

• Earlier approaches require construction of proof of 

a formula from given set of formulae and are

called direct methods.• In semantic tableaux, the set of rules are applied

systematically on a formula or set of formulae to

establish its consistency or inconsistency.

• Semantic tableau is a binary tree constructed by

using semantic rules with a formula as a rootSemantic Tableaux Rules

• Assumeα  and

β  be any two formulae.

E  d i   t   e d  b  y 

F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar 

 e C  om p an y  ,2  0  0  5 -2  0  0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 25/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 26/72

Rule 3: A tableau for a formula (α

 V β) is constructed

by adding two new paths one containing α  and othercontaining β.

α

 V β

α β

Rule 4: A tableau for a formula ~ (α

 V β) is

constructed by adding both ~ α  and ~ β  to the samepath. This can be expressed as follows:

` ~ ( α

 V β)

~ α~ β

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 27/72

Rule 5: Semantic tableau for ~ ~ α

 ~ ~ α

α

Rule 6: Semantic tableau for α → βα → β

~ α β

Rule 7: Semantic tableau for ~ ( α → β)

~ (α → β)α

~ β

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 28/72

Rule 8: Semantic tableau for α ↔ βα ↔ β ≅

 (α Λ β) V (~ α Λ ~ β)

α ↔ β

α Λ β

 ~ α Λ ~ β

Rule 9: Semantic tableau for ~ (α ↔ β)

~ (α ↔ β) ≅

 (α Λ ~ β) V (~ α Λ β)

~ (α ↔ β)

α Λ ~ β   ~ α Λ β

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 29/72

Consistency and Inconsistency

•  Whenever an atom P and ~ P appear on a same path of a semantic tableau, then inconsistency is indicated and

such path is said to be contradictory or closed

(finished) path.•

 Even if one path remains non contradictory or

unclosed (open), then the formula α

 at the root of a

tableau is consistent.•

 Contradictory tableau (or finished tableau) is

defined to be a tableau in which all the paths are

contradictory or closed (finished).

 If a tableau for a formula α

 at the root is a contradictory

tableau, then a formula α

 is said to be inconsistent.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 30/72

Example: Show that α: ( Q Λ

 ~ R) Λ

 ( R →

 P)

is consistent and find its model.

{Tableau root} ( Q Λ

 ~ R) Λ

 ( R →

 P) (1)

{Apply rule 1 to 1} (Q Λ  ~ R) (2)( R →

 P) (3)

{Apply rule 1 to 2} Q

{Apply rule 6 to 3} ~R~ R P

open open• { Q = T, R = F } and { P = T , Q = T, R = F } are

models of α.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 31/72

Example: Show that α

 : (P Λ

 Q →

 R) Λ

 ( ~P →

 S) Λ

 Q Λ

 ~ R Λ

 ~ S is inconsistent using tableaux method.

(Root} (P ΛQ →

 R) Λ

 ( P → S) Λ

 Q Λ

 ~R Λ

 ~S (1)

{Apply rule 1 to 1} P Λ

 Q →

 R (2)

~P → S (3)Q

~ R

~ S{Apply rule 6 to 3} ~ ~P = P S

Closed: {S, ~ S} on the path

{Apply rule 6 to 2)} ~ (P Λ  Q) RClosed { R, ~ R}

~P ~ Q

Closed {P, ~ P} Closed{Q, ~ Q}

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 32/72

Resolution Refutation in PL

• Resolution refutation is another simple method

to prove a formula by contradiction.

• Here negation of goal to be proved is added togiven set of clauses and shown that there is a

refutation in new set using resolution principle.• During resolution we need to identify two

clauses, one with positive atom (P) and other

with negative atom (~ P) for the application of resolution rule.

• It is based on modus ponen inference rule.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 33/72

Conjunctive and Disjunctive Normal Forms

• In Disjunctive Normal Form (DNF), a formula isrepresented in the form (L11 Λ  ….. Λ  L1n ) V ..…

V (Lm1 Λ

 ….. Λ

 Lmk ), where all Lij are literals.

• Disjunctive Normal Form is disjunction of 

conjunction.

• Conjunctive Normal Form (CNF) is conjunctionof disjunction. The formula is represented in the

form (L11 V ….. V L1n ) Λ

 …… Λ

 (Lp1 V ….. V

Lpm ) , where all Lij are literals.• A clause is a formula of the form (L1V … V Lm),

where each Lk 

is a positive or negative atom.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 34/72

Conversion of a Formula to its CNF• Each formula in Propositional Logic can be

easily transformed into its equivalent DNF or

CNF representation using equivalence laws .

• Eliminate →  and ↔  by using the following

equivalence laws.P →  Q ≅   ~ P V Q

P ↔ Q ≅

 ( P → Q) Λ

 ( Q → P)

• Eliminate double negation signs by using

~ ~ P ≅

 P

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 35/72

• Use De Morgan’s laws to push ~ (negation)

immediately before atomic formula.

~ ( P Λ

 Q) ≅

 ~ P V ~ Q

~ ( P V Q) ≅   ~ P Λ  ~ Q• Use distributive law to get CNF.

P V (Q Λ  R) ≅   (P V Q) Λ  (P V R)

• We notice that CNF representation of a

formula is of the form (C1 Λ….. ΛCn ) ,

where each Ck  , (1≤  k  ≤  n ) is a clausewhich is disjunction of literals.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 36/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 37/72

Example: Find resolvent of:

C1 = P V Q V R; C2 = ~ Q V W; C3 = P V ~ W

• Inverted Resolution Tree

P V Q V R ~ Q V W{Q, ~ Q}

P V R V W P V ~ W

{W, ~ W}

P V R

• Resolvent(C1,C2, C3) = P V R

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 38/72

Theorem: If C is a resolvent of two clauses C1

and C2 , then C is a logical consequence of 

{C1 , C2 }.

• A deduction of an empty clause from a set Sof clauses is called a resolution refutation of S.

Theorem: Let S be a set of clauses.

• A clause C is a logical consequence of S iff the

set S’= S ∪

 {~ C} is unsatisfiable.

• In otherwords, C is a logical consequence of agiven set S iff an empty clause is deduced from

the set S'.

E  d i   t   e d  b  y F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (  

 C  )   b  y F  ox i   t   S  of   t  w ar  e C  om p an y  ,2  0  0  5 -2  0  0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 39/72

 Example: Show that C V D is a logical consequence

of S ={AVB, ~ AVD, C V~ B} using resolution

refutation principle.

• First we will add negation of logical consequence

i.e., ~ (C V D) ≅  ~C Λ  ~D to the set S.• Get S’ = {A V B, ~ A V D, C V~ B, ~C, ~D}.

• Now we show that S’ is unsatisfiable by derivingcontradiction using resolution principle.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 40/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 41/72

First Order Predicate Logic

Limitation of Propositional Logic:

• The facts: “peter is a man”, “paul is a man”, “john is

a man” can be symbolized by P, Q and R,respectively , in PL.

• But we would not be able to draw any conclusions

about similarities between P, Q and R.

• It would be much better to represent these facts as

MAN(peter), MAN(paul) and MAN(john).•  Further, we are even in more difficulty, if we try to

represent sentences like “All men are mortal” in

Propositional Logic.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 42/72

 In Predicate Logic, such sentences can be easily

represented and the limitations of propositional logicare removed to some extent.

 The predicate logic is logical extension of 

propositional logic. The first order predicate logic is

one where the quantification is over simple variables.

Predicate Calculus• It has three more logical notions as compared to

propositional calculus.

• Terms, Predicates and

• Quantifiers (universal or existential quantifiers i.e.

“for all' and “there exists”)

E  d i   t   e d  b  y F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (  

 C  )   b  y F  ox i   t   S  of   t  w ar  e C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 43/72

A term is a constant (single individual or concept

i.e.,5, john etc.), a variable that stands for differentindividuals and n-place function f(t1, …, tn) where

t1, …, tn are terms.

•  A function is a mapping that maps n terms to a term.

 A predicate is a relation that maps n terms to a truth

value true (T) or false (F).

Examples:

• A statement x is greater than y is represented in

predicate calculus as GREATER(x, y). It is defined asfollows:

GREATER( x, y) = T , if x >

 y

= F , otherwise

E  d i   t   e d  b  y F  ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 44/72

• A statement   x loves yis represented as LOVE(x, y)

which maps it to true or false when x and y getinstantiated to actual values.

• A statement  john’s father loves john is represented as

LOVE(father(john), john). Here  father  is a function

that maps john to his father.

• The predicate names GREATER and LOVE take two

terms and map to T or F depending upon the values of 

their terms.

Quantifiers: Variables are used in conjunction withquantifiers. There are two types of quantifiers viz..,

“there exist” (∃) and “for all” (∀).

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 45/72

Example: Translate the text "Every man is mortal. John is a man. Therefore, John is mortal" into

Predicate Calculus formula.

Solution: Let MAN(x), MORTAL(x) represent‘x is a man’ and ‘x is mortal’ respectively.

• Every man is mortal :(∀x) (MAN(x) → MORTAL(x))

• John is a man : MAN(john)

• John is mortal : MORTAL(john)

The whole text can be represented by the followingformula.

(∀x) ((MAN(x) → MORTAL(x)) Λ

 MAN(john))

→ MORTAL(john)

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 46/72

First Order Predicate Logic (FOL)• First order predicate calculus becomes First Order

Predicate Logic if inference rules are added to it.

• Using inference rules one can derive new formulausing the existing ones.

Interpretations of Formulae in FOL•

 In PL, an interpretation is simply an assignment of 

truth values to the atoms. In FOL, there are variables,

so we have to do more than that.•

 An interpretation of a formula α

 in FOL consists of a

non empty domain D and an assignment of values to

each constant, function symbol and predicate symbol.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 47/72

Example: Let α

 : (∀x) (∃

 y) P(x, y) be a formula.

Evaluate it under the following interpretation I.

D = {1, 2}I I[P(1, 1)] = F, I[P(1, 2)] = T,

I[P(2, 1)] = T, I[P(2, 2)] = F

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 48/72

• We use notation I[α] = T (or F), which means thatα  is evaluated to be true or false under interpretation

I over a domain D.

• Let α  and β  are formulae and I is an interpretation

over any domain D. The following holds true.

I[α Λ β] = I[α] Λ  I[β]

I[α  V β] = I[α] V I[β]

I[α → β] = I[α] → I[β]

I[~α] = ~ I[α]= T iff I[α] = F

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 49/72

• A formula α  is said to beconsistent

(satisfiable) if and only if there exists an interpretation I such thatI[α] = T. Alternatively we say that I is a model of α  or I satisfies α.

• A formula α  is said to be inconsistent(unsatisfiable) if and only if ∃  no interpretation thatsatisfies α  or there exists no model for α.

• A formula α  is valid if and only if for everyinterpretation I, I[α] = T.

• A formula α  is a logical consequence of a set of formulae {α1, α2, ..., αn } if and only if for everyinterpretation I, if I[α1 Λ

 … Λ αn ] = T, then

I[α] = T.

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 50/72

Prenex Normal Form

• In FOL, there are infinite number of domains andconsequently infinite number of interpretations of 

a formula.• Therefore, unlike PL, it is not possible to verify a

validity and inconsistency of a formula by

evaluating it under all possible interpretations.• We will discuss the formalism for verifying

inconsistency and validity in FOL.

• In FOL, there is also a third type of normal formcalled Prenex Normal Form.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 51/72

Contd..

• A closed formula α  of FOL is said to be inPrenex Normal Form (PNF) if and only if  α

 is

represented as

(q1 x1) (q2 x2) … (qn xn) (M),

where, qk , (1 ≤

 k ≤

 n ) quant (∀

 or ∃) and M is

a formula free from quantifiers.

 A list of quantifiers [(q1 x1) … (qn xn)] is calledprefix and M is called the matrix of a formula α.Here M is represented in CNF.

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 52/72

Transformation of Formula into PNF

• A formula can be easily tranformed into

PNF using various equivalence laws. We usethe following conventions:

α

 [x] - a formula α, which contains

a variable x.α   - a formula without a variable

x.q - Quantifier (∀  or ∃  ).

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 53/72

 Equivalence Laws: There are following pairs of 

logically equivalent formulae called equivalencelaws in addition to the equivalence laws given for

PL.

1. (q x) α  [x] V β ≅ (q x) (α  [x] V β  )

2. α

 V (q x) β

 [x] ≅

 (q x) (α

 V β

 [x])

3. (q x) α  [x] Λ β  ≅   (q x) (α  [x] Λ β )

4. α Λ (q x) β  [x] ≅   (q x) (α Λ β [x])

5. ~ ((∀x) α

 [x]) ≅

  (∃x) (~α

 [x])

6. ~ ((∃x) α  [x]) ≅   (∀x) (~ α  [x])

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 54/72

Skolemisation (Standard Form)

• Prenex normal form of a formula is furthertransformed into special form calledSkolemisation or Standard Form.

• This form is used in resolution of clauses.

• The process of eliminating existential quantifiersand replacing the corresponding variable by aconstant or a function is called skolemisation.

• A constant or a function is called skolem constant

or function.

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 55/72

Convertion of PNF to its Standard Form

• Scan prefix from left to right. If q1 is the firstexistential quantifier then choose a new constant c∉

 Matrix. Replace all occurrence of x1 appearing

in Matrix by c and delete (q1 x1) from the prefixto obtain new prefix and matrix.

 If qr is an existential quantifier and q1….qr-1 are

universal quantifiers appearing before qr , thenchoose a new (r-1) place function symbol 'f ' ∉  Matrix. Replace all occurrence of xr in Matrix byf(x

1

, …,xr-1

) and remove (qr

xr

).

•  Repeat the process till all existential quantifiersare removed from matrix.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 56/72

 Any formula α

 in FOL can be transformed into its standard

form.•

 Matrix of standard formula is in CNF and prefix is freefrom existential quantifiers.

 Formula in standard form is expressed as:

(∀x1)… (∀xn) (C1 Λ… ΛCm),where Ck ,(1≤

 k ≤m) is formula in disjunctive normal form.

 Since all the variables in prefix are universally quantified,

we omit prefix part from the standard form for the sake of convenience and write standard form as (C1 Λ… ΛCm).

 A clause is a closed formula of the form (∀x1) … (∀xn)(L1V … V Lm), where each Lk  is a literal and x1,…,xn are

variables occurring in L1, …, Lm.•

 Since all the variables in a clause are universallyquantified, we omit them and write clause as (L1V … VLm ) for the sake of simplicity.

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 57/72

 The standard form of any formula is of the form

(C1 Λ… ΛCm), where each Ci , (1 ≤  i ≤  m) is a clause.•

 We define S = { C1, … ,Cm } to be a set of clauses thatrepresents a standard form of a formula α.

•  S is said to be unsatisfiable (inconsistent) if and only if there ∃

 no interpretation that satisfies all the clauses of S

simultaneously.

 A formula α

 is unsatisfiable (inconsistent) if and only if its

corresponding set S is unsatisfiable.•

 S is said to be satisfiable (consistent) if and only if eachclause is consistent i.e., ∃

 an interpretation that satisfies all

the clauses of S simultaneously.•

 Alternatively, an interpretation I models S if and only if Imodels each clause of S.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 58/72

Resolution in Predicate Logic

• Resolution method is used to test unsatisfiabilityof a set S of clauses in Predicate Logic. It is an

extension of resolution method for PL.• The resolution principle basically checks whether

empty clause is contained or derived from S.

• Resolution for the clauses containing no variablesis very simple and is similar to prop logic. Itbecomes complicated when clauses contain

variables.• In such case, two complementary literals are

resolved after proper substitutions so that both the

literals have same arguments.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 59/72

Example: Consider two clauses C1 and C2 as follows:

C1 = P(x) V Q(x)C2 = ~ P(f(x)) V R(x)

• Substitute 'f(a)' for 'x' in C1 and 'a' for 'x' in C2 , where 'a'is a new constant from the domain, then

C3 = P(f(a)) V Q(f(a))

C4 = ~ P(f(a)) V R(a)

• Resolvent C of C3 and C4 is [Q(f(a)) V R(a)]

• Here C3 and C4 do not have variables. They are calledground instances of C1 and C2 .

• In general, if we substitute 'f(x)' for 'x' in C1 , then

C'1 = P(f(x)) V Q(f(x))• Resolvent C' of C'1 and C2 is [Q(f(x)) V R(x)]

• We notice that C is an instance of C' .

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C  )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a

 t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 60/72

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 61/72

Procedure:

•  Obtain a set S of all the clauses by converting each αk  toits corresponding standard form and then to the clauses.

 Show that a set S ∪

 { ~ L} is unsatisfiable i.e., the set S ∪

 { ~ L} contains either empty clause or empty clause can bederived in finite steps using resolution method.

 If so, then report 'Yes'  and conclude that L is a logicalconsequence of S and subsequently of formulae α1, …, αn

otherwise report 'No' .• If the choice of clauses to resolve at each step is made in a

systematic ways, then resolution algorithm will find a

contradiction if one exists.• There exist various strategies for making the right choice

that can speed up the process considerably.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 62/72

Useful Tips:

 Initially choose a clause from the negated goal clauses asone of the parents to be resolved ( This corresponds tointuition that the contradiction we are looking for must be

because of the formula we are trying to prove) .•

 Choose a resolvent and some existing clause if bothcontain complementary literals.

 If such clauses do not exists, then resolve any pairs of clauses that contain complementary literals.

 Whenever possible, resolve with the clauses with singleliteral. Such resolution generate new clauses with fewer

literals than the larger of their parent clauses and thusprobably algorithm terminates faster.

 Eliminate tautologies and clauses that are subsumed byother clauses as soon as they are generated.

L i P i

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 63/72

Logic Programming

• Logic programming is based on first orderpredicate logic. Clauses are very common inlogic programming which are special forms of FOL.

•  Program in logic programming is a collectionof clauses. Clause in logic programming

adopts a special clausal notation.•  Queries are solved using resolution principle.

 A clause in logic programming is represented

in a clausal notation as A1, …, Ak  ←  B1,…, Bt , where A j are positive literals andBk are negative literals.

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C 

 )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 64/72

Conversion of a Clause into Clausal Notation

• A clause in FOL is a closed formula of the form,

(∀x1) … (∀xn) (L1V… V Lm), where each Lk  ,(1 ≤  k ≤  n) is a literal and xk  , (1 ≤  k ≤  n) are allthe variables occurring in L1, …, Lm .

•  Remove the prefix (∀x1) … (∀xn) for the sake of simplicity because all the variables appearing in aclause are universally quantified .

•  Now a clause is represented as L1V… V Lm,where Lk  , (1 ≤  k ≤  n) are literals free from quant.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 65/72

 Separate positive and negative literals in the clause

as follows:(L1V L2 V… V Lm)

 (A1 V … VAk  V ~ B1 V …V~ Bt),

where m = k + t, A j, (1 ≤   j ≤  k) are positive literalsand B j , (1 ≤

  j ≤

 t) are negative literals.

 (A1 V … VAk ) V ~ (B1 Λ

 … Λ

 Bt)

 (B1 Λ

 … Λ

 Bt) →

 (A1 V … VAk )

{since P → Q ≅

 ~ P V Q}

• Clausal notation is written in the form :(A1 V … VAk ) ← (B1 Λ

 … Λ

 Bt) Or

A1, …, Ak ← B1,…, Bt .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 66/72

• Here A j , (1 ≤   j ≤  k) are positive literals andBi , (1 ≤  i ≤  t) are negative literals.

• It must be noted that interpretation of A ← B

is same as B → A• In clausal notation, all variables are assumed

to be universally quantified.

• Bi , (1 ≤  i ≤  t) (negative literals) are calledantecedents and A j , (1 ≤   j ≤  k) (positiveliterals) are called consequents.

• Commas in antecedent and consequent denoteconjunction and disjunction respectively.

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C 

 )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 67/72

•  Applying the results of FOL to the logicprograms, a goal G with respect to a program P(finite set of clauses) is solved by showing thatthe set of clauses P ∪

 { ~ G} is unsatisfiable or

there is a resolution refutation of P ∪  { ~ G}.

 If so, then G is logical consequence of a

program P. The basic constructs of logicprogramming are inherited from FOL.

•  There are three basic statements: facts, rulesand queries. These are special forms of clauses.

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 68/72

Example: Consider the following logic program.

GRANDFATHER (x, y) ←  FATHER (x, z) , PARENT (z, y)PARENT (x, y) ←

 FATHER (x, y)

PARENT (x, y) ←

 MOTHER (x, y)

FATHER ( abraham, robert) ←

FATHER ( robert, mike) ←• In FOL above program is represented as a set of clauses as:

S = { GRANDFATHER (x, y) V ~ FATHER (x, z) V ~ PARENT(z, y), PARENT(x, y) V ~ FATHER (x, y), PARENT(x, y) V ~MOTHER (x, y), FATHER ( abraham, robert), FATHER ( robert,mike) }

• Let us number the clauses of S as follows:

i.GRANDFATHER (x, y) V ~ FATHER (x, z) V ~ PARENT(z, y)

ii. PARENT(x, y) V ~ FATHER (x, y)

iii. PARENT(x, y) V ~ MOTHER (x, y),

iv. FATHER ( abraham, robert)

v. FATHER ( robert, mike)

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 69/72

• Simple queries :

(a)Ground QueryQuery: “Is abraham a grandfather of mike ?"

← GRANDFATHER (abraham, mike).

• In FOL, ~ GRANDFATHER (abraham, mike) is negationof goal { GRANDFATHER (abraham, mike).

• Include {~goal} in the set S and show using resolutionrefutation that S ∪{~ goal} is unsatisfiable in order toconclude the goal.

• Let ~ goal is numbered as ( vi) in continuation of first fiveclauses of S listed above.

vi. ~ GRANDFATHER (abraham, mike)• Resolution tree is given as follows:

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 70/72

( i ) ( vi )

{x / abraham, y / mike}

( iv) ~ FATHER (abraham, z) V ~ PARENT (z, mike)

{z / robert}

~ PARENT (robert, mike) ( ii)

~ FATHER (robert, mike) (v)

Answer: Yes

E  d i   t   e d  b  y F 

 ox i   t  R  e a d  er 

 C  o p y r i   gh  t   (   C 

 )   b  y F  ox i   t   S  of   t  w ar  e

 C  om p an y  ,2  0  0  5 -2  0 

 0  8 

F  or E v  al   u a t  i   on Onl   y .

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 71/72

(b) Non ground queries

Query: “Does there exist x such that x is a

father of robert ?” {Who is father of robert?}

← FATHER (x, robert).Query: “Does there exist x such that abraham is a

father of x?" {abraham is father of whom?}

← FATHER (abraham, x).

• Query : “Do there exist x and y such that x is a

father of y?" { who is father of whom?}← FATHER (x, y).

8/6/2019 L9 Logic Concepts

http://slidepdf.com/reader/full/l9-logic-concepts 72/72

Assignment 4

• Write a program in language of your choice

for “Checkers” game. Use α-β  pruning

concept.

• Last date of submission: 5th Nov.

– Late submission : 6th Nov. (with penalty)