Presentation is loading. Please wait.

Presentation is loading. Please wait.

Soundness of SLD-Resolution

Similar presentations


Presentation on theme: "Soundness of SLD-Resolution"— Presentation transcript:

1 Soundness of SLD-Resolution
procedural semantics

2 Definition: A substitution  is a finite set of the form
{v1/t1…vn/tn}, where each vi is a variable, each ti is a term distinct from vi and the variables v1…vn are distinct. Each element vi/ti is called a binding for vi.  is called a ground substitution, if the ti are all ground terms.  is called a variable-pure substitution, if the ti are all variables.

3 Execution of the Substitution
Definition: An expression is either a term, a literal or a conjunction or disjunction of literals. A simple expression is either a term or an atom. Definition: Let ={v1/t1…vn/tn} be a substitution and E be an expression. Then Ethe instance of E by is the expression obtained from E by simultaneously replacing each occurrence of the variablevi in E by the term ti. If E is ground, then E is called a ground instance of E. Example

4 Composition of the Substitution
Definition: Let ={u1/s1…un/sn} and ={v1/t1…vn/tn} be substitutions. Then the composition ofand, is the substitution obtained from the set {u1/s1 …un/sn, v1/t1…vn/tn}, by: a. deleting any binding ui/si for which ui=si b. deleting any binding vi/ti for which vi{u1…un} Notation: The substitution given by the empty set {} is called the identity substitution denoted by 

5 Properties of the Substitution
Propositions: Let , ,  be substitutions, E an expression. == (Identity) (E) = E() () = () (Associativity) Proof: Follows from definition of  prove proposition for E=x prove E() = E() for E=x and 2. Example

6 Variants Definition: Let E and F be expressions. We say E and F are variants if there exist substitutions , such that E=F und F=E Example

7 Unifier Definition: Let S be a finite set of simple expressions. A Substitution  is called a unifier for S, if S is a singleton. A unifier  is called a most general unifier (mgu) for S if, for each unifier  of S there exists a substitution  such that =. Example Note: If there exist two mgu's then they are variants.

8 Disagreement Set Definition: Let S be a finite set of simple expressions. Locate the leftmost symbol position at which not all expressions in S have the same symbol and extract from each expression in S the subexpression beginning at that symbol position. The set of all such subexpressions is the disagreement set. Example: Let S={p(f(x),h(y),a), p(f(x),z,a), p(f(x),h(y),b)}, then the disagreement set is {h(y),z}

9 Unification Algorithm
put k:=0 and 0:= If Sk is a singleton, Then return(k) Else find the disagreement set Dk of Sk If there exist a variable v and a term t in Dk such that v does not occur in t, // non-deterministic choice Then put k+1 := k{v/t}, k++, goto 2 Else exit // S is not unifiable

10 return. , k=1 S={even(0),even(y)} D0={0,y}
Example , k=1 S={even(0),even(y)} D0={0,y} choose variable y, term 0 put 1 := {y/0}, k=1 S={even(0)} return.

11 Unification Theorem Theorem: Let S be a finite set of simple expressions. If S is unifiable, then the unification algorithm terminates and gives a mgu for s. If S is not unifiable, then the unification algorithm terminates and reports this fact. Proof Sketch: Assume  is a unifier for S. Show that until termination for all k : =kk

12 Soundness of SLD Resolution Completeness of SLD Resolution
Structure - 1 Preliminaries Definite Programs Semantics Soundness of SLD Resolution Completeness of SLD Resolution

13 SLD: SL-resolution for definite clauses
SLD-Resolution SLD: SL-resolution for definite clauses SL: Linear resolution with selection function

14 Derivation Definition: Let G be ← A1,…., Am,…, Ak and C be A ← B1,…., Bq. Then G' is derived from G and C using mgu , if: a. Am is an Atom, called the selected atom, in G b.  is an mgu of Am and A. c. G‘ is the goal ← (A1,…., B1,…., Bq,…, Ak). In resolution terminology G‘ is called a resolvent of G and C.

15 SLD-Derivation Definition: Let P be a definite program and G0 a definite goal. An SLD-Derivation of P  {G0} consists of a (finite or infinite) sequence G0, G1, G2,… of goals, a sequence C1, C2 ,… of variants of program clauses of P and a sequence 1, 2, … of mgu's such that each Gi+1 is derived from Gi and Ci+1 using i+1. standardising apart the variables: subscribe all variables in Ci with i. Otherwise ←p(x). could not be unified with p(f(x)) ← . each program clause variant C1, C2 ,… is called an input clause of the derivation

16 SLD-Derivation visualised
(← A1,…., B1,…., Bq,…, Ak)1 ← A1,…., Am,…, Ak (← A11,..,B11,..,D1,..,Dl,…,Bq1,..,Ak 1) 2 G0 G1 G2 G3 Gn-1 Gn C1 ,1 C2,2 C3 ,3 Cn ,n A ← B1,…., Bq. 1=mgu(A,Am). B ← D1,…., Dl. 2=mgu(B,Bo 1).

