Coalgebras in Type Theory Equations CoInductive Types - - PowerPoint PPT Presentation

coalgebras in type theory
SMART_READER_LITE
LIVE PREVIEW

Coalgebras in Type Theory Equations CoInductive Types - - PowerPoint PPT Presentation

Coalgebras in Type Theory Venanzio Capretta Corecursive Coalgebras in Type Theory Equations CoInductive Types Bisimulations Venanzio Capretta Constructive Infinity Tabulations General CMCS 2010, Paphos, Cyprus Recursion Non-Standard


slide-1
SLIDE 1

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Coalgebras in Type Theory

Venanzio Capretta CMCS 2010, Paphos, Cyprus

Venanzio Capretta Coalgebras in Type Theory

slide-2
SLIDE 2

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Corecursive Equations

Venanzio Capretta Coalgebras in Type Theory

slide-3
SLIDE 3

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Streams

Streams: infinite sequence over a domain D, SD. nat = 0 : : 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : · · · : SN fib = 0 : : 1 : : 1 : : 2 : : 3 : : 5 : : 8 : : · · · : SN

Venanzio Capretta Coalgebras in Type Theory

slide-4
SLIDE 4

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Streams

Streams: infinite sequence over a domain D, SD. nat = 0 : : 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : · · · : SN fib = 0 : : 1 : : 1 : : 2 : : 3 : : 5 : : 8 : : · · · : SN Notation: head :

h

nat = 0 tail :

t

nat = 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : 7 : : · · ·

Venanzio Capretta Coalgebras in Type Theory

slide-5
SLIDE 5

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Streams

Streams: infinite sequence over a domain D, SD. nat = 0 : : 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : · · · : SN fib = 0 : : 1 : : 1 : : 2 : : 3 : : 5 : : 8 : : · · · : SN Notation: head :

h

nat = 0

h3nat = 3 h3fib = 2

tail :

t

nat = 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : 7 : : · · ·

Venanzio Capretta Coalgebras in Type Theory

slide-6
SLIDE 6

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Streams

Streams: infinite sequence over a domain D, SD. nat = 0 : : 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : · · · : SN fib = 0 : : 1 : : 1 : : 2 : : 3 : : 5 : : 8 : : · · · : SN Notation: head :

h

nat = 0

h3nat = 3 h3fib = 2

tail :

t

nat = 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : 7 : : · · ·

4tnat = 4 :

: 5 : : 6 : : 7 : : 8 : : 9 : : 10 : : · · ·

4tfib = 3 :

: 5 : : 8 : : 13 : : 21 : : 34 : : 55 : : · · ·

Venanzio Capretta Coalgebras in Type Theory

slide-7
SLIDE 7

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Streams

Streams: infinite sequence over a domain D, SD. nat = 0 : : 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : · · · : SN fib = 0 : : 1 : : 1 : : 2 : : 3 : : 5 : : 8 : : · · · : SN Notation: head :

h

nat = 0

h3nat = 3 h3fib = 2

tail :

t

nat = 1 : : 2 : : 3 : : 4 : : 5 : : 6 : : 7 : : · · ·

4tnat = 4 :

: 5 : : 6 : : 7 : : 8 : : 9 : : 10 : : · · ·

4tfib = 3 :

: 5 : : 8 : : 13 : : 21 : : 34 : : 55 : : · · · Corecursive equations on streams:

[Rutten 2007]

nat = 0 : : nat + 1 fib = 0 : : fib + (1 : : fib) (x : : s1) ⋉ s2 = x : : s2 ⋉ s1 even (x : : s) = x : : odd s

  • dd (x :

: s) = even s

Venanzio Capretta Coalgebras in Type Theory

slide-8
SLIDE 8

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Harder corecursive equations

Equations that are more difficult to solve [Zantema 2009] Three functions of type S → S: φ s = h s : : φ(even t s) ⋉ φ(odd t s)

Venanzio Capretta Coalgebras in Type Theory

slide-9
SLIDE 9

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Harder corecursive equations

Equations that are more difficult to solve [Zantema 2009] Three functions of type S → S: φ s = h s : : φ(even t s) ⋉ φ(odd t s) χ s = h s : : t s ⋉ t (χ t s)

Venanzio Capretta Coalgebras in Type Theory

slide-10
SLIDE 10

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Harder corecursive equations

Equations that are more difficult to solve [Zantema 2009] Three functions of type S → S: φ s = h s : : φ(even t s) ⋉ φ(odd t s) χ s = h s : : t s ⋉ t (χ t s) ψ s = h s : : even(ψ(odd t s)) ⋉ odd(ψ(even t s))

Venanzio Capretta Coalgebras in Type Theory

slide-11
SLIDE 11

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Harder corecursive equations

Equations that are more difficult to solve [Zantema 2009] Three functions of type S → S: φ s = h s : : φ(even t s) ⋉ φ(odd t s) χ s = h s : : t s ⋉ t (χ t s) ψ s = h s : : even(ψ(odd t s)) ⋉ odd(ψ(even t s)) Puzzle: Find equation f s = C[s, f ] that generates: f nat = 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : :4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15 : :0 : : 16 : : 8 : : 17 : : 4 : : 18 : : 9 : : 19 : : 2 : : 20 : : 10 : : 21 : : 5 : : 22 : :11 : : 23 : : 1 : : 24 : : 12 : : 25 : : 6 : : 26 : : 13 : : 27 : : 3 : : 28 : : 14 : :29 : : 7 : : 30 : : 15 : : 31 : : 0 : : 32 : : 16 : : 33 : : 8 : : 34 : : 17 : : 35 : :4 : : 36 : : 18 : : 37 : : 9 : : 38 : : · · ·

Venanzio Capretta Coalgebras in Type Theory

slide-12
SLIDE 12

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Images of recursive streams

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Images of streams of Booleans [Zantema] The Boolean Fibonacci stream: f (0 : : s) = 0 : : 1 : : f s bfib = f bfib f (1 : : s) = 0 : : f s

Venanzio Capretta Coalgebras in Type Theory

slide-13
SLIDE 13

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Images of recursive streams

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Images of streams of Booleans [Zantema] The Boolean Fibonacci stream: f (0 : : s) = 0 : : 1 : : f s bfib = f bfib f (1 : : s) = 0 : : f s

bfib = 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : :1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : :0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : :1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : :0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : :0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : :1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : :0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : :0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : :1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : :0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : :0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : :1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : :0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : :0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : :1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : :0 : : 0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : 0 : :0 : : 1 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 0 : : 1 : : 0 : : 1 : : · · · Venanzio Capretta Coalgebras in Type Theory

slide-14
SLIDE 14

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

CoInductive Types

Venanzio Capretta Coalgebras in Type Theory

slide-15
SLIDE 15

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

CoInductive Definitions

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

CoInductive Types:

[Hagino 1987, Aczel & Mendler 1989]

Type-theoretic implementation of final coalgebras.

Venanzio Capretta Coalgebras in Type Theory

slide-16
SLIDE 16

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

CoInductive Definitions

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

CoInductive Types:

[Hagino 1987, Aczel & Mendler 1989]

Type-theoretic implementation of final coalgebras. Final Coalgebra: codata SD : Set h −, t − : SD → D × SD (: :) : D → SD → SD

Venanzio Capretta Coalgebras in Type Theory

slide-17
SLIDE 17

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

CoInductive Definitions

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

CoInductive Types:

[Hagino 1987, Aczel & Mendler 1989]

Type-theoretic implementation of final coalgebras. Final Coalgebra: codata SD : Set h −, t − : SD → D × SD (: :) : D → SD → SD codata TA,B : Set leaf b → inl b leaf : B → TA,B node f → inr f node : (A → TA,B) → TA,B : TA,B → B + (A → TA,B)

Venanzio Capretta Coalgebras in Type Theory

slide-18
SLIDE 18

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

CoInductive Definitions

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

CoInductive Types:

[Hagino 1987, Aczel & Mendler 1989]

Type-theoretic implementation of final coalgebras. Final Coalgebra: codata SD : Set h −, t − : SD → D × SD (: :) : D → SD → SD codata TA,B : Set leaf b → inl b leaf : B → TA,B node f → inr f node : (A → TA,B) → TA,B : TA,B → B + (A → TA,B) (: :), leaf and node are constructors Guardedness by constructors:

[Coquand 1993]

A corecursive equation has a unique solution if all recursive calls occur only directly under constructor applications.

Venanzio Capretta Coalgebras in Type Theory

