Resolution for First Order Logic Meghdad Ghari Institute for - - PowerPoint PPT Presentation

resolution for first order logic
SMART_READER_LITE
LIVE PREVIEW

Resolution for First Order Logic Meghdad Ghari Institute for - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Outline

1

Propositional Logic Conjunctive Normal Form Propositional Resolution

2

First Order Logic Syntax Semantics Resolution for FOL PROLOG

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

slide-3
SLIDE 3

Language

Atom = {p1, p2, p3, . . .}, A (finite or infinite) set of atomic propositions (or propositional variables). L = Atom ∪ {(, ), ¬, ∧, ∨, →} Formulas of propositional logic are defined by the following grammar in Backus Naur form (BNF): φ ::= p | (¬φ) | (φ ∧ φ) | (φ ∨ φ) | (φ → φ), p ∈ Atom

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

slide-4
SLIDE 4

Semantics: principle of compositionality

The meaning of a complex expression is determined by the meanings

  • f 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

slide-5
SLIDE 5

Decideability

Definition

A logical system is decidable if there is an effective method (or algorithm) for determining whether arbitrary formulas are theorems of the logical system. Truth tables provide a decision procedure for propositional logic.

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

slide-6
SLIDE 6

Validity and satisfiability

Theorem

Let φ be a formula of propositional logic. Then φ is satisfiable iff ¬φ is not valid.

Theorem

Given 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

slide-7
SLIDE 7

Validity and satisfiability

Theorem

Let φ be a formula of propositional logic. Then φ is satisfiable iff ¬φ is not valid.

Theorem

Given 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

slide-8
SLIDE 8

Conjunctive Normal Form (CNF)

L ::= p | ¬p, p ∈ Atom Literal D ::= L | L ∨ D Clause C ::= 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}}

Facts

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

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

slide-9
SLIDE 9

Converting formulas to CNF

Theorem

Every formula in propositional logic can be transformed into an equivalent 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

slide-10
SLIDE 10

Resolution

John Alan Robinson, A Machine-Oriented Logic Based on the Resolution Principle

  • J. ACM. 12 (1): 23-41, 1965.

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

slide-11
SLIDE 11

Propositional Resolution

Resolution is a refutation procedure used to check if a formula in clausal form is unsatisfiable. The resolution procedure consists of a sequence of applications of the resolution rule to a set of clauses. The rule maintains satisfiability: if a set of clauses is satisfiable, so is the set of clauses produced by an application of the rule. Therefore, if the (unsatisfiable) empty clause is ever obtained, the

  • riginal set of clauses must have been unsatisfiable.

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

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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

slide-14
SLIDE 14

Propositional Resolution Rule

Propositional Resolution Rule: C ⊔ {p} D ⊔ {¬p} C ∪ D where C and D are clauses and ⊔ denotes disjoint union. C ∪ D is called the resolvent of C ⊔ {p} and D ⊔ {¬p}: C ∪ D = Res(C ⊔ {p}, D ⊔ {¬p}) Resolution on clause forms: {C1, . . . , C ⊔ {p}, D ⊔ {¬p}, . . . , Cn} {C1, . . . , C ∪ D, . . . , Cn} Resolution on clause forms preserves satisfiability.

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

slide-15
SLIDE 15

Proof by resolution

Definition

A resolution refutation of S is a resolution proof of empty clause from S.

Theorem

S 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

slide-16
SLIDE 16

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:

◮ two clauses resolve to yield the empty clause , in which case

φ1, φ2, . . . , φn | = ψ.

◮ there are no new clauses that can be added, in which case

φ1, φ2, . . . , φn | = ψ;

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

slide-17
SLIDE 17

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 ∈ S do S := S ∪ {C} If ∈ S then return unsatisfiable else (i.e. if ∈ S) return satisfiable.

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

slide-18
SLIDE 18

Example I

We 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

slide-19
SLIDE 19

Example II

We show that p | = 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 S

2

{¬p, ¬q} a clause of S

3

{¬q} resolvent of clauses 1 and 2 S is satisfiable, since there are no new resolvents that can be added and ∈ S.

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

slide-20
SLIDE 20

Resolution refutation as a tree

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

  • ¯

p p ¯ p¯ q ¯ pq ¯ p¯ qr ¯ r

✟ ✟ ✟ ✟ ✟ ✟ ❍❍❍❍❍ ❍

❅ ❅ ❅ ✁ ✁ ✁ ✁ ❆ ❆ ❆ ❆

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

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

slide-21
SLIDE 21

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 | = it is raining.

2

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

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

slide-22
SLIDE 22

Ontological commitment

Ontological commitment: what the logic assumes about the nature of reality: propositional logic assumes that there are facts that either hold or do not hold in the world. First-order logic assumes that the world consists of objects with certain relations among them that do or do not hold.

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

slide-23
SLIDE 23

Language

Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball games, wars, centuries . . . Relations: these can be unary relations or properties such as red, round, prime, . . ., or more general n-ary relations such as brother of, bigger than, inside, part of, has color, occurred after,

  • wns, comes between, . . .

Functions: father of, best friend, one more than, beginning of . . .

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

slide-24
SLIDE 24

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 predicate symbols) 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

slide-25
SLIDE 25

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

slide-26
SLIDE 26

Examples

Natural language Logical formula John 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

slide-27
SLIDE 27

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

slide-28
SLIDE 28

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 ∈ FV(A),

4

A{t/x} → ∃xA, where t is free for x in A,

5

∀x(A → B) → (∃xA → B), where x ∈ FV(B),

6

∀x(x = x),

7

t1 = t2 ∧ A{t1/x} → A{t2/x}. Rules: ⊢ A → B ⊢ A ⊢ B MP ⊢ A ⊢ ∀xAGen

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

slide-29
SLIDE 29

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

slide-30
SLIDE 30

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

slide-31
SLIDE 31

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 ∈ y) ∧ ∀y ∈ x∃z ∈ x∀w(w ∈ z ↔ w ∈ y ∨ w = y)),

7

∃y(y ∈ x) → ∃y ∈ x∀z ∈ y(z ∈ x).

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

slide-32
SLIDE 32

Peano Arithmetic PA

L = {¯ 0, s, ⊕, ⊙}, ¯ 0 is a constant symbol, s is a unary function symbol and ⊕, ⊙ are binary function symbol. Proper axioms:

1

∀x(s(x) = ¯ 0),

2

∀x(x = ¯ 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

slide-33
SLIDE 33

Semantics of FOL

Syntactic expressions of language

semantics

  • Real situations

Example

M(x) ⇋ x is a man B(y) ⇋ y is a bicycle R(x, y) ⇋ x rides y ∃x∃y(M(x) ∧ B(y) ∧ R(x, y))

  • Meghdad Ghari (IPM)

Resolution Logic Short Course 2017 31 / 82

slide-34
SLIDE 34

Models

Definition

A model for the first-order language L(R, F, C) is a pair M = (D, I) such that Domain: D is a non-empty set of individual objects. Interpretation: I is a function mapping relation symbols, function symbols, and constant symbols to relations on D, functions on D, and objects in D.

◮ I(Pn) ⊆ Dn, for Pn ∈ R. ◮ I(f n) : Dn → D, for f n ∈ F. ◮ I(c) ∈ D, for c ∈ C. Meghdad Ghari (IPM) Resolution Logic Short Course 2017 32 / 82

slide-35
SLIDE 35

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

slide-36
SLIDE 36

Variable assignment

Is φ(x) true in natural numbers? φ(x) ≡ ∃y(x = y ⊕ y) Variable assignment in a model M = (D, I): s : V → D

Example

Let N = (N, I) be the standard model of PA. s : V → N s′ : V → N s(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

slide-37
SLIDE 37

Variable assignment

Is φ(x) true in natural numbers? φ(x) ≡ ∃y(x = y ⊕ y) Variable assignment in a model M = (D, I): s : V → D

Example

Let N = (N, I) be the standard model of PA. s : V → N s′ : V → N s(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

slide-38
SLIDE 38

A variable assignment models a memory state of a computer, where the variables are “addresses" that store “current values". A computer typically works by successively replacing values in addresses by new values. s[x := a] is the variable assignment that is completely like σ except that x now gets the value a (where σ might have assigned a different value).

Example

Let D = {1, 2, 3} and V = {x, y, z}. s s[x := 2]

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

slide-39
SLIDE 39

Values of terms

Given a model M = (D, I) and variable assignment s in M, we define the value (or interpretation) of terms as follows: xI,s := s(x), for x ∈ V cI,s := I(c), for c ∈ C [f(t1, . . . , tn)]I,s := I(f)(tI,s

1 , . . . , tI,s n )

for f ∈ F

Example

Let L = {¯ 0, s, ⊕, ⊙} be the language of PA, N = (N, I) be the standard model 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

slide-40
SLIDE 40

Tarski’s theory of truth

Notation: M | =s φ φ is ture in M under assignment s

Definition

Let M = (D, I) be a model and s be an assignment in M: M | =s P(t1, . . . , tn) iff (tI,s

1 , . . . , tI,s n ) ∈ I(P).

M | =s ¬φ iff M | =s φ. M | =s φ ∧ ψ iff M | =s φ and M | =s ψ. M | =s φ → ψ iff M | =s φ implies M | =s ψ. M | =s ∀xφ iff M | =s[x:=a] φ for all a ∈ D. M | =s ∃xφ iff M | =s[x:=a] φ for some a ∈ D.

Definition

φ is (logically) valid if M | =s φ for every model M and every assignment s in M. Notation: | = φ.

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

slide-41
SLIDE 41

Example

Let φ(x) ≡ ∃y(x = y ⊕ y) Let N = (N, I) be the standard model of PA. s : V → N s′ : V → N s(x) = 6 s′(x) = 7 N | =s φ(x) N | =s′ φ(x) In fact, N | =s φ(x) iff s(x) is an even number.

Exercise

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

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

slide-42
SLIDE 42

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

slide-43
SLIDE 43

Completeness

Theorem

FOL 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

slide-44
SLIDE 44

Completeness

Theorem

FOL 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

slide-45
SLIDE 45

Undecidability

Theorem

Validity in first order logic is undecidable.

Proof.

The proof that there is no decision procedure for validity describes an algorithm that takes an arbitrary Turing machine T and generates a formula ST in first-order logic, such that | = ST iff T halts. If there were a decision procedure for validity, this construction would give us an decision procedure for the halting problem.

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

slide-46
SLIDE 46

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.

Theorem

Validity in monadic predicate logic is decidable. Johan van Benthem, Hans van Ditmarsch, Jan van Eijck, Jan Jaspars, Logic in Action New Edition, November 23, 2016

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

slide-47
SLIDE 47

CNF in Predicate Logic

In propositional logic, every formula is equivalent to one in CNF , but this is not true in first-order logic. However, a formula in first-order logic can be transformed into an equisatisfiable 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

slide-48
SLIDE 48

Prenex Normal Form (PNF)

Theorem

For every formula A there is an equivalent formula A′ (prenex normal form of A) with the same free variables in which all quantifiers appear at the begining.

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

slide-49
SLIDE 49

⊢ ¬∀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

slide-50
SLIDE 50

A decidable fragment

Theorem

There are decision procedures for the validity of PNF formulas without constant 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

slide-51
SLIDE 51

Skolemization

Theorem

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

Lemma

For any sentence A = ∀x1 . . . ∀xn∃yB of a language L, A and A′ = ∀x1 . . . ∀xnB[f(x1, . . . , xn)/y] are equisatisfiable, where f is a function 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

slide-52
SLIDE 52

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

slide-53
SLIDE 53

Herbrand Theorem

Reduction of first-order logic to propositional logic.

Theorem

Let φ = (∃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.

Theorem

Let 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 expanded languge 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

slide-54
SLIDE 54

Substitution and unifier

Definition

An 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 a substitution θ, called a unifier for S, such that E1θ = . . . = Enθ. A unifier θ for S is a most general unifier (mgu) for S if for every unifier σ for S there is a substitution λ such that σ = θλ.

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

slide-55
SLIDE 55

Substitution and unifier

Definition

An 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 a substitution θ, called a unifier for S, such that E1θ = . . . = Enθ. A unifier θ for S is a most general unifier (mgu) for S if for every unifier σ for S there is a substitution λ such that σ = θλ.

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

slide-56
SLIDE 56

Substitution and unifier

Definition

An 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 a substitution θ, called a unifier for S, such that E1θ = . . . = Enθ. A unifier θ for S is a most general unifier (mgu) for S if for every unifier σ for S there is a substitution λ such that σ = θλ.

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

slide-57
SLIDE 57

Substitution and unifier

Definition

An 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 a substitution θ, called a unifier for S, such that E1θ = . . . = Enθ. A unifier θ for S is a most general unifier (mgu) for S if for every unifier σ for S there is a substitution λ such that σ = θλ.

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

slide-58
SLIDE 58

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

slide-59
SLIDE 59

Disagreement set

Definition

For 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 at which elements of S differ.

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

slide-60
SLIDE 60

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “non-unifiable" else σ := σ{t/x} and S := Sσ return σ

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

slide-61
SLIDE 61

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “non-unifiable" else σ := σ{t/x} and S := Sσ return σ

Example

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

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

slide-62
SLIDE 62

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “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

slide-63
SLIDE 63

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “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

slide-64
SLIDE 64

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “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

slide-65
SLIDE 65

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “non-unifiable" else σ := σ{t/x} and S := Sσ return σ

Example

Thus 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

slide-66
SLIDE 66

Unification Algorithm

/*Input: A set S = ∅ 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 ∈ t if there is no such disagreement pair then return “non-unifiable" else σ := σ{t/x} and S := Sσ return σ

Exercise

Apply 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

slide-67
SLIDE 67

Resolution Rule

Let C ⊔ {P t1, . . . , P tn} and D ⊔ {¬P s1, . . . , ¬P sm} be clauses which by renaming of variables have no variables in common. Resolution Rule: C ⊔ {P t1, . . . , P tn} D ⊔ {¬P s1, . . . , ¬P sm} Cσ ∪ Dσ where σ is an mgu for {P t1, . . . , P tn, P s1, . . . , P sm}. Cσ ∪ Dσ is the resolvent of the parent clauses.

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

slide-68
SLIDE 68

Definition

A resolution proof of C from a given formula S is a finite sequence C1, C2, . . . , Cn such that each Ci is either a clause in S or obtained by renamig variables of a clause in S or is inferred from earlier member of the sequence by the resolution rule and Cn = C. In this case we write S ⊢R C. A resolution refutation of S is a resolution proof of empty clause from S.

Theorem

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

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

slide-69
SLIDE 69

Resolution algorithm

/* Input: A set of clauses S */ /* Output: S is satisfiable or unsatisfiable */ S0 := S Loop do Choose a new pair of clauses C1, C2 ∈ Si C := 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 a suitable systematic execution of the procedure, the existence of infinite models means that the resolution procedure on a satisfiable set of clauses may never terminate, so resolution is not a decision procedure for first order logic.

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

slide-70
SLIDE 70

Example

We 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

slide-71
SLIDE 71

Example

We 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

slide-72
SLIDE 72

Example

We 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

slide-73
SLIDE 73

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

slide-74
SLIDE 74

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 clauses

1

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

slide-75
SLIDE 75

Example 1 (Prover 9)

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

slide-76
SLIDE 76

Example 2 (Prover 9)

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

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

slide-77
SLIDE 77

Example 3 (Prover 9)

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

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

slide-78
SLIDE 78

Example 4 (Prover 9)

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

slide-79
SLIDE 79

Other forms of resolution

Ground resolution Positive resolution Hyperresolution Semantic resolution Set-of-support resolution Unit resolution Input resolution Linear resolution SLD 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

slide-80
SLIDE 80

Logic Programming PROLOG

Definition

A Horn clause T is a clause which contains at most one positive literal. A program clause P is a Horn clause which contains exactly one positive literal (PROLOG notation p : − p1, . . . , pn for C = {p, ¬p1, . . . , ¬pn}, read “to compute p (head), compute p1, . . . , 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 positive literal (i.e. p : − p1, . . . , pn with n = 0; PROLOG notation p.). A PROLOG program (or knowledge base or database) is a set of program clauses (rules or facts). A goal clause G is a Horn clause which contains no positive

  • literals. (PROLOG notation ? − q1, . . . , qn for G = {¬q1, . . . , ¬qn}).

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

slide-81
SLIDE 81

Logic Programming PROLOG

Definition

A Horn clause T is a clause which contains at most one positive literal. A program clause P is a Horn clause which contains exactly one positive literal (PROLOG notation p : − p1, . . . , pn for C = {p, ¬p1, . . . , ¬pn}, read “to compute p (head), compute p1, . . . , 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 positive literal (i.e. p : − p1, . . . , pn with n = 0; PROLOG notation p.). A PROLOG program (or knowledge base or database) is a set of program clauses (rules or facts). A goal clause G is a Horn clause which contains no positive

  • literals. (PROLOG notation ? − q1, . . . , qn for G = {¬q1, . . . , ¬qn}).

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

slide-82
SLIDE 82

Logic Programming PROLOG

Definition

A Horn clause T is a clause which contains at most one positive literal. A program clause P is a Horn clause which contains exactly one positive literal (PROLOG notation p : − p1, . . . , pn for C = {p, ¬p1, . . . , ¬pn}, read “to compute p (head), compute p1, . . . , 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 positive literal (i.e. p : − p1, . . . , pn with n = 0; PROLOG notation p.). A PROLOG program (or knowledge base or database) is a set of program clauses (rules or facts). A goal clause G is a Horn clause which contains no positive

  • literals. (PROLOG notation ? − q1, . . . , qn for G = {¬q1, . . . , ¬qn}).

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

slide-83
SLIDE 83

Logic Programming PROLOG

Definition

A Horn clause T is a clause which contains at most one positive literal. A program clause P is a Horn clause which contains exactly one positive literal (PROLOG notation p : − p1, . . . , pn for C = {p, ¬p1, . . . , ¬pn}, read “to compute p (head), compute p1, . . . , 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 positive literal (i.e. p : − p1, . . . , pn with n = 0; PROLOG notation p.). A PROLOG program (or knowledge base or database) is a set of program clauses (rules or facts). A goal clause G is a Horn clause which contains no positive

  • literals. (PROLOG notation ? − q1, . . . , qn for G = {¬q1, . . . , ¬qn}).

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

slide-84
SLIDE 84

Logic Programming PROLOG

Definition

A Horn clause T is a clause which contains at most one positive literal. A program clause P is a Horn clause which contains exactly one positive literal (PROLOG notation p : − p1, . . . , pn for C = {p, ¬p1, . . . , ¬pn}, read “to compute p (head), compute p1, . . . , 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 positive literal (i.e. p : − p1, . . . , pn with n = 0; PROLOG notation p.). A PROLOG program (or knowledge base or database) is a set of program clauses (rules or facts). A goal clause G is a Horn clause which contains no positive

  • literals. (PROLOG notation ? − q1, . . . , qn for G = {¬q1, . . . , ¬qn}).

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

slide-85
SLIDE 85

Logic Programming PROLOG

Definition

A Horn clause T is a clause which contains at most one positive literal. A program clause P is a Horn clause which contains exactly one positive literal (PROLOG notation p : − p1, . . . , pn for C = {p, ¬p1, . . . , ¬pn}, read “to compute p (head), compute p1, . . . , 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 positive literal (i.e. p : − p1, . . . , pn with n = 0; PROLOG notation p.). A PROLOG program (or knowledge base or database) is a set of program clauses (rules or facts). A goal clause G is a Horn clause which contains no positive

  • literals. (PROLOG notation ? − q1, . . . , qn for G = {¬q1, . . . , ¬qn}).

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

slide-86
SLIDE 86

Correct Answer Substitution

Definition

If P is a program and G = {¬q1, . . . , ¬qn} a goal clause, we say that the substitution θ is a correct answer substitution if P | = ∀(q1 ∧ . . . ∧ qn)θ.

Theorem

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

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

slide-87
SLIDE 87

Correct Answer Substitution

Definition

If P is a program and G = {¬q1, . . . , ¬qn} a goal clause, we say that the substitution θ is a correct answer substitution if P | = ∀(q1 ∧ . . . ∧ qn)θ.

Theorem

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

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

slide-88
SLIDE 88

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 PROLOG program P and wish to deduce consequences from them, or typically to know if the conjunction of some facts q1, . . . , qn follows from the

  • program. We enter this as a question (query) ? − q1, . . . , qn at the

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

Theorem

P ∪ {G} is unsatisfiable iff there is an SLD-resolution refutation of P ∪ {G}.

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

slide-89
SLIDE 89

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 PROLOG program P and wish to deduce consequences from them, or typically to know if the conjunction of some facts q1, . . . , qn follows from the

  • program. We enter this as a question (query) ? − q1, . . . , qn at the

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

Theorem

P ∪ {G} is unsatisfiable iff there is an SLD-resolution refutation of P ∪ {G}.

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

slide-90
SLIDE 90

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 PROLOG program P and wish to deduce consequences from them, or typically to know if the conjunction of some facts q1, . . . , qn follows from the

  • program. We enter this as a question (query) ? − q1, . . . , qn at the

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

Theorem

P ∪ {G} is unsatisfiable iff there is an SLD-resolution refutation of P ∪ {G}.

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

slide-91
SLIDE 91

SLD-resolution

Definition

An 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, and for each i < n, the ordered clause Gi+1 is the resolvent of Gi and Ci (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

slide-92
SLIDE 92

G0 C0 |

  • G1

C1 |

  • .

. . Gn Cn |

  • Meghdad Ghari (IPM)

Resolution Logic Short Course 2017 75 / 82

slide-93
SLIDE 93

Example

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

  • Meghdad Ghari (IPM)

Resolution Logic Short Course 2017 76 / 82

slide-94
SLIDE 94

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

slide-95
SLIDE 95

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

slide-96
SLIDE 96

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

slide-97
SLIDE 97

References

  • M. Fitting,

First-Order Logic and Automated Theorem Proving, Springer, 1996.

  • J. H. Gallier,

Logic for Computer Science Foundations of Automatic Theorem Proving, John Wiley, 1987.

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

slide-98
SLIDE 98

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

slide-99
SLIDE 99

References

  • A. Nerode and R. Shore,

Logic for Applications, Springer, 1997.

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