comodules over relative comonads for streams and infinite
play

Comodules over relative comonads for streams and infinite matrices - PowerPoint PPT Presentation

Comodules over relative comonads for streams and infinite matrices R egis Spadotti joint work with Benedikt Ahrens Institut de Recherche en Informatique de Toulouse Universit e Paul Sabatier types 2014 B. Ahrens and R. Spadotti


  1. Comodules over relative comonads for streams and infinite matrices R´ egis Spadotti joint work with Benedikt Ahrens Institut de Recherche en Informatique de Toulouse Universit´ e Paul Sabatier types 2014 B. Ahrens and R. Spadotti Comodules over relative comonads 1/28

  2. Goal • Category-theoretic semantics of co inductive data types in intensional Martin-L¨ of type theory (IMLTT) � Develop a notion of “coalgebra” for the signature of a codata type • Incorporate canonical cosubstitution B. Ahrens and R. Spadotti Comodules over relative comonads 2/28

  3. Outline 1 Syntax: inductives and substitution 2 Homogeneous cosyntax: streams 3 Heterogeneous cosyntax: infinite triangular matrices B. Ahrens and R. Spadotti Comodules over relative comonads 3/28

  4. Outline 1 Syntax: inductives and substitution 2 Homogeneous cosyntax: streams 3 Heterogeneous cosyntax: infinite triangular matrices B. Ahrens and R. Spadotti Comodules over relative comonads 4/28

  5. Heterogeneous data types Motivation: binding syntax in MLTT Lc : Type → Type s , t : Lc X t : Lc( X + 1) x : X var( x ) : Lc( X ) app( s , t ) : Lc X abs( t ) : Lc X Heterogeneity of abs : recursive argument with bigger parameter X + 1 Substitution: � � subst X , Y : X → Lc Y → Lc X → Lc Y Avoiding capture: � � shift X , Y : X → Lc Y → X + 1 → Lc( Y + 1) B. Ahrens and R. Spadotti Comodules over relative comonads 5/28

  6. Initial semantics for binding syntax Initial semantics for lambda calculus: Fiore, Plotkin & Turi ’99 • characterizes not only data type but also substitution • reformulated using monads by Hirschowitz & Maggesi ’07 Basis for this reformulation: Lemma (Substitution is monadic: Altenkirch & Reus ’99) (Lc , var , subst) forms a monad (in Kleisli form) B. Ahrens and R. Spadotti Comodules over relative comonads 6/28

  7. Initial semantics for λ -calculus using monads Definition (Algebra for signature of Lc , H & M ’07) • a monad ( T , unit , bind) on Type • two morphisms of modules over T , App : T × T → T Abs : T ( + 1) → T B. Ahrens and R. Spadotti Comodules over relative comonads 7/28

  8. Initial semantics for λ -calculus using monads Definition (Algebra for signature of Lc , H & M ’07) • a monad ( T , unit , bind) on Type • two morphisms of modules over T , App : T × T → T Abs : T ( + 1) → T “Module morphism” expresses commutativity with bind : App ◦ (bind f ) 2 bind f ◦ App = bind f ◦ Abs = Abs ◦ bind (shift f ) B. Ahrens and R. Spadotti Comodules over relative comonads 7/28

  9. Initial semantics for λ -calculus using monads Definition (Algebra for signature of Lc , H & M ’07) • a monad ( T , unit , bind) on Type • two morphisms of modules over T , App : T × T → T Abs : T ( + 1) → T “Module morphism” expresses commutativity with bind : App ◦ (bind f ) 2 bind f ◦ App = bind f ◦ Abs = Abs ◦ bind (shift f ) Lemma (Initial semantics for Lc , H & M ’07) (Lc , app , abs) is the initial algebra, where Lc = (Lc , var , subst) B. Ahrens and R. Spadotti Comodules over relative comonads 7/28

  10. Goal: characterize co data types with co substitution Goal dualize techniques of H & M to characterize • co data types in intensional ML type theory with • co substitution as final object In this talk • streams • infinite triangular matrices B. Ahrens and R. Spadotti Comodules over relative comonads 8/28

  11. Outline 1 Syntax: inductives and substitution 2 Homogeneous cosyntax: streams 3 Heterogeneous cosyntax: infinite triangular matrices B. Ahrens and R. Spadotti Comodules over relative comonads 9/28

  12. Streams over a base type • Streams = infinite lists over some base type A . . . a 0 a 1 a 2 head tail • Specified by destructors s : Stream A s : Stream A head A ( s ) : A tail A ( s ) : Stream A • Propositional equality is not adequate for infinite object � bisimulation B. Ahrens and R. Spadotti Comodules over relative comonads 10/28

  13. Axioms for streams • Formation rules Stream : Type → Type ∼ : Stream A → Stream A → Prop • Destructors � head , tail � : Stream A → A × Stream A ∼ head : s 1 ∼ s 2 → head s 1 = head s 2 ∼ tail : s 1 ∼ s 2 → tail s 1 ∼ tail s 2 coiter T : ( T → A × T ) → T → Stream A • Coiterator bisim R : R ⊆ R on � head , tail � → R ⊆ ∼ head(coiter T f t ) = π 1 ( f t ) • Computation tail(coiter T f t ) ∼ coiter T f ( π 2 ( f t )) B. Ahrens and R. Spadotti Comodules over relative comonads 11/28

  14. Axioms for streams • Formation rules Stream : Type → Type ∼ : Stream A → Stream A → Prop • Destructors � head , tail � : Stream A → A × Stream A ∼ head : s 1 ∼ s 2 → head s 1 = head s 2 ∼ tail : s 1 ∼ s 2 → tail s 1 ∼ tail s 2 coiter T : ( T → A × T ) → T → Stream A • Coiterator bisim R : R ⊆ R on � head , tail � → R ⊆ ∼ head(coiter T f t ) = π 1 ( f t ) • Computation tail(coiter T f t ) ∼ coiter T f ( π 2 ( f t )) Provable with Coq coinductive type definitions B. Ahrens and R. Spadotti Comodules over relative comonads 11/28

  15. Structure on streams • (Stream A , ∼ ) is a setoid , Stream : Type → Setoid • Canonical cosubstitution cosubst A , B : (Stream A → B ) → Stream A → Stream B is compatible with bisimilarity: cosubst A , B : Setoid(Stream A , eq B ) → Setoid(Stream A , Stream B ) with eq : Type → Setoid eq ⊣ forget B. Ahrens and R. Spadotti Comodules over relative comonads 12/28

  16. Structure on streams Lemma (Stream , head , cosubst) is a comonad relative to eq : Type → Setoid . Definition ( Relative (co)monad, Alten., Chapm. & Uust. ’10) • underlying functor is not necessarily endo • needs “mediating” functor (above: eq ) B. Ahrens and R. Spadotti Comodules over relative comonads 13/28

  17. About the destructor tail Morphisms of modules over monads characterize commutativity of substitution with constructors app : Lc × Lc → Lc subst f ◦ app = app ◦ (subst f ) 2 Morphisms of co modules over relative co monads characterize commutativity of co substitution with destructors tail : Stream → Stream tail ◦ cosubst f = cosubst f ◦ tail B. Ahrens and R. Spadotti Comodules over relative comonads 14/28

  18. Final semantics for Stream Definition (Category of coalgebras) A coalgebra for the signature of Stream is given by a pair ( S , t ) : • a comonad S relative to eq : Type → Setoid • a morphism of comodules over S t : S → S Morphisms: . . . Lemma (Stream , tail) is the final object in the above category. B. Ahrens and R. Spadotti Comodules over relative comonads 15/28

  19. Outline 1 Syntax: inductives and substitution 2 Homogeneous cosyntax: streams 3 Heterogeneous cosyntax: infinite triangular matrices B. Ahrens and R. Spadotti Comodules over relative comonads 16/28

  20. An example of cosyntax: infinite triangular matrices Tri : the codata type of infinite triangular matrices • omit redundant information below the diagonal • have a variable type A of diagonal elements • e.g. invertible elements • a fixed type E of elements for rest of matrix • usage: Pascal matrices (binomial coefficients), mathematical physics (infinite-dim. problems) A E E E . . . A E E A E A B. Ahrens and R. Spadotti Comodules over relative comonads 17/28

  21. Matrices through trapezia: the destructors of Tri A E E E t : Tri A . . . A E E top A ( t ) : A A E A E E E E t : Tri A A E E E rest A ( t ) : Tri( E × A ) . . . A E E A E A B. Ahrens and R. Spadotti Comodules over relative comonads 18/28

  22. Matrices through trapezia: the destructors of Tri A E E E t : Tri A . . . A E E top A ( t ) : A A E A E × A E E E t : Tri A E × A E E rest A ( t ) : Tri( E × A ) . . . E × A E E × A B. Ahrens and R. Spadotti Comodules over relative comonads 18/28

  23. Redecoration redec A , B : (Tri A → B ) → (Tri A → Tri B ) f : Tri A → B A E E E B E E E . . . . . . A E E B E E A E B E A B top ◦ redec f := f and rest ◦ redec f := redec (lift f ) ◦ rest with lift f : Tri( E × A ) → E × B B. Ahrens and R. Spadotti Comodules over relative comonads 19/28

  24. Tri is a weak constructive comonad Sameness = bisimilarity Bisimilarity ∼ coinductively defined via destructors t ∼ t ′ t ∼ t ′ top( t ) = top( t ′ ) rest( t ) ∼ rest( t ′ ) Lemma (Matthes and Picard ’11) (Tri : Type → Type , top , redec) forms a “weak constructive comonad”. � “weak constructive” refers to compatibility conditions with bisimilarity B. Ahrens and R. Spadotti Comodules over relative comonads 20/28

  25. Tri is a relative comonad Alternatively, Tri A is a setoid rather than a (plain) type top A : Setoid(Tri A , eq A ) redec A , B : Setoid(Tri A , eq B ) → Setoid(Tri A , Tri B ) with eq : Type → Setoid B. Ahrens and R. Spadotti Comodules over relative comonads 21/28

  26. Tri is a relative comonad Alternatively, Tri A is a setoid rather than a (plain) type top A : Setoid(Tri A , eq A ) redec A , B : Setoid(Tri A , eq B ) → Setoid(Tri A , Tri B ) with eq : Type → Setoid Lemma (Reformulation of Matthes and Picard ’11) (Tri : Type → Setoid , top , redec) forms a comonad relative to eq : Type → Setoid . B. Ahrens and R. Spadotti Comodules over relative comonads 21/28

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend