e unification of higher order patterns
play

E -Unification of Higher-order Patterns Alexandre Boudet Evelyne - PowerPoint PPT Presentation

E -Unification of Higher-order Patterns Alexandre Boudet Evelyne Contejean LRI Orsay France Motivations Higher-order unification is undecidable (Huet) Unification of higher-order patterns is decidable (Miller) Combination of


  1. E -Unification of Higher-order Patterns Alexandre Boudet Evelyne Contejean LRI Orsay France

  2. Motivations • Higher-order unification is undecidable (Huet) • Unification of higher-order patterns is decidable (Miller) • Combination of algebraic and functional programming paradigms • Local confluence of HRSs ⇓ Unification of higher-order patterns modulo equational theories 2

  3. Patterns First-Order Term Pattern General High-Order Term ✁ ❆ ✁ ❆ ✁ ❆ ✁ ✁ ✁ ❆ ❆ ❆ ✁ ✁ ✁ ❆ ❆ ❆ ✁ ✁ ✁ ❆ ❆ ❆ ✁ ✁ ✁ F ❆ ❆ ❆ ✁ ✁ ✁ ❆ ❆ ❆ FG H H ✁ ✁ ✁ ❆ ❆ G ❆ ✁ ✁ ✁ x y z x y z ❆ ❆ ❆ ✁ ❆ ✁ ❆ ✁ ❆ Definition Pattern: • term of the simply-typed λ -calculus in β -normal form • the arguments of a free variable are η -equivalent to distinct bound variables. Patterns Not patterns λxyz.f ( H ( x, y ) , H ( x, z )) λxy.G ( x, x, y ) λx.F ( λz.x ( z )) = η λx.F ( x ) λxy.H ( F ( x ) , y ) No equational theory, but α, β, η . Theorem (Miller) In the case of patterns, unifiability is decidable there is an algorithm for computing a mgu. 3

  4. Patterns First-Order Term Pattern General High-Order Term ✁ ❆ ✁ ❆ ✁ ❆ ✁ ✁ ✁ ❆ ❆ ❆ ✁ ✁ ✁ ❆ ❆ ❆ ✁ ✁ ✁ ❆ ❆ ❆ ✁ ✁ ✁ F ❆ ❆ ❆ ✁ ✁ ✁ ❆ ❆ ❆ FG H H ✁ ✁ ✁ ❆ ❆ G ❆ ✁ ✁ ✁ x y z x y z ❆ ❆ ❆ ✁ ❆ ✁ ❆ ✁ ❆ Definition Pattern: • term of the simply-typed λ -calculus in β -normal form • the arguments of a free variable are η -equivalent to distinct bound variables. Patterns Not patterns λxyz.f ( H ( x, y ) , H ( x, z )) λxy.G ( x, x, y ) λx.F ( λz.x ( z )) = η λx.F ( x ) λxy.H ( F ( x ) , y ) No equational theory, but α, β, η . Theorem (Miller) In the case of patterns, unifiability is decidable there is an algorithm for computing a mgu. 4

  5. E-unification of Patterns Definition E = { l 1 ≃ r 1 , . . . , l n ≃ r n } : set of First-Order axioms. Equational theory = E : least congruence containing all the l i σ ≃ r i σ (context, application and abstraction) Definition s = t , pair of patterns of the same type. Equation : Unification problem : ⊤ , ⊥ or P ≡ s 1 = t 1 ∧ · · · ∧ s n = t n . substitution σ such that ∀ i , s i σ = βηE t i σ . E -unifier of P : ⇒ u � η β = E v � η Theorem ( Tannen) ∀ u, v u = βηE v ⇐ β . 5

  6. How to split when E = E 1 ∪ . . . ∪ E n ? Aim : unification of patterns modulo ✛ ✘ β , η ✚ ✙ ✛ ✘ E 1 . . . E i . . . E n ✚ ✙ Naive approach Counter-Example (Qian & Wang) with E = AC (+) : λxy · F ( x, y ) = λxy · F ( y, x ) has the solutions ∀ n ∈ N σ n = { F �→ λxy · G ( H 1 ( x, y ) + H 1 ( y, x ) , . . . , H n ( x, y ) + H n ( y, x )) } 6

  7. How to split when E = E 1 ∪ . . . ∪ E n ? Aim : unification of patterns modulo ✛ ✘ β , η ✚ ✙ ✛ ✘ E 1 . . . E i . . . E n ✚ ✙ Naive approach Counter-Example (Qian & Wang) with E = AC (+) : λxy · F ( x, y ) = λxy · F ( y, x ) has the solutions ∀ n ∈ N σ n = { F �→ λxy · G ( H 1 ( x, y ) + H 1 ( y, x ) , . . . , H n ( x, y ) + H n ( y, x )) } 7

  8. How to split when E = E 1 ∪ . . . ∪ E n ? Aim : unification of patterns modulo ✛ ✘ β , η ✚ ✙ ✛ ✘ E 1 . . . E i . . . E n ✚ ✙ Naive approach Counter-Example (Qian & Wang) with E = AC (+) : λxy · F ( x, y ) = λxy · F ( y, x ) has the solutions ∀ n ∈ N σ n = { F �→ λxy · G ( H 1 ( x, y ) + H 1 ( y, x ) , . . . , H n ( x, y ) + H n ( y, x )) } 8

  9. How to split when E = E 1 ∪ . . . ∪ E n ? Aim : unification of patterns modulo ✛ ✘ β , η ✟ ❍ ✟✟✟✟✟✟✟✟✟✟✟ ❍ ❍ ❍ ❍ ✟ ❍ ✟✟✟✟✟✟✟✟✟✟✟✟✟ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ E 1 . . . E i . . . E n ❍ ❍ ✚ ✙ ❍ ❍ ❍ Realistic approach practice, ∅ , AC, ACU, ACUN, AG Counter-Example (Qian & Wang) with E = AC (+) : λxy · F ( x, y ) = λxy · F ( y, x ) has the solutions ∀ n ∈ N σ n = { F �→ λxy · G ( H 1 ( x, y ) + H 1 ( y, x ) , . . . , H n ( x, y ) + H n ( y, x )) } 9 Algorithms for patterns unification modulo the E i s are assumed to be given. In

  10. How to split when E = E 1 ∪ . . . ∪ E n ? Aim : unification of patterns modulo ✛ ✘ β , η ✟ ❍ ✟✟✟✟✟✟✟✟✟✟✟ ❍ ❍ ❍ ❍ ✟ ❍ ✟✟✟✟✟✟✟✟✟✟✟✟✟ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ ❍ E 1 . . . E i . . . E n ❍ ❍ ✚ ✙ ❍ ❍ ❍ Realistic approach Counter-Example (Qian & Wang) with E = AC (+) : Algorithms for patterns unification modulo the E i s are assumed to be given. λxy · F ( x, y ) = λxy · F ( y, x ) has the solutions In practice, ∅ , AC, ACU, ACUN, AG ∀ n ∈ N σ n = { F �→ λxy · G ( H 1 ( x, y ) + H 1 ( y, x ) , . . . , H n ( x, y ) + H n ( y, x )) } 10

  11. Splitting the unification problem Definition Theory of f , algebraic symbol, or of x , bound variable Th ( f ) = E i , E i such that f ∈ F i Th ( x ) = E ∅ Alien subterm u in t [ u ] p : u argument of f and Th ( f ) � = Th ( head ( u )) . VA → ∃ H λx. t [ H ( y )] p = λx. s ∧ λy. H ( y ) = λy. u λx. t [ u ] p = λx. s if u is an alien subterm of t [ u ] p , y = FV ( u ) ∩ x , and H new variable. Split ∃ F λx. F ( x ) = λx.γ ( s ) ∧ λx.γ ( s ) = λx.δ ( t ) → λx. F ( x ) = λx.δ ( t ) if γ and δ not free variables, Th ( γ ) � = Th ( δ ) , and F new variable. 11

  12. Split unification problem A unification problem in NF wrt VA and Split : P ≡ P F ∧ P 0 ∧ P 1 ∧ · · · ∧ P n • P F contains all the Flex-Flex equations λx.F ( x ) = λx.F ( x π ) . • P 0 is pure in E 0 , with no λx.F ( x ) = λx.F ( x π ) . • P 1 is a pure unification problem in E 1 . • P n is a pure unification problem in E n . Notation λx.F ( x π ) : λx 1 . . . λx n .F ( x π (1) ,. . .,x π ( n ) ) , where π is a permutation over { 1 ,. . .,n } . 12

  13. A combination algorithm through don’t know non-determinism Guess the actual arguments of a variable Definition Constant preserving substitution: σ = { F �→ λx.s } , λx.s in NF and every x i of x has a free occurrence in s . Projection: σ = { F �→ λx.F ′ ( y ) | { y } ⊆ { x }} Lemma σ a substitution, then σ � η β = ( πθ ) � η β with π projection and θ constant- preserving substitution. → ∃ F ′ F = λx.F ′ ( y ) ∧ P { F �→ λx.F ′ ( y ) } Project P where F ′ is a new variable and { y } ⊂ { x } 13

  14. A combination algorithm through don’t know non-determinism Guess the flex-flex equations → F = λx.G ( x π ) ∧ P { F �→ λx.G ( x π ) } FF � = P where π is a permutation, types of F and G π are compatible, F � = G and F and G occur in P . Guess the permutations over the arguments → λx.F ( x )= λx.F ( x π ) ∧ P FF = P where F is a free variable of P , types of F and F π are compatible. 14

  15. A combination algorithm through don’t know non-determinism Find a representative for each variable Apply as long as possible Coalesce λx.F ( y )= λx.G ( z ) ∧ P → F = λy.G ( z ) ∧ P { F �→ λy.G ( z ) } if F � = G and F, G ∈ FV ( P ) , where y is a permutation of z . Guess the theory of the representatives Guess an ordering on representatives 15

  16. Dealing with λx.F ( x ) = λx.F ( x π ) by freezing Example (Qian & Wang) E = AC (+) : λxy · F ( x, y ) = λxy · F ( y, x ) has the solutions σ n = { F �→ λxy · G ( H 1 ( x, y )+ H 1 ( y, x ) , . . . , H n ( x, y )+ H n ( y, x )) } for all n ∈ N . In addition σ n +1 is strictly more general than σ n (nullary theory). 16

  17. Solving the pure problems, compatiblity with frozen equations Definition Solve rule for E i : algorithm input: P i , pure problem in E i and P F frozen equations output: P ′ and P ′ iF such that i 1. P ′ i ≡ σ E i , is a solved form without flex-flex equations. 2. P ′ iF is equal to P F plus some additonnal λx.F ( x )= λx.F ( x π ) . 3. F instantiated by σ E i only if E i is the chosen theory of F 4. the value of F may contain G only if F < oc G , for the chosen ordering 5. for all the equations s = t of P i and P F , sσ E i and tσ E i can be proven E i -equal (by using the equations in P ′ iF ). 17

  18. Example: AC(+) Input : λxy.F ( x, y ) + G ( x, y ) = λxy. 2 H ( x, y ) ∧ λxy.H ( x, y ) = λxy.H ( y, x ) Output : F = λxy.F ′ ( x, y ) + 2 F ′′ ( x, y ) G = λxy.F ′ ( x, y ) + 2 F ′′ ( y, x ) ∧ λxy.F ′ ( x, y ) = λxy.F ′ ( y, x ) H = λxy.F ′ ( x, y ) + F ′′ ( x, y ) + F ′′ ( y, x ) In order to prove that λxy.Hσ ( x, y ) = AC λxy.Hσ ( y, x ) , that is λxy.F ′ ( x, y ) + F ′′ ( x, y ) + F ′′ ( y, x ) = AC λxy.F ′ ( y, x ) + F ′′ ( y, x ) + F ′′ ( x, y ) , we need λxy.F ′ ( x, y ) = λxy.F ′ ( y, x ) . 18

  19. Solving the pure problems, compatiblity with frozen equations Proposition s = t a pure equation in E i , and σ such that sσ = E tσ . Then there exists P perm = { λx π .F ( x )= λx ϕ .F ( x ) } , σ E i and θ such that • σ = E σ E i θ . • σ E i pure in E i , • θ E -solution of P perm . • for all pure equations s ′ = t ′ (in particular s = t ) such that s ′ σ = E t ′ σ , s ′ σ E i and t ′ σ E i can be proven E i -equal (using the equations of P perm ). 19

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