foundational extensible corecursion
play

Foundational Extensible Corecursion Jasmin Blanchette Andrei - PowerPoint PPT Presentation

Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel Am I Productive? s = 0 : s primitive corecusion s = 0 : s primitive


  1. Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel

  2. Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel

  3. Am I Productive?

  4. s = 0 : s primitive corecusion

  5. s = 0 : s primitive corecusion

  6. s = 0 : tail s tail evil

  7. s = 0 : tail s tail evil

  8. s = 0 : 1 : s corecursion up to constructors

  9. s = 0 : 1 : s corecursion up to constructors

  10. eo s = head s : eo (tail (tail s)) primitive corecusion

  11. eo s = head s : eo (tail (tail s)) primitive corecusion

  12. s = 0 : 1 : eo s eo evil

  13. s = 0 : 1 : eo s eo evil

  14. s ⊕ t = (head s + head t) : (tail s ⊕ tail t) primitive corecusion

  15. s ⊕ t = (head s + head t) : (tail s ⊕ tail t) primitive corecusion

  16. s ⊗ t = (head s * head t) : (tail s ⊗ t ⊕ s ⊗ tail t) corecursion up to ⊕

  17. s ⊗ t = (head s * head t) : (tail s ⊗ t ⊕ s ⊗ tail t) corecursion up to ⊕

  18. s = (0 : 1 : s) ⊕ (0 : s) corecursion up to constructors and ⊕

  19. s = (0 : 1 : s) ⊕ (0 : s) corecursion up to constructors and ⊕

  20. s n = if n > 0 then s (n - 1) ⊕ (0 : s (n + 1)) else 1 : s 1 mixed recursion/corecursion up to ⊕

  21. s n = if n > 0 then s (n - 1) ⊕ (0 : s (n + 1)) else 1 : s 1 mixed recursion/corecursion up to ⊕

  22. Contribution Foundational framework for defining all the green stuff and more

  23. Contribution Foundational framework for defining all the green stuff and more   in an LCF-style proof assistant  

  24. Contribution Foundational framework for defining all the green stuff and more   in an LCF-style proof assistant    parametricity    Burden on the user : prove  here and there or termination 

  25. Contribution Foundational framework for defining all the green stuff and more   in an LCF-style proof assistant    parametricity    Burden on the user : prove  here and there or termination  Most of the time: automatic

  26. Context LCF Philosophy: Reduce everything to a small trusted kernel  simply typed lambda calculus +     classical higher-order logic (axioms) +  ≈ Kernel of nonrecursive constant definition +     nonrecursive type definition 

  27. Context LCF Philosophy: Reduce everything to a small trusted kernel  simply typed lambda calculus +     classical higher-order logic (axioms) +  ≈ Kernel of nonrecursive constant definition +     nonrecursive type definition  Our agenda make Isabelle/HOL a (co)recursion-friendly environment LICS’12 ITP’14 IJCAR’14 ESOP’15 ICFP’15

  28. Related Work A lot

  29. Related Work Guarded Coprogramming/Proof Assistants Isabelle primitive corecursion corecursor

  30. Related Work Guarded Coprogramming/Proof Assistants Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in

  31. Related Work Guarded Coprogramming/Proof Assistants Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in Agda copatterns + sized types built-in + type system

  32. Related Work Guarded Coprogramming/Proof Assistants Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in Agda copatterns + sized types built-in + type system - FRP (Krishnaswami & Benton, ... ) type system - clocks (Atkey & McBride) type system - guards (Clouston et al.) type system

  33. Related Work Guarded Coprogramming/Proof Assistants Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in Agda copatterns + sized types built-in + type system - FRP (Krishnaswami & Benton, ... ) type system - clocks (Atkey & McBride) type system - guards (Clouston et al.) type system Isabelle’ corecursion up-to friendly operations smart corecursor mixed with recursion + wellfounded recursion

  34. Primitive Corecursor codatatype Stream = Int : Stream

  35. Primitive Corecursor codatatype Stream = Int : Stream – Stream ˜ = gfp ( Int ×− ) – corec P :: ( A → Int × A ) → A → Stream

  36. Primitive Corecursor codatatype Stream = Int : Stream – Stream ˜ = gfp ( Int ×− ) – corec P :: ( A → Int × A ) → A → Stream primcorec s ⊕ t = ( head s + head t ) : ( tail s ⊕ tail t )

  37. Primitive Corecursor codatatype Stream = Int : Stream – Stream ˜ = gfp ( Int ×− ) – corec P :: ( A → Int × A ) → A → Stream primcorec s ⊕ t = ( head s + head t ) : ( tail s ⊕ tail t ) – s ⊕ t = corec P ( λ ( s , t ) . (( head s + head t ) , ( tail s , tail t )) ) ( s , t )

  38. Primitive Corecursor codatatype C = ··· – C ˜ = gfp F – corec P :: ( A → F A ) → A → C primcorec f x = ··· – f x = corec P ( λ ( x ) . ··· ) ( x ) (Assuming F is a bounded natural functor)

  39. Smart Corecursor corec P :: ( A → F A ) → A → C

  40. Smart Corecursor corec P :: ( A → F A ) → A → C corec S 0 :: ( A → ( F ( A ))) → A → C

  41. Smart Corecursor corec P :: ( A → F A ) → A → C corec S 0 :: ( A → ( F ( A ))) → A → C corec S 1 :: ( A → ⊕ ( F ( ⊕ A ))) → A → C

  42. Smart Corecursor corec P :: ( A → F A ) → A → C corec S 0 :: ( A → ( F ( A ))) → A → C corec S 1 :: ( A → ⊕ ( F ( ⊕ A ))) → A → C corec s ⊗ t = ( head s ∗ head t ) : ( tail s ⊗ t ⊕ s ⊗ tail t ) – s ⊗ t = corec S 1 ( λ ( s , t ) . η (( head s ∗ head t ) , η ( tail s , t ) ⊕ η ( s , tail t )) ) ( s , t ) – ⊕ :: ⊕ A → ⊕ A → ⊕ A – η :: A → ⊕ A

  43. Smart Corecursor corec P :: ( A → F A ) → A → C corec S 0 :: ( A → ( F ( A ))) → A → C corec S 1 :: ( A → ⊕ ( F ( ⊕ A ))) → A → C corec S 2 :: ( A → ⊕ ⊗ ( F ( ⊕ ⊗ A ))) → A → C corec s ⊗ t = ( head s ∗ head t ) : ( tail s ⊗ t ⊕ s ⊗ tail t ) – s ⊗ t = corec S 1 ( λ ( s , t ) . η (( head s ∗ head t ) , η ( tail s , t ) ⊕ η ( s , tail t )) ) ( s , t ) – ⊕ :: ⊕ A → ⊕ A → ⊕ A – η :: A → ⊕ A

  44. ⊗ :: C → C → C has to be friendly A friendly function can destroy one constructor to produce at least one constructor.

  45. ⊗ :: C → C → C has to be friendly ∃ parametric ρ ⊗ :: ( A × F A ) → ( A × F A ) → F ( ⊕ ⊗ A ) s.t. s ⊗ t = ··· ( ρ ⊗ ( ··· ( s , t )))

  46. ⊗ :: C → C → C has to be friendly ∃ parametric ρ ⊗ :: ( A × F A ) → ( A × F A ) → F ( ⊕ ⊗ A ) s.t. s ⊗ t = ··· ( ρ ⊗ ( ··· ( s , t ))) ρ ⊗ :: ( A × ( Int × A )) → ( A × ( Int × A )) → ( Int × ⊕ ⊗ A ) ρ ⊗ ( s , hs , ts ) ( t , ht , tt ) = ( hs ∗ ht , η ts ⊗ η t ⊕ η s ⊗ η tt )

  47. In the paper

  48. In the paper

  49. In the paper

  50. In the paper In the meantime

  51. In the paper In the meantime constructor + Coq constructor + · arbitrary (manual proofs) Agda friendly ∗ · constructor · friendly ∗ (auto proofs) Isabelle Thanksforlistening! Questions?

  52. Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel What is s 1 ? s n = if n > 0 then s (n - 1) ⊕ (0 : s (n + 1)) else 1 : s 1

Recommend


More recommend