Logic for Computer Scientists/Predicate Logic/Resolution: Difference between revisions

From testwiki
Jump to navigation Jump to search
 
(No difference)

Latest revision as of 09:14, 20 January 2023

Resolution

In the propositional case we defined the resolution inference rule by "cutting away" a pair of complementary literals in two clauses which are resolved upon. In the first order case however this is not always sufficient:

C1:p(x)q(x)C2:¬p(f(x))

In these two clauses there are no complementary literals, however, after substituting the term f(a) for the variable x in C1 and a for x in C2 we arrive at:

C1:p(f(a))q(f(a))C2:¬p(f(a))

Now we can apply the inference rule from propositional logic and arrive at the resolvent q(f(a)).

Another possibility is to substitute f(x) for x in C1 to get

C1:p(f(x))q(f(x))

and then we can have the resolvent q(f(x)) from C1 and C2, which is in a certain sense more general then the resolvent derived previously.

Definition 18

A substitution σ is a function, which maps variables to terms and which is the identical mapping almost everywhere. Hence it can be represented as

σ={x1/t1,,xn/tn}

If t1,,tn are groundterms, we call σ a ground substitution. The empty substitution is notated by ϵ .

Definition 19

Let θ={x1/t1,,xn/tn} be a substitution and E an expression (i.e. a literal or a term), then Eθ is the expression, obtained from E by replacing simultaneously each occurrence of Xi,1in in E by the term ti.

Example:
With θ={x/a,y/f(b),z/e} and E=p(x,y,z), we get Eθ=p(a,f(b),c)

Definition 20

Let σ={x1/t1,,xn/tn} and λ={y1/s1,,ym/sm} be substitutions. Then the composition of substitutions, denoted by σλ, is the substitution, which is obtained from {x1/t1λ,,xn/tnλ,y1/s1,,ym/sm} by deleting any element xj/tjλ for which tjλ=xj and any element yi/si such that yi{x1,,xn} .
Example:

Definition 21

Let {E1,,En} be a set of expressions and θ a substitution, θ is unifier for {E1,,En} iff

E1θ=E2θ=Enθ

.

A unifier θ is called most general unifier iff for every unifier σ there is a substitution λ such that σ=θλ.

In the following we discuss an algorithm for computing most general unifiers. For this we assume a set of terms {t1,,tn} to be unified. First we transform this into a set of equations by introducing a new variable not yet occurring in this set, say y and by defining the set of equations

N={y=t1,,y=tn}

We will now transform this set such that its unifiers stay invariant, where a σ is a unifier of a set of {s1=t1,,sn=tn} if {s1σ=t1σ,,snσ=tnσ} holds.

Template:Box

Theorem 7

Let N be a set of expressions. The above unification algorithm terminates. If it returns FAIL, there is no unifier for N, otherwise N is transformed into a set of equation {y1=u1,,ym=um}, which represents the most general unifier for N.

Definition 22

Let two or more literals of a clause C have a unifier σ, then Cσ is called a factor of C.

Example:
With C={p(x),p(f(y)),¬q(x)} and σ={x/f(y)} we get the factor Cσ={p(f(y)),¬q(f(y))}

Definition 23

Let C1 and C2 be two clauses with no variables in common, such that L1C1 and L2C2 and L1 and L2 have a most general unifier σ. A binary resolvent of C1 and C2 is

(C1σL1σ)(C2σL2σ)


Example: Given C1={p(x),q(x)} and C2={¬p(a),r(x)}. After renaming C2 into C2={¬p(a),r(y)} we get the resolvent {q(a),r(y)} by using the most general unifier {x/a}.


We often depict resolvent graphically, e.g.

Definition 24

A resolvent of two clauses C1 and C2 is one of the following binary resolvents:

  • a binary resolvent of C1 and C2
  • a binary resolvent of C1 and a factor of C2
  • a binary resolvent of a factor of C1 and C2
  • a binary resolvent of a factor of C1 and a factor of C2


Example:

Given C1={p(x),p(f(y)),r(g(y))} and C2={¬p(f(g(a))),q(b)}.

A factor of C1 is C1={p(f(y)),r(g(y))}. A binary resolvent of C1 and C2 and hence also of C1 and C2 is C3={r(g(g(a))),q(b)}.

The following lemma is used in the completeness proof of resolution.

Lemma 5 (Lifting lemma)

If C'1 and C'2 are instances of C1 and C2, respectively, and C is a resolvent of C'1 and C'2, then there is a resolvent C of C1 and C2 such that C is an instance of C.

Figure 1

Theorem 8

A set S of clauses is unsatisfiable iff the empty clause can be derived from S by resolution.
Proof:
Assume that S is unsatisfiable. Let A={A1,A2,} be the ground atom set of S, hence the Herbrand basis. Let T be a complete binary tree, as given in Figure 2. According to Herbrand's theorem (version1) there exists a closed finite semantic tree T. There are two cases:

  • If T consists only of one node (hence the root), The interpretation to be collected from the empty branch in this tree falsifies only the empty clause. Hence the empty clause must be in S.
  • Assume T consists of more than one node. Then there must be an inference node N in T, hence both its descendants N1 and N2 are failure nodes. If such a node would not exist, every node would have at least one non-failure node, which would mean that there is at least an infinite path in T, which would violate, that fact that it is a finite closed semantic tree. Let N,N1,N2 given as described above; and let
    I(N)={m1,m2,,mn}I(N1)={m1,m2,,mn,mn,mn+1}I(N2)={m1,m2,,mn,mn,¬mn+1}

Now, let C1 and C2 be ground instances of clauses C1 and C2, such that C1 is falsified by I(N1) and C2 by I(N2), such that both are not falsified by I(N).

Hence we have

¬mn+1C1

and

mn+1C2

and we can construct the resolvent

C=(C1{¬mn+1})(C2{mn+1})

C must be false in I(N), because both (C1¬mn+1) and (C2mn+1) are false in I(N). According to the Lifting Lemma 5 there exists a resolvent C of C1 and C2, such that C is a ground instance of C. Let T be the closed semantic tree for S{C} , obtained from T by deleting all nodes below the first node which falsifies C. Note, that S is unsatisfiable if and only if S{C} is unsatisfiable. Clearly, T has less nodes than T and we now can iterate this process until only the root of the semantic tree is remaining. This, however is only possible if the empty clause is derivable. For the opposite direction, assume that is derivable by resolution from S and let R1,,Rk the resolvents constructed during this process. Assume S is satisfiable and M to be a model for S. From the correctness lemma according to the propositional case we known, that if a model satisfies two clauses it also satisfies its resolvent. Therefore M has to satisfy R1,,Rk; this, however, is impossible, because one of this resolvents is .



Figure 2

Problems

Problem 14 (Predicate)

Indicate in each case a derivation of the empty clause with predicate-logical resolution!

  1. {{p(x,0,x)},{p(x,s(y),s(z)),¬p(x,y,z)},{¬p(s(s(s(0))),s(s(0)),u)}}
  2. {{q(x),q(s(x))},{¬q(x),¬q(s(s(x)))}}
    ()
  3. {{¬r(x,f(x),y),¬r(x,g(y),z)},{r(c,u,i(v)),r(h(u),v,j(v))}}


Problem 15 (Predicate)

Show the following Lifting lemma by means of induction over the term- and formula construction: Is F a predicate-logical formula, and a fitting interpretation for

F

and

F[x/t]

. Then

(F[x/t])=[x/(t)](F),


is valid, if

t

does not contain any variable that

[x/t]

is laced

by the substitution in F.

Problem 16 (Predicate)

Compute - if possible - the most general unifier of following sets of clauses:

  1. {p(x,a),p(f(c),y)}
  2. {p(f(x),a,x),p(y,z,z)}
  3. {q(x,x),q(g(y),y)}
  4. {r(x,x),r(a,h(y))}


Problem 17 (Predicate)

Determine all direct resolvents of the following pairs of clauses:

  1. {¬p(x),q(x,b)} and {p(a),q(a,b)}
  2. {p(x),p(f(x))} and {¬p(x),¬p(f(f(x)))}
  3. {¬q(c,g(c))} and {¬p(x),q(x,x)}
  4. {¬p(x,y,z),¬p(y,u,v),¬p(x,v,w),p(z,u,w)} and {p(g(x,y),x,y)}


Problem 18 (Predicate)

Compute - if possible - the most general unifier of following sets of clauses:

  1. {o(x,x),o(a,f(y))}
  2. {p(x,a),p(f(c),y)}
  3. {q(g(x),a,x),q(y,z,z)}
  4. {r(x,x),r(h(y),y)}


Problem 19 (Predicate)

Determine all direct resolvents of the following pairs of clauses:

  1. {¬p(x),¬p(b),q(x,b)} and {p(a),q(a,b)}
  2. {r(x),r(f(x))} and {¬r(x),¬r(f(f(x)))}
  3. {¬s(c,g(c))} and {s(x,x),¬t(x)}


Problem 20 (Predicate)

Give for the following set of clauses (a) a linear derivation, (b) a derivation with unit resolution, (c) a further (maximally short) derivation of the empty clause by means of predicate-logical resolution!

{{¬e(x),o(s(x))},{¬e(x),¬o(s(x)),e(s(s(x)))},{e(a)},{¬o(s(s(s(s(s(a))))))}}


Problem 21 (Predicate)

Indicate in each case a derivation of the empty clause with predicate-logical resolution!

  1. {{p(x,0,x)},{p(x,s(y),s(z)),¬p(x,y,z)},{¬p(s(s(s(0))),s(s(0)),u)}}
  2. {{q(x),q(s(x))},{¬q(x),¬q(s(s(x)))}}
    ()
  3. {{¬r(x,f(x),y),¬r(x,g(y),z)},{r(c,u,i(v)),r(h(u),v,j(v))}}


Template:BookCat