Verification of Redecoration for Infinite Triangular Matrices in Coq - - PowerPoint PPT Presentation

verification of redecoration for infinite triangular
SMART_READER_LITE
LIVE PREVIEW

Verification of Redecoration for Infinite Triangular Matrices in Coq - - PowerPoint PPT Presentation

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion Verification of Redecoration for Infinite Triangular Matrices in Coq Celia Picard joint work with Ralph Matthes 13/09/2012 13/09/2012


slide-1
SLIDE 1

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Verification of Redecoration for Infinite Triangular Matrices in Coq

Celia Picard joint work with Ralph Matthes 13/09/2012

13/09/2012 Celia Picard Redecoration for Infinite Triangles 1/20

slide-2
SLIDE 2

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Introduction

The finite case: finite triangles seen as triangular matrices

E E E E E E A A A A . . . Type E fixed throughout Special type A for elements of the diagonal Inductive family Trifin A

13/09/2012 Celia Picard Redecoration for Infinite Triangles 2/20

slide-3
SLIDE 3

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Introduction

The finite case: definitions

Triangles and trapeziums E E E E E E A A A A E E E E . . . E E E E E E E × A E × A E × A E × A . . . triangle trapezium Formal definition a : A sgfin a : Trifin A a : A t : Trifin(E × A) constrfin a t : Trifin A

13/09/2012 Celia Picard Redecoration for Infinite Triangles 3/20

slide-4
SLIDE 4

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Introduction

The finite case: redecoration

E E E E E E A A A A . . . E E E E E E B B B B . . . f

Verifications of redecoration: against a list-based model comonad laws All details in:

[A. Abel, R. Matthes, and T. Uustalu. Iteration and coiteration schemes for higher-order and nested datatypes. Theoretical Computer Science 2005] [R. Matthes and M. Strecker. Verification of the redecoration algorithm for triangular matrices. TYPES 2007]

13/09/2012 Celia Picard Redecoration for Infinite Triangles 4/20

slide-5
SLIDE 5

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Outline

1

Reference Representation with a Coinductive Family

2

Another Conception of Triangles

3

Conclusion

13/09/2012 Celia Picard Redecoration for Infinite Triangles 5/20

slide-6
SLIDE 6

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Outline

1

Reference Representation with a Coinductive Family Definitions Redecoration Properties of redecoration

2

Another Conception of Triangles

3

Conclusion

13/09/2012 Celia Picard Redecoration for Infinite Triangles 6/20

slide-7
SLIDE 7

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Reference Representation with a Coinductive Family

Definitions

Definition of the infinite triangles a : A t : Tri(E × A) constr a t : Tri A Trap A = Tri(E × A) Projections and function cut E E E E E E A A A A . . . rest top cut top : ∀A. Tri A → A top (constr a r) := a rest : ∀A. Tri A → Trap A rest (constr a r) := r cut (constr e, a r) := constr a (cut r) top: counit of the comonad (signature)

13/09/2012 Celia Picard Redecoration for Infinite Triangles 7/20

slide-8
SLIDE 8

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Outline

1

Reference Representation with a Coinductive Family Definitions Redecoration Properties of redecoration

2

Another Conception of Triangles

3

Conclusion

13/09/2012 Celia Picard Redecoration for Infinite Triangles 8/20

slide-9
SLIDE 9

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Reference Representation with a Coinductive Family

Redecoration

The lift operation

E E E E E E A A A

. . .

E × B id f lift : ∀A∀B. (Tri A → B) → Tri(E × A) → E × B lift f r := fst(top r), f(cut r)

The redec operation

E E E E E E A A A A

. . .

E E E E E E B B B B

. . .

f

redec (lift f) redec : ∀A∀B. (Tri A → B) → Tri A → Tri B redec f t := constr (f t)

  • redec (lift f)

(rest t)

  • 13/09/2012

Celia Picard Redecoration for Infinite Triangles 9/20

slide-10
SLIDE 10

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Outline

1

Reference Representation with a Coinductive Family Definitions Redecoration Properties of redecoration

2

Another Conception of Triangles

3

Conclusion

13/09/2012 Celia Picard Redecoration for Infinite Triangles 10/20

slide-11
SLIDE 11

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Reference Representation with a Coinductive Family

Properties of redecoration – New tools on Tri

Equivalence relation on Tri and associated result

t1 , t2 : Tri A top t1 = top t2 rest t1 ≃ rest t2 t1 ≃ t2 ∀A∀B∀(f f ′ : Tri A → B). (∀t, f t = f ′ t) ⇒ ∀t, redec f t ≃ redec f ′ t with full extensionality of lift.

New tools to manipulate Tri

E E E E E E A A A A

. . .

r t es_cut r frow t es_cut : ∀A. Trap A → Str E es_cut (constr e, a r) := e :: (es_cut r) frow : ∀A. Tri A → Str E frow t := es_cut (rest t) addes : ∀A. Str E → Tri A → Trap A addes (e :: es) (constr a r) := constr e, a (addes es r) ∀A∀(r : Trap A). addes (es_cut r) (cut r) ≃ r

13/09/2012 Celia Picard Redecoration for Infinite Triangles 11/20

slide-12
SLIDE 12

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Reference Representation with a Coinductive Family

Properties of redecoration – Comonad

Comonad laws ∀A∀B∀f Tri A→B∀tTri A. top(redec f t) = f t (1) ∀A∀tTri A. redec top t ≃ t (2) ∀A∀B∀f Tri A→B∀gTri B→C∀tTri A. redec (g ◦ redec f) t ≃ redec g (redec f t) (3) Application to Tri The type transformation Tri, the projection function top (counit) and redec (cobind) form a constructive weak comonad w. r. t. ≃. Weak: compatibility of g in (3) required. Proved with a stronger form of (2): ∀A∀(f : Tri A → A). (∀(t : Tri A), f t = top t) ⇒ ∀(t : Tri A). redec f t ≃ t (2’)

13/09/2012 Celia Picard Redecoration for Infinite Triangles 12/20

slide-13
SLIDE 13

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Outline

1

Reference Representation with a Coinductive Family

2

Another Conception of Triangles Definitions Redecoration

3

Conclusion

13/09/2012 Celia Picard Redecoration for Infinite Triangles 13/20

slide-14
SLIDE 14

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Definitions (1/2)

New visualization E E E E E E A A A A . . . Tri′ A := Str(A × Str E) The three parts of the definition E E E E E E A A A A . . . top′ frow′ rest′ top′ : ∀A. Tri′ A → A top′ (a, es :: t) := a frow′ : ∀A. Tri′ A → Str E frow′ (a, es :: t) := es rest′ : ∀A. Tri′ A → Tri′ A rest′ (a, es :: t) := t

13/09/2012 Celia Picard Redecoration for Infinite Triangles 14/20

slide-15
SLIDE 15

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Definitions (2/2)

Equivalence relation

t1 , t2 : Tri′ A top′ t1 = top′ t2 frow′ t1 ≡ frow′ t2 rest′ t1 ∼ = rest′ t2 t1 ∼ = t2

with ≡ relation on Str (cannot use it directly) Conversion functions to/from Tri Tri Tri′ toStrRep fromStrRep

∀A∀(t : Tri′ A). toStrRep (fromStrRep t) ∼ = t ∀A∀(t : Tri A). fromStrRep (toStrRep t) ≃ t

13/09/2012 Celia Picard Redecoration for Infinite Triangles 15/20

slide-16
SLIDE 16

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Outline

1

Reference Representation with a Coinductive Family

2

Another Conception of Triangles Definitions Redecoration

3

Conclusion

13/09/2012 Celia Picard Redecoration for Infinite Triangles 16/20

slide-17
SLIDE 17

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Redecoration

Definition – Much simpler than redec E E E E E E A A A A

. . .

E E E E E E B B B B

. . .

f redec′ f id redec′ : ∀A∀B. (Tri′ A → B) → Tri′ A → Tri′ B redec′ f t := f t, frow′ t :: redec′ f (rest′ t) Results ∀f t, (∀t t′, t ∼ = t′ ⇒ f t = f t′) ⇒ redec′ f t ∼ = toStrRep (redec (f ◦ toStrRep) (fromStrRep t)) ∀f t, (∀t t′, t ≃ t′ ⇒ f t = f t′) ⇒ redec f t ≃ fromStrRep (redec′ (f ◦ fromStrRep) (toStrRep t))

13/09/2012 Celia Picard Redecoration for Infinite Triangles 17/20

slide-18
SLIDE 18

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Simplifying again

E E E E E E A A A A

. . .

E E E E E E

E A A A A

. . .

E E E A A A

. . .

E E E E E E A A

. . .

  • A. . .

. . .

E E E E E E B B B B

. . .

1st step 2nd step E E E E E E A A A A

. . .

  • E

A A A A

. . . ;

E E E A A A

. . . ;

E E E E E E A A

. . . ;

A . . .

;. . . E E E E E E B B B B

