quotients of bounded natural functors
play

Quotients of Bounded Natural Functors Basil Frer Andreas Lochbihler - PowerPoint PPT Presentation

Quotients of Bounded Natural Functors Basil Frer Andreas Lochbihler Joshua Schneider Dmitriy Traytel 1 Dramatis personae Isabelle HOL = Andreas Dmitriy Isabelle Isabelle Expert Working Formalizer Proof


  1. Quotients of Bounded Natural Functors Basil Fürer Andreas Lochbihler Joshua Schneider Dmitriy Traytel 1

  2. Dramatis personae Isabelle HOL ∀ = α λ β → Andreas Dmitriy Isabelle Isabelle Expert Working Formalizer Proof Assistant and Narrator The characters and incidents portrayed and the names used herein are fictitious and any re- semblance to the names, character, or history of any person is coincidental and unintentional. 2

  3. A formalization problem datatype a re = Atom a | Alt ( a re ) ( a re ) | Conc ( a re ) ( a re ) | Star ( a re ) 3

  4. A formalization problem datatype a re = Atom a | Alt ( a re ) ( a re ) | Conc ( a re ) ( a re ) | Star ( a re ) datatype ldl = Prop string | And ldl ldl | Neg ldl | Match ( ldl re ) 3

  5. A formalization problem datatype a re = Atom a | Alt ( a re ) ( a re ) | Conc ( a re ) ( a re ) | Star ( a re ) inductive ∼ ACI where Alt ( Alt r s ) t ∼ ACI Alt r ( Alt s t ) Alt r s ∼ ACI Alt s r Alt r r ∼ ACI r r ∼ ACI r’ s ∼ ACI s’ r ∼ ACI r’ s ∼ ACI s’ r ∼ ACI r’ Alt r s ∼ ACI Alt r’ s’ Conc r s ∼ ACI Conc r’ s’ Star r ∼ ACI Star r’ r ∼ ACI s r ∼ ACI s s ∼ ACI t r ∼ ACI r s ∼ ACI r r ∼ ACI t datatype ldl = Prop string | And ldl ldl | Neg ldl | Match ( ldl re ) 3

  6. A formalization problem datatype a re = Atom a | Alt ( a re ) ( a re ) | Conc ( a re ) ( a re ) | Star ( a re ) inductive ∼ ACI where Alt ( Alt r s ) t ∼ ACI Alt r ( Alt s t ) Alt r s ∼ ACI Alt s r Alt r r ∼ ACI r r ∼ ACI r’ s ∼ ACI s’ r ∼ ACI r’ s ∼ ACI s’ r ∼ ACI r’ Alt r s ∼ ACI Alt r’ s’ Conc r s ∼ ACI Conc r’ s’ Star r ∼ ACI Star r’ r ∼ ACI s r ∼ ACI s s ∼ ACI t r ∼ ACI r s ∼ ACI r r ∼ ACI t quotient_type a re ACI = a re / ∼ ACI datatype ldl = Prop string | And ldl ldl | Neg ldl | Match ( ldl re ACI ) 3

  7. A formalization problem datatype a re = Atom a | Alt ( a re ) ( a re ) | Conc ( a re ) ( a re ) | Star ( a re ) inductive ∼ ACI where Alt ( Alt r s ) t ∼ ACI Alt r ( Alt s t ) Unsupported recursive occurrence Alt r s ∼ ACI Alt s r Alt r r ∼ ACI r of type ldl via type constructor r ∼ ACI r’ s ∼ ACI s’ r ∼ ACI r’ s ∼ ACI s’ r ∼ ACI r’ re ACI in type expression ldl re ACI . Alt r s ∼ ACI Alt r’ s’ Conc r s ∼ ACI Conc r’ s’ Star r ∼ ACI Star r’ Use the bnf command to register r ∼ ACI s r ∼ ACI s s ∼ ACI t re ACI as a bounded natural functor r ∼ ACI r s ∼ ACI r r ∼ ACI t to allow nested (co)recursion through it. quotient_type a re ACI = a re / ∼ ACI datatype ldl = Prop string | And ldl ldl | Neg ldl | Match ( ldl re ACI ) 3

  8. Interlude: Contribution Identified sufficient conditions on when quotients of BNFs are BNFs Relevant for (co)datatypes, relational parametricity, refinement 4

  9. Interlude: Contribution Identified sufficient conditions on when quotients of BNFs are BNFs Relevant for (co)datatypes, relational parametricity, refinement Automated BNF preservation Isabelle HOL ∀ = proofs via lift_bnf command in α λ β → 4

  10. Datatype recursion worries Unsupported recursive occurrence of type ldl via type constructor re ACI in type expression ldl re ACI . Use the bnf command to register re ACI as a bounded natural functor to allow nested (co)recursion through it. 5

  11. Datatype recursion worries Unsupported recursive occurrence of type ldl via type constructor re ACI in type expression ldl re ACI . Use the bnf command to register re ACI as a bounded natural functor to allow nested (co)recursion through it. datatype bad = C ( bad set ) | ... C :: bad set ⇒ bad injective 5

  12. Datatype recursion worries Unsupported recursive occurrence of type ldl via type constructor re ACI in type expression ldl re ACI . Use the bnf command to register re ACI as a bounded natural functor to allow nested (co)recursion through it. Isabelle HOL datatype bad = C ( bad set ) | ... Datatypes may recurse ∀ = α only through BNFs C :: bad set ⇒ bad λ injective β → 5

  13. Bounded Natural Functors (BNF) A 1 3 2 F [1] [] [2,3] [3,3] [1,2,3] F ( A ) 6

  14. Bounded Natural Functors (BNF) A B 1 a 3 2 b F F [1] [] [] [a] [2,3] [3,3] [b,b] [a,b] [1,2,3] [a,b,b] F ( A ) F ( B ) 6

  15. Bounded Natural Functors (BNF) A B Functor map F id = id f map F g ◦ map F f = map F ( g ◦ f ) 1 a 3 2 b F F [1] [] [] [a] [2,3] [3,3] [b,b] [a,b] [1,2,3] [a,b,b] map F f F ( A ) F ( B ) 6

  16. Bounded Natural Functors (BNF) A B Functor map F id = id f map F g ◦ map F f = map F ( g ◦ f ) 1 a 3 2 b Bound | set F x | < ℵ set F F F [1] [] [] [a] [2,3] [3,3] [b,b] [a,b] [1,2,3] [a,b,b] map F f F ( A ) F ( B ) 6

  17. Bounded Natural Functors (BNF) A B Functor map F id = id f map F g ◦ map F f = map F ( g ◦ f ) 1 a 3 2 b Bound | set F x | < ℵ set F Natural F F set F ( map F f x ) = f 〈 set F x 〉 ∀x ∈ set F x . f x = g x [1] [] [] [a] map F f x = map F g x [2,3] [3,3] [b,b] [a,b] [1,2,3] [a,b,b] map F f F ( A ) F ( B ) 6

  18. Bounded Natural Functors (BNF) A B Functor map F id = id f map F g ◦ map F f = map F ( g ◦ f ) 1 a 3 2 b Bound | set F x | < ℵ � � F 〈 A 〉 F ( A ) = set F Natural F F set F ( map F f x ) = f 〈 set F x 〉 ∀x ∈ set F x . f x = g x [1] [] [] [a] map F f x = map F g x [2,3] [3,3] [b,b] [a,b] [1,2,3] [a,b,b] map F f F ( A ) F ( B ) 6

  19. Bounded Natural Functors (BNF) A B R Functor map F id = id f map F g ◦ map F f = map F ( g ◦ f ) 1 a 3 2 b Bound | set F x | < ℵ � � F 〈 A 〉 F ( A ) = set F Natural F F rel F R set F ( map F f x ) = f 〈 set F x 〉 ∀x ∈ set F x . f x = g x [1] [] [] [a] map F f x = map F g x [2,3] [3,3] [b,b] [a,b] Relator [1,2,3] [a,b,b] map F f ( x , y ) ∈ rel F R = ∃z ∈ F ( R ) . map F π 1 z = x ∧ map F π 2 z = y F ( A ) F ( B ) rel F R • rel F S = rel F ( R • S ) 6

  20. Closure properties of BNF Derived BNFs Basic BNFs _ × _ _ + _ τ ⇒ _ _ ⇒ τ _ set Non-BNFs 7

  21. Closure properties of BNF Derived BNFs Basic BNFs _ × _ _ + _ composition codatatypes unit + _ × _ τ ⇒ _ _ stream datatypes subtypes ∗ _ list _ balanced-tree _ ⇒ τ _ set ∗ Conditions apply. Non-BNFs 7

  22. Viewing re ACI as a subtype fun nf ACI :: a re ⇒ a re where ... lemma r ∼ ACI s ←→ nf ACI r = nf ACI s 〈 proof 〉 typedef a re ACI = { nf ACI r | r :: a re } by auto � �� � NF 8

  23. Viewing re ACI as a subtype fun nf ACI :: a re ⇒ a re where ... lemma r ∼ ACI s ←→ nf ACI r = nf ACI s 〈 proof 〉 typedef a re ACI = { nf ACI r | r :: a re } by auto � �� � NF lift_bnf a re ACI 1. s ∈ NF −→ map re f s ∈ NF 2. ... 8

  24. Viewing re ACI as a subtype fun nf ACI :: a re ⇒ a re where ... lemma r ∼ ACI s ←→ nf ACI r = nf ACI s 〈 proof 〉 typedef a re ACI = { nf ACI r | r :: a re } by auto � �� � NF unlikely for non-injective f lift_bnf a re ACI 1. s ∈ NF −→ map re f s ∈ NF 2. ... 8

  25. Viewing re ACI as a subtype fun nf ACI :: a re ⇒ a re where ... lemma r ∼ ACI s ←→ nf ACI r = nf ACI s 〈 proof 〉 typedef a re ACI = { nf ACI r | r :: a re } by auto � �� � NF unlikely for non-injective f lift_bnf a re ACI 1. s ∈ NF −→ map re f s ∈ NF 2. ... Quotients can be viewed as subtypes via representatives but we cannot lift the BNF structure along this view. 8

  26. Quotients of Polynomial Functors Data Types as Quotients of Polynomial Functors Jeremy Avigad Department of Philosophy, Carnegie Mellon University, Pittsburgh, PA, USA http://www.andrew.cmu.edu/user/avigad/ avigad@cmu.edu Mario Carneiro Department of Philosophy, Carnegie Mellon University, Pittsburgh, PA, USA di.gama@gmail.com Simon Hudon Department of Philosophy, Carnegie Mellon University, Pittsburgh, PA, USA https://www.cmu.edu/dietrich/philosophy/people/postdoc-fellows/simon-hudon%20.html simon.hudon@gmail.com Abstract A broad class of data types, including arbitrary nestings of inductive types, coinductive types, and quotients, can be represented as quotients of polynomial functors. This provides perspicuous ways of constructing them and reasoning about them in an interactive theorem prover. [1,2] [T,F] [2,1] [F,T] [] [] [1] [T] [2,3] [3,2] [T,T] F ( A ) F ( B ) 9

  27. Quotients of Polynomial Functors Data Types as Quotients of Polynomial Functors Jeremy Avigad Department of Philosophy, Carnegie Mellon University, Pittsburgh, PA, USA http://www.andrew.cmu.edu/user/avigad/ avigad@cmu.edu Mario Carneiro Department of Philosophy, Carnegie Mellon University, Pittsburgh, PA, USA di.gama@gmail.com Simon Hudon Department of Philosophy, Carnegie Mellon University, Pittsburgh, PA, USA https://www.cmu.edu/dietrich/philosophy/people/postdoc-fellows/simon-hudon%20.html simon.hudon@gmail.com Abstract A broad class of data types, including arbitrary nestings of inductive types, coinductive types, and quotients, can be represented as quotients of polynomial functors. This provides perspicuous ways of constructing them and reasoning about them in an interactive theorem prover. ∼ [1,2] [T,F] [2,1] [F,T] ∼ [] [] [1] [T] [2,3] [3,2] [T,T] F ( A ) / ∼ F ( B ) / ∼ 9

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