slide-19
SLIDE 19

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Example of guarded definition

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Definitions are accepted if they satisfy the guardedness condition [Gim`

enez 1998]

fguard : N → S fguard n = case mod(n, 3)    0 → nat 1 → n : : (n − 1) : : fguard (n + 1) 2 → n : : map (2 · −) (fguard (2 · n)) No recursive calls. Recursive calls under two constructors. Map filters the constructors.

Venanzio Capretta Coalgebras in Type Theory

slide-20
SLIDE 20

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution.

Venanzio Capretta Coalgebras in Type Theory

slide-21
SLIDE 21

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution. More powerful methods:

Venanzio Capretta Coalgebras in Type Theory

slide-22
SLIDE 22

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution. More powerful methods:

◮ Metrics (fixpoints of contractions) [Di Giannantonio/Miculan 2002]

Venanzio Capretta Coalgebras in Type Theory

slide-23
SLIDE 23

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution. More powerful methods:

◮ Metrics (fixpoints of contractions) [Di Giannantonio/Miculan 2002] ◮ Pebbleflow Networks [Endrullis/Grabmayer/Hendriks/Isihara/Klop 2008]

Venanzio Capretta Coalgebras in Type Theory

slide-24
SLIDE 24

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution. More powerful methods:

◮ Metrics (fixpoints of contractions) [Di Giannantonio/Miculan 2002] ◮ Pebbleflow Networks [Endrullis/Grabmayer/Hendriks/Isihara/Klop 2008] ◮ Circular Coinduction (CIRC) [Ro¸

su/Lucanu 2009] Venanzio Capretta Coalgebras in Type Theory

slide-25
SLIDE 25

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution. More powerful methods:

◮ Metrics (fixpoints of contractions) [Di Giannantonio/Miculan 2002] ◮ Pebbleflow Networks [Endrullis/Grabmayer/Hendriks/Isihara/Klop 2008] ◮ Circular Coinduction (CIRC) [Ro¸

su/Lucanu 2009]

◮ Termination of Rewriting Systems [Zantema 2009]

Venanzio Capretta Coalgebras in Type Theory

slide-26
SLIDE 26

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Methods to solve corecursive equations

Puzzle: 0 : : 0 : : 1 : : 0 : : 2 : : 1 : : 3 : : 0 : : 4 : : 2 : : 5 : : 1 : : 6 : : 3 : : 7 : : 0 : : 8 : : 4 : : 9 : : 2 : : 10 : : 5 : : 11 : : 1 : : 12 : : 6 : : 13 : : 3 : : 14 : : 7 : : 15

Some equations don’t satisfy guardedness but they still have a unique solution. More powerful methods:

◮ Metrics (fixpoints of contractions) [Di Giannantonio/Miculan 2002] ◮ Pebbleflow Networks [Endrullis/Grabmayer/Hendriks/Isihara/Klop 2008] ◮ Circular Coinduction (CIRC) [Ro¸

su/Lucanu 2009]

◮ Termination of Rewriting Systems [Zantema 2009] ◮ Unicity by Bisimulation [VC 2010]

Venanzio Capretta Coalgebras in Type Theory

slide-27
SLIDE 27

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulations

Venanzio Capretta Coalgebras in Type Theory

slide-28
SLIDE 28

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulations and the Coinduction Principle

Definition of bisimulation.

[Park 1981, Milner 1989] Venanzio Capretta Coalgebras in Type Theory

slide-29
SLIDE 29

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulations and the Coinduction Principle

Definition of bisimulation.

[Park 1981, Milner 1989]

A relation ∼ on a coinductive type is a bisimulation if x1 ∼ x2 ⇒    same top constructor same non-recursive arguments recursive arguments related by ∼

Venanzio Capretta Coalgebras in Type Theory

slide-30
SLIDE 30

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulations and the Coinduction Principle

Definition of bisimulation.

[Park 1981, Milner 1989]

A relation ∼ on a coinductive type is a bisimulation if x1 ∼ x2 ⇒    same top constructor same non-recursive arguments recursive arguments related by ∼ On Streams: s1 ∼ s2 ⇒ h s1 = h s2 ∧ t s1 ∼ t s2

Venanzio Capretta Coalgebras in Type Theory

slide-31
SLIDE 31

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulations and the Coinduction Principle

Definition of bisimulation.

[Park 1981, Milner 1989]

A relation ∼ on a coinductive type is a bisimulation if x1 ∼ x2 ⇒    same top constructor same non-recursive arguments recursive arguments related by ∼ On Streams: s1 ∼ s2 ⇒ h s1 = h s2 ∧ t s1 ∼ t s2 On Trees: t1 ∼ t2 ⇒    t1 = leaf b = t2 ∨ t1 = node f1 ∧ t2 = node f2 ∧ ∀a.f1 a ∼ f2 a

Venanzio Capretta Coalgebras in Type Theory

slide-32
SLIDE 32

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulations and the Coinduction Principle

Definition of bisimulation.

[Park 1981, Milner 1989]

A relation ∼ on a coinductive type is a bisimulation if x1 ∼ x2 ⇒    same top constructor same non-recursive arguments recursive arguments related by ∼ On Streams: s1 ∼ s2 ⇒ h s1 = h s2 ∧ t s1 ∼ t s2 On Trees: t1 ∼ t2 ⇒    t1 = leaf b = t2 ∨ t1 = node f1 ∧ t2 = node f2 ∧ ∀a.f1 a ∼ f2 a The Coinduction principle: x1 ∼ x2 ⇒ x1 = x2.

Venanzio Capretta Coalgebras in Type Theory

slide-33
SLIDE 33

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation as a coinductive relation

The Coinduction principle doesn’t hold in Type Theory: Equality is intentional: Equality of normal forms

Venanzio Capretta Coalgebras in Type Theory

slide-34
SLIDE 34

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation as a coinductive relation

The Coinduction principle doesn’t hold in Type Theory: Equality is intentional: Equality of normal forms Instead: Bisimilarity is defined as a coinductive relation: codata (≈) : S → S → Prop conssim : (x : D)(s1, s2 : S)s1 ≈ s2 → (x : : s1) ≈ (x : : x2)

Venanzio Capretta Coalgebras in Type Theory

slide-35
SLIDE 35

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation as a coinductive relation

The Coinduction principle doesn’t hold in Type Theory: Equality is intentional: Equality of normal forms Instead: Bisimilarity is defined as a coinductive relation: codata (≈) : S → S → Prop conssim : (x : D)(s1, s2 : S)s1 ≈ s2 → (x : : s1) ≈ (x : : x2) codata (≈) : T → T → Prop leafsim : (b : B)leaf b ≈ leaf b nodesim : (f1, f2 : A → T)(∀a.f1 a ≈ f2 a) → (node f1) ≈ (node f2)

Venanzio Capretta Coalgebras in Type Theory

slide-36
SLIDE 36

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s)

Venanzio Capretta Coalgebras in Type Theory

slide-37
SLIDE 37

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s) Suppose χ1 and χ2 are solutions.

Venanzio Capretta Coalgebras in Type Theory

slide-38
SLIDE 38

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s) Suppose χ1 and χ2 are solutions. Ad hoc bisimulation, inductively defined by:

Venanzio Capretta Coalgebras in Type Theory

slide-39
SLIDE 39

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s) Suppose χ1 and χ2 are solutions. Ad hoc bisimulation, inductively defined by: s : S χ1 s ∼ χ2 s (R0)

Venanzio Capretta Coalgebras in Type Theory

slide-40
SLIDE 40

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s) Suppose χ1 and χ2 are solutions. Ad hoc bisimulation, inductively defined by: s : S χ1 s ∼ χ2 s (R0) s, x1, x2 : S x1 ∼ x2 s ⋉ t x1 ∼ s ⋉ t x2 (R1)

Venanzio Capretta Coalgebras in Type Theory

slide-41
SLIDE 41

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s) Suppose χ1 and χ2 are solutions. Ad hoc bisimulation, inductively defined by: s : S χ1 s ∼ χ2 s (R0) s, x1, x2 : S x1 ∼ x2 s ⋉ t x1 ∼ s ⋉ t x2 (R1) s, x1, x2 : S x1 ∼ x2 x1 ⋉ s ∼ x2 ⋉ s (R2).

Venanzio Capretta Coalgebras in Type Theory

slide-42
SLIDE 42

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bisimulation and Unicity of Solutions

Unicity of solutions for the equation: χ : S → S χ s = h s : : t s ⋉ t (χ t s) Suppose χ1 and χ2 are solutions. Ad hoc bisimulation, inductively defined by: s : S χ1 s ∼ χ2 s (R0) s, x1, x2 : S x1 ∼ x2 s ⋉ t x1 ∼ s ⋉ t x2 (R1) s, x1, x2 : S x1 ∼ x2 x1 ⋉ s ∼ x2 ⋉ s (R2). By the coinduction principle and R0, χ1 = χ2 .

Venanzio Capretta Coalgebras in Type Theory

slide-43
SLIDE 43

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Constructive Infinity

Venanzio Capretta Coalgebras in Type Theory

slide-44
SLIDE 44

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Brouwer’s Continuity Principle

Brouwer’s Continuity (In Functional Programming terms): Given a function f : SN → N, for every s : SN, there exists n : N such that for every s′ : SN, if take n s′ = take n s, then f s′ = f s.

Venanzio Capretta Coalgebras in Type Theory

slide-45
SLIDE 45

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Brouwer’s Continuity Principle

Brouwer’s Continuity (In Functional Programming terms): Given a function f : SN → N, for every s : SN, there exists n : N such that for every s′ : SN, if take n s′ = take n s, then f s′ = f s. Apparently impossible functional program:

[Martin Escardo]

allb : (SB → B) → B

Venanzio Capretta Coalgebras in Type Theory

slide-46
SLIDE 46

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Brouwer’s Continuity Principle

Brouwer’s Continuity (In Functional Programming terms): Given a function f : SN → N, for every s : SN, there exists n : N such that for every s′ : SN, if take n s′ = take n s, then f s′ = f s. Apparently impossible functional program:

[Martin Escardo]

allb : (SB → B) → B allb f = f (counterexample f )

Venanzio Capretta Coalgebras in Type Theory

slide-47
SLIDE 47

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Brouwer’s Continuity Principle

Brouwer’s Continuity (In Functional Programming terms): Given a function f : SN → N, for every s : SN, there exists n : N such that for every s′ : SN, if take n s′ = take n s, then f s′ = f s. Apparently impossible functional program:

[Martin Escardo]

allb : (SB → B) → B allb f = f (counterexample f ) counterexample : (SB → B) → SB counterexample f = if (allb ft) then (false : : counterexample ff ) else (true : : counterexample ft) where ft = λs.f (true : : s) ff = λs.f (false : : s)

Venanzio Capretta Coalgebras in Type Theory

slide-48
SLIDE 48

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on inductive types

Integers in binary representation: [B].

Venanzio Capretta Coalgebras in Type Theory

slide-49
SLIDE 49

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on inductive types

Integers in binary representation: [B]. A function f : [B] → A can be represented by a tree: codata TA : Set node : A → TA → TA → TA

Venanzio Capretta Coalgebras in Type Theory

slide-50
SLIDE 50

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on inductive types

Integers in binary representation: [B]. A function f : [B] → A can be represented by a tree: codata TA : Set node : A → TA → TA → TA Tabulation of the function: tabulate : ([B] → A) → TA tabulate f = node (f []) (tabulate ft) (tabulate ff ) where ft = λs.f (true : : s) ff = λs.f (false : : s)

Venanzio Capretta Coalgebras in Type Theory

slide-51
SLIDE 51

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on inductive types

Integers in binary representation: [B]. A function f : [B] → A can be represented by a tree: codata TA : Set node : A → TA → TA → TA Tabulation of the function: tabulate : ([B] → A) → TA tabulate f = node (f []) (tabulate ft) (tabulate ff ) where ft = λs.f (true : : s) ff = λs.f (false : : s) Application of a tabulation: apply : TA → [B] → A apply (node a t1 t2) [] = a apply (node a t1 t2) (true : : l) = apply t1 l apply (node a t1 t2) (false : : l) = apply t2 l

Venanzio Capretta Coalgebras in Type Theory

slide-52
SLIDE 52

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on coinductive types

A function f : SA → B can (?) be represented by

Venanzio Capretta Coalgebras in Type Theory

slide-53
SLIDE 53

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on coinductive types

A function f : SA → B can (?) be represented by a well-founded tree:

[Ghani/Hancock/Pattinson:2006]

data TA,B : Set leaf : B → TA,B node : (A → TA,B) → TA,B

Venanzio Capretta Coalgebras in Type Theory

slide-54
SLIDE 54

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on coinductive types

A function f : SA → B can (?) be represented by a well-founded tree:

[Ghani/Hancock/Pattinson:2006]

data TA,B : Set leaf : B → TA,B node : (A → TA,B) → TA,B Application of a tabulation: apply : TA,B → SA → B apply (leaf b) s = b apply (node g) (a : : s) = apply (g a) s

Venanzio Capretta Coalgebras in Type Theory

slide-55
SLIDE 55

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation of functions on coinductive types

A function f : SA → B can (?) be represented by a well-founded tree:

[Ghani/Hancock/Pattinson:2006]

data TA,B : Set leaf : B → TA,B node : (A → TA,B) → TA,B Application of a tabulation: apply : TA,B → SA → B apply (leaf b) s = b apply (node g) (a : : s) = apply (g a) s Is there an inverse transformation/tabulation? tabulate : (SA → B) → TA,B Surely B must be a discrete/inductive type.

Venanzio Capretta Coalgebras in Type Theory

slide-56
SLIDE 56

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Tabulation Duality?

What is the relation between the two kinds of tabulations?

◮ Function on Inductive Types : Coinductive Tabulations. ◮ Function on CoInductive Types : Inductive Tabulations.

How to build a tabulation in the second case? We need strong intentionality.

Venanzio Capretta Coalgebras in Type Theory

slide-57
SLIDE 57

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

General Recursion

Venanzio Capretta Coalgebras in Type Theory

slide-58
SLIDE 58

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Partial Recursion in Type Theory

In Type Theory all functions are total. How do we represent partial recursive functions?

Venanzio Capretta Coalgebras in Type Theory

slide-59
SLIDE 59

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Partial Recursion in Type Theory

In Type Theory all functions are total. How do we represent partial recursive functions? Partiality Monad:

[VC 2005]

codata Bν : Set ⌈−⌉ : B → Bν ⊳ : Bν → Bν

Venanzio Capretta Coalgebras in Type Theory

slide-60
SLIDE 60

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Partial Recursion in Type Theory

In Type Theory all functions are total. How do we represent partial recursive functions? Partiality Monad:

[VC 2005]

codata Bν : Set ⌈−⌉ : B → Bν ⊳ : Bν → Bν A partial function is represented as f : A → Bν.

Venanzio Capretta Coalgebras in Type Theory

slide-61
SLIDE 61

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Partial Recursion in Type Theory

In Type Theory all functions are total. How do we represent partial recursive functions? Partiality Monad:

[VC 2005]

codata Bν : Set ⌈−⌉ : B → Bν ⊳ : Bν → Bν A partial function is represented as f : A → Bν. f defined on a: f a = ⊳⊳⊳ · · · ⊳⌈b⌉.

Venanzio Capretta Coalgebras in Type Theory

slide-62
SLIDE 62

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Partial Recursion in Type Theory

In Type Theory all functions are total. How do we represent partial recursive functions? Partiality Monad:

[VC 2005]

codata Bν : Set ⌈−⌉ : B → Bν ⊳ : Bν → Bν A partial function is represented as f : A → Bν. f defined on a: f a = ⊳⊳⊳ · · · ⊳⌈b⌉. f undefined on a: f a = ⊳⊳⊳⊳ · · · .

Venanzio Capretta Coalgebras in Type Theory

slide-63
SLIDE 63

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bove/Capretta method

Different approach to partial recursive functions.[Bove/VC 2001]

Venanzio Capretta Coalgebras in Type Theory

slide-64
SLIDE 64

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bove/Capretta method

Different approach to partial recursive functions.[Bove/VC 2001] A partial function f : A ⇀ B is represented by A domain predicate and a function on the domain: Dom : A → Prop f : (a : A)Dom a → B

Venanzio Capretta Coalgebras in Type Theory

slide-65
SLIDE 65

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bove/Capretta method

Different approach to partial recursive functions.[Bove/VC 2001] A partial function f : A ⇀ B is represented by A domain predicate and a function on the domain: Dom : A → Prop f : (a : A)Dom a → B Example, function that seeks a 0 in a stream: seek : SN ⇀ N

Venanzio Capretta Coalgebras in Type Theory

slide-66
SLIDE 66

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bove/Capretta method

Different approach to partial recursive functions.[Bove/VC 2001] A partial function f : A ⇀ B is represented by A domain predicate and a function on the domain: Dom : A → Prop f : (a : A)Dom a → B Example, function that seeks a 0 in a stream: seek : SN ⇀ N data Domseek : SN → Prop seek : (s : SN)Domseek s → N

Venanzio Capretta Coalgebras in Type Theory

slide-67
SLIDE 67

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Bove/Capretta method

Different approach to partial recursive functions.[Bove/VC 2001] A partial function f : A ⇀ B is represented by A domain predicate and a function on the domain: Dom : A → Prop f : (a : A)Dom a → B Example, function that seeks a 0 in a stream: seek : SN ⇀ N data Domseek : SN → Prop found : (s : SN)Domseek (0 : : s) notfound : (n : N)(s : SN)Domseek s → Domseek (S n : : s) seek : (s : SN)Domseek s → N seek (0 : : s) (found z) = 0 seek (S n : : s) (notfound n s h) = S (seek s h)

Venanzio Capretta Coalgebras in Type Theory

slide-68
SLIDE 68

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Prophecy

Coinductive version of the domain: trace of computation.

[Bove/VC 2007] Venanzio Capretta Coalgebras in Type Theory

slide-69
SLIDE 69

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Prophecy

Coinductive version of the domain: trace of computation.

[Bove/VC 2007]

codata Traceseek : SN → Prop found : (s : SN)Traceseek (0 : : s) notfound : (n : N)(s : SN)Traceseek s → Traceseek (S n : : s) seek : (s : SN)Traceseek s → Nν

Venanzio Capretta Coalgebras in Type Theory

slide-70
SLIDE 70

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Prophecy

Coinductive version of the domain: trace of computation.

[Bove/VC 2007]

codata Traceseek : SN → Prop found : (s : SN)Traceseek (0 : : s) notfound : (n : N)(s : SN)Traceseek s → Traceseek (S n : : s) seek : (s : SN)Traceseek s → Nν In all these representations: How do we effectively compute the function? Coinductive objects don’t automatically unfold. Domain predicate must be proved.

Venanzio Capretta Coalgebras in Type Theory

slide-71
SLIDE 71

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Judgement Rewriting

To compute seek (7 : : 2 : : 5 : : · · · ) Assume the domain predicate and type-check the result: h : Domseek (7 : : 2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) h : N

Venanzio Capretta Coalgebras in Type Theory

slide-72
SLIDE 72

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Judgement Rewriting

To compute seek (7 : : 2 : : 5 : : · · · ) Assume the domain predicate and type-check the result: h : Domseek (7 : : 2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) h : N Inversion: h must have the form (notfound 6 (2 : : 5 : : · · · ) h1). Rewrite the judgement:

Venanzio Capretta Coalgebras in Type Theory

slide-73
SLIDE 73

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Judgement Rewriting

To compute seek (7 : : 2 : : 5 : : · · · ) Assume the domain predicate and type-check the result: h : Domseek (7 : : 2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) h : N Inversion: h must have the form (notfound 6 (2 : : 5 : : · · · ) h1). Rewrite the judgement: → h1 : Domseek (2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) (notfound 6 (2 : : 5 : : · · · ) h1) : N

Venanzio Capretta Coalgebras in Type Theory

slide-74
SLIDE 74

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Judgement Rewriting

To compute seek (7 : : 2 : : 5 : : · · · ) Assume the domain predicate and type-check the result: h : Domseek (7 : : 2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) h : N Inversion: h must have the form (notfound 6 (2 : : 5 : : · · · ) h1). Rewrite the judgement: → h1 : Domseek (2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) (notfound 6 (2 : : 5 : : · · · ) h1) : N

  • h1 : Domseek (2 :

: 5 : : · · · ) ⊢ S seek (2 : : 5 : : · · · ) h1 : N

Venanzio Capretta Coalgebras in Type Theory

slide-75
SLIDE 75

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Judgement Rewriting

To compute seek (7 : : 2 : : 5 : : · · · ) Assume the domain predicate and type-check the result: h : Domseek (7 : : 2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) h : N Inversion: h must have the form (notfound 6 (2 : : 5 : : · · · ) h1). Rewrite the judgement: → h1 : Domseek (2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) (notfound 6 (2 : : 5 : : · · · ) h1) : N

  • h1 : Domseek (2 :

: 5 : : · · · ) ⊢ S seek (2 : : 5 : : · · · ) h1 : N → h2 : Domseek (5 : : · · · ) ⊢ S S seek (5 : : · · · ) h2 : N

Venanzio Capretta Coalgebras in Type Theory

slide-76
SLIDE 76

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Computation by Judgement Rewriting

To compute seek (7 : : 2 : : 5 : : · · · ) Assume the domain predicate and type-check the result: h : Domseek (7 : : 2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) h : N Inversion: h must have the form (notfound 6 (2 : : 5 : : · · · ) h1). Rewrite the judgement: → h1 : Domseek (2 : : 5 : : · · · ) ⊢ seek (7 : : 2 : : 5 : : · · · ) (notfound 6 (2 : : 5 : : · · · ) h1) : N

  • h1 : Domseek (2 :

: 5 : : · · · ) ⊢ S seek (2 : : 5 : : · · · ) h1 : N → h2 : Domseek (5 : : · · · ) ⊢ S S seek (5 : : · · · ) h2 : N Connection with Non-Standard Type Theory [Martin-L¨

  • f 1988]

Venanzio Capretta Coalgebras in Type Theory

slide-77
SLIDE 77

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Mixing Induction and Coinduction

Venanzio Capretta Coalgebras in Type Theory

slide-78
SLIDE 78

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Mixed Inductive/Coinductive Types

Data structures with both:

[Danielsson/Altenkirch 2009]

◮ Constructors that must be well-founded; ◮ Constructors that can be iterated infinitely

Example, equality for the partiality monad: codata (≃) : Bν → Bν → Prop eqstep : (x1, x2 : Bν)x1 ≃ x2 → ⊳x1 ≃ ⊳x2 eqval : (b : B)⌈b⌉ ≃ ⌈b⌉ eqmix1 : (x1, x2 : Bν)x1 ≃ x2 → ⊳x1 ≃ x2 eqmix2 : (x1, x2 : Bν)x1 ≃ x2 → x1 ≃ ⊳x2

Venanzio Capretta Coalgebras in Type Theory

slide-79
SLIDE 79

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Mixed Inductive/Coinductive Types

Data structures with both:

[Danielsson/Altenkirch 2009]

◮ Constructors that must be well-founded; ◮ Constructors that can be iterated infinitely

Example, equality for the partiality monad: codata (≃) : Bν → Bν → Prop eqstep : (x1, x2 : Bν)x1 ≃ x2 → ⊳x1 ≃ ⊳x2 eqval : (x1, x2 : Bν)(b : B)x1 ↓ b → x2 ↓ b → x1 ≃ x2 x ↓ b inductive convergence relation

Venanzio Capretta Coalgebras in Type Theory

slide-80
SLIDE 80

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Mixed Inductive/Coinductive Types

Data structures with both:

[Danielsson/Altenkirch 2009]

◮ Constructors that must be well-founded; ◮ Constructors that can be iterated infinitely

Example, equality for the partiality monad: data (≃) : Bν → Bν → Prop eqstep : (x1, x2 : Bν)x1

≃ x2 → ⊳x1 ≃ ⊳x2 eqval : (b : B)⌈b⌉ ≃ ⌈b⌉ eqmix1 : (x1, x2 : Bν)x1 ≃ x2 → ⊳x1 ≃ x2 eqmix2 : (x1, x2 : Bν)x1 ≃ x2 → x1 ≃ ⊳x2 The ∞ marks arguments that need not be well-founded

Venanzio Capretta Coalgebras in Type Theory

slide-81
SLIDE 81

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Conclusion

Interesting topics for future research:

Venanzio Capretta Coalgebras in Type Theory

slide-82
SLIDE 82

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Conclusion

Interesting topics for future research:

◮ Solution of corecursive equations;

Venanzio Capretta Coalgebras in Type Theory

slide-83
SLIDE 83

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Conclusion

Interesting topics for future research:

◮ Solution of corecursive equations; ◮ Tabulations of functions on coinductive domains;

Venanzio Capretta Coalgebras in Type Theory

slide-84
SLIDE 84

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Conclusion

Interesting topics for future research:

◮ Solution of corecursive equations; ◮ Tabulations of functions on coinductive domains; ◮ General recursion and non-standard type theory;

Venanzio Capretta Coalgebras in Type Theory

slide-85
SLIDE 85

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Conclusion

Interesting topics for future research:

◮ Solution of corecursive equations; ◮ Tabulations of functions on coinductive domains; ◮ General recursion and non-standard type theory; ◮ Mixed inductive/coinductive definitions.

Venanzio Capretta Coalgebras in Type Theory

slide-86
SLIDE 86

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

Conclusion

Interesting topics for future research:

◮ Solution of corecursive equations; ◮ Tabulations of functions on coinductive domains; ◮ General recursion and non-standard type theory; ◮ Mixed inductive/coinductive definitions.

There are many other exiting topics.

Venanzio Capretta Coalgebras in Type Theory

slide-87
SLIDE 87

Coalgebras in Type Theory Venanzio Capretta Corecursive Equations CoInductive Types Bisimulations Constructive Infinity Tabulations General Recursion Non-Standard Type Theory Mixing Induction and Coinduction

MSFP

Mathematically Structured Functional Programming Baltimore, 25 September 2010 http://cs.ioc.ee/msfp/msfp2010/ Deadline: 9 - 16 April

Venanzio Capretta Coalgebras in Type Theory