17 Example – Restricted SLD-Refutation
← R(g(f(z))). Program P 1 Q(x) :- R(g(x)). 2 R(y). Goal: Q(f(z)). ← Q(f(z)) Computed Answer {x/f(z), y/g(f(z))} restricted to variables of Q(f(z)) results in  G0 G1 C1 ,1 C2,2 Q(x) :- R(g(x)). 1=mgu(Q(x),Q(f(z))) ={x/f(z)} R(y)←. 2=mgu(R(y), R(g(f(z)))) = {y/g(f(z))}

18 Example – Unrestricted SLD-Refutation
← R(g(f(a))). Program P 1 Q(x) :- R(g(x)). 2 R(y). Goal: Q(f(z)). ← Q(f(z)) Correct Answer: {x/f(a), z/a, y/g(f(z))} restricted to variables of Q(f(z)) results in {z/a} G0 G1 C1 ,1 C2,2 Q(x) :- R(g(x)). 1={x/f(a), z/a} R(y)←. 2={y/g(f(a))}

19 SLD Refutation Definition: An SLD-refutation of P  {G} is a finite SLD-derivation of P  {G}, which has □ as the last goal in the derivation. If Gn=□, we say the refutation has length n. SLD-derivations can be finite or infinite. A finite SLD-derivation can be successful or fail. An SLD-derivation is successful, if it ends in □. An SLD-derivation is failed, if it ends in a non-empty goal, which cannot be unified with the head of a program clause.

20 Procedural Counterpart of the Least Herbrand Model!
Success Set Definition: Let P be a definite program. The success set of P is the set of all ABP such that P  {← A} has an SLD-refutation. Procedural Counterpart of the Least Herbrand Model!

21 Computed Answer Definition: Let P be a definite program and G a definite goal. Let 1…n be the sequence of mgu's used in an SLD-refutation of P{G}. A computed answer  for P{G} is the substitution obtained by restricting the composition 1…n to the variables of G.

22 goal: ← sort(17.22.6.5.nil,y) computed answer: {y/5.6.17.22.nil}
Example: P=Slowsort goal: ← sort( nil,y) computed answer: {y/ nil} sort(x,y) ← sorted(y), perm(x,y) sorted(nil) ← sorted(x.nil) ← sorted(x.y.z) ← xy, sorted(y.z) perm(nil,nil) ← perm(x.y,u.v) ← delete(u,x.y,z),perm(z,v) delete(x,x.y,y) ← delete(x,y.z,y.w) ← delete(x,z,w) 0x ← f(x) f(y) ← xy.

23 Soundness of SLD-Resolution - 1
Theorem Let P be a definite program and G a definite goal. Then every computed answer for P{G} is a correct answer for P{G}. Proof Let G be the goal ← A1,…, Ak and 1…n the sequence of mgu's in a refutation of P{G}. Show that ((A1,…, Ak )1…n)is a logical consequence of P using induction (starting at the last goal) over the length of the derivation.

24 Corollary The success set of a definite program is contained in its least Herbrand model.
Proof Let the program be P, let ABP and suppose P{← A} has a refutation. By the theorem on the prior slide A is a logical consequence of P. Thus A is in the least Herbrand model of P.

25 Ground Instances of A strengthen this corollary If ABP and P{← A} has a refutation of length n, then A TPn. Notation [A]={A‘ BP: A‘=A for some substitution }

26 Soundness of SLD-Resolution - 2
Theorem Let P be a definite program and G a definite goal ← A1,…, Ak. Suppose that P{G} has a SLD-refutation of length n and 1…n is the corresponding sequence of mgu's., Then we have that kj=1 [Aj1…n] TPn. Proof (basis) Induction on the length of the refutation n=1: G= ← A1, the program has a unit clause of the form A← and A11 =A1. Then we have that (see next slide) [A] TP1 and so [A11] TP1.

27 Van Emden & Kowalski: The Semantics of Predicate Logic as a Programming Language, J. ACM 23, 4, 1976, pp Definition Let P be a definite program. The mapping TP: 2BP 2BP is defined as follows: Let I be an Herbrand interpretation. Then TP(I)={ABP: A ← A1  … An is a ground instance of a clause in P and {A1,…,An }I} Repetition!

28 Soundness of SLD-Resolution - 2
Theorem Let P be a definite program and G a definite goal ← A1,…, Ak. Suppose that P{G} has a SLD-refutation of length n and 1…n is the corresponding sequence of mgu's., Then we have that kj=1 [Aj1…n] TPn. Proof (Inductive step - Case 1) Induction valid for SLD refutation of length n-1. Consider a refutation of length n of P{G}. Let Aj be an Atom of G. Case 1: Aj is not the selected Atom of G. Then Aj1 is an Atom of G1, the second goal of the refutation. The induction hypothesis implies that [Aj1…n]TPn-1TPn because of the monotony of TP.

29 Soundness of SLD-Resolution - 2
Proof (Inductive step – Case 2) Induction valid for SLD refutation of length n-1. Suppose a refutation of length n of P{G}. Let Aj be an atom of G. Case 2: Aj is the selected atom of G. Let B← B1,…, Bq (q0) be the first input clause. Then Aj1 is an instance of B. If q=0 we have [B] is in TP1. Thus [Aj1…n] [Aj1][B]TP1 TPn. If q>0 by the induction hypothesis, [Bi1…n] TP(n-1) for i=1,…,q By the definition of TP we have that [Aj1…n]TPn.


Download ppt "Soundness of SLD-Resolution"

Similar presentations


Ads by Google