foundational compositional co datatypes for higher order
play

Foundational, Compositional (Co)datatypes for Higher-Order Logic - PowerPoint PPT Presentation

Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving Dmitriy Traytel Andrei Popescu Jasmin Blanchette Isabelle = unit + = Outline Datatypes in


  1. What are bounded natural functors good for? BNFs ... ◮ cover basic type constructors (e.g. + , × , unit, and α → β for fixed α ) ◮ cover non-free type constructors (e.g. fset , cset) ◮ are closed under composition ◮ admit initial algebras (datatypes) ◮ admit final coalgebras (codatatypes) ◮ are closed under initial algebras and final coalgebras ◮ make initial algebras and final coalgebras expressible in HOL

  2. Outline Datatypes in HOL—State of the Art Bounded Natural Functors (Co)datatypes (Co)nclusion

  3. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list )

  4. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β

  5. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF

  6. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-algebras

  7. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-algebras 4. Construct initial algebra ( α list , fld : unit + α × α list → α list )

  8. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-algebras 4. Construct initial algebra ( α list , fld : unit + α × α list → α list ) 5. Define iterator iter : ( unit + α × α list → β ) → α list → β

  9. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-algebras 4. Construct initial algebra ( α list , fld : unit + α × α list → α list ) 5. Define iterator iter : ( unit + α × α list → β ) → α list → β 6. Prove characteristic theorems (e.g. induction)

  10. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-algebras 4. Construct initial algebra ( α list , fld : unit + α × α list → α list ) 5. Define iterator iter : ( unit + α × α list → β ) → α list → β 6. Prove characteristic theorems (e.g. induction) 7. Prove that list is a BNF

  11. From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-algebras 4. Construct initial algebra ( α list , fld : unit + α × α list → α list ) 5. Define iterator iter : ( unit + α × α list → β ) → α list → β 6. Prove characteristic theorems (e.g. induction) 7. Prove that list is a BNF (enables nested recursion)

  12. From user specifications to (co)datatypes Given codatatype α llist = LNil | LCons α ( α llist ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF 3. Define F-coalgebras 4. Construct final coalgebra ( α llist , unf : α llist → unit + α × α llist ) 5. Define coiterator coiter : ( β → unit + α × α llist ) → β → α llist 6. Prove characteristic theorems (e.g. coinduction) 7. Prove that llist is a BNF (enables nested corecursion)

  13. Induction β = ( α, β ) F ◮ Given ϕ : α IF → bool

  14. Induction β = ( α, β ) F ◮ Given ϕ : α IF → bool ◮ Abstract induction principle ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x . ϕ x

  15. Induction β = unit + α × β ◮ Given ϕ : α list → bool ◮ Given ϕ : α IF → bool ◮ Abstract induction principle ◮ Case distinction on z ( ∀ ys ∈ / 0 . ϕ ys ) ⇒ ϕ ( fld ( Inl ())) ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x xs . ( ∀ ys ∈ { xs } . ϕ ys ) ⇒ ϕ ( fld ( Inr ( x , xs ))) ∀ x . ϕ x ∀ xs . ϕ xs

  16. Induction β = unit + α × β ◮ Given ϕ : α list → bool ◮ Given ϕ : α IF → bool ◮ Abstract induction principle ◮ Concrete induction principle ϕ ( fld ( Inl ())) ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x xs . ⇒ ϕ ( fld ( Inr ( x , xs ))) ϕ xs ∀ x . ϕ x ∀ xs . ϕ xs

  17. Induction β = unit + α × β ◮ Given ϕ : α list → bool ◮ Given ϕ : α IF → bool ◮ Abstract induction principle ◮ In constructor notation ϕ Nil ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x xs . ⇒ ϕ ( Cons x xs ) ϕ xs ∀ x . ϕ x ∀ xs . ϕ xs

  18. Induction & Coinduction β = ( α, β ) F ◮ Given ϕ : α IF → bool ◮ Given ψ : α JF → α JF → bool ◮ Abstract induction principle ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x . ϕ x

  19. Induction & Coinduction β = ( α, β ) F ◮ Given ϕ : α IF → bool ◮ Given ψ : α JF → α JF → bool ◮ Abstract induction principle ◮ Abstract coinduction principle ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x y . ψ x y ⇒ Fpred Eq ψ ( unf x ) ( unf y ) ∀ x . ϕ x ∀ x y . ψ x y ⇒ x = y

  20. Example codatatype α tree = Node ( lab : α ) ( sub : α tree fset )

  21. Example codatatype α tree = Node ( lab : α ) ( sub : α tree fset ) corec tmap : ( α → β ) → α tree → β tree where lab ( tmap f t ) = f ( lab t ) sub ( tmap f t ) = image ( tmap f ) ( sub t )

  22. Example codatatype α tree = Node ( lab : α ) ( sub : α tree fset ) corec tmap : ( α → β ) → α tree → β tree where lab ( tmap f t ) = f ( lab t ) sub ( tmap f t ) = image ( tmap f ) ( sub t ) lemma tmap ( f ◦ g ) t = tmap f ( tmap g t )

  23. Example codatatype α tree = Node ( lab : α ) ( sub : α tree fset ) corec tmap : ( α → β ) → α tree → β tree where lab ( tmap f t ) = f ( lab t ) sub ( tmap f t ) = image ( tmap f ) ( sub t ) lemma tmap ( f ◦ g ) t = tmap f ( tmap g t ) by ( intro tree_coinduct [ where ψ = λ t 1 t 2 . ∃ t . t 1 = tmap ( f ◦ g ) t ∧ t 2 = tmap f ( tmap g t )]) force+

  24. Outline Datatypes in HOL—State of the Art Bounded Natural Functors (Co)datatypes (Co)nclusion

  25. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving

  26. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL

  27. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL ◮ Characteristic theorems are derived, not stated as axioms

  28. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL ◮ Characteristic theorems are derived, not stated as axioms ◮ Mutual and nested combinations of (co)datatypes and custom BNFs

  29. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL ◮ Characteristic theorems are derived, not stated as axioms ◮ Mutual and nested combinations of (co)datatypes and custom BNFs ◮ Adapt insights from category theory to HOL ’s restrictive type system

  30. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL ◮ Characteristic theorems are derived, not stated as axioms ◮ Mutual and nested combinations of (co)datatypes and custom BNFs ◮ Adapt insights from category theory to HOL ’s restrictive type system ◮ Formalized & implemented in Isabelle/HOL

  31. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL ◮ Characteristic theorems are derived, not stated as axioms ◮ Mutual and nested combinations of (co)datatypes and custom BNFs ◮ Adapt insights from category theory to HOL ’s restrictive type system ◮ Formalized & implemented in Isabelle/HOL Thank you for your attention!

  32. Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving Dmitriy Traytel Andrei Popescu Jasmin Blanchette Isabelle β = unit + α × β ∀ = α λ β →

  33. Outline Backup slides

  34. Type constructors act on sets ( A 1 , A 2 ) F = { z | Fset 1 z ⊆ A 1 ∧ Fset 2 z ⊆ A 2 } A 1 : α set A 2 : β set a 1 a 2 b Action of F a 2 a 1 b a 1 a 2 b ( A 1 , A 2 ) F : ( α, β ) F set

  35. Type constructors act on sets ( A 1 , A 2 ) F = { z | Fset 1 z ⊆ A 1 ∧ Fset 2 z ⊆ A 2 } A 1 : α set A 2 : β set a 1 a 2 b Action of F a 2 a 1 b a 1 a 2 b ( A 1 , A 2 ) F : ( α, β ) F set ( ∀ i ∈ { 1 , 2 } . ∀ x ∈ Fset i z . f i x = g i x ) ⇒ Fmap f 1 f 2 z = Fmap g 1 g 2 z

  36. Type constructors are bounded Fbd: infinite cardinal ( α, β ) F a 1 a 2 b Fset 1 Fset 2 a 1 a 2 b β set α set

  37. Type constructors are bounded Fbd: infinite cardinal ( α, β ) F a 1 a 2 b Fset 1 Fset 2 a 1 a 2 b β set α set | Fset i z | ≤ Fbd

  38. Type constructors are bounded Fbd: infinite cardinal ( α, β ) F A 1 : α set A 2 : β set a 1 a 2 a 1 a 2 b b Action of F Fset 1 Fset 2 a 1 a 2 a 2 b a 1 b a 1 a 2 b β set α set ( A 1 , A 2 ) F : ( α, β ) F set | Fset i z | ≤ Fbd

  39. Type constructors are bounded Fbd: infinite cardinal ( α, β ) F A 1 : α set A 2 : β set a 1 a 2 a 1 a 2 b b Action of F Fset 1 Fset 2 a 1 a 2 a 2 b a 1 b a 1 a 2 b β set α set ( A 1 , A 2 ) F : ( α, β ) F set | Fset i z | ≤ Fbd ( | A 1 | + | A 2 | + 2 ) Fbd | ( A 1 , A 2 ) F | ≤

  40. Algebras, Coalgebras & Morphisms β = ( α, β ) F ( α, A ) F s A

  41. Algebras, Coalgebras & Morphisms β = ( α, β ) F ( α, A ) F s A Fmap id f ( α, A ) F ( α, B ) F s A s B f A B

  42. Algebras, Coalgebras & Morphisms β = ( α, β ) F ( α, A ) F A s s ( α, A ) F A Fmap id f ( α, A ) F ( α, B ) F s A s B f A B

  43. Algebras, Coalgebras & Morphisms β = ( α, β ) F ( α, A ) F A s s ( α, A ) F A Fmap id f f ( α, A ) F ( α, B ) F A B s A s B s A s B Fmap id f f ( α, A ) F ( α, B ) F A B

  44. Initial Algebras & Final Coalgebras β = ( α, β ) F weakly initial: exists morphism to any other algebra initial: exists unique morphism to any other algebra weakly final: exists morphism from any other coalgebra final: exists unique morphism from any other coalgebra

  45. Initial Algebras & Final Coalgebras β = ( α, β ) F weakly initial: exists morphism to any other algebra initial: exists unique morphism to any other algebra weakly final: exists morphism from any other coalgebra final: exists unique morphism from any other coalgebra ◮ Product of all algebras is weakly initial ◮ Suffices to consider algebras over types of certain cardinality ◮ Minimal subalgebra of weakly initial algebra is initial

  46. Initial Algebras & Final Coalgebras β = ( α, β ) F weakly initial: exists morphism to any other algebra initial: exists unique morphism to any other algebra weakly final: exists morphism from any other coalgebra final: exists unique morphism from any other coalgebra ◮ Product of all algebras is weakly initial ◮ Suffices to consider algebras over types of certain cardinality ◮ Minimal subalgebra of weakly initial algebra is initial ◮ Construct minimal subalgebra from below by transfinite recursion ⇒ Have a bound for its cardinality ⇒ ( α IF , fld : ( α, α IF ) F → α IF )

  47. Initial Algebras & Final Coalgebras β = ( α, β ) F weakly initial: exists morphism to any other algebra initial: exists unique morphism to any other algebra weakly final: exists morphism from any other coalgebra final: exists unique morphism from any other coalgebra ◮ Product of all algebras is weakly initial ◮ Sum of all coalgebras is weakly final ◮ Suffices to consider algebras over types ◮ Suffices to consider coalgebras over of certain cardinality types of certain cardinality ◮ Minimal subalgebra of weakly initial ◮ Quotient of weakly final coalgebra to the algebra is initial greatest bisimulation is final ◮ Construct minimal subalgebra from below by transfinite recursion ⇒ Have a bound for its cardinality ⇒ ( α IF , fld : ( α, α IF ) F → α IF )

  48. Initial Algebras & Final Coalgebras β = ( α, β ) F weakly initial: exists morphism to any other algebra initial: exists unique morphism to any other algebra weakly final: exists morphism from any other coalgebra final: exists unique morphism from any other coalgebra ◮ Product of all algebras is weakly initial ◮ Sum of all coalgebras is weakly final ◮ Suffices to consider algebras over types ◮ Suffices to consider coalgebras over of certain cardinality types of certain cardinality ◮ Minimal subalgebra of weakly initial ◮ Quotient of weakly final coalgebra to the algebra is initial greatest bisimulation is final ◮ Construct minimal subalgebra from ◮ Use concrete weakly final coalgebra below by transfinite recursion (elements are tree-like structures) ⇒ Have a bound for its cardinality ⇒ Have a bound for its cardinality ⇒ ( α IF , fld : ( α, α IF ) F → α IF ) ⇒ ( α JF , unf : α JF → ( α, α JF ) F )

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