ac unification of higher order patterns
play

AC-Unification of Higher-order Patterns Alexandre Boudet Evelyne - PDF document

CP97 1 AC-Unification of Higher-order Patterns Alexandre Boudet Evelyne Contejean LRI Orsay France Linz, Austria. Oct 30th, 1997 CP97 2 Motivations Higher-order unification is undecidable


  1. CP’97 1 ✬ ✩ AC-Unification of Higher-order Patterns Alexandre Boudet Evelyne Contejean LRI Orsay France ✫ ✪ Linz, Austria. Oct 30th, 1997

  2. CP’97 2 ✬ ✩ Motivations ∗ Higher-order unification is undecidable ∗ Unification of higher-order patterns is decidable ∗ Combination of algebraic and functional programming paradigms ∗ Local confluence of HRSs ⇓ Unification of higher-order patterns modulo equational theories ✫ ✪ Linz, Austria. Oct 30th, 1997

  3. CP’97 3 ✬ ✩ Patterns Definition A pattern is ∗ a term of the simply-typed λ -calculus in β -normal form ∗ in which the arguments of a free variable are η -equivalent to distinct bound variables.  λxyz.f ( H ( x, y ) , H ( x, z ))  are patterns λx.F ( λz.x ( z )) = η λx.F ( x )   λxy.G ( x, x, y )  are not patterns λxy.H ( F ( x ) , y )  No equational theory, but α, β, η . Theorem (Miller) The unifiability of patterns is decidable and if two patterns are unifiable, there is an algorithm com- puting a unique most general unifier. Notation λx.F ( x π ) denotes λx 1 . . . λx n .F ( x π (1) , . . . , x π ( n ) ), where π is a permutation over { 1 , . . . , n } . ✫ ✪ Linz, Austria. Oct 30th, 1997

  4. CP’97 4 ✬ ✩ AC-unification of Patterns Definition Let E = { l 1 ≃ r 1 , . . . , l n ≃ r n } a set of axioms such that l i and r i of the same type, for 1 ≤ i ≤ n . The equational theory = E is the least congruence (compatible also with application and abstraction) containing all the instances of the axioms of E . Definition An equation s = t is a pair of patterns of the same type.  − ⊤    A unification problem is − ⊥   − P ≡ s 1 = t 1 ∧ · · · ∧ s n = t n .  A substitution σ is an E -unifier of P if ∀ i , s i = βηE t i . ⇒ u � η β = E v � η Theorem (Tannen) ∀ u, v u = βηE v ⇐ β . We consider the case where E is � { x + y = y + x, x + ( y + z ) = ( x + y ) + z } + ∈ AC The type of + is α → α → α , where α is a base type. ✫ ✪ Linz, Austria. Oct 30th, 1997

  5. CP’97 5 ✬ ✩ Alien subterms and Purification Definition u = t | p · i is an alien subterm of t ∗ if t ( p ) ∈ AC and Head( u ) / ∈ FV , ∗ or t ( p ) ∈ FC and Head( u ) ∈ AC. VA → λ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 at position p , and y = FV ( u ) ∩ x , where H is a new variable. A unification problem in normal form wrt VA has the form P ≡ P F ∧ P 0 ∧ P 1 ∧ · · · ∧ P n ∗ P 0 is pure in the free theory, with no λx.F ( x ) = λx.F ( x π ). ∗ P F contains all the Flex-Flex equations λx.F ( x ) = λx.F ( x π ). ∗ P i is a pure unification problem in the AC theory of + i , the arguments of + i being of the form F ( x ) where F is a free variable. ✫ ✪ Linz, Austria. Oct 30th, 1997

  6. CP’97 6 ✬ ✩ Why Frozen Equations ? Example (Qian & Wang) λ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). ✫ ✪ Linz, Austria. Oct 30th, 1997

  7. CP’97 7 ✬ ✩ Free: a subset of Nipkow’s rules for pattern unification Dec-free λx.a ( s 1 , . . . , s n ) = λx.a ( t 1 , . . . , t n ) ∧ P 0 → λx.s 1 = λx.t 1 ∧ · · · ∧ λx.s n = λx.t n ∧ P 0 if a is a free constant symbol or a bound variable of x . FR-free λx.F ( y ) = λx.a ( s 1 , . . . , s m ) ∧ P 0 → λy.H 1 ( y ) = λy.s 1 ∧ · · · ∧ λy.H m ( y ) = λy.s m ∧ P 0 { F �→ λx.a ( H 1 ( y ) , . . . , H m ( y )) } ∧ F = λx.a ( H 1 ( y ) , . . . , H m ( y )) } If F is a free variable, a a free constant and F / ∈ FV ( s i ) for 1 ≤ i ≤ m , where H 1 , . . . , H m are new variables. FF � = λx.F ( y ) = λx.G ( z ) ∧ P 0 → P 0 { F �→ λy.H ( v ) , G �→ λz.H ( v ) } ∧ F = λy.H ( v ) ∧ G = λz.H ( v ) if F and G are different free variables where v = y ∩ z . Fail1 → ⊥ λx.a ( s ) = λx.b ( t ) if a and b are constants or bound variables and a � = b . Fail2 λx.F ( y ) = λx.a ( s ) → ⊥ if F is free in s or a ∈ x \ y . ✫ ✪ Linz, Austria. Oct 30th, 1997

  8. CP’97 8 ✬ ✩ Freeze P F ∧ ( λx.F ( x ) = λx.F ( x π ) ∧ P 0 ) ∧ P 1 ∧ · · · ∧ P n → ( λx.F ( x ) = λx.F ( x π ) ∧ P F ) ∧ P 0 ∧ P 1 ∧ · · · ∧ P n if F is a free variable. Normal Forms A unification problem (with no alien subterms) in normal form wrt ( Free + Freeze ) has the form P F ∧ P 0 ∧ P 1 ∧ · · · ∧ P n where ∗ P F contains only λx.F ( x ) = λx.F ( x π ), ∗ P 0 is solved, ∗ P i is a pure problem in the AC -theory of + i . ✫ ✪ Linz, Austria. Oct 30th, 1997

  9. CP’97 9 ✬ ✩ Pure AC Patterns: An Example From AC Problems to Diophantine Problems λxyz. 2 F ( x, y, z ) + F ( y, z, x ) = λxyz. 2 G ( x, y, z ) Let σ be a solution of the above equation: ∗ σ may introduce t ( x, y, z ) such that t ( x, y, z ) = t ( y, z, x ). λxyz. 2 F ( x, y, z )+ F ( y, z, x )= λxyz. 2 G ( x, y, z ) # of t 2 α + α = 2 β ( α, β ) is a positive solution of 3 n = 2 m . ∗ σ may introduce t ( x, y, z ) such that t ( x, y, z ) � = t ( y, z, x ). λxyz. 2 F ( x, y, z )+ F ( y, z, x )= λxyz. 2 G ( x, y, z ) # of t ( x, y, z ) 2 α 1 + α 3 = 2 β 1 # of t ( y, z, x ) 2 α 2 + α 1 = 2 β 2 # of t ( z, x, y ) 2 α 3 + α 2 = 2 β 3 ( α 1 , α 2 , α 3 , β 1 , β 2 , β 3 ) are positive solutions of the system 2 n 1 + n 3 = 2 m 1 2 n 2 + n 1 = 2 m 2 2 n 3 + n 2 = 2 m 3 ✫ ✪ Linz, Austria. Oct 30th, 1997

  10. CP’97 10 ✬ ✩ Pure AC Patterns: An Example (Continued) Recombination + Constraints The set of minimal solutions of 3 n = 2 m is { (2 , 3) } The set of minimal solutions of 2 n 1 + n 3 = 2 m 1 2 n 2 + n 1 = 2 m 2 2 n 3 + n 2 = 2 m 3 is { (2 , 0 , 0 , 2 , 1 , 0) , (0 , 2 , 0 , 0 , 2 , 1) , (0 , 0 , 2 , 1 , 0 , 2) } . F(x,y,z) G(x,y,z) L 1 2 3 L 2 2 0 0 2 1 0 L 3 0 2 0 0 2 1 L 4 0 0 2 1 0 2 (x,y,z) (y,z,x) (z,x,y) (x,y,z) (y,z,x) (z,x,y) ✫ ✪ Linz, Austria. Oct 30th, 1997

  11. CP’97 11 ✬ ✩ Pure AC Patterns: An Example (End) A solution of the original problem is { F �→ λxyz. 2 L 1 ( x, y, z ) θ + 2 L 2 ( x, y, z ) + 2 L 3 ( y, z, x ) + 2 L G �→ λxyz. 3 L 1 ( x, y, z ) θ + 2 L 2 ( x, y, z ) + L 2 ( y, z, x ) + 2 L 3 L 4 ( x, y, z ) + 2 L 4 ( z, x, y ) } provided that L 1 ( x, y, z ) θ = L 1 ( y, z, x ) θ = L 1 ( z, x, y ) θ . ✫ ✪ Linz, Austria. Oct 30th, 1997

  12. CP’97 12 ✬ ✩ Pure AC Patterns: Another Example λxyz.G ( x, y, z ) = λxyz.G ( y, z, x ) ∧ λxyz. 2 F ( x, y, z ) + F ( y, z, x ) = λxyz. 2 G ( x, y, z ) Let σ be a solution of the above problem: σ may introduce t ( x, y, z ) such that t ( x, y, z ) � = t ( y, z, x ). λxyz. 2 F ( x, y, z )+ F ( y, z, x )= λxyz. 2 G ( x, y, z ) # of t ( x, y, z ) 2 α 1 + α 3 = 2 β 1 # of t ( y, z, x ) 2 α 2 + α 1 = 2 β 2 # of t ( z, x, y ) 2 α 3 + α 2 = 2 β 3 λxyz.G ( x, y, z ) = λxyz.G ( x, y, z ) # of t ( x, y, z ) β 1 = β 3 # of t ( y, z, x ) β 2 = β 1 # of t ( z, x, y ) β 3 = β 2 ( α 1 , α 2 , α 3 , β 1 , β 2 , β 3 ) are positive solutions of the system 2 n 1 + n 3 = 2 m 1 2 n 2 + n 1 = 2 m 2 2 n 3 + n 2 = 2 m 3 m 1 = m 3 m 2 = m 1 m 3 = m 2 ✫ ✪ Linz, Austria. Oct 30th, 1997

  13. CP’97 13 ✬ ✩ Pure AC Patterns: Another Example (End) The set of minimal solutions of 3 n = 2 m is { (2 , 3) } The set of minimal solutions of P Dioph is { (2 , 2 , 2 , 3 , 3 , 3) } .  2 n 1 + n 3 = 2 m 1      2 n 2 + n 1 = 2 m 2      2 n 3 + n 2 = 2 m 3   P Dioph ≡ m 1 = m 3      m 2 = m 1      m 3 = m 2   F(x,y,z) G(x,y,z) L 1 2 3 L 2 2 2 2 3 3 3 (x,y,z) (y,z,x) (z,x,y) (x,y,z) (y,z,x) (z,x,y) A solution of the original problem is { F �→ λxyz. 2 L 1 ( x, y, z ) θ +2 L 2 ( x, y, z )+2 L 2 ( y, z, x )+2 L 2 ( z, x, y ) , G �→ λxyz. 3 L 1 ( x, y, z ) θ +3 L 2 ( x, y, z )+3 L 2 ( y, z, x )+3 L 2 ( z, x, y ) } provided that L 1 ( x, y, z ) θ = L 1 ( y, z, x ) θ = L 1 ( z, x, y ) θ . ✫ ✪ Linz, Austria. Oct 30th, 1997

  14. CP’97 14 ✬ ✩ Pure AC Patterns: General Case n 1 n 2 � � � � a i,π F i ( x π ) = λx · a i,π F i ( x π ) E ≡ λx · i =1 π ∈ Π i = n 1 +1 π ∈ Π Π is the group of permutations over all the variables of x . n 2 � � y i,π 1 = y i,π 2 ∧ i =1 E Π 0 ( π 1 ,π 2 ) | Π 0 ◦ π 1 =Π 0 ◦ π 2 Dioph ≡ n 1 n 2 � � � � � a i,π − 1 ◦ π ′ y i,π = a i,π − 1 ◦ π ′ y i,π π ′ ∈ Π i =1 π ∈ Π i = n 1 +1 π ∈ Π Π 0 subgroup of Π E Π 0 E Dioph is the disjunction � Dioph . Proposition Let P be any subset of the minimal solutions of P Dioph , which is great enough. Then σ P is a solution of E : � � � m ( i, π ′ ) L m ( x π ′ ) } σ P = { F i �→ λx. Π 0 m ∈P Π0 π ′ ∈ Π / Π 0 where L m , m ∈ P Π 0 is a new variable constrained by ∀ π ∈ Π 0 L m ( x π ) = L m ( x ). Proposition { σ P | P is great enough } is a complete set of solutions for P . ✫ ✪ Linz, Austria. Oct 30th, 1997

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