00:00

Gradual Propositional Equality in Programming Languages

This research explores the application of gradual typing to enhance equational specification checking between compile time and run time. It discusses the challenges of including propositional equality in a gradual language without disrupting the metatheory, focusing on gradual run-time checks and maintaining correctness while accommodating gradual changes. The study also delves into single constructor reflexivity, transport functions for preserving witness information, and the design aspects necessary for safety and conservativeness in programming languages.

baget
Download Presentation

Gradual Propositional Equality in Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Joseph Eremondi, University of British Columbia Ronald Garcia, University of British Columbia Éric Tanter, University of Chile

  2. Gradual Propositional Equality Can gradual typing be used to move Can gradual typing be used to move equational specification checking equational specification checking between compile time and run time? between compile time and run time? Can propositional equality be included Can propositional equality be included in a gradual language without breaking in a gradual language without breaking the metatheory? the metatheory? Family of refl constructors - dynamic consistency info 2

  3. 3

  4. sort : List Nat -> List Nat sort Nil = Nil Removes duplicates! sort [9, 8, 9] = [8,9] sort (Cons h t) = let lower = sort (filter (< h) t) higher = sort (filter (> h) t) in lower ++ [h] ++ higher Silently incorrect 4

  5. F Fixed-length Lists: Lists: Length index FList : Type -> Nat -> Type FList a n = (lst : List a) × (length lst = n) Dependent pair • Propositional equality: length matches index Underlying list 5

  6. To run, must prove: length (lower ++ [h] ++ higher) = 1 + length t sort : List Nat sort : FList n Nat -> FList n Nat -> List Nat sort Nil = Nil sort (Nil , pf) = Nil (Nil , pf) sort (Cons h t , pf) = sort (Cons h t) = let lower = sort (filter (< h) t) higher = sort (filter (> h) t) in lower ++ [h] ++ higher in (lower ++ [h] ++ higher , …) “Sort accidentally removes duplicates” 6

  7. 7

  8. sort : FList n Nat -> FList n Nat sort (Nil , pf) = Nil (Nil , pf) Can’t run code Blocks reduction, doesn’t check error sort (Cons h t , pf) = let lower = sort (filter (< h) t) higher = sort (filter (> h) t) in (lower ++ [h] ++ higher , …) axiom hole 8

  9. sort : FList n Nat -> FList n Nat sort (Nil , pf) = Nil (Nil , pf) The impreciseterm sort (Cons h t , pf) = let lower = sort (filter (< h) t) higher = sort (filter (> h) t) in (lower ++ [h] ++ higher , …) ? ? 9

  10. The run time should see that this is absurd sort ([9, 8, 9] , refl) Gradual run- time checks ? ? : 2 = 3 No errors: safe but incorrect Same silent failure! ([8, 9] , ? ?) 10

  11. 11

  12. 〈 B ⇐An〉…〈A2⇐ A1〉 〈 B ⇐ A 〉≡〈B ⇐ (A & B) ⇐ A 〉 ≡〈B ⇐(A1& … & An & B) ⇐A1〉 Cast from A to B Cast through Middle Type: lower bound A & B ⊑ A A & B ⊑ B Middle type remembers multiple casts 12

  13. Single constructor refl : x = x Family of constructors refl(w) : x = y for any consistent x, y ⊑ x ⊑ y space of possible witnesses w ∈ 13

  14. Fully static refl(x): x = x Initial Witness ? ? : x = y ≡ refl(x & y) x & y … 14

  15. 〈 x = y ⇐ x’ = y’ 〉refl(w) ≡ refl(w & x & y) Cast between equality types Remembers x’, y’, and all previous constraints x & y ⊑ x & y & z … 15

  16. 16

  17. • Collapse to single value • Only witness is error x ≇ y = x & y x & y ⊑ = … ⊑ error error 17

  18. sort [9, 8, 9] Goal was impossible to prove lower := [8] upper := [] returns ([8, 9], ? ?) refl(2 & 3) refl(error) ? ? : 2 = 3 18

  19. transport(eq : x = y) P(x) P(y) transport(refl(w)) transport(refl) P(x) P(y) P(x) P(x) Retains info from witness Cast Cast P(w) 19

  20. f & f = f f := (λx. λy. x + x ) Should be statically distinguishable Should be dynamically indistinguishable fsame:= (λx. λy. 2 × x) f & fsame= … fdiff:=(λx. λy. y + y ) 20

  21. & is operation in language f & fsame= λx. λy. (f x) & (fsamex) Blocked by neutral Witness that fand fdiffare consistent? f & fdiff= λx. λy. (f x) & (fdiffx) Static consistency (syntactic equality up to ?) Dynamic consistency (compose to non- error) for conversion check valid refl witnesses 21

  22. • Design of precision to accommodate composition • Safety, weak consistency, conservative extension • Identify relationship between composition and precision needed for these properties • Extensions : inductive types, empty types, Axiom K 22

  23. Gradual Propositional Equality Gradual Propositional Equality • Unifies static equality types and dynamic assertions • Witnesses of consistency dynamically track type information • Composition operator plays nicely with function types 23

More Related