Foundational Extensible Corecursion Jasmin Blanchette Andrei - - PowerPoint PPT Presentation

foundational extensible corecursion
SMART_READER_LITE
LIVE PREVIEW

Foundational Extensible Corecursion Jasmin Blanchette Andrei - - PowerPoint PPT Presentation

Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel Foundational Extensible Corecursion Jasmin Blanchette Andrei Popescu Dmitriy Traytel Am I Productive? s = 0 : s primitive corecusion s = 0 : s primitive


slide-1
SLIDE 1

Foundational Extensible Corecursion

Jasmin Blanchette Andrei Popescu Dmitriy Traytel

slide-2
SLIDE 2

Foundational Extensible Corecursion

Jasmin Blanchette Andrei Popescu Dmitriy Traytel

slide-3
SLIDE 3

Am I Productive?

slide-4
SLIDE 4

s = 0 : s

primitive corecusion

slide-5
SLIDE 5

s = 0 : s

primitive corecusion

slide-6
SLIDE 6

s = 0 : tail s

tail evil

slide-7
SLIDE 7

s = 0 : tail s

tail evil

slide-8
SLIDE 8

s = 0 : 1 : s

corecursion up to constructors

slide-9
SLIDE 9

s = 0 : 1 : s

corecursion up to constructors

slide-10
SLIDE 10

eo s = head s : eo (tail (tail s))

primitive corecusion

slide-11
SLIDE 11

eo s = head s : eo (tail (tail s))

primitive corecusion

slide-12
SLIDE 12

s = 0 : 1 : eo s

eo evil

slide-13
SLIDE 13

s = 0 : 1 : eo s

eo evil

slide-14
SLIDE 14

s ⊕ t = (head s + head t) : (tail s ⊕ tail t)

primitive corecusion

slide-15
SLIDE 15

s ⊕ t = (head s + head t) : (tail s ⊕ tail t)

primitive corecusion

slide-16
SLIDE 16

s ⊗ t = (head s * head t) : (tail s ⊗ t ⊕ s ⊗ tail t) corecursion up to ⊕

slide-17
SLIDE 17

s ⊗ t = (head s * head t) : (tail s ⊗ t ⊕ s ⊗ tail t) corecursion up to ⊕

slide-18
SLIDE 18

s = (0 : 1 : s) ⊕ (0 : s)

corecursion up to constructors and ⊕

slide-19
SLIDE 19

s = (0 : 1 : s) ⊕ (0 : s)

corecursion up to constructors and ⊕

slide-20
SLIDE 20

s n = if n > 0 then s (n - 1) ⊕ (0 : s (n + 1)) else 1 : s 1

mixed recursion/corecursion up to ⊕

slide-21
SLIDE 21

s n = if n > 0 then s (n - 1) ⊕ (0 : s (n + 1)) else 1 : s 1

mixed recursion/corecursion up to ⊕

slide-22
SLIDE 22

Contribution

Foundationalframework for

definingall the green stuffand more

slide-23
SLIDE 23

Contribution

Foundationalframework for

definingall the green stuffand more in an LCF-style proof assistant

   

slide-24
SLIDE 24

Contribution

Foundationalframework for

definingall the green stuffand more in an LCF-style proof assistant

   

Burden on the user: prove

  

parametricity

  • r

termination

   here and there

slide-25
SLIDE 25

Contribution

Foundationalframework for

definingall the green stuffand more in an LCF-style proof assistant

   

Burden on the user: prove

  

parametricity

  • r

termination

   here and there

Most of the time: automatic

slide-26
SLIDE 26

Context

LCF Philosophy: Reduce everything to a small trusted kernel

Kernel of

≈           

simply typed lambda calculus+ classical higher-order logic (axioms)+ nonrecursive constant definition+ nonrecursive type definition

slide-27
SLIDE 27

Context

LCF Philosophy: Reduce everything to a small trusted kernel

Kernel of

≈           

simply typed lambda calculus+ classical higher-order logic (axioms)+ nonrecursive constant definition+ nonrecursive type definition Our agenda make Isabelle/HOL a (co)recursion-friendly environment LICS’12 ITP’14 IJCAR’14 ESOP’15 ICFP’15

slide-28
SLIDE 28

Related Work

A lot

slide-29
SLIDE 29

Related Work

Guarded Coprogramming/Proof Assistants

Isabelle primitive corecursion corecursor

slide-30
SLIDE 30

Related Work

Guarded Coprogramming/Proof Assistants

Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in

slide-31
SLIDE 31

Related Work

Guarded Coprogramming/Proof Assistants

Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in Agda copatterns + sized types built-in + type system

slide-32
SLIDE 32

Related Work

Guarded Coprogramming/Proof Assistants

Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in Agda copatterns + sized types built-in + type system

  • FRP (Krishnaswami & Benton, ...)

type system

  • clocks (Atkey & McBride)

type system

  • guards (Clouston et al.)

type system

slide-33
SLIDE 33

Related Work

Guarded Coprogramming/Proof Assistants

Isabelle primitive corecursion corecursor Coq corecursion up-to constructors built-in Agda copatterns + sized types built-in + type system

  • FRP (Krishnaswami & Benton, ...)

type system

  • clocks (Atkey & McBride)

type system

  • guards (Clouston et al.)

type system Isabelle’ corecursion up-to friendly operations smart corecursor mixed with recursion + wellfounded recursion

slide-34
SLIDE 34

Primitive Corecursor

codatatype Stream = Int : Stream

slide-35
SLIDE 35

Primitive Corecursor

codatatype Stream = Int : Stream

– Stream ˜

= gfp (Int ×−)

– corecP :: (A → Int × A) → A → Stream

slide-36
SLIDE 36

Primitive Corecursor

codatatype Stream = Int : Stream

– Stream ˜

= gfp (Int ×−)

– corecP :: (A → Int × A) → A → Stream

primcorec s ⊕ t = (head s + head t) : (tail s ⊕ tail t)

slide-37
SLIDE 37

Primitive Corecursor

codatatype Stream = Int : Stream

– Stream ˜

= gfp (Int ×−)

– corecP :: (A → Int × A) → A → Stream

primcorec s ⊕ t = (head s + head t) : (tail s ⊕ tail t)

– s ⊕ t=corecP (λ(s,t). ((head s + head t) , (tail s , tail t))) (s,t)

slide-38
SLIDE 38

Primitive Corecursor

codatatype C = ···

– C ˜

= gfp F

– corecP :: (A → F A) → A → C

primcorec f x =

···

– f x=corecP (λ(x). ···) (x)

(Assuming F is a bounded natural functor)

slide-39
SLIDE 39

Smart Corecursor corecP :: (A → F A) → A → C

slide-40
SLIDE 40

Smart Corecursor corecP :: (A → F A) → A → C corecS

0 :: (A →

(F (

A))) → A → C

slide-41
SLIDE 41

Smart Corecursor corecP :: (A → F A) → A → C corecS

0 :: (A →

(F (

A))) → A → C corecS

1 :: (A → ⊕ (F (⊕ A))) → A → C

slide-42
SLIDE 42

Smart Corecursor corecP :: (A → F A) → A → C corecS

0 :: (A →

(F (

A))) → A → C corecS

1 :: (A → ⊕ (F (⊕ A))) → A → C

corec s ⊗ t = (head s ∗ head t) : (tail s ⊗ t ⊕ s ⊗ tail t)

– s ⊗ t=corecS

1 (λ(s,t).

η((head s ∗ head t) , η(tail s, t)⊕η(s, tail t))) (s,t)

– ⊕ :: ⊕ A → ⊕ A → ⊕ A – η :: A → ⊕ A

slide-43
SLIDE 43

Smart Corecursor corecP :: (A → F A) → A → C corecS

0 :: (A →

(F (

A))) → A → C corecS

1 :: (A → ⊕ (F (⊕ A))) → A → C

corecS

2 :: (A → ⊕

⊗ (F (⊕ ⊗ A))) → A → C

corec s ⊗ t = (head s ∗ head t) : (tail s ⊗ t ⊕ s ⊗ tail t)

– s ⊗ t=corecS

1 (λ(s,t).

η((head s ∗ head t) , η(tail s, t)⊕η(s, tail t))) (s,t)

– ⊕ :: ⊕ A → ⊕ A → ⊕ A – η :: A → ⊕ A

slide-44
SLIDE 44

⊗ :: C → C → C has to be friendly

A friendly function can destroy

  • ne constructor to produce

at least one constructor.

slide-45
SLIDE 45

⊗ :: C → C → C has to be friendly

∃ parametric ρ⊗ :: (A× F A) → (A× F A) → F (⊕ ⊗ A) s.t.

s ⊗ t = ··· (ρ⊗ (··· (s, t)))

slide-46
SLIDE 46

⊗ :: C → C → C has to be friendly

∃ parametric ρ⊗ :: (A× F A) → (A× F A) → F (⊕ ⊗ A) s.t.

s ⊗ t = ··· (ρ⊗ (··· (s, t)))

ρ⊗ :: (A×(Int × A)) → (A×(Int × A)) → (Int × ⊕ ⊗ A) ρ⊗ (s, hs, ts) (t, ht, tt) = (hs ∗ ht, η ts ⊗η t ⊕ η s ⊗η tt)

slide-47
SLIDE 47

In the paper

slide-48
SLIDE 48

In the paper

slide-49
SLIDE 49

In the paper

slide-50
SLIDE 50

In the paper In the meantime

slide-51
SLIDE 51

In the paper In the meantime Coq constructor+ Agda constructor+ · arbitrary (manual proofs) Isabelle friendly∗ · constructor · friendly∗ (auto proofs)

Thanksforlistening! Questions?

slide-52
SLIDE 52

Foundational Extensible Corecursion

Jasmin Blanchette Andrei Popescu Dmitriy Traytel

What is s 1?

s n = if n > 0 then s (n - 1) ⊕ (0 : s (n + 1)) else 1 : s 1