Lecture 14: Theorem Proving 2

10:30 AM, Mar 12, 2009

Contents

1 Overview 1 2 Conversion to Normal Form 1 3 Unification: Definition and Procedure 4 4 Sample Proof-by-Refutation 6

1 Overview

At this point, we have all the machinery in place to automate theorem proving in first-order logic. More specifically, our goal is solve the logical entailment problem: KB |= A? At a high-level, our strategy is as follows:

  1. Add A to KB.
  2. Convert KB to normal form.

3. Using unification and resolution, search for a refutation: i.e., a proof of ⊤→⊥. The rest of this lecture details these steps and traces through an example.

2 Conversion to Normal Form

Thefollowing algorithmconvertsanarbitraryformulaof first-orderlogicintoaset ofquantifier-free formulas in normal form.

1. Eliminate implications.

  • Rewrite φ ψ as ¬φ ψ.
  • Rewrite φ ψ as ¬ψ φ.

2. Move negations inwards.

    • Use DeMorgan’s laws:
      • Rewrite ¬(φ ψ)as ¬φ ∧¬ψ.
      • Rewrite ¬(φ ψ)as ¬φ ∨¬ψ.
      • Rewrite ¬∀xφ as x ¬φ.
      • Rewrite ¬∃xφ as x ¬φ.
  • Use the law of double negation:

Rewrite ¬¬φ as φ.

  1. Standardize variables apart. If the same variable name appears within the scope of multiple quantifiers, replace these multiple occurrences ofthe same variable name withdistinctvariable names. For example, rewrite xP (x)∨∀xQ(x)as xP (x)∨∀yQ(y). Changing the names of bound variables does not change the meaning of formulas.
    1. Move universal quantifiers left.
      • Rewrite()ψ as x (φ ψ).
      • Rewrite φ ()as x (φ ψ).
      • Rewrite()ψ as x (φ ψ).
      • Rewrite φ ()as x (φ ψ).

Since variables are standardized apart, this step is sound. Otherwise, if we rewrite xP (x)xQ(x)as xP (x)Q(x),themeaningof theformulachanges. Forexample,let P = black and Q = white. The latter formula is true of piano keys, all of which are either black or white. But the original formula is not true of piano keys, since it is neither the case that all piano keys are black nor that all piano keys are white.

At this point the formula is in prenex normal form.

5. Skolemize to eliminate existential quantifiers. Rewrite quantified formulas of the form

x1 ,...,xn (xi,y)

as x1 ,...,xn φ(xi, skm(x1 ,...,xn))

where skm is a new function symbol that does not appear elsewhere in the database. The subscript m denotes the mth Skolemization, thereby ensuring that skm has not appeared previously. For example, the Skolemization of this formula:

x, y(x<y)→∃z(x<z)(z<y)

is this formula: x, y(x<y)(x< sk(x, y))(sk(x, y)<y)

where sk(x, y)denotes,for example,thefunctionthat averages(thedenotations of) x and y. The following example is an incorrect Skolemization. The premise states “everyone has a mother;” the conclusion states “sk1 is everyone’s mother.”

x y mother of(x)= y

x mother of(x)= sk1

The following is a correct Skolemization: it states that “sk1 (x)is x’s mother.”

x y mother of(x)= y x mother of(x)= sk1 (x)

Lemma: Given any first-order formula x1 ,...,xn yψ in prenex normal form, there exists a corresponding Skolemized formula x1 ,...,xn ψ|{sk(x1 ,...,xn)/y} s.t. the two are equisatisfiable, meaning either both have a model or neither does (though the models need not coincide).

Remark: Aformula(inprenex normalform) anditsSkolemization are notlogically equiv

alent. Exercise: Let φ be an atomic formula, and let sk be a function symbol not occurring in φ. Show that |{sk(x)/y} |= x , but x yφ �|= |{sk(x)/y} .

  1. Drop the prefix: i.e., eliminate universal quantifiers. The convention after this point is that all variables are universally quantified.
    1. Distribute over .
      • Rewrite φ (ψ τ )as(φ ψ)(φ τ ).
      • Rewrite(φ ψ)τ as(φ τ )(ψ τ ).

(Note: Theknowledgebaseis nowin conjuctive normalform(CNF).)

8. Split conjunctions: split up formulas like φ ψ into two separate entries in the knowledge base, namely φ and ψ.

9. Flattennesteddisjunctions: flattenformulasoftheform((φ ψ)χ)into φ ψ χ. (This is often done along the way.)

10. Eliminate negations by reintroducing implications.

  • Rewrite ¬φ ψ as φ ψ.
  • Rewrite ¬φ as φ →⊥.
  • Rewrite φ as φ.

