lifting proof relevant unification to higher dimensions
play

Lifting proof-relevant unification to higher dimensions Jesper - PowerPoint PPT Presentation

Lifting proof-relevant unification to higher dimensions Jesper Cockx Dominique Devriese 17 January 2017 The rewrite tactic: day one k : N n : N p : P k e : k N n ? : P n 1 / 22 The rewrite tactic: day one k : N k : N n : N n : N rewrite e


  1. Lifting proof-relevant unification to higher dimensions Jesper Cockx Dominique Devriese 17 January 2017

  2. The rewrite tactic: day one k : N n : N p : P k e : k ≡ N n ? : P n 1 / 22

  3. The rewrite tactic: day one k : N k : N n : N n : N rewrite e p : P k p : P n = = = = ⇒ e : k ≡ N n e : k ≡ N n ? : P n ? : P n 1 / 22

  4. The unify tactic: day one k : N n : N n : N unify e p : P k p : P n = = = ⇒ e : k ≡ N n ? : P n ? : P n 2 / 22

  5. The rewrite tactic: day two k : N n : N p : P k e : suc k ≡ N suc n ? : P n 3 / 22

  6. The rewrite tactic: day two k : N k : N n : N n : N rewrite e p : P k p : P k = = = = ⇒ e : suc k ≡ N suc n e : suc k ≡ N suc n ? : P n ? : P n 3 / 22

  7. The unify tactic: day two k : N n : N n : N unify e p : P k p : P n = = = ⇒ e : suc k ≡ N suc n ? : P n ? : P n 4 / 22

  8. The rewrite tactic: day three k : N n : N xs : Vec A ( suc k ) p : P k xs e : suc k ≡ N suc n ? : P n ( subst ( Vec A ) e xs ) 5 / 22

  9. The rewrite tactic: day three k : N n : N xs : Vec A ( suc k ) ⇒ error rewrite e = = = = p : P k xs e : suc k ≡ N suc n ? : P n ( subst ( Vec A ) e xs ) 5 / 22

  10. The unify tactic: day three k : N n : N n : N xs : Vec A ( suc k ) xs : Vec A ( suc n ) unify e = = = ⇒ p : P k xs p : P n xs e : suc k ≡ N suc n ? : P n xs ? : P n ( subst ( Vec A ) e xs ) 6 / 22

  11. Proof-relevant unification Unification of indexed data Lifting unifiers to higher dimensions

  12. Proof-relevant unification Unification of indexed data Lifting unifiers to higher dimensions

  13. Proof-relevant unification • Represent unification rules internally • Rules get a computational interpretation • Core of dependent pattern matching See Unifiers as Equivalences (ICFP ’16) 7 / 22

  14. Proof-relevant unification: example ( k n : N )( e : suc k ≡ N suc n ) 8 / 22

  15. Proof-relevant unification: example ( k n : N )( e : suc k ≡ N suc n ) ≃ ( k n : N )( e : k ≡ N n ) 8 / 22

  16. Proof-relevant unification: example ( k n : N )( e : suc k ≡ N suc n ) ≃ ( k n : N )( e : k ≡ N n ) ≃ ( k : N ) 8 / 22

  17. Proof-relevant unification: example ( k n : N )( e : suc k ≡ N suc n ) ≃ ( k n : N )( e : k ≡ N n ) ≃ ( k : N ) 8 / 22

  18. Unifiers as equivalences Goal: given some equations ¯ u ≡ ∆ ¯ v with free variables in Γ, find an equivalence f of type v ) ≃ Γ ′ Γ(¯ e : ¯ u ≡ ∆ ¯ 9 / 22

  19. Unification rules ( x : A )( e : x ≡ A t ) ≃ ⊤ (solution) ( suc x ≡ N suc y ) ≃ ( x ≡ N y ) (injectivity) ( left x ≡ A ⊎ B right y ) ≃ ⊥ (conflict) ( n ≡ N suc n ) ≃ ⊥ (cycle) 10 / 22

  20. Telescopic equality The type of an equation can depend on previous equations: ( u : Vec A k )( v : Vec A n ) ( e 1 : k ≡ N n )( e 2 : u ≡ Vec A e 1 v ) This allows us to keep track of dependencies between equations. 11 / 22

  21. Proof-relevant unification Unification of indexed data Lifting unifiers to higher dimensions

  22. Injectivity for indexed data Idea: simplify equations between indices together with equation between constructors: ( e 1 : i ≡ I j )( e 2 : c u ≡ D e 1 c v ) ≃ ( e : u ≡ A v ) 12 / 22

  23. Injectivity for indexed data Idea: simplify equations between indices together with equation between constructors: ( e 1 : i ≡ I j )( e 2 : c u ≡ D e 1 c v ) ≃ ( e : u ≡ A v ) Indices of D must be fully general : must be distinct equation variables. 12 / 22

  24. Injectivity for indexed data: example cons : ( n : N )( x : A )( xs : Vec A n ) → Vec A ( suc n ) 13 / 22

  25. Injectivity for indexed data: example cons : ( n : N )( x : A )( xs : Vec A n ) → Vec A ( suc n ) ( e 1 : suc k ≡ N suc n ) ( e 2 : cons k x xs ≡ Vec A e 1 cons n y ys ) 13 / 22

  26. Injectivity for indexed data: example cons : ( n : N )( x : A )( xs : Vec A n ) → Vec A ( suc n ) ( e 1 : suc k ≡ N suc n ) ( e 2 : cons k x xs ≡ Vec A e 1 cons n y ys ) ≃ ( e ′ 1 : k ≡ N n )( e ′ 2 : x ≡ A y ) ( e ′ 3 : xs ≡ Vec A e 1 ys ) 13 / 22

  27. Injectivity for indexed data: example cons : ( n : N )( x : A )( xs : Vec A n ) → Vec A ( suc n ) ( e 1 : suc k ≡ N suc n ) ( e 2 : cons k x xs ≡ Vec A e 1 cons n y ys ) ≃ ( e ′ 1 : k ≡ N n )( e ′ 2 : x ≡ A y ) ( e ′ 3 : xs ≡ Vec A e 1 ys ) 13 / 22

  28. What if the indices are not fully general? ( e : cons n x xs ≡ Vec A ( suc n ) cons n y ys ) ≃ ??? 14 / 22

  29. Solution: generalizing the indices ( e : cons n x xs ≡ Vec A ( suc n ) cons n y ys ) 15 / 22

  30. Solution: generalizing the indices ( e : cons n x xs ≡ Vec A ( suc n ) cons n y ys ) ≃ ( e 1 : suc n ≡ N suc n ) ( e 2 : cons n x xs ≡ Vec A e 1 cons n y ys ) ( p : e 1 ≡ suc n ≡ N suc n refl ) 15 / 22

  31. Solution: generalizing the indices ( e : cons n x xs ≡ Vec A ( suc n ) cons n y ys ) ≃ ( e 1 : suc n ≡ N suc n ) ( e 2 : cons n x xs ≡ Vec A e 1 cons n y ys ) ( p : e 1 ≡ suc n ≡ N suc n refl ) ≃ ( e ′ 1 : n ≡ N n )( e ′ 2 : x ≡ A y )( e ′ 3 : xs ≡ Vec A e ′ 1 ys ) ( p : cong suc e ′ 1 ≡ suc n ≡ N suc n refl ) 15 / 22

  32. Solution: generalizing the indices ( e : cons n x xs ≡ Vec A ( suc n ) cons n y ys ) ≃ ( e 1 : suc n ≡ N suc n ) ( e 2 : cons n x xs ≡ Vec A e 1 cons n y ys ) ( p : e 1 ≡ suc n ≡ N suc n refl ) ≃ ( e ′ 1 : n ≡ N n )( e ′ 2 : x ≡ A y )( e ′ 3 : xs ≡ Vec A e ′ 1 ys ) ( p : cong suc e ′ 1 ≡ suc n ≡ N suc n refl ) 15 / 22

  33. Higher-dimensional unification ( e ′ 1 : n ≡ N n )( e ′ 2 : x ≡ A y )( e ′ 3 : xs ≡ Vec A e ′ 1 ys ) ( p : cong suc e ′ 1 ≡ suc n ≡ N suc n refl ) Now we have to solve equations between equality proofs! 16 / 22

  34. Proof-relevant unification Unification of indexed data Lifting unifiers to higher dimensions

  35. How to solve higher-dimensional equations? Existing unification rules do not apply. . . 17 / 22

  36. How to solve higher-dimensional equations? Existing unification rules do not apply. . . We solve the problem in three steps: 1. lower the dimension of equations 2. solve lower-dimensional equations 3. lift unifier to higher dimension 17 / 22

  37. Step 1: lower the dimension of equations We replace all equation variables by regular variables: instead of ( e 1 : n ≡ N n )( e 2 : x ≡ A y )( e 3 : xs ≡ Vec A e 1 ys ) ( p : cong suc e 1 ≡ suc n ≡ N suc n refl ) let’s first consider ( k : N )( u : A )( us : Vec A k ) ( e : suc k ≡ N suc n ) 18 / 22

  38. Step 2: solve lower-dimensional equations This gives us an equivalence f of type ( k : N )( u : A )( us : Vec A k ) ( e : suc k ≡ N suc n ) ≃ ( u : A )( us : Vec A n ) 19 / 22

  39. Step 3: lift unifier to higher dimension We lift f to an equivalence f ↑ of type ( e 1 : n ≡ N n )( e 2 : x ≡ A y ) ( e 3 : xs ≡ Vec A e 1 ys ) ( p : cong suc e 1 ≡ suc n ≡ N suc n refl ) ≃ ( e 2 : x ≡ A y )( e 3 : xs ≡ Vec A n ys ) 20 / 22

  40. Lifting equivalences: (mostly) general case Theorem. If we have an equivalence f of type ( x : A )( e : b 1 x ≡ B x b 2 x ) ≃ C we can construct f ↑ of type ( e : u ≡ A v )( p : cong b 1 e ≡ r ≡ B e s cong b 2 e ) ≃ ( e ′ : f u r ≡ C f v s ) 21 / 22

  41. Conclusion Proof-relevant unification is useful to deal with many equality constraints. 22 / 22

  42. Conclusion Proof-relevant unification is useful to deal with many equality constraints. To make it work on indexed datatypes, we need to solve higher-dimensional equations . 22 / 22

  43. Conclusion Proof-relevant unification is useful to deal with many equality constraints. To make it work on indexed datatypes, we need to solve higher-dimensional equations . We can reuse existing unification rules by lifting them to higher dimensions. 22 / 22

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