+ All Categories
Home > Documents > Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is...

Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is...

Date post: 31-Jul-2021
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
99
Resolution for First Order Logic Meghdad Ghari Institute for Research in Fundamental Sciences (IPM) School of Mathematics-Isfahan Branch Logic Group http://math.ipm.ac.ir/Isfahan/Logic-Group.htm Logic Short Course II, Computational Predicate Logic March 9, 2017 Meghdad Ghari (IPM) Resolution Logic Short Course 2017 1 / 82
Transcript
Page 1: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Resolution for First Order Logic

Meghdad Ghari

Institute for Research in Fundamental Sciences (IPM)School of Mathematics-Isfahan Branch

Logic Grouphttp://math.ipm.ac.ir/Isfahan/Logic-Group.htm

Logic Short Course II, Computational Predicate LogicMarch 9, 2017

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 1 / 82

Page 2: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Outline

1 Propositional LogicConjunctive Normal FormPropositional Resolution

2 First Order LogicSyntaxSemanticsResolution for FOLPROLOG

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 2 / 82

Page 3: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Language

Atom = {p1,p2,p3, . . .},A (finite or infinite) set of atomic propositions (or propositionalvariables).L = Atom ∪ {(, ),¬,∧,∨,→}

Formulas of propositional logic are defined by the following grammar inBackus Naur form (BNF):

φ ::= p | (¬φ) | (φ ∧ φ) | (φ ∨ φ) | (φ→ φ), p ∈ Atom

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 3 / 82

Page 4: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Semantics: principle of compositionality

The meaning of a complex expression is determined by the meaningsof its constituent expressions and the rules used to combine them.Valuations:

v : Atom→ {T,F}

Valuations can be extended to the set of all formulas as follows:

v(¬φ) = 1− v(φ)

v(φ ∧ ψ) = min(v(φ), v(ψ))

v(φ ∨ ψ) = max(v(φ), v(ψ))

v(φ→ ψ) = min(1,1− v(φ) + v(ψ))

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 4 / 82

Page 5: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Decideability

DefinitionA logical system is decidable if there is an effective method (oralgorithm) for determining whether arbitrary formulas are theorems ofthe logical system.

Truth tables provide a decision procedure for propositional logic.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 5 / 82

Page 6: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Validity and satisfiability

TheoremLet φ be a formula of propositional logic. Then

φ is satisfiable iff ¬φ is not valid.

TheoremGiven formulas φ1, φ2, . . . , φn and ψ of propositional logic,

φ1, φ2, . . . , φn |= ψ iff |= φ1 ∧ φ2 ∧ . . . ∧ φn → ψ

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 6 / 82

Page 7: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Validity and satisfiability

TheoremLet φ be a formula of propositional logic. Then

φ is satisfiable iff ¬φ is not valid.

TheoremGiven formulas φ1, φ2, . . . , φn and ψ of propositional logic,

φ1, φ2, . . . , φn |= ψ iff |= φ1 ∧ φ2 ∧ . . . ∧ φn → ψ

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 6 / 82

Page 8: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Conjunctive Normal Form (CNF)

L ::= p | ¬p, p ∈ Atom LiteralD ::= L | L ∨ D ClauseC ::= D | D ∧ C Conjunctive normal form

Example (Set representation)

CNF Clausal form(¬q ∨ p ∨ r) ∧ (¬p ∨ r) ∧ q ∧ (r ∨ ¬p) {{¬q,p, r}, {¬p, r}, {q}}

FactsThe empty clsuse � is always false and unsatisfiable.The empty clause form ∅ is valid.A clause form that has � is a contradiction, and henceunsatisfiable.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 7 / 82

Page 9: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Converting formulas to CNFTheoremEvery formula in propositional logic can be transformed into anequivalent formula in CNF

Step 1. Elimination of→ and↔:

φ→ ψ ≡ ¬φ ∨ ψφ↔ ψ ≡ (¬φ ∨ ψ) ∧ (φ ∨ ¬ψ)

Step 2. Converting to negation normal forms (NNF):

¬¬φ ≡ φ¬(φ ∧ ψ) ≡ ¬φ ∨ ¬ψ¬(φ ∨ ψ) ≡ ¬φ ∧ ¬ψ

Step 3. Distributivity rules:

φ ∧ (ψ ∨ σ) ≡ (φ ∧ ψ) ∨ (φ ∧ σ)

φ ∨ (ψ ∧ σ) ≡ (φ ∨ ψ) ∧ (φ ∨ σ)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 8 / 82

Page 10: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Resolution

John Alan Robinson,A Machine-Oriented Logic Based on the Resolution PrincipleJ. ACM. 12 (1): 23-41, 1965.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 9 / 82

Page 11: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Propositional Resolution

Resolution is a refutation procedure used to check if a formula inclausal form is unsatisfiable.

The resolution procedure consists of a sequence of applications of theresolution rule to a set of clauses.

The rule maintains satisfiability: if a set of clauses is satisfiable, so isthe set of clauses produced by an application of the rule.

Therefore, if the (unsatisfiable) empty clause is ever obtained, theoriginal set of clauses must have been unsatisfiable.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 10 / 82

Page 12: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Propositional Resolution Rule

Resolution:¬φ ∨ ψ φ ∨ χ

ψ ∨ χResolution is sound (preserves validity).

Modus Ponens:φ→ ψ φ

ψ

¬φ ∨ ψ φ ∨ >ψ ∨ χ

Modus Ponens is a special case of resolution.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 11 / 82

Page 13: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Propositional Resolution Rule

Resolution:¬φ ∨ ψ φ ∨ χ

ψ ∨ χResolution is sound (preserves validity).