. . .

tails map (lift′ f) tails : ∀A. Str A → Str(Str A) lift′ : ∀A∀B. (Tri′ A → B) → Tri′ A → B × Str E tails s := s :: tails (tl s) lift′ f := λx.f x, frow′ x redec′

alt : ∀A∀B. (Tri′ A → B) → Tri′ A → Tri′ B

redec′

alt f t := map (lift′ f) (tails t)

redec′ f t ≡ redec′

alt f t

13/09/2012 Celia Picard Redecoration for Infinite Triangles 18/20

slide-19
SLIDE 19

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Simplifying again

E E E E E E A A A A

. . .

E E E E E E

E A A A A

. . .

E E E A A A

. . .

E E E E E E A A

. . .

  • A. . .

. . .

E E E E E E B B B B

. . .

1st step 2nd step E E E E E E A A A A

. . .

  • E

A A A A

. . . ;

E E E A A A

. . . ;

E E E E E E A A

. . . ;

A . . .

;. . . E E E E E E B B B B

. . .

tails map (lift′ f) tails : ∀A. Str A → Str(Str A) lift′ : ∀A∀B. (Tri′ A → B) → Tri′ A → B × Str E tails s := s :: tails (tl s) lift′ f := λx.f x, frow′ x redec′

alt : ∀A∀B. (Tri′ A → B) → Tri′ A → Tri′ B

redec′

alt f t := map (lift′ f) (tails t)

redec′ f t ≡ redec′

alt f t

13/09/2012 Celia Picard Redecoration for Infinite Triangles 18/20

slide-20
SLIDE 20

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Simplifying again

E E E E E E A A A A

. . .

E E E E E E

E A A A A

. . .

E E E A A A

. . .

E E E E E E A A

. . .

  • A. . .

. . .

E E E E E E B B B B

. . .

1st step 2nd step E E E E E E A A A A

. . .

  • E

A A A A

. . . ;

E E E A A A

. . . ;

E E E E E E A A

. . . ;

A . . .

;. . . E E E E E E B B B B

. . .

tails map (lift′ f) tails : ∀A. Str A → Str(Str A) lift′ : ∀A∀B. (Tri′ A → B) → Tri′ A → B × Str E tails s := s :: tails (tl s) lift′ f := λx.f x, frow′ x redec′

alt : ∀A∀B. (Tri′ A → B) → Tri′ A → Tri′ B

redec′

alt f t := map (lift′ f) (tails t)

redec′ f t ≡ redec′

alt f t

13/09/2012 Celia Picard Redecoration for Infinite Triangles 18/20

slide-21
SLIDE 21

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Another Conception of Triangles

Generalizing

Generalizing redecoration (redecoration on Str) redec′

gen : ∀A∀B. (Str A → B) → Str A → Str B

redec′

gen f s := map f (tails s)

∀A∀B∀(f : Tri′ A → B)(t : Tri′ A). redec′

alt f t = redec′ gen (lift′ f) t

Comonads The type transformation Str, the projection function hd and redec′

gen form a constructive comonad with respect to ≡

The type transformation Tri′, the projection function top′ and redec′

alt form a constructive comonad with respect to

≡ (more precisely, the equivalence relation is ≡A×Str E for every A) – stronger result than before

13/09/2012 Celia Picard Redecoration for Infinite Triangles 19/20

slide-22
SLIDE 22

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Conclusion

Redecoration for infinite triangles:

dualized directly from representation of finite triangles:

columnwise visualization tricky algorithm for redec (polymorphic recursion) constructive weak comonad

representation with streams:

row-wise visualization purely coinductive simple versions of redecoration constructive comonad

Easier to work on totally infinite structure than with partially finite ones. Even easier than finite triangles. www.irit.fr/~Celia.Picard/Coq/Redecoration/

13/09/2012 Celia Picard Redecoration for Infinite Triangles 20/20

slide-23
SLIDE 23

Introduction Reference Representation with a Coinductive Family Another Conception of Triangles Conclusion

Conclusion

Redecoration for infinite triangles:

dualized directly from representation of finite triangles:

columnwise visualization tricky algorithm for redec (polymorphic recursion) constructive weak comonad

representation with streams:

row-wise visualization purely coinductive simple versions of redecoration constructive comonad

Easier to work on totally infinite structure than with partially finite ones. Even easier than finite triangles. www.irit.fr/~Celia.Picard/Coq/Redecoration/ Thanks for your attention.

13/09/2012 Celia Picard Redecoration for Infinite Triangles 20/20