DOC PREVIEW
Stanford CS 157 - Lecture 09 - Computational Logic

This preview shows page 1-2-3-26-27-28 out of 28 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

UnificationComputational LogicLecture 9Michael GeneserethSpring 20022Resolution PrincipleThe Resolution Principle is a rule of inference.Using the Resolution Principle alone (without axiom schemataor other rules of inference), it is possible to build a theoremprover that is sound and complete for all of Relational Logic.The search space using the Resolution Principle is muchsmaller than with standard axiom schemata.3PlanFirst Lecture:Pattern MatchingUnificationSecond Lecture:Relational Clausal FormResolution PrincipleResolution Theorem ProvingThird Lecture:True or False QuestionsFill in the Blank QuestionsResidueFourth Lecture:Strategies to enhance efficiency4Difficulty with Universal Instantiation∀x.p(x,b)∀y.(p(a,y) ⇒ q(y))p(a,b)p(a,b) ⇒ q(b)5SubstititionsA substitution is a finite set of pairs of variables andterms. The variables together constitute the domain of thesubstitution, and the terms are called replacements.{x←a, y←f(b), z←v}A substitution is pure if and only if all replacements arefree of the variables in the domain of the substitution.Otherwise, the substitution is impure.{x←a, y←f(b), z←x}6ApplicationThe result of applying a substitution σ to an expression ϕ is theexpression ϕσ obtained from the original expression byreplacing every occurrence of every variable in the substitutionby the term with which it is associated.q(x, y){x ← a,y ← f(b),z ← v}= q(a, f(b))q(x, x){x ← a,y ← f(b),z ← v}= q(a,a)q(x,w){x ← a,y ← f(b),z ← v}= q(a,w)q(z,v){x ← a,y ← f(b),z ← v}= q(v,v)7IdempotenceFor pure substitution, application is idempotent.Not so for impure substitutions.q(x,x,y,w,z){x ← a,y ← f (b),z ← v}= q(a,a, f(b),w,v)q(a,a, f(b),w,v){x ← a, y ← f (b),z ← v}= q(a,a, f(b),w,v)q(x,x,y,w,z){x ← a, y ← f (b),z ← x}= q(a,a, f(b),w,x)q(a,a, f(b),w,x){x ← a, y ← f (b),z ← x}= q(a,a, f(b),w,a)8Cascaded Substitutionsr{x,y,z}{x←a, y←f(u), z←v}=r{x,f(u),v}r{x,f(u),v}{u←d, v←e}=r(a,f(d),e)r{x,y,z}{x←a,y←f(d),z←e}=r(a,f(d),e)9Composition of SubstitutionsThe composition of substitution σ and τ is the substitution(written στ) obtained by(1) applying τ to the replacements in σ(2) adjoining to σ the pairs from τ with different variables(3) deleting any assignments of variable to itself.{x←a, y←f(u), z←v}{u←d,v←e,z←g}={x←a,y←f(d),z←e}{u←d,v←e,z←g}={x←a,y←f(d),z←e,u←d,v←e}10PurityThe composition of impure substitutions may be pure.{x←a,y←f(x),z←c}{x←b,z←g(x)}={x←a,y←f(b),z←c}The composition of pure substitutions may be impure.{x←a}{y←f(x)}={x←a,y←f(x)}11ComposabilityA substitution σ and a substitution τ are composable if andonly if the variables in the domain of σ do not appear amongthe replacements of τ.{x←a,y←b,z←v}{x←u,v←b}Otherwise, they are noncomposable.{x←a,y←b,z←v}{u←x,v←b}Theorem: The composition of composable pure substitutionsmust be pure.12CompositionComposition is associative.(τσ)γ=τ(σγ)Composition has left and right identities.σ{}=σ{}σ=σComposition is not commutative.{x←y}{y←x}={x←x}{y←x}={x←x,y←x}{y←x}{x←y}={y←y}{x←y}={y←y,x←y}13Pattern MatchingA substitution σ is a matcher for a pattern ϕ and anexpression ψ if and only if ϕσ=ψ.An expression ψ matches a pattern ϕ if and only if there is amatcher for ϕ and ψ.Example: p(a,b) matches p(x,y)p(x,y){x←a,y←b}=p(a,b)14Universal Instantiation ProblemExample:Example:p(a,b)∀y.(p(a,y) ⇒ q(y))∀x.p(x,b)∀y.(p(a,y) ⇒ q(y))15UnificationA substitution σ is a unifier for an expression ϕ and anexpression ψ if and only if ϕσ=ψσ.p(x,y){x←a,y←b,v←b}=p(a,b)p(a,v){x←a,y←b,v←b}=p(a,b)If two expressions have a unifier, they are said to be unifiable.Otherwise, they are nonunifiable.p(a,b)p(b,a)16Non-Uniqueness of UnificationUnifier 1:p(x,y){x←a,y←b,v←b}=p(a,b)p(a,v){x←a,y←b,v←b}=p(a,b)Unifier 2:p(x,y){x←a,y←f(w),v←f(w)}=p(a,f(w))p(a,v){x←a,y←f(w),v←f(w)}=p(a,f(w))Unifier 3:p(x,y){x←a,y←v}=p(a,v)p(a,v){x←a,y←v}=p(a,v)17Generality of UnifiersA unifier σ is as general as or more general than a unifierτ if and only if there exists a substitution γ such that τ=σγ.{x←a,y←v}{v←f(w)}={x←a,y←f(w),v←f(w)}18Most General UnifierA substitution σ is a most general unifier of two expressions ifand only if it is as general as or more general than any otherunifier.Theorem: If two expressions are unifiable, then they have amost general unifier that is unique up to variable permutation.p(x,y){x←a,y←v}=p(a,v)p(a,v){x←a,y←v}=p(a,v)p(x,y){x←a,v←y}=p(a,y)p(a,v){x←a,v←y}=p(a,y)19Expression StructureEach expression is treated as a sequence of its immediatesubexpressions.Linear Version:p(a,f(b,c),d)Sequence Version:p a df b c20mgux,yx=yσ={}variable(x)τ=mgu(first(x),first(y))τ=failx=rest(x)y=rest(y)x=xτy=yτσ=στvariable(y)constant(x) or constant(y){}{x/y}{y/x}failfailx=[] and y=[]σ21Example↓p(x,b){}{}={}p(a,y) ↓p(x,b){}{x←a}={x←a}p(a,y) ↓p(a,b) {x←a}{y←b}={x←a,y←b}p(a,y) ↓p(a,b) {x←a,y←b}p(a,b)22Example↓p(x,x){}{}={}p(a,b) ↓p(x,x){}{x←a}={x←a}p(a,b) ↓p(a,a)Failp(a,b)23Example↓p(f(x),f(x)){}{}={}p( y,f(a)) ↓p(f(x),f(x)){}{y←f(x)}={y←f(x)}p( y,f(a)) ↓p(f(x),f(x)) {y←f(x)}{}={y←f(x)}p(f(x),f(a)) ↓p(f(x),f(x)) {y←f(x)}{x←a}={y←f(a),x←a}p(f(x),f(a))24Example↓p(x,x){}{}={}p(y,f(y)) ↓p(x,x){}{x←y}={x←y}p(y,f(y)) ↓p(y,y) {x←y}{y←f(y)}={x←f(y),y←f(y)}p(y,f(y)) ↓p(f(y),f(y)) {x←f(y),y←f(y)} Wrong!!!p(f(y),f(f(y)))25Problem¬hates(x,x)hates(y, f (y))26SolutionBefore assigning a variable to an expression, first check that thevariable does not occur within that expression.This is called, oddly enough, the occur check test.Prolog does not do the occur check (and is proud of it).27Flowchartx,yx=yσ={}variable(x)τ=mgu(first(x),first(y))τ=failx=rest(x)y=rest(y)x=xτy=yτσ=στvariable(y)constant(x) or constant(y){}x occurs in y{x/y}faily occurs in x{y/x}failfailfailx=[] and y=[]σ28Example↓p(x,x){}{}={}p(y,f(y)) ↓p(x,x){}{x←y}={x←y}p(y,f(y))


View Full Document

Stanford CS 157 - Lecture 09 - Computational Logic

Documents in this Course
Lecture 1

Lecture 1

15 pages

Equality

Equality

32 pages

Lecture 19

Lecture 19

100 pages

Epilog

Epilog

29 pages

Equality

Equality

34 pages

Load more
Download Lecture 09 - Computational Logic
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 09 - Computational Logic and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 09 - Computational Logic 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?