Modus Ponens:φ→ ψ φ

ψ

¬φ ∨ ψ φ ∨ >ψ ∨ χ

Modus Ponens is a special case of resolution.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 11 / 82

Page 14: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Propositional Resolution Rule

Propositional Resolution Rule:

C t {p} D t {¬p}C ∪ D

where C and D are clauses and t denotes disjoint union.

C ∪ D is called the resolvent of C t {p} and D t {¬p}:

C ∪ D = Res(C t {p},D t {¬p})

Resolution on clause forms:

{C1, . . . ,C t {p},D t {¬p}, . . . ,Cn}{C1, . . . ,C ∪ D, . . . ,Cn}

Resolution on clause forms preserves satisfiability.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 12 / 82

Page 15: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Proof by resolution

DefinitionA resolution refutation of S is a resolution proof of empty clause �from S.

TheoremS is unsatisfiable iff there is a resolution refutation of S.

Checking validityφ is valid, if ¬φ is unsatisfiable or there is a resolution refutation of ¬φ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 13 / 82

Page 16: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Proof by resolution

In order to show thatφ1, φ2, . . . , φn |= ψ,

we show that φ1 ∧ φ2 ∧ . . . ∧ φn ∧ ¬ψ is unsatisfiable.

1 First, φ1 ∧ φ2 ∧ . . . ∧ φn ∧ ¬ψ is converted into CNF.2 Then, the resolution rule is applied to the resulting clauses.3 The process continues until one of two things happens:

I two clauses resolve to yield the empty clause �, in which caseφ1, φ2, . . . , φn |= ψ.

I there are no new clauses that can be added, in which caseφ1, φ2, . . . , φn 6|= ψ;

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 14 / 82

Page 17: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Resolution algorithm

/* Input: A set of clauses S *//* Output: S is satisfiable or unsatisfiable */

while there are clauses C1,C2 ∈ S and C := Res(C1,C2)such that C 6∈ S

do S := S ∪ {C}If � ∈ S then

return unsatisfiableelse (i.e. if � 6∈ S)

return satisfiable.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 15 / 82

Page 18: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example IWe prove that

|= ¬(p ∨ q)→ (¬p ∧ ¬q).

To this end, we show that

¬[¬(p ∨ q)→ (¬p ∧ ¬q)] (1)

is unsatisfiable. The CNF of (1) is:

¬p ∧ ¬q ∧ (p ∨ q),

and in clausal form:{{¬p}, {¬q}, {p,q}}.

The following is a resolution refutation of it:

{¬p} {p,q}{q} {¬q}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 16 / 82

Page 19: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example IIWe show that

p 6|= p ∧ q.

To this end, we show that

p ∧ ¬(p ∧ q) (2)

is satisfiable. The CNF of (2) is:

p ∧ (¬p ∨ ¬q),

and in clausal form:S = {{p}, {¬p,¬q}}.

Using resolution algorithm we update S as follows:1 {p} a clause of S2 {¬p,¬q} a clause of S3 {¬q} resolvent of clauses 1 and 2

S is satisfiable, since there are no new resolvents that can be addedand � 6∈ S.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 17 / 82

Page 20: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Resolution refutation as a treeIn order to prove that (p → (q → r))→ ((p → q)→ (p → r)) is valid,we show that its negation is unsatisfiable. The following is a resolutionrefutation tree of its negation:

p p

pq pq

pqr r

����

��

HHHH

HH

����

@@@@

����

AAAA

p denotes ¬p.pq denotes the clause {¬p,q}.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 18 / 82

Page 21: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Exercise

By the resolution algorithm show that:1 ¬(p → ¬q) |= p.

Counterexample in natural language:it is not the case that if it is raining then the ground is not wet |= itis raining.

2 p → q 6|= ¬(p → ¬q).Counterexample in natural language:if it is raining then the ground is wet |= it is not the case that if it israining then the ground is not wet.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 19 / 82

Page 22: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Ontological commitment

Ontological commitment: what the logic assumes about the nature ofreality:

propositional logic assumes that there are facts that either hold ordo not hold in the world.First-order logic assumes that the world consists of objects withcertain relations among them that do or do not hold.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 20 / 82

Page 23: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Language

Objects: people, houses, numbers, theories, Ronald McDonald,colors, baseball games, wars, centuries . . .Relations: these can be unary relations or properties such asred, round, prime, . . ., or more general n-ary relations such asbrother of, bigger than, inside, part of, has color, occurred after,owns, comes between, . . .Functions: father of, best friend, one more than, beginning of . . .

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 21 / 82

Page 24: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Language

Variables:V = {x1, x2, x3, . . .}

Logical operators:

L = {⊥,¬,∨,∧,→, ∀x ,∃x ,=}x∈V for x ∈ V

First order language:

L(R,F , C) = L ∪R ∪ F ∪ C

R is a finite or countable set of relation symbols (or predicatesymbols) of any arity.F is a finite or countable set of function symbols of any arity.C is a finite or countable set of constant symbols.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 22 / 82

Page 25: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Language

Terms (Tm):t ::= x | c | f (t , t , . . . , t),

where x ∈ V, c ∈ C, f ∈ F .

Formulas (Fml):

φ ::= P(t , t , . . . , t) | t = t | (¬φ) | (φ∧φ) | (φ∨φ) | (φ→ φ) | (∀x)φ | ∃xφ,

where P ∈ R, t ∈ Tm, x ∈ V

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 23 / 82

Page 26: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Examples

Natural language Logical formulaJohn walks W (j)

John sees Mary S(j ,m)John gives Mary the book G(j ,m,b)

He walks W (x)John sees her S(j , x)

Someone walks ∃xW (x)Some boy walks ∃x(B(x) ∧W (x))Everyone walks ∀xW (x)

Every girl sees Mary ∀x(G(x)→ S(x ,m))Someone creates everythings ∃x∀yC(x , y)

Natural language processing Computers translate

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 24 / 82

Page 27: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

First Order Theories

First order logic is a framework to formalize mathematical theories.It is a universal language for talking about structures.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 25 / 82

Page 28: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Axioms of FOL

Axioms:1 A finite complete set of axioms of propositional logic,2 ∀xA→ A{t/x}, where t is free for x in A,3 ∀x(A→ B)→ (A→ ∀xB), where x 6∈ FV (A),4 A{t/x} → ∃xA, where t is free for x in A,5 ∀x(A→ B)→ (∃xA→ B), where x 6∈ FV (B),6 ∀x(x = x),7 t1 = t2 ∧ A{t1/x} → A{t2/x}.

Rules:` A→ B ` A

` BMP

` A` ∀xA

Gen

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 26 / 82

Page 29: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Graph Theory

L = {R}, R is a predicate symbol with two arguments.

Proper axioms:1 ∀x¬R(x , x),2 ∀x∀y(R(x , y)→ R(y , x)).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 27 / 82

Page 30: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Group Theory

L = {∗,e}, ∗ is a binary function symbol and e is a constant symbol.

Proper axioms:1 ∀x(e ∗ x = x ∗ e = x),2 ∀x∀y∀z(x ∗ (y ∗ z) = (x ∗ y) ∗ z),3 ∀x∃y(x ∗ y = y ∗ x = e).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 28 / 82

Page 31: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Set Theory

L = {∈}, ∈ is a predicate symbol with two arguments.

Proper axioms:1 ∀z(z ∈ x ↔ z ∈ y)→ x = y ,2 ∀x(ϕ(x)→ x ∈ y)→ ∃w∀x(x ∈ w ↔ ϕ(x)),3 ∃w∀z(z ∈ w ↔ ∃y ∈ x(z ∈ y)),4 ∃w∀x(x ∈ w ↔ x ⊆ y),5 ∃w∀x(x ∈ w ↔ ∃y ∈ z(x = F (y)), where F is a unary operation,6 ∃x(∃y ∈ x∀z(z 6∈ y) ∧ ∀y ∈ x∃z ∈ x∀w(w ∈ z ↔ w ∈ y ∨w = y)),7 ∃y(y ∈ x)→ ∃y ∈ x∀z ∈ y(z 6∈ x).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 29 / 82

Page 32: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Peano Arithmetic PA

L = {0,s,⊕,�}, 0 is a constant symbol, s is a unary function symboland ⊕,� are binary function symbol.

Proper axioms:1 ∀x(s(x) 6= 0),2 ∀x(x 6= 0→ (∃y)s(y) = x),3 ∀x(x ⊕ 0 = x),4 ∀x∀y(x ⊕ s(y) = s(x ⊕ y)),5 ∀x(x � 0 = 0),6 ∀x∀y(x � s(y) = (x � y)⊕ x).7 ∀y [ϕ(0, y) ∧ ∀x(ϕ(x , y)→ ϕ(s(x), y))→ ∀xϕ(x , y)].

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 30 / 82

Page 33: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Semantics of FOL

Syntactic expressions of languagesemantics99K Real situations

ExampleM(x) x is a manB(y) y is a bicycleR(x , y) x rides y

∃x∃y(M(x) ∧ B(y) ∧ R(x , y))

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 31 / 82

Page 34: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Models

DefinitionA model for the first-order language L(R,F , C) is a pairM = (D, I)such that

Domain: D is a non-empty set of individual objects.Interpretation: I is a function mapping relation symbols, functionsymbols, and constant symbols to relations on D, functions on D,and objects in D.

I I(Pn) ⊆ Dn, for Pn ∈ R.I I(f n) : Dn → D, for f n ∈ F .I I(c) ∈ D, for c ∈ C.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 32 / 82

Page 35: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example

Let L = {0,s,⊕,�} be the language of PA.

The standard model N = (N, I) of PA is defined as follows:

I(0) = 0.I(s) = suc, where suc : N→ N is suc(n) = n + 1.I(⊕) = +, where + : N× N→ N is +(n,m) = n + m.I(�) = ·, where · : N× N→ N is ·(n,m) = n ·m.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 33 / 82

Page 36: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Variable assignment

Is φ(x) true in natural numbers?

φ(x) ≡ ∃y(x = y ⊕ y)

Variable assignment in a modelM = (D, I):

s : V → D

ExampleLet N = (N, I) be the standard model of PA.

s : V → N s′ : V → Ns(x) = 6 s′(x) = 7φ(x) is true under s φ(x) is false under s′

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 34 / 82

Page 37: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Variable assignment

Is φ(x) true in natural numbers?

φ(x) ≡ ∃y(x = y ⊕ y)

Variable assignment in a modelM = (D, I):

s : V → D

ExampleLet N = (N, I) be the standard model of PA.

s : V → N s′ : V → Ns(x) = 6 s′(x) = 7φ(x) is true under s φ(x) is false under s′

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 34 / 82

Page 38: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

A variable assignment models a memory state of a computer, wherethe variables are “addresses" that store “current values".

A computer typically works by successively replacing values inaddresses by new values.

s[x := a] is the variable assignment that is completely like σ exceptthat x now gets the value a (where σ might have assigned a different

value).

ExampleLet D = {1,2,3} and V = {x , y , z}.

s s[x := 2]

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 35 / 82

Page 39: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Values of terms

Given a modelM = (D, I) and variable assignment s inM, we definethe value (or interpretation) of terms as follows:

x I,s := s(x), for x ∈ VcI,s := I(c), for c ∈ C

[f (t1, . . . , tn)]I,s := I(f )(t I,s1 , . . . , t I,s

n ) for f ∈ F

Example

Let L = {0,s,⊕,�} be the language of PA, N = (N, I) be the standardmodel of PA, and s′ is an assignment s.t. s′(x) = 3.

[s(0)⊕ x ]I,s′

= 4

[s(s(0))� s(x)]I,s′

= 8

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 36 / 82

Page 40: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Tarski’s theory of truthNotation:

M |=s φ φ is ture inM under assignment s

DefinitionLetM = (D, I) be a model and s be an assignment inM:

M |=s P(t1, . . . , tn) iff (t I,s1 , . . . , t I,s

n ) ∈ I(P).M |=s ¬φ iffM 6|=s φ.M |=s φ ∧ ψ iffM |=s φ andM |=s ψ.M |=s φ→ ψ iffM |=s φ impliesM |=s ψ.M |=s ∀xφ iffM |=s[x :=a] φ for all a ∈ D.M |=s ∃xφ iffM |=s[x :=a] φ for some a ∈ D.

Definitionφ is (logically) valid ifM |=s φ for every modelM and everyassignment s inM. Notation: |= φ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 37 / 82

Page 41: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example

Letφ(x) ≡ ∃y(x = y ⊕ y)

Let N = (N, I) be the standard model of PA.

s : V → N s′ : V → Ns(x) = 6 s′(x) = 7N |=s φ(x) N 6|=s′ φ(x)

In fact,

N |=s φ(x) iff s(x) is an even number.

ExerciseShow that 6|= ∀y∃x p(x , y)→ ∃x∀y p(x , y).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 38 / 82

Page 42: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Semantics

Valuations:v : Formulas → {T,F}

v(¬φ) = 1− v(φ)

v(φ ∧ ψ) = min(v(φ), v(ψ))

v(φ ∨ ψ) = max(v(φ), v(ψ))

v(φ→ ψ) = min(1,1− v(φ) + v(ψ))

v(∀xφ) = min{v(φ[a/x ]) | a ∈ D}v(∃xφ) = max{v(φ[a/x ]) | a ∈ D}

∀ is a generalization of ∧, and ∃ is a generalization of ∨.

Semantics of FOL does not provide a decision procedure for FOL.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 39 / 82

Page 43: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Completeness

TheoremFOL is sound and complete:

` φ iff |= φ

There exists a proof for φ iff φ is true in all models.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 40 / 82

Page 44: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Completeness

TheoremFOL is sound and complete:

` φ iff |= φ

There exists a proof for φ iff φ is true in all models.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 40 / 82

Page 45: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Undecidability

TheoremValidity in first order logic is undecidable.

Proof.The proof that there is no decision procedure for validity describes analgorithm that takes an arbitrary Turing machine T and generates aformula ST in first-order logic, such that

|= ST iff T halts.

If there were a decision procedure for validity, this construction wouldgive us an decision procedure for the halting problem.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 41 / 82

Page 46: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Syllogism

All A are B ∀x(A(x)→ B(x))

No A are B ¬∃x(A(x) ∧ B(x)) or ∀x(A(x)→ ¬B(x))

Some A are B ∃x(A(x) ∧ B(x))

Not all A are B ¬∀x(A(x)→ B(x)) or ∃x(A(x) ∧ ¬B(x))

The language of Syllogism is a small fragment of predicate logic:monadic predicate logic, which has unary predicates only.

TheoremValidity in monadic predicate logic is decidable.

Johan van Benthem, Hans van Ditmarsch, Jan van Eijck, Jan Jaspars,Logic in ActionNew Edition, November 23, 2016

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 42 / 82

Page 47: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

CNF in Predicate LogicIn propositional logic, every formula is equivalent to one in CNF, butthis is not true in first-order logic.However, a formula in first-order logic can be transformed into anequisatisfiable formula in CNF.

Arbitrary formulas in predicate logic

Formulas in prenex normal form (PNF)

Skolemization

Formulas in clausal form or CNF

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 43 / 82

Page 48: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Prenex Normal Form (PNF)

TheoremFor every formula A there is an equivalent formula A′ (prenex normalform of A) with the same free variables in which all quantifiers appearat the begining.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 44 / 82

Page 49: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

` ¬∀xA↔ ∃x¬A.` ¬∃xA↔ ∀x¬A.

` (∀xA ∗ B)↔ ∀y(A[y/x ] ∗ B).

` (A ∗ ∀xB)↔ ∀y(A ∗ B[y/x ]).

` (∃xA ∗ B)↔ ∃y(A[y/x ] ∗ B).

` (A ∗ ∃xB)↔ ∃y(A ∗ B[y/x ]).

` (∀xA→ B)↔ ∃y(A[y/x ]→ B).

` (A→ ∀xB)↔ ∀y(A→ B[y/x ]).

` (∃xA→ B)↔ ∀y(A[y/x ]→ B).

` (A→ ∃xB)↔ ∃y(A→ B[y/x ]).

where ∗ ∈ {∧,∨}, and y does not occur in A,B.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 45 / 82

Page 50: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

A decidable fragment

TheoremThere are decision procedures for the validity of PNF formulas withoutconstant and function symbols whose prefixes are of one of the forms(where m,n ≥ 0):

∀x1 . . . ∀xn∃y1 . . . ∃ym

∀x1 . . . ∀xn∃y∀z1 . . . ∀zm

∀x1 . . . ∀xn∃y1∃y2∀z1 . . . ∀zm

These classes are conveniently abbreviated ∀∗∃∗, ∀∗∃∀∗, ∀∗∃∃∀∗.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 46 / 82

Page 51: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Skolemization

TheoremFor every sentence A in a given language L there is an equisatisfiableuniversal formula A′ (Skolemization of A) in an expanded language L′gotten by the addition of new function symbols.

LemmaFor any sentence A = ∀x1 . . . ∀xn∃yB of a language L, A andA′ = ∀x1 . . . ∀xnB[f (x1, . . . , xn)/y ] are equisatisfiable, where f is afunction symbol not in L.

Example

∃x∀yP(x , y) ∀yP(c, y)

∀x∃yP(x , y) ∀xP(x , f (x))

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 47 / 82

Page 52: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example

∀x∀y [∃z(P(x , z) ∧ P(y , z))→ ∃uQ(x , y ,u)]

↓∀x∀y∀w [P(x ,w) ∧ P(y ,w)→ ∃uQ(x , y ,u)]

↓∀x∀y∀w∃v [P(x ,w) ∧ P(y ,w)→ Q(x , y , v)]

↓∀x∀y∀w [P(x ,w) ∧ P(y ,w)→ Q(x , y , f (x , y ,w))]

L′ = L ∪ {f}↓

P(x ,w) ∧ P(y ,w)→ Q(x , y , f (x , y ,w))

↓¬P(x ,w) ∨ ¬P(y ,w) ∨Q(x , y , f (x , y ,w))

Clausal form (CNF)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 48 / 82

Page 53: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Herbrand TheoremReduction of first-order logic to propositional logic.

TheoremLet φ = (∃y1, . . . , yn)F (y1, . . . , yn) and F is quantifier-free.Then φ is valid if and only if there exists a finite sequence of terms tij ,possibly in an expansion of the language, with 1 ≤ i ≤ k and 1 ≤ j ≤ n,such that

F (t11, . . . , t1n) ∨ . . . ∨ F (tk1, . . . , tkn)

is a tautology of propositional logic.

TheoremLet A be a sentence in PNF in a language L, B a prenex equivalent of¬A, and C(~x) a quantifier-free Skolemization of B in the expandedlanguge L′.Then A is valid iff there are terms~t1, . . . ,~tn of L′ such that¬C(~t1) ∨ . . . ∨ ¬C(~tn) is a tautology of propositional logic.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 49 / 82

Page 54: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Substitution and unifier

DefinitionAn expression is any term or literal.A substitution is a mapping θ : V → Tm, denoted by{t1/x1, . . . , tn/xn}.The result of applying θ on expression E is denoted by Eθ.A set of expressions S = {E1, . . . ,En} is unifiable if there is asubstitution θ, called a unifier for S, such that E1θ = . . . = Enθ.A unifier θ for S is a most general unifier (mgu) for S if for everyunifier σ for S there is a substitution λ such that σ = θλ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 50 / 82

Page 55: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Substitution and unifier

DefinitionAn expression is any term or literal.A substitution is a mapping θ : V → Tm, denoted by{t1/x1, . . . , tn/xn}.The result of applying θ on expression E is denoted by Eθ.A set of expressions S = {E1, . . . ,En} is unifiable if there is asubstitution θ, called a unifier for S, such that E1θ = . . . = Enθ.A unifier θ for S is a most general unifier (mgu) for S if for everyunifier σ for S there is a substitution λ such that σ = θλ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 50 / 82

Page 56: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Substitution and unifier

DefinitionAn expression is any term or literal.A substitution is a mapping θ : V → Tm, denoted by{t1/x1, . . . , tn/xn}.The result of applying θ on expression E is denoted by Eθ.A set of expressions S = {E1, . . . ,En} is unifiable if there is asubstitution θ, called a unifier for S, such that E1θ = . . . = Enθ.A unifier θ for S is a most general unifier (mgu) for S if for everyunifier σ for S there is a substitution λ such that σ = θλ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 50 / 82

Page 57: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Substitution and unifier

DefinitionAn expression is any term or literal.A substitution is a mapping θ : V → Tm, denoted by{t1/x1, . . . , tn/xn}.The result of applying θ on expression E is denoted by Eθ.A set of expressions S = {E1, . . . ,En} is unifiable if there is asubstitution θ, called a unifier for S, such that E1θ = . . . = Enθ.A unifier θ for S is a most general unifier (mgu) for S if for everyunifier σ for S there is a substitution λ such that σ = θλ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 50 / 82

Page 58: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 51 / 82

Page 59: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Disagreement set

DefinitionFor a finite nonempty set of expressions S, the disagreement set D(S)is the set of subexpressions of S that begin at the leftmost position atwhich elements of S differ.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 52 / 82

Page 60: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 53 / 82

Page 61: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

ExampleWe find a mgu for S = {P(x ,g(b)),P(h(y ,a), z)} by the unificationalgorithm.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 54 / 82

Page 62: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

Example (Step 1)σ := εS = {P(x ,g(b)),P(h(y ,a), z)}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 55 / 82

Page 63: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

Example (Step 2)D(S) = {x ,h(y ,a)}σ := ε{h(y ,a)/x} = {h(y ,a)/x}S := Sσ = {P(h(y ,a),g(b)),P(h(y ,a), z)}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 56 / 82

Page 64: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

Example (Step 3)D(S) = {g(b), z}σ := {h(y ,a)/x}{g(b)/z} = {h(y ,a)/x ,g(b)/z}S := Sσ = {P(h(y ,a),g(b)),P(h(y ,a),g(b))} = {P(h(y ,a),g(b))}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 57 / 82

Page 65: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

ExampleThus the mgu for S = {P(x ,g(b)),P(h(y ,a), z)} isσ = {h(y ,a)/x ,g(b)/z}.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 58 / 82

Page 66: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Unification Algorithm

/*Input: A set S 6= ∅ of literals *//* Output: A most general unifier for S or report not unifiable */

σ := ε (the empty substitution)while S is not a singleton do

choose a disagreement pair x ∈ V, t ∈ Tm in D(S) s.t. x 6∈ tif there is no such disagreement pair thenreturn “non-unifiable"else σ := σ{t/x} and S := Sσ

return σ

ExerciseApply the unification algorithm to the following sets:

1 {P(a, y , f (y)),P(z, z,u)}, where a ∈ C, y , z,u ∈ V, f ∈ F .2 {P(g(x), y),P(y , y),P(y , f (u))}, where x , y ,u ∈ V, f ∈ F .

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 59 / 82

Page 67: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Resolution Rule

Let C t {P~t1, . . . ,P~tn} and D t {¬P~s1, . . . ,¬P~sm} be clauses which byrenaming of variables have no variables in common.

Resolution Rule:

C t {P~t1, . . . ,P~tn} D t {¬P~s1, . . . ,¬P~sm}Cσ ∪ Dσ

where σ is an mgu for {P~t1, . . . ,P~tn,P~s1, . . . ,P~sm}. Cσ ∪ Dσ is theresolvent of the parent clauses.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 60 / 82

Page 68: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

DefinitionA resolution proof of C from a given formula S is a finite sequenceC1,C2, . . . ,Cn such that each Ci is either a clause in S or obtainedby renamig variables of a clause in S or is inferred from earliermember of the sequence by the resolution rule and Cn = C. Inthis case we write S `R C.A resolution refutation of S is a resolution proof of empty clause �from S.

TheoremS is unsatisfiable iff there is a resolution refutation of S.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 61 / 82

Page 69: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Resolution algorithm

/* Input: A set of clauses S *//* Output: S is satisfiable or unsatisfiable */S0 := SLoop do

Choose a new pair of clauses C1,C2 ∈ SiC := Res(C1,C2)If C = � then return unsatisfiable

else Si+1 := Si ∪ {C}If Si+1 := Si for all pairs of clauses then

return satisfiable.

While an unsatisfiable set of clauses will eventually produce � under asuitable systematic execution of the procedure, the existence of infinitemodels means that the resolution procedure on a satisfiable set ofclauses may never terminate, so resolution is not a decisionprocedure for first order logic.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 62 / 82

Page 70: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

ExampleWe want to show that A1,A2 `R A3,

A1 := ∀x∀y∀z[P(x , y) ∧ P(y , z)→ P(x , z)] (transitivity)

A2 := ∀x∀y [P(x , y)→ P(y , x)] (symmetry)

A3 := ∀x∀y∀z[P(x , y) ∧ P(x , z)→ P(y , z)] (Euclideanness)

Note that

¬A3 := ∃x∃y∃z[P(x , y) ∧ P(x , z) ∧ ¬P(y , z)]

The clausal form of A1,A2,¬A3 are

{{¬P(x , y),¬P(y , z),P(x , z)}}

{{¬P(u, v),P(v ,u)}}

{{P(a,b)}, {P(a, c)}, {¬P(b, c)}}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 63 / 82

Page 71: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

ExampleWe want to show that A1,A2 `R A3,

A1 := ∀x∀y∀z[P(x , y) ∧ P(y , z)→ P(x , z)] (transitivity)

A2 := ∀x∀y [P(x , y)→ P(y , x)] (symmetry)

A3 := ∀x∀y∀z[P(x , y) ∧ P(x , z)→ P(y , z)] (Euclideanness)

Note that

¬A3 := ∃x∃y∃z[P(x , y) ∧ P(x , z) ∧ ¬P(y , z)]

The clausal form of A1,A2,¬A3 are

{{¬P(x , y),¬P(y , z),P(x , z)}}

{{¬P(u, v),P(v ,u)}}

{{P(a,b)}, {P(a, c)}, {¬P(b, c)}}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 63 / 82

Page 72: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

ExampleWe want to show that A1,A2 `R A3,

A1 := ∀x∀y∀z[P(x , y) ∧ P(y , z)→ P(x , z)] (transitivity)

A2 := ∀x∀y [P(x , y)→ P(y , x)] (symmetry)

A3 := ∀x∀y∀z[P(x , y) ∧ P(x , z)→ P(y , z)] (Euclideanness)

Note that

¬A3 := ∃x∃y∃z[P(x , y) ∧ P(x , z) ∧ ¬P(y , z)]

The clausal form of A1,A2,¬A3 are

{{¬P(x , y),¬P(y , z),P(x , z)}}

{{¬P(u, v),P(v ,u)}}

{{P(a,b)}, {P(a, c)}, {¬P(b, c)}}

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 63 / 82

Page 73: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example

Resolution proof:1 {¬P(x , y),¬P(y , z),P(x , z)}2 {¬P(u, v),P(v ,u)}3 {P(a,b)}4 {P(a, c)}5 {¬P(b, c)}6 {P(b,a)} Res(2,3), {a/u,b/v}7 {¬P(a, z),P(b, z)} Res(1,6), {b/x ,a/y}8 {¬P(a, c)} Res(5,7), {c/z}9 � Res(4,8)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 64 / 82

Page 74: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Exercise

Using resolution prove that

father(y , x) ∧male(x)→ son(x , y), father(jim, tim),male(tim)

` son(tim, jim)

I.e. show that the clause

S = {son(tim, jim)}

follows from the following clauses1 C1 = {son(x , y),¬father(y , x),¬male(x)}.2 C2 = {father(jim, tim)}.3 C3 = {male(tim)}.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 65 / 82

Page 75: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example 1 (Prover 9)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 66 / 82

Page 76: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example 2 (Prover 9)

` ∃x∀yp(x , y)→ ∀y∃xp(x , y)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 67 / 82

Page 77: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example 3 (Prover 9)

6` ∀y∃xp(x , y)→ ∃x∀yp(x , y)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 68 / 82

Page 78: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example 4 (Prover 9)

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 69 / 82

Page 79: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Other forms of resolution

Ground resolutionPositive resolutionHyperresolutionSemantic resolutionSet-of-support resolutionUnit resolutionInput resolutionLinear resolutionSLD resolution...

Samuel R. Buss,An Introduction to Proof Theory,In Handbook of Proof Theory, Elsevier 1998

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 70 / 82

Page 80: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

DefinitionA Horn clause T is a clause which contains at most one positiveliteral.A program clause P is a Horn clause which contains exactly onepositive literal (PROLOG notation p : − p1, . . . ,pn forC = {p,¬p1, . . . ,¬pn}, read “to compute p (head), computep1, . . . ,pn (body)").A rule is a program clause which contains some negative literals(i.e. p : − p1, . . . ,pn with n > 0).A fact is a program clause which contains exactly one positiveliteral (i.e. p : − p1, . . . ,pn with n = 0; PROLOG notation p.).A PROLOG program (or knowledge base or database) is a set ofprogram clauses (rules or facts).A goal clause G is a Horn clause which contains no positiveliterals. (PROLOG notation ?− q1, . . . ,qn for G = {¬q1, . . . ,¬qn}).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 71 / 82

Page 81: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

DefinitionA Horn clause T is a clause which contains at most one positiveliteral.A program clause P is a Horn clause which contains exactly onepositive literal (PROLOG notation p : − p1, . . . ,pn forC = {p,¬p1, . . . ,¬pn}, read “to compute p (head), computep1, . . . ,pn (body)").A rule is a program clause which contains some negative literals(i.e. p : − p1, . . . ,pn with n > 0).A fact is a program clause which contains exactly one positiveliteral (i.e. p : − p1, . . . ,pn with n = 0; PROLOG notation p.).A PROLOG program (or knowledge base or database) is a set ofprogram clauses (rules or facts).A goal clause G is a Horn clause which contains no positiveliterals. (PROLOG notation ?− q1, . . . ,qn for G = {¬q1, . . . ,¬qn}).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 71 / 82

Page 82: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

DefinitionA Horn clause T is a clause which contains at most one positiveliteral.A program clause P is a Horn clause which contains exactly onepositive literal (PROLOG notation p : − p1, . . . ,pn forC = {p,¬p1, . . . ,¬pn}, read “to compute p (head), computep1, . . . ,pn (body)").A rule is a program clause which contains some negative literals(i.e. p : − p1, . . . ,pn with n > 0).A fact is a program clause which contains exactly one positiveliteral (i.e. p : − p1, . . . ,pn with n = 0; PROLOG notation p.).A PROLOG program (or knowledge base or database) is a set ofprogram clauses (rules or facts).A goal clause G is a Horn clause which contains no positiveliterals. (PROLOG notation ?− q1, . . . ,qn for G = {¬q1, . . . ,¬qn}).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 71 / 82

Page 83: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

DefinitionA Horn clause T is a clause which contains at most one positiveliteral.A program clause P is a Horn clause which contains exactly onepositive literal (PROLOG notation p : − p1, . . . ,pn forC = {p,¬p1, . . . ,¬pn}, read “to compute p (head), computep1, . . . ,pn (body)").A rule is a program clause which contains some negative literals(i.e. p : − p1, . . . ,pn with n > 0).A fact is a program clause which contains exactly one positiveliteral (i.e. p : − p1, . . . ,pn with n = 0; PROLOG notation p.).A PROLOG program (or knowledge base or database) is a set ofprogram clauses (rules or facts).A goal clause G is a Horn clause which contains no positiveliterals. (PROLOG notation ?− q1, . . . ,qn for G = {¬q1, . . . ,¬qn}).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 71 / 82

Page 84: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

DefinitionA Horn clause T is a clause which contains at most one positiveliteral.A program clause P is a Horn clause which contains exactly onepositive literal (PROLOG notation p : − p1, . . . ,pn forC = {p,¬p1, . . . ,¬pn}, read “to compute p (head), computep1, . . . ,pn (body)").A rule is a program clause which contains some negative literals(i.e. p : − p1, . . . ,pn with n > 0).A fact is a program clause which contains exactly one positiveliteral (i.e. p : − p1, . . . ,pn with n = 0; PROLOG notation p.).A PROLOG program (or knowledge base or database) is a set ofprogram clauses (rules or facts).A goal clause G is a Horn clause which contains no positiveliterals. (PROLOG notation ?− q1, . . . ,qn for G = {¬q1, . . . ,¬qn}).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 71 / 82

Page 85: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

DefinitionA Horn clause T is a clause which contains at most one positiveliteral.A program clause P is a Horn clause which contains exactly onepositive literal (PROLOG notation p : − p1, . . . ,pn forC = {p,¬p1, . . . ,¬pn}, read “to compute p (head), computep1, . . . ,pn (body)").A rule is a program clause which contains some negative literals(i.e. p : − p1, . . . ,pn with n > 0).A fact is a program clause which contains exactly one positiveliteral (i.e. p : − p1, . . . ,pn with n = 0; PROLOG notation p.).A PROLOG program (or knowledge base or database) is a set ofprogram clauses (rules or facts).A goal clause G is a Horn clause which contains no positiveliterals. (PROLOG notation ?− q1, . . . ,qn for G = {¬q1, . . . ,¬qn}).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 71 / 82

Page 86: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Correct Answer Substitution

DefinitionIf P is a program and G = {¬q1, . . . ,¬qn} a goal clause, we say thatthe substitution θ is a correct answer substitution ifP |= ∀(q1 ∧ . . . ∧ qn)θ.

TheoremIf P is a program and G = {¬R(~x)} a goal clause, P ∪ {G} isunsatisfiable iff P |= ∃~xR(~x) iff there are Herbrand terms~t such thatP |= R(~t) (i.e., there is a correct answer substitution).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 72 / 82

Page 87: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Correct Answer Substitution

DefinitionIf P is a program and G = {¬q1, . . . ,¬qn} a goal clause, we say thatthe substitution θ is a correct answer substitution ifP |= ∀(q1 ∧ . . . ∧ qn)θ.

TheoremIf P is a program and G = {¬R(~x)} a goal clause, P ∪ {G} isunsatisfiable iff P |= ∃~xR(~x) iff there are Herbrand terms~t such thatP |= R(~t) (i.e., there is a correct answer substitution).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 72 / 82

Page 88: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

"Programming in Logic" PROLOG are based on Horn clause logic.

The general view of a PROLOG program is that we are given a PROLOGprogram P and wish to deduce consequences from them, or typicallyto know if the conjunction of some facts q1, . . . ,qn follows from theprogram. We enter this as a question (query ) ?− q1, . . . ,qn at thePROLOG prompt.

PROLOG adds a goal clause G = {¬q1, . . . ,¬qn} to P and ask ifP ∪ {G} of Horn clauses is unsatisfiable. If all attempts at finding aproof fail PROLOG answers “no". If a proof is found, PROLOG gives usan correct answer substitution.

TheoremP ∪ {G} is unsatisfiable iff there is an SLD-resolution refutation ofP ∪ {G}.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 73 / 82

Page 89: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

"Programming in Logic" PROLOG are based on Horn clause logic.

The general view of a PROLOG program is that we are given a PROLOGprogram P and wish to deduce consequences from them, or typicallyto know if the conjunction of some facts q1, . . . ,qn follows from theprogram. We enter this as a question (query ) ?− q1, . . . ,qn at thePROLOG prompt.

PROLOG adds a goal clause G = {¬q1, . . . ,¬qn} to P and ask ifP ∪ {G} of Horn clauses is unsatisfiable. If all attempts at finding aproof fail PROLOG answers “no". If a proof is found, PROLOG gives usan correct answer substitution.

TheoremP ∪ {G} is unsatisfiable iff there is an SLD-resolution refutation ofP ∪ {G}.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 73 / 82

Page 90: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Logic Programming PROLOG

"Programming in Logic" PROLOG are based on Horn clause logic.

The general view of a PROLOG program is that we are given a PROLOGprogram P and wish to deduce consequences from them, or typicallyto know if the conjunction of some facts q1, . . . ,qn follows from theprogram. We enter this as a question (query ) ?− q1, . . . ,qn at thePROLOG prompt.

PROLOG adds a goal clause G = {¬q1, . . . ,¬qn} to P and ask ifP ∪ {G} of Horn clauses is unsatisfiable. If all attempts at finding aproof fail PROLOG answers “no". If a proof is found, PROLOG gives usan correct answer substitution.

TheoremP ∪ {G} is unsatisfiable iff there is an SLD-resolution refutation ofP ∪ {G}.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 73 / 82

Page 91: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

SLD-resolution

DefinitionAn SLD-resolution refutation of P ∪ {G} (as a set of ordered clauses)is a sequence < G0,C0 >, . . ., < Gn,Cn > such that

G0 = G,Gn+1 = �,each Gi is an ordered goal clause,each Ci is an ordered program clause, andfor each i < n, the ordered clause Gi+1 is the resolvent of Gi andCi (the topmost clause) by the following (sequence version)resolution:

{¬q1, . . . ,¬qn} {p,¬p1, . . . ,¬pm}{¬p1, . . . ,¬pm,¬q2, . . . ,¬qn}

where the resolution rule resolve on the leftmost literal in Gi (i.e.p = q1).

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 74 / 82

Page 92: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

G0 C0

| �G1 C1

| �...

Gn Cn

| ��

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 75 / 82

Page 93: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Example

Consider the following program:p : −q, r .p : −s.q.r .Suppose G = {¬p}. An SLD-resolution refutation of P ∪ {G} is asfollows:

{¬p} {p,¬q,¬r}{¬q,¬r} {q}

{¬r} {r}�

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 76 / 82

Page 94: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 77 / 82

Page 95: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 78 / 82

Page 96: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 79 / 82

Page 97: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

References

M. Fitting,First-Order Logic and Automated TheoremProving,Springer, 1996.J. H. Gallier,Logic for Computer ScienceFoundations of Automatic Theorem Proving,John Wiley, 1987.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 80 / 82

Page 98: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

References

M. Ben Ari,Mathematical Logic for Computer Science,Springer, 2012.S. J. Russell and P. Norvig,Artificial Intelligence, A Modern Approach,Prentice Hall, 2010.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 81 / 82

Page 99: Resolution for First Order Logicmath.ipm.ir/isfahan/old/Logic group/Ghari-Predicate-Logic...S is unsatisfiable iff there is a resolution refutation of S. Checking validity ˚is valid,

References

A. Nerode and R. Shore,Logic for Applications,Springer, 1997.

Meghdad Ghari (IPM) Resolution Logic Short Course 2017 82 / 82


Recommended