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

foundational compositional co datatypes for higher order
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

Category Theory Applied to Theorem Proving Dmitriy Traytel Andrei Popescu Jasmin Blanchette

λ → ∀

=

Isabelle

β α

β=unit+α×β

slide-2
SLIDE 2

Outline

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

slide-3
SLIDE 3

Outline

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

slide-4
SLIDE 4

Isabelle/HOL

◮ LCF philosophy

slide-5
SLIDE 5

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

slide-6
SLIDE 6

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

◮ Foundational approach

slide-7
SLIDE 7

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

◮ Foundational approach

Reduce high-level specifications to primitive mechanisms

slide-8
SLIDE 8

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

◮ Foundational approach

Reduce high-level specifications to primitive mechanisms

◮ HOL = simply typed set theory with ML-style polymorphism

slide-9
SLIDE 9

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

◮ Foundational approach

Reduce high-level specifications to primitive mechanisms

◮ HOL = simply typed set theory with ML-style polymorphism

Restrictive logic

slide-10
SLIDE 10

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

◮ Foundational approach

Reduce high-level specifications to primitive mechanisms

◮ HOL = simply typed set theory with ML-style polymorphism

Restrictive logic Weaker than ZF

slide-11
SLIDE 11

Isabelle/HOL

◮ LCF philosophy

Small inference kernel

◮ Foundational approach

Reduce high-level specifications to primitive mechanisms

◮ HOL = simply typed set theory with ML-style polymorphism

Restrictive logic Weaker than ZF

slide-12
SLIDE 12

◮ Datatype specification

datatype α list

=

Nil | Cons α (α list)

datatype α tree

=

Node α (α tree list)

slide-13
SLIDE 13

◮ Datatype specification

datatype α list

=

Nil | Cons α (α list)

datatype α tree

=

Node α (α tree list)

◮ Primitive type definitions

New type α Representing set Existing type β

slide-14
SLIDE 14

The traditional approach

Melham 1989, Gunter 1994 ◮ Fragment of ML (non-co)datatypes

slide-15
SLIDE 15

The traditional approach

Melham 1989, Gunter 1994 ◮ Fragment of ML (non-co)datatypes ◮ Fixed universe for recursive types

slide-16
SLIDE 16

The traditional approach

Melham 1989, Gunter 1994 ◮ Fragment of ML (non-co)datatypes ◮ Fixed universe for recursive types ◮ Simulate nested recursion by mutual recursion

datatype α list

=

Nil | Cons α (α list)

datatype α tree

=

Node α (α tree list)

slide-17
SLIDE 17

The traditional approach

Melham 1989, Gunter 1994 ◮ Fragment of ML (non-co)datatypes ◮ Fixed universe for recursive types ◮ Simulate nested recursion by mutual recursion

datatype α list

=

Nil | Cons α (α list)

datatype α tree

=

Node α (α tree_list)

and

α tree_list =

Nil | Cons (α tree) (α tree_list)

slide-18
SLIDE 18

The traditional approach

Melham 1989, Gunter 1994 ◮ Fragment of ML (non-co)datatypes ◮ Fixed universe for recursive types ◮ Simulate nested recursion by mutual recursion

datatype α list

=

Nil | Cons α (α list)

datatype α tree

=

Node α (α tree_list)

and

α tree_list =

Nil | Cons (α tree) (α tree_list)

◮ Implemented in Isabelle by Berghofer & Wenzel 1999

slide-19
SLIDE 19

Limitations

Berghofer & Wenzel 1999

  • 1. noncompositionality

  • 2. no codatatypes

  • 3. no non-free structures

slide-20
SLIDE 20

Limitations

LICS 2012

  • 1. noncompositionality

  • 2. no codatatypes

  • 3. no non-free structures

slide-21
SLIDE 21

Limitations

LICS 2012

  • 1. noncompositionality

  • 2. no codatatypes

  • 3. no non-free structures

slide-22
SLIDE 22

Limitations

LICS 2012

  • 1. noncompositionality

  • 2. no codatatypes

  • 3. no non-free structures

slide-23
SLIDE 23

Limitations

LICS 2012

  • 1. noncompositionality

  • 2. no codatatypes

  • 3. no non-free structures

slide-24
SLIDE 24

Outline

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

slide-25
SLIDE 25

