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
Outline Datatypes in HOL—State of the Art Bounded Natural Functors (Co)datatypes (Co)nclusion
From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list )
From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β
From user specifications to (co)datatypes Given datatype α list = Nil | Cons α ( α list ) 1. Abstract to β = unit + α × β 2. Prove that ( α, β ) F = unit + α × β is a BNF
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
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 )
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 → β
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)
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
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)
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)
Induction β = ( α, β ) F ◮ Given ϕ : α IF → bool
Induction β = ( α, β ) F ◮ Given ϕ : α IF → bool ◮ Abstract induction principle ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x . ϕ x
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
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
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
Induction & Coinduction β = ( α, β ) F ◮ Given ϕ : α IF → bool ◮ Given ψ : α JF → α JF → bool ◮ Abstract induction principle ∀ z . ( ∀ x ∈ Fset 2 z . ϕ x ) ⇒ ϕ ( fld z ) ∀ x . ϕ x
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
Example codatatype α tree = Node ( lab : α ) ( sub : α tree fset )
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 )
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 )
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+
Outline Datatypes in HOL—State of the Art Bounded Natural Functors (Co)datatypes (Co)nclusion
Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving
Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL
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
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
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
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
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!
Foundational, Compositional (Co)datatypes for Higher-Order Logic Category Theory Applied to Theorem Proving Dmitriy Traytel Andrei Popescu Jasmin Blanchette Isabelle β = unit + α × β ∀ = α λ β →
Outline Backup slides
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
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
Type constructors are bounded Fbd: infinite cardinal ( α, β ) F a 1 a 2 b Fset 1 Fset 2 a 1 a 2 b β set α set
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
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
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 | ≤
Algebras, Coalgebras & Morphisms β = ( α, β ) F ( α, A ) F s A
Algebras, Coalgebras & Morphisms β = ( α, β ) F ( α, A ) F s A Fmap id f ( α, A ) F ( α, B ) F s A s B f A B
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
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
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
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
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 )
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 )
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 )
Recommend
More recommend