Higher Order Unification Unification Modulo Observational Equivalence Solution Unification Modulo Observational Equivalence over simply-typed λ -terms in call-by-value semantics St´ ephane Gimenez, Joe Wells 18/08/04 St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Higher Order Unification Unification Modulo Observational Equivalence Solution Higher Order Unification Unification Objectives Higher Order Huet’s Algorithm Unification Modulo Observational Equivalence Calculus Semantics Observational equivalence Unification Solution Reusing HOU Augmented call-by-value reduction Reduction of unification problems St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Higher Order Unification Unification Modulo Observational Equivalence Solution Motivations ◮ C. Haack proposed a tool for automatic adaptation of software components that would need UMOE. ◮ The approximation made was to use HOU to find unification candidates modulo β -equivalence, then check in a second time that the observational behavior are the same. ◮ We propose to find solutions in a single phase. ◮ Possibly, finding solutions that are not needed to respect β -equivalence. St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Unification ◮ Classical unification problems deals with solving equations at the syntax level modulo some equivalence relations such as associativity or commutativity. b + X + Y ≈ a + Z St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Unification ◮ Classical unification problems deals with solving equations at the syntax level modulo some equivalence relations such as associativity or commutativity. b + X + Y ≈ a + Z ◮ Ground Solution: X �→ a , Y �→ a , Z �→ b + a St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Unification ◮ Classical unification problems deals with solving equations at the syntax level modulo some equivalence relations such as associativity or commutativity. b + X + Y ≈ a + Z ◮ Ground Solution: X �→ a , Y �→ a , Z �→ b + a ◮ Unifiers: Y �→ a , Z �→ b + X Y �→ a + T , Z �→ b + T + X St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Definition An unification problem is a set of equations t 1 ≈ t 2 in an algebra extended with unknowns X , Y , Z ... , for which equivalence is written ≃ . St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Definition An unification problem is a set of equations t 1 ≈ t 2 in an algebra extended with unknowns X , Y , Z ... , for which equivalence is written ≃ . Definition An unifier for a given unification problem is a substitution θ (that replaces unknowns with terms) such for each equation t 1 ≈ t 2 of the unification problem, θ t 1 ≃ θ t 2 . St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Definition An unification problem is a set of equations t 1 ≈ t 2 in an algebra extended with unknowns X , Y , Z ... , for which equivalence is written ≃ . Definition An unifier for a given unification problem is a substitution θ (that replaces unknowns with terms) such for each equation t 1 ≈ t 2 of the unification problem, θ t 1 ≃ θ t 2 . Definition An unifier θ 1 is said more general than θ 2 ( θ 1 ≤ θ 2 ) iff there exists a substitution θ such that θ 2 = θθ 1 St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm ◮ In our example, X �→ a , Y �→ a , Z �→ b + a ≥ Y �→ a , Z �→ b + X ≥ Y �→ a + T , Z �→ b + T + X St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm ◮ In our example, X �→ a , Y �→ a , Z �→ b + a ≥ Y �→ a , Z �→ b + X ≥ Y �→ a + T , Z �→ b + T + X ◮ In fact there are two minimal unifiers, X �→ a + T , Z �→ b + T + Y Y �→ a + T , Z �→ b + T + X St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Objectives ◮ Find a most general unifier when it exists. ◮ Find a complete finite (finitely representable) set of minimal unifiers. ◮ Find a complete finite (finitely representable) set of unifiers. ◮ Enumerate a complete set of unifiers. ◮ Find an unifier when there is one. The existence of an unifier is undecidable for almost every “complex” algebra, only the two last specifications can be assured. Incomplete results can also be interesting. St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Higher Order ◮ When the algebra considered is the algebra of λ -terms modulo βη -equivalence, unification is said Higher Order Unification. ◮ Higher Order Unification is semi-decidable. ◮ A exhaustive “generate and test” algorithm allows to know that a specific problem has solutions. ◮ Huet’s algorithms allows to restrict the search space. St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Definition Simply-typed λ -terms are built using the following syntax: l σ → τ λ x σ . t τ ::= t τ l τ x τ X τ t σ → τ t σ ::= 1 2 Definition A unification problem is syntactically defined as: t τ 1 ≈ t τ ::= P 1 , P 2 ⊥ P ∅ 2 St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm Huet’s Algorithm Rules for Higher Order Unification ◮ delete: P , t ≈ t → P ◮ decompose: t ′ → P , t 1 ≈ t ′ 1 , . . . , t n ≈ t ′ P , x � t ≈ x � n ◮ eliminate: P , X ≈ t → P [ X := t ] , X ≈ t if X �∈ fv t St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Unification Higher Order Unification Objectives Unification Modulo Observational Equivalence Higher Order Solution Huet’s Algorithm ◮ imitate: ω ranges over x and X , P , X � t ≈ ω� t ′ P , X � t ≈ ω� t ′ , → X = λ� r . ω ( λ� s 1 . Z 1 ( � r ,� s 1 ) , . . . , λ� s n . Z n ( � r ,� s n )) ◮ project: P , X ≈ x � P , X ≈ x � → t , t X = λ� r . r i ( λ� s 1 . Z 1 ( � r ,� s 1 ) , . . . , λ� s n . Z n ( � r ,� s n )) ◮ guess: P , X � t ≈ Y � t ′ P , X � t ≈ Y � t ′ , → X = λ� r . ω ( λ� s 1 . Z 1 ( � r ,� s 1 ) , . . . , λ� s n . Z n ( � r ,� s n )) St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Calculus Higher Order Unification Semantics Unification Modulo Observational Equivalence Observational equivalence Solution Unification Unification Modulo Observational Equivalence ◮ A different kind of unification on simply-typed λ -terms. ◮ Observational equivalence instead of βη -equivalence. ◮ Call-by-value semantics, since the two equivalences are the same in call-by-name semantics. St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Calculus Higher Order Unification Semantics Unification Modulo Observational Equivalence Observational equivalence Solution Unification Calculus Definition Simply-typed λ -terms are built using the following syntax: l σ → τ λ x σ . t τ ::= τ v τ l τ x τ ::= X Γ ¯ X τ t τ v τ t σ → τ t σ ¯ ::= 1 2 Γ t τ , Γ Γ ::= ∅ St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Calculus Higher Order Unification Semantics Unification Modulo Observational Equivalence Observational equivalence Solution Unification Calculus Definition Simply-typed λ -terms are built using the following syntax: l σ → τ λ x σ . t τ ::= τ v τ l τ x τ ::= X Γ ¯ X τ t τ v τ t σ → τ t σ ¯ ::= 1 2 Γ t τ , Γ Γ ::= ∅ X τ τ X τ ¯ ::= X Γ Γ Γ ¯ St´ ephane Gimenez, Joe Wells Unification Modulo Observational Equivalence
Recommend
More recommend