datatype α list

=

Nil | Cons α (α list)

codatatype α tree

=

Node α (α tree list)

slide-26
SLIDE 26

datatype α list

=

Nil | Cons α (α list)

codatatype α tree

=

Node α (α tree list)

◮ P n = print n; for i = 1 to n do P (n + i);

slide-27
SLIDE 27

datatype α list

=

Nil | Cons α (α list)

codatatype α tree

=

Node α (α tree list)

◮ P n = print n; for i = 1 to n do P (n + i); ◮ evaluation tree for P 2 [2] [3, 4] [4, 5, 6] [5, 6, 7, 8] ··· ··· ··· ··· [6, 7, 8, 9, 10] ··· ··· ··· ··· ··· [7, 8, 9, 10, 11, 12] ··· ··· ··· ··· ··· ··· [5, 6, 7, 8] ··· ··· ··· ···

slide-28
SLIDE 28

datatype α list

=

Nil | Cons α (α list)

codatatype α tree

=

Node α (α tree list)

◮ Compositionality = no unfolding

slide-29
SLIDE 29

datatype α list

=

Nil | Cons α (α list)

codatatype α tree

=

Node α (α tree fset)

◮ Compositionality = no unfolding ◮ Need abstract interface

slide-30
SLIDE 30

datatype α list

=

Nil | Cons α (α list)

codatatype α tree

=

Node α (α tree fset)

◮ Compositionality = no unfolding ◮ Need abstract interface ◮ What interface?

slide-31
SLIDE 31

Type constructors are not just operators on types!

slide-32
SLIDE 32

The interface: bounded natural functor

type constructor F

slide-33
SLIDE 33

The interface: bounded natural functor

type constructor F Fmap

  • functor
slide-34
SLIDE 34

The interface: bounded natural functor

type constructor F Fmap

  • functor

Fset

} natural transformation

slide-35
SLIDE 35

The interface: bounded natural functor

type constructor F Fmap

  • functor

Fset

} natural transformation

Fbd

} infinite cardinal

slide-36
SLIDE 36

The interface: bounded natural functor

type constructor F Fmap

  • functor

Fset

} natural transformation

Fbd

} infinite cardinal

  • BNF = type constructor + polymorphic constrants + assumptions
slide-37
SLIDE 37

Type constructors are functors

Fmap : (α → α′) → (β → β′) → (α, β) F → (α′, β′) F

a1 a2 b f a1 f a2 g b

(α, β) F (α′, β′) F

Fmap f g

slide-38
SLIDE 38

Type constructors are functors

Fmap : (α → α′) → (β → β′) → (α, β) F → (α′, β′) F

a1 a2 b f a1 f a2 g b

(α, β) F (α′, β′) F

Fmap f g

Fmap id id

=

id Fmap f1 f2 ◦ Fmap g1 g2

=

Fmap (f1 ◦ g1) (f2 ◦ g2)

slide-39
SLIDE 39

Type constructors are containers

Fset1 : (α, β) F → α set Fset2 : (α, β) F → β set

a1 a2 b a1 a2 b

(α, β) F α set β set

Fset1 Fset2

slide-40
SLIDE 40

Type constructors are containers

Fset1 : (α, β) F → α set Fset2 : (α, β) F → β set

a1 a2 b a1 a2 b

(α, β) F α set β set

Fset1 Fset2

Fset1 ◦ Fmap f1 f2

=

image f1 ◦ Fset1 Fset2 ◦ Fmap f1 f2

=

image f2 ◦ Fset2

slide-41
SLIDE 41

Further BNF assumptions

∀x ∈ Fset1 z. f1 x = g1 x ∀x ∈ Fset2 z. f2 x = g2 x

Fmap f1 f2 z = Fmap g1 g2 z

slide-42
SLIDE 42

Further BNF assumptions

∀x ∈ Fset1 z. f1 x = g1 x ∀x ∈ Fset2 z. f2 x = g2 x

Fmap f1 f2 z = Fmap g1 g2 z

ℵ0 ≤

Fbd

slide-43
SLIDE 43

Further BNF assumptions

∀x ∈ Fset1 z. f1 x = g1 x ∀x ∈ Fset2 z. f2 x = g2 x

Fmap f1 f2 z = Fmap g1 g2 z

ℵ0 ≤

Fbd

|Fseti z| ≤

Fbd

slide-44
SLIDE 44

Further BNF assumptions

∀x ∈ Fset1 z. f1 x = g1 x ∀x ∈ Fset2 z. f2 x = g2 x

Fmap f1 f2 z = Fmap g1 g2 z

ℵ0 ≤

Fbd

|Fseti z| ≤

Fbd

|(α1, α2) F| ≤ (|α1|+|α2|)Fbd

slide-45
SLIDE 45

Further BNF assumptions

∀x ∈ Fset1 z. f1 x = g1 x ∀x ∈ Fset2 z. f2 x = g2 x

Fmap f1 f2 z = Fmap g1 g2 z

ℵ0 ≤

Fbd

|Fseti z| ≤

Fbd

|(α1, α2) F| ≤ (|α1|+|α2|)Fbd (F, Fmap) preserves weak pullbacks

slide-46
SLIDE 46

What are bounded natural functors good for?

BNFs ...

slide-47
SLIDE 47

What are bounded natural functors good for?

BNFs ...

◮ cover basic type constructors (e.g. +, ×, unit, and α → β for fixed α)

slide-48
SLIDE 48

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)

slide-49
SLIDE 49

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

slide-50
SLIDE 50

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)

slide-51
SLIDE 51

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)

slide-52
SLIDE 52

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

slide-53
SLIDE 53

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

slide-54
SLIDE 54

Outline

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

slide-55
SLIDE 55

From user specifications to (co)datatypes

Given

datatype α list = Nil | Cons α (α list)

slide-56
SLIDE 56

From user specifications to (co)datatypes

Given

datatype α list = Nil | Cons α (α list)

  • 1. Abstract to β = unit+α×β
slide-57
SLIDE 57

From user specifications to (co)datatypes

Given

datatype α list = Nil | Cons α (α list)

  • 1. Abstract to β = unit+α×β
  • 2. Prove that (α, β) F = unit+α×β is a BNF
slide-58
SLIDE 58

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
slide-59
SLIDE 59

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)

slide-60
SLIDE 60

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 → β

slide-61
SLIDE 61

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)
slide-62
SLIDE 62

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
slide-63
SLIDE 63

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)
slide-64
SLIDE 64

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)
slide-65
SLIDE 65

Induction

β = (α, β) F

◮ Given ϕ : α IF → bool

slide-66
SLIDE 66

Induction

β = (α, β) F

◮ Given ϕ : α IF → bool ◮ Abstract induction principle

∀z. (∀x ∈ Fset2 z. ϕ x) ⇒ ϕ (fld z) ∀x. ϕ x

slide-67
SLIDE 67

Induction

β = unit+α×β

◮ Given ϕ : α IF → bool ◮ Abstract induction principle

∀z. (∀x ∈ Fset2 z. ϕ x) ⇒ ϕ (fld z) ∀x. ϕ x

◮ Given ϕ : α list → bool ◮ Case distinction on z

(∀ys ∈ /

  • 0. ϕ ys) ⇒ ϕ (fld (Inl ()))

∀x xs.(∀ys ∈ {xs}. ϕ ys) ⇒ ϕ (fld (Inr (x, xs)))

∀xs. ϕ xs

slide-68
SLIDE 68

Induction

β = unit+α×β

◮ Given ϕ : α IF → bool ◮ Abstract induction principle

∀z. (∀x ∈ Fset2 z. ϕ x) ⇒ ϕ (fld z) ∀x. ϕ x

◮ Given ϕ : α list → bool ◮ Concrete induction principle

ϕ (fld (Inl ())) ∀x xs. ϕ xs ⇒ ϕ (fld (Inr (x, xs)))

∀xs. ϕ xs

slide-69
SLIDE 69

Induction

β = unit+α×β

◮ Given ϕ : α IF → bool ◮ Abstract induction principle

∀z. (∀x ∈ Fset2 z. ϕ x) ⇒ ϕ (fld z) ∀x. ϕ x

◮ Given ϕ : α list → bool ◮ In constructor notation

ϕ Nil ∀x xs. ϕ xs ⇒ ϕ (Cons x xs)

∀xs. ϕ xs

slide-70
SLIDE 70

Induction & Coinduction

β = (α, β) F

◮ Given ϕ : α IF → bool ◮ Abstract induction principle

∀z. (∀x ∈ Fset2 z. ϕ x) ⇒ ϕ (fld z) ∀x. ϕ x

◮ Given ψ : α JF → α JF → bool

slide-71
SLIDE 71

Induction & Coinduction

β = (α, β) F

◮ Given ϕ : α IF → bool ◮ Abstract induction principle

∀z. (∀x ∈ Fset2 z. ϕ x) ⇒ ϕ (fld z) ∀x. ϕ x

◮ Given ψ : α JF → α JF → bool ◮ Abstract coinduction principle

∀x y. ψ x y ⇒ Fpred Eq ψ (unf x) (unf y) ∀x y. ψ x y ⇒ x = y

slide-72
SLIDE 72

Example

codatatype α tree = Node (lab: α) (sub: α tree fset)

slide-73
SLIDE 73

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)

slide-74
SLIDE 74

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)

slide-75
SLIDE 75

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 ψ=λt1 t2.∃t. t1=tmap (f◦g) t ∧ t2=tmap f (tmap g t)]) force+

slide-76
SLIDE 76

Outline

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

slide-77
SLIDE 77

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

Category Theory Applied to Theorem Proving

slide-78
SLIDE 78

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

Category Theory Applied to Theorem Proving ◮ Framework for defining types in HOL

slide-79
SLIDE 79

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

slide-80
SLIDE 80

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

slide-81
SLIDE 81

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

slide-82
SLIDE 82

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

slide-83
SLIDE 83

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!

slide-84
SLIDE 84

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

Category Theory Applied to Theorem Proving Dmitriy Traytel Andrei Popescu Jasmin Blanchette

λ → ∀

=

Isabelle

β α

β=unit+α×β

slide-85
SLIDE 85

Outline

Backup slides

slide-86
SLIDE 86

Type constructors act on sets

(A1, A2) F = {z | Fset1 z ⊆ A1 ∧ Fset2 z ⊆ A2}

a1 a2 b

a1 a2 b a2 a1 b

Action of F

A1 : α set A2 : β set

(A1, A2) F : (α, β) F set

slide-87
SLIDE 87

Type constructors act on sets

(A1, A2) F = {z | Fset1 z ⊆ A1 ∧ Fset2 z ⊆ A2}

a1 a2 b

a1 a2 b a2 a1 b

Action of F

A1 : α set A2 : β set

(A1, A2) F : (α, β) F set (∀i ∈ {1, 2}. ∀x ∈ Fseti z. fi x = gi x) ⇒

Fmap f1 f2 z = Fmap g1 g2 z

slide-88
SLIDE 88

Type constructors are bounded

Fbd: infinite cardinal

a1 a2 b a1 a2 b

(α, β) F α set β set

Fset1 Fset2

slide-89
SLIDE 89

Type constructors are bounded

Fbd: infinite cardinal

a1 a2 b a1 a2 b

(α, β) F α set β set

Fset1 Fset2

|Fseti z| ≤

Fbd

slide-90
SLIDE 90

Type constructors are bounded

Fbd: infinite cardinal

a1 a2 b a1 a2 b

(α, β) F α set β set

Fset1 Fset2 a1 a2 b

a1 a2 b a2 a1 b

Action of F

A1 : α set A2 : β set

(A1, A2) F : (α, β) F set |Fseti z| ≤

Fbd

slide-91
SLIDE 91

Type constructors are bounded

Fbd: infinite cardinal

a1 a2 b a1 a2 b

(α, β) F α set β set

Fset1 Fset2 a1 a2 b

a1 a2 b a2 a1 b

Action of F

A1 : α set A2 : β set

(A1, A2) F : (α, β) F set |Fseti z| ≤

Fbd

|(A1, A2) F| ≤ (|A1|+|A2|+ 2)Fbd

slide-92
SLIDE 92

Algebras, Coalgebras & Morphisms

β = (α, β) F

A

(α, A) F

s

slide-93
SLIDE 93

Algebras, Coalgebras & Morphisms

β = (α, β) F

A

(α, A) F

s A B

(α, A) F (α, B) F

f sB sA Fmap id f

slide-94
SLIDE 94

Algebras, Coalgebras & Morphisms

β = (α, β) F

A

(α, A) F

s A B

(α, A) F (α, B) F

f sB sA Fmap id f A

(α, A) F

s

slide-95
SLIDE 95

Algebras, Coalgebras & Morphisms

β = (α, β) F

A

(α, A) F

s A B

(α, A) F (α, B) F

f sB sA Fmap id f A

(α, A) F

s A B

(α, A) F (α, B) F

f sB sA Fmap id f

slide-96
SLIDE 96

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

slide-97
SLIDE 97

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

  • f certain cardinality

◮ Minimal subalgebra of weakly initial algebra is initial

slide-98
SLIDE 98

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

  • f 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)

slide-99
SLIDE 99

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

  • f 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)

◮ Sum of all coalgebras is weakly final ◮ Suffices to consider coalgebras over types of certain cardinality ◮ Quotient of weakly final coalgebra to the greatest bisimulation is final

slide-100
SLIDE 100

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

  • f 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)

◮ Sum of all coalgebras is weakly final ◮ Suffices to consider coalgebras over types of certain cardinality ◮ Quotient of weakly final coalgebra to the greatest bisimulation is final ◮ Use concrete weakly final coalgebra (elements are tree-like structures)

⇒ Have a bound for its cardinality

⇒ (α JF, unf : α JF → (α, α JF) F)

slide-101
SLIDE 101

Iteration & Coiteration

β = (α, β) F

◮ Given s : (α, β) F → β

slide-102
SLIDE 102

Iteration & Coiteration

β = (α, β) F

◮ Given s : (α, β) F → β ◮ Obtain unique morphism iter s

from (α IF, fld) to (Uβ, s)

α IF β (α, α IF) F (α, β) F

iter s s fld Fmap id (iter s)

slide-103
SLIDE 103

Iteration & Coiteration

β = (α, β) F

◮ Given s : (α, β) F → β ◮ Obtain unique morphism iter s

from (α IF, fld) to (Uβ, s)

α IF β (α, α IF) F (α, β) F

iter s s fld Fmap id (iter s)

◮ Given s : β → (α, β) F

slide-104
SLIDE 104

Iteration & Coiteration

β = (α, β) F

◮ Given s : (α, β) F → β ◮ Obtain unique morphism iter s

from (α IF, fld) to (Uβ, s)

α IF β (α, α IF) F (α, β) F

iter s s fld Fmap id (iter s)

◮ Given s : β → (α, β) F ◮ Obtain unique morphism coiter s

from (Uβ, s) to (α JF, unf)

α IF β (α, α IF) F (α, β) F

coiter s s unf Fmap id (coiter s)

slide-105
SLIDE 105

Preservation of BNF Properties

β = (α, β) F

◮ IFmap f = iter (fld ◦ Fmap f id) ◮ IFset = iter collect, where

collect z=Fset1 z ∪

  • Fset2 z
slide-106
SLIDE 106

Preservation of BNF Properties

β = (α, β) F

◮ IFmap f = iter (fld ◦ Fmap f id) ◮ IFset = iter collect, where

collect z=Fset1 z ∪

  • Fset2 z

Theorem (IF, IFmap, IFset, 2Fbd) is a BNF

slide-107
SLIDE 107

Preservation of BNF Properties

β = (α, β) F

◮ IFmap f = iter (fld ◦ Fmap f id) ◮ IFset = iter collect, where

collect z=Fset1 z ∪

  • Fset2 z

Theorem (IF, IFmap, IFset, 2Fbd) is a BNF

◮ JFmap f = coiter (Fmap f id ◦ unf) ◮ JFset x =

i∈N

collecti x, where collect0 x=/ collecti+1 x=Fset1 (unf x)∪

  • y∈Fset2 (unf x)

collecti y

slide-108
SLIDE 108

Preservation of BNF Properties

β = (α, β) F

◮ IFmap f = iter (fld ◦ Fmap f id) ◮ IFset = iter collect, where

collect z=Fset1 z ∪

  • Fset2 z

Theorem (IF, IFmap, IFset, 2Fbd) is a BNF

◮ JFmap f = coiter (Fmap f id ◦ unf) ◮ JFset x =

i∈N

collecti x, where collect0 x=/ collecti+1 x=Fset1 (unf x)∪

  • y∈Fset2 (unf x)

collecti y

Theorem (JF, JFmap, JFset, FbdFbd) is a BNF