Example: [Ginsberg1993] If a house is big and old, then it is a lot of work to maintain, unless it comes with a housecleaner and doesn’t have a garden.

We express this sentence of first-order logic using the predicates big, old, work, cleans, and garden, as well as the “type” predicates isa house, isa man, and isa garden:

h (isa house(h)big(h)old(h))work(h)(m isa man(m)cleans(m, h)¬∃g isa garden(g)garden(g, h))

To demonstrate how to convert a sentence of first-order logic such as this one to normal form, we work with the following simplification which does not include type predicates:

h big(h)old(h)work(h)(m cleans(m, h)¬∃g garden(g, h))

  1. Eliminate implications:
  2. Move negations inwards:

h ¬ (big(h)old(h))work(h)(m cleans(m, h)¬∃g garden(g, h)) h ¬big(h)∨¬old(h)work(h)(m cleans(m, h)∧∀g ¬garden(g, h))

3. Standardize variables apart: If the formula were,

x ¬big(x)∨¬old(x)work(x)(y cleans(y, x)∧∀y ¬garden(y, x))

we could rewrite it as it is written in the previous step.

  1. Skolemize to eliminate existential quantifiers: h ¬big(h)∨¬old(h)work(h)(cleans(sk cleans(h),h)∧∀g ¬garden(g, h))
  2. Move universal quantifiers left: h, g ¬big(h)∨¬old(h)work(h)(cleans(sk cleans(h),h)∧¬garden(g, h))
  3. Drop the prefix: ¬big(h)∨¬old(h)work(h)(cleans(sk cleans(h),h)∧¬garden(g, h))
  4. Distribute over :

(¬big(h)∨¬old(h)work(h)cleans(sk cleans(h),h))(¬big(h)∨¬old(h)work(h)∨¬garden(g, h))

8. Split conjuctions:

¬big(h)∨¬old(h)work(h)cleans(sk cleans(h),h) ¬big(h)∨¬old(h)work(h)∨¬garden(g, h)

  1. Flatten nested disjunctions. (We’ve been doingthat along the way.)
  2. Eliminate negations by reintroducing implications:

big(h)old(h)work(h)cleans(sk cleans(h),h) big(h)old(h)garden(g, h)work(h)

Unification: Definition and Procedure

An expression isatermoraformulaof first-orderlogic. Giventwoexpressions e1 ,e2 ,a unifier of e1 and e2 is a substitution σ of terms to variables s.t. e1 |σ = e2 |σ. Given two substitutions σ and τ that unify expressions e1 and e2 , σ is moregeneral than τ iff there existsθ s.t. e1 |τ = e1 |σθ = e2 |σθ = e2 |τ. Intuitively, σ is moregeneral than τ iff σ is less constraining than τ iff σ bindsfewer variables to terms than τ . As an example, consider the expressions g(f (x)) and g(y). The substitution τ = {1/x, f (1)/y} unifies these terms forming g(f (1)). More generally, σ = {f (x)/y} unifies these terms, with θ = {1/x}, as follows: g(f (x))|τ = g(f (x))|σθ = g(f (1))= g(y)|σθ = g(y)|τ.

Given two expressions e1 and e2 ,themostgeneral unification(mgu) algorithm returns the most general substitution σ s.t. e1 |σ = e2 |σ. The mgu algorithm pattern matches as follows:

  • if e1 and e2 agree everywhere, return σ else if neither e1 nor e2 are variables, fail
  • if e1 is a variable, substitute e2 for e1 , and recur else if e2 is a variable, substitute e1 for e2 , and recur

mgu(e1 ,e2 )

Inputs expressions e1 and e2 , substitution σ

Output most general unifier σ

  1. (u, v)= disagree(e1 ,e2 ) if(u, v)is empty, return σ
  2. if u is a variable

(a) if occurs(u, v),fail

(b) else mgu(e1 ,e 2 ,σ ), whereσ = σ ∪{v/u}, e = e1 |σ, and e = e2 |σ

12

3. else if v is a variable

(a) if occurs(v, u),fail

(b) else mgu(e1 ,e 2 ,σ ), whereσ = σ ∪{u/v}, e1 = e1 |σ, and e2 = e2 |σ

4. else if neither u nor v are variables, fail

Table 1: Unification Algorithm.

disagree(e1 ,e2 )

Inputs expressions e1 and e2

Output first pair of subexpressions of e1 and e2 that disagree

1. if either of e1 or e2 is a variable or symbol

(a)
if e1 = e2 , return (e1 ,e2 )
(b)
else return ()

2. else recursively check if subexpressions of e1 and e2 disagree: return disagree(first(e1 ), first(e2 ))or disagree(rest(e1 ), rest(e2 ))

Table 2: Disagreement Subroutine.

Unification relies on a subroutine that finds the first disagreement between two expressions by recursively comparing the expressions’ constituents(seeTable 2). Soundimplementations of unification also make use of a further subroutine that checks whether one expression occurs within another(see Table 3).

Exercise: Compute the most general unifier or state why no unifier exists, for the following pairs of expressions:

R(f (x, x),a)and R(f (y, f (y, a)),a)

occurs(x, t)

Inputs variable x and term t
Output if x occurs in t, then return true
if x does not occur in t, then return false
  1. if t is a symbol, return false
  2. if t is a variable, return x = t
  3. else recursively check whether x is a subterm of t: return occurs(x, first(t))or occurs(x, rest(t))

Table 3: Occurs Check Subroutine.

Solution: No unifier exists, since occurs check fails on y f (y, a).

f (f (y, x),x)and f (f (v, f (b, v)),f (u, a))

Solution: The most general unifier σ = {f (b, a)/x, a/y, a/v, b/u}, since f (f (y, x),x)|σ = f (f (a, f (b, a)),f (b, a))= f (f (v, f (b, v)),f (u, a))|σ.

Sample Proof-by-Refutation

Example: Today is a day, and further, it is one on which we have class. If we have class on a day, thenthatday iseitherTuesday orThursday. IfitisTuesday,thenthe students can relax(students workhard on weekends). If the students are relaxing,thentheirprofessor can relax. Theprofessor can also relax if it is Thursday, since s/he does not teach again until the following Tuesday. Noah is a student. Amy is a professor. (In fact, Amyis Noah’s professor.) Can anyone relax today?

To express this scenario in the language of first-order logic, we introduce the following alphabet:

A = {today, yesterday, tomorrow,..., sunday, monday, tuesday,..., noah, amy,..., prof of(·), C, D, T, H, S, P, R}.

Thedaysinouralphabetareintended torepresentthemselves. Similarly,thenamesareintendedto represent the people being named. The function prof of(·)takes as input a student and returns that student’sprofessor. And thepredicatesincludedin our alphabet canbe understood asfollows:

    • The first four predicates represent relations that relate objects like today, tomorrow, and yesterday, as well as days of the week.
      1. C(d)is a unary predicate representing the relation “we have class on day d”.
      2. D(d)is a unary predicate representing the relation “d is a day of the week”.
      3. T (d)is a unary predicate representing the relation “d is a Tuesday”.
      4. H(d)is a unary predicate representing the relation “d is a Thursday”.
    • The next two predicates represent relations that relate people:
      1. S(x)is a unary predicate representing the relation “x is a student”.
      2. P (x)is a unary predicate representing the relation “x is a professor”.
  • The last predicate, R(x, d), relates days and people, and indicates whether or not“person x can relax on day d”.

Using this alphabet, the following formulas express our knowledge base in first-order logic (in normalform). Thefinal sentencerepresentsthenegationof thequery, “Cananyonerelaxtoday?”.

  1. D(today)
  2. C(today)
  3. D(d1 )C(d1 )T (d1 )H(d1 )
  4. T (d2 )S(x2 )R(x2 ,d2 )
  5. D(d3 )S(x3 )R(x3 ,d3 )R(prof

of(x3 ),d3 )

6.
H(x4 )P (d4 )R(x4 ,d4 )
7.
P (amy)
8.
S(noah)
9.
R(x, d)

Thefollowingproof-by-refutation shows someone(namely,Noah’sprofessor) can relaxtoday.

D(d1 )C(d1 )T (d1 )H(d1 ) D(today)

{today/d1 }

C(today)T (today)H(today) C(today) T (today)H(today)

.

.

.

. T (today)H(today) T (d2 )S(x2 )R(x2 ,d2 ) D(today) D(x3 )S(x3 )R(x3 ,d3 )R(p

{today/d2 }

S(x2 )R(x2 , today)H(today) S(x3 )R(x3 ,d3 )R(prof S(x2 )R(prof

of(x2 ), today)H(today)

.

.

.

.

S(x2 )R(prof

of(x2 ), today)H(today) S(noah)

{noah/x2 }

R(prof

of(noah), today)H(today) R(x, d)

{prof

H(today)

.

.

.

. H(today) H(x4 )P (d4 )R(x4 ,d4 )

{today/d4 }

P (x4 )R(x4 , today) P (prof of(noah)) {prof of(noah)/x4 }R(prof

of(noah), today)

⊤→