unification algorithm idea eliminate disagreements
play

Unification Algorithm Idea: eliminate disagreements Consider the set - PowerPoint PPT Presentation

Unification Algorithm Idea: eliminate disagreements Consider the set of expressions { P ( a ) , P ( x ) } The expressions disagree on a and x The disagreement set is { a, x } Since x is a variable, we can eliminate this


  1. Unification Algorithm

  2. Idea: eliminate ‘disagreements’ Consider the set of expressions { P ( a ) , P ( x ) } – The expressions ‘disagree’ on a and x – The disagreement set is { a, x } – Since x is a variable, we can eliminate this disagreement by using the substitution θ = { x/a } – Then P ( a ) θ = P ( x ) θ = P ( a ) Unification algorithm 1

  3. Idea: eliminate ‘disagreements’ Consider the set of expressions { P ( a ) , P ( x ) } – The expressions ‘disagree’ on a and x – The disagreement set is { a, x } – Since x is a variable, we can eliminate this disagreement by using the substitution θ = { x/a } – Then P ( a ) θ = P ( x ) θ = P ( a ) Definition The disagreement set for a set W of expressions is obtained by find- ing the first position (starting from the left) at which not all expressions in W have the same symbol. We then extract from each expression in W the sub- expression that begins with the symbol occupying that position. The set of these sub-expressions is the disagreement set for W . Exercise Find the disagreement set for W = { P ( x, f ( y, z )) , P ( x, a ) , P ( x, g ( h ( k ( x )))) } Unification algorithm 1

  4. Unification algorithm Step 1 Set k = 0 , W 0 = W and σ 0 = ε (empty substitution) Step 2 If W k is a singleton, STOP: σ k is an MGU for W . Otherwise, find the disagreement set D k for W k . Step 3 If there are x k , t k ∈ D k such that x k is a variable that does not occur in t k , then go to step 4; otherwise STOP: the set W is not unifiable. Step 4 Set σ k +1 = σ k { x k /t k } and W k +1 = W k { x k /t k } ( = W σ k +1 ) Step 5 Set k = k + 1 and go to step 2 Unification algorithm 2

  5. Unification algorithm Step 1 Set k = 0 , W 0 = W and σ 0 = ε (empty substitution) Step 2 If W k is a singleton, STOP: σ k is an MGU for W . Otherwise, find the disagreement set D k for W k . Step 3 If there are x k , t k ∈ D k such that x k is a variable that does not occur in t k , then go to step 4; otherwise STOP: the set W is not unifiable. Step 4 Set σ k +1 = σ k { x k /t k } and W k +1 = W k { x k /t k } ( = W σ k +1 ) Step 5 Set k = k + 1 and go to step 2 Examples Find MGUs for the following sets: – W 1 = { P ( a, y ) , P ( x, f ( b )) } – W 2 = { P ( a, x, f ( g ( y ))) , P ( z, f ( z ) , f ( u )) } – W 3 = { Q ( f ( a ) , g ( x )) , Q ( y, y ) } – W 4 = { Q ( a, x, f ( x )) , Q ( a, y, y ) } – W 5 = { Q ( x, y, z ) , Q ( u, h ( v, v ) , u ) } Unification algorithm 2

  6. Unification algorithm: termination The unification algorithm always comes to a stop after finitely many steps – For otherwise there would be an infinite sequence W σ 0 , W σ 1 , W σ 2 , . . . – Each step eliminates one variable from W – Which is a contradiction since W contains finitely many variables Unification algorithm 3

  7. Unification algorithm: termination The unification algorithm always comes to a stop after finitely many steps – For otherwise there would be an infinite sequence W σ 0 , W σ 1 , W σ 2 , . . . – Each step eliminates one variable from W – Which is a contradiction since W contains finitely many variables Unification algorithm: correctness Theorem If W is a finite unifiable set of expressions, then the unification algorithm always comes to a stop and returns an MGU for W . Proof Suppose θ is a unifier for W . By induction on k one can show that there is a substitution λ k such that θ = σ k λ k . Unification algorithm 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend