from axiom down to imp
play

From AXIOM down to IMP Dominique Duval with the help of - PowerPoint PPT Presentation

From AXIOM down to IMP Dominique Duval with the help of Jean-Guillaume Dumas, Burak Ekici, Alexis Laouar, Damien Pous, Jean-Claude Reynaud Algebraic Algorithms and Applications Pisa 31 March 2017 Happy birthday Patrizia! AXIOM


  1. From AXIOM down to IMP Dominique Duval with the help of Jean-Guillaume Dumas, Burak Ekici, Alexis Laouar, Damien Pous, Jean-Claude Reynaud Algebraic Algorithms and Applications – Pisa – 31 March 2017 Happy birthday Patrizia!

  2. � AXIOM IMP

  3. � � � DiaLog AXIOM Effects IMP

  4. � � � � DiaLog Th = F ( Sp ) mod Dom Effects and IMP � Th ′ � Th ′′ Th mod ′ mod ′′ mod � Dom ′ � Dom ′′ Dom

  5. Outline Diagrammatic Logics Computational effects Proofs for an IMPerative language

  6. From Axiom to DiaLog AXIOM is (loosely) based on abstract data types (ADT) and algebraic specifications (booleans, integers, lists, ...) [developped by the ADJ group at IBM Research] Question. Can we find a more powerful, more accurate, theoretical basis? ◮ Institutions are too close to algebraic specifications [Goguen, Burstall] ◮ We have proposed the framework of Diagrammatic Logics [Dom´ ınguez, Duval, Lair] “An inference rule is a (categorical) fraction”

  7. � � The modus ponens rule Written AS a fraction A A ⇒ B B “if A implies B and A is true, then B is true” or in two steps: “( A implies B and A is true) if and only if ( A implies B and A is true and B is true), and [obviously] if ( A implies B and A is true and B is true) then ( B is true)” This rule IS a fraction ⊆ ⊇ � { A , A ⇒ B , B } { A , A ⇒ B } { B } if then if and only if

  8. � � � � � Rules as fractions A rule, written AS a fraction H C , actually IS a fraction c h H c h � H ′ c or H C or C h where H ′ = “ H and C ”, with respect to a functor S F � T h � H ′ c • Solid arrows H C are in S F ( h ) − 1 H ′ F ( H ′ ) • Dashed arrow H stands for F ( H ) in T – S is the category of specifications – T is the category of theories – F ( Sp ) is the theory generated by the specification Sp

  9. � Logic as adjunction Definition? A diagrammatic logic is an adjunction F ⊣ G such that the counit F ◦ G ⇒ Id T is an iso, i.e., G is full and faithful F � T S ⊥ G In addition, this adjunction must be “syntactic” Definition! A diagrammatic logic is [determined by] a morphism of limit sketches which simply adds inverses to some arrows.

  10. � ✤ ✤ � � � Models Given a diagrammatic logic A model of Th in Dom is a morphism mod : Th → Dom in T Thus, if Th = F ( Sp ) (i.e., Th is presented by Sp ) then a model of Th in Dom is a morphism mod : Sp → Dom in S F Sp Th = F ( Sp ) mod mod G Dom = G ( Dom ) Dom

  11. � Morphisms as fractions Given a diagrammatic logic if Th 1 = F ( Sp 1 ) and Th 2 = F ( Sp 2 ) then each morphism of theories th : Th 1 → Th 2 is presented by a fraction sp 1 sp 2 � Sp 2 ′ Sp 1 � Sp 2 i.e., th = F ( sp 2 ) − 1 ◦ F ( sp 1 ) F ( sp 2 ) − 1 F ( sp 1 ) � Th 2 ′ � Th 2 Th 1 Example: implementation of the operations in Sp 1 using the operations in Sp 2

  12. Outline Diagrammatic Logics Computational effects Proofs for an IMPerative language

  13. From DiaLog to computational effects There is a simple and powerful notion of morphism of diagrammatic logics. This allows to deal with situations where the syntax and the semantics do not fit. Example. In an imperative language with exceptions, a piece of program p : x → y is interpreted as a partial function � p � : S × � x � ⇀ S × � y � + S × E A computational effect involves several kinds of terms (values and computations, or pure and effectful) and here in addition “A computational effect involves several kinds of equations”

  14. State Our first motivation for building diagrammatic logic was to get a proof system for programs involving states In an imperative language, we can distinguish 3 kinds of terms: – pure terms – accessors or read-only – modifiers or read-write � y in the syntax is interpreted A term x using the set S of states: � y – pure: x � y – read-only: S × x � S × y – read-write: S × x

  15. � � � � � � � � � � � � � � � Denotational semantics of states Models in relevant logics involve the product comonad S × − : S et → S et pure read-only read-write � Im S et Kl S ×− S et ( x → y ) ✤ ( x → y ) ✤ ( x → y ) ❴ ❴ ❴ ( x → y ) ✗ ( S × x → y ) ✘ ( S × x → S × y )

  16. “up-to-state” quasi-equations The rules involve 2 kinds of “equations” on read-write terms: – strong equations: f 1 ≡ f 2 : x → y , interpreted as f 1 = f 2 : S × x → S × y – “up-to-state” quasi-equations: f 1 ∼ f 2 : x → y , interpreted as pr ◦ f 1 = pr ◦ f 2 : S × x → y with different rules: – strong equations form a congruence: an equivalence relation compatible with composition: g 1 ≡ g 2 h ◦ g 1 ◦ f ≡ h ◦ g 2 ◦ f – “up-to-state” quasi-equations form a “weak” congruence: an equivalence relation “weakly” compatible with composition: g 1 ∼ g 2 h ( pure ) ◦ g 1 ◦ f ∼ h ( pure ) ◦ g 2 ◦ f

  17. Operations on states Let Loc = { X , Y , ... } be the set of locations (or “variables”) (assumed of type integer Z ) – lookup X : 1 → Z is an accessor – update X : Z → 1 is a modifier Quasi-equations: � lookup X ◦ update X ∼ id Z lookup Y ◦ update X ∼ lookup Y (if Y � = X ) Interpretation as required, when S = Z Loc = � X ∈ Loc Z – � lookup X � : S → Z such that s �→ s ( X ) – � update X � : S × Z → S such that ( s , n ) �→ s [ n / X ]

  18. States and exceptions: duality Then we realized that by duality from states we get a proof system for programs involving exceptions We distinguish 3 kinds of terms: – pure terms – propagators (that may throw and must propagate exceptions) – catchers (that may recover from exceptions) � y in the syntax is interpreted A term x using the set E of exceptions: � y – pure: x � y + E – propagator: x � y + E – catcher: x + E

  19. � � � � � � � � � � � � � � � Denotational semantics of exceptions Models in relevant logics involve the coproduct monad − + E : S et → S et pure propagator catcher � Im S et Kl − + E S et ( x → y ) ✤ ( x → y ) ✤ ( x → y ) ❴ ❴ ❴ ( x → y ) ✗ ( x → y + E ) ✘ ( x + E → y + E )

  20. “up-to-exceptions” quasi-equations The rules involve 2 kinds of “equations” on catchers: – strong equations: f 1 ≡ f 2 : x → y , interpreted as f 1 = f 2 : x + E → y + E – “up-to-exceptions” quasi-equations: f 1 ∼ f 2 : x → y , interpreted as f 1 ◦ in = f 2 ◦ in : x → y + E with different rules: – strong equations form a congruence: an equivalence relation compatible with composition: g 1 ≡ g 2 h ◦ g 1 ◦ f ≡ h ◦ g 2 ◦ f – “up-to-exceptions” quasi-equations form a “weak” congruence: an equivalence relation “weakly” compatible with composition: g 1 ∼ g 2 h ◦ g 1 ◦ f ( pure ) ∼ h ◦ g 2 ◦ f ( pure )

  21. Operations on exceptions Let Exc = { e , e ′ , ... } be the set of exception names (assumed with parameter of type integer Z ) – tag e : Z → 0 is a propagator – untag e : 0 → Z is a catcher Equations: � untag e ◦ tag e ∼ id Z untag e ◦ tag e ′ ∼ tag e ′ (if e ′ � = e ) Then tag e and untag e have to be encapsulated for getting the required throw and try / catch constructions

  22. � � � � What is a computational effect? Effect = strong monad [Moggi] Effect = Lawvere theory [Plotkin, Power, Hyland] Effect = ?? I do not know... Some features appear: – several kinds of terms – several kinds of “quasi-equations” Th (0) Th (1) ... mod (0) mod (1) � Dom (1) � ... Dom (0) Combinaison of effects may look systematic by composition, but combinaison of quasi-equations is not systematic

  23. Outline Diagrammatic Logics Computational effects Proofs for an IMPerative language

  24. From computational effects to IMP Goal. Design a proof assistant for imperative or object-oriented languages (based on Coq, for example) – close to the syntax – for proving equivalence of parts of programs A case study. The basic IMPerative language IMP: with the state effect [and IMP-EX: with the state and the exceptions effects] Actually, it is convenient to “Consider conditionals and loops as effects”

  25. IMP syntax IMP is a very simple IMPerative language Loc = { X , Y , ... } is the set of locations (or “variables”) Expressions: a ::= 0 | 1 | − 1 | ... | X | Y | ... | a + a | ... b ::= true | false | b ∧ b | ... | a = a | ... Commands: c ::= skip | c ; c | X := a | if b then c else c | while b do c

  26. � � � � IMP syntax, categorically: expressions • “types” A , B as objects, • “type” unit or void as initial object 1 • expressions as arrows • binary operations using products a � A or 1 b � B EXPRESSION a or b 1 binary operation a 1 + a 2 A a 1 = + � A 2 � A 1 = a 2 A

  27. � � � IMP syntax, categorically: commands • commands as arrows • conditionals using coproducts c � 1 COMMAND c 1 id � 1 do-nothing skip 1 c 1 c 2 � 1 � 1 sequence c 1 ; c 2 1 a X := � 1 � A assignment X := a 1 conditional if b then c 1 else c 2 1 c 1 true � = 1 b � B � 1 = false c 2 1

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