objects and subtyping in the calculus modulo
play

Objects and subtyping in the -calculus modulo Ali Assaf, Raphal - PowerPoint PPT Presentation

. . . . . . . . . . . . . . . . . . . . TYPES 2014, May 12 TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . 1 / 24 Objects and subtyping in the -calculus modulo Ali Assaf,


  1. . . . . . . . . . . . . . . . . . . . . TYPES 2014, May 12 TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . 1 / 24 Objects and subtyping in the λ Π -calculus modulo Ali Assaf, Raphaël Cauderlier , Catherine Dubois Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  2. . . . . . . . . . . . . . . . . . Motivations Functional Pure Type Systems Proof assistants: Coq, HOL, FoCaLize Theorem provers: Zenon, iProver Object calculi have type systems with (object) subtyping Subtyping is a common feature of type systems, also present in Coq (universes) TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . 2 / 24 . . . . . The λ Π -calculus modulo has been designed to encode other calculi We use λ Π -calculus modulo rewriting to study OOL semantics How can we translate object mechanisms in the λ Π -calculus modulo? The λ Π -calculus modulo lacks subtyping Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  3. . . . . . . . . . . . . . Related work . Several deep encodings: Cardelli (1984), Pierce, Turner and Hofmann (1993-1995), Bruce (1993), Abadi, Cardelli and Viswanathan (1996) Implemented in Yarrow (1997): a proof assistant with object subtyping Objects , Springer Verlag, 1996 Deep encodings in Coq, focus on proving properties on the type system by Gillard and Despeyroux (1999): reasoning on binders encoded via DeBrujn indices and Liquori (2007): proof of the subject-reduction theorem In Isabelle/HOL: deep formalisation of class-based languages (parts of Java and Scala) with extensible records: Klein and Nipkow (2005), Foster and Vytiniotis (2006) TYPES 2014, May 12 . . . . . . . . . . . . . . . . 3 / 24 . . . . . . . . . . . . . . In System F ω <: (polymorphism, type operators and subtyping) Object calculi (a.k.a ς -calculi) from Abadi and Cardelli, A Theory of Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  4. . . . . . . . . . . . . . . . . . This work Shallow embedding semantically equal terms, types or proofs should not be distinguishable after the encoding expected efficiency readability TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 / 24 Encoding of an object calculus: the simply-typed ς -calculus In the λ Π -calculus modulo Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  5. . . . . . . . . . . . . . . . . . . Outline 1 2 3 TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . 5 / 24 The λ Π -calculus modulo and Dedukti The simply-typed ς -calculus Explicit subtyping in the λ Π -calculus modulo Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  6. . . . . . . . . . . . . . . . . . . . . (Conv) TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . 6 / 24 . . . . . The λ Π -calculus modulo The λ Π -calculus is a typed λ calculus with dependent types The λ Π -calculus modulo, introduced by Cousineau and Dowek in 2007, extends the λ Π -calculus with a rewrite system R . Γ ⊢ t : A A ≡ β R B Γ ⊢ t : B Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  7. . . . . . . . . . . . . . . . . . Dedukti It is a free software, available at https://www.rocq.inria.fr/deducteam/Dedukti/ Dependent types Rewriting on terms and types Partial functions and proofs Non-linear pattern-matching TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 / 24 Type-checker for the λ Π -calculus modulo Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  8. . . . . . . . . . . . . . . . . . . of Objects , 1996 Functional semantics (imperative semantics also studied) Model of both class-based and object-based languages No termination guaranted by typing Structural subtyping TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . 8 / 24 The simply-typed ς -calculus: Abadi and Cardelli, A Theory Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  9. . . . . . . . . . . . . . . . . Syntax and semantics Types labels are unordered Terms t, u ::= t.l Operational semantics t.l j TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . 9 / 24 . . . . . A ::= [ l i : A i ] i=1..n [ l i = ς (x : A) t i ] i=1..n t.l ⇐ ς (x : A) u (t.l ⇐ u) abbreviates (t.l ⇐ ς (x : A) u) where x ̸∈ FV(u). (l = u) abbreviates (l = ς (x : A) u) where x ̸∈ FV(u). A := [ l i : A i ] i=1..n t := [ l i = ς (x : A) t i ] i=1..n ↣ t j [t/x] t.l j ⇐ ς (x : A) u [ l j = ς (x : A) u, l i = ς (x : A) t i ] i =1..n, i ̸ = j ↣ Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  10. . . . . . . . . . . . . . . . . . Typing and subtyping (obj) (select) (update) A <: B (subsume) TYPES 2014, May 12 . . . . . . . . . . . . . . . 10 / 24 . . . . . . . . . . . . A := [ l i : A i ] i=1..n ∀ i=1..n Γ , x : A ⊢ t i : A i Γ ⊢ t : A Γ ⊢ [ l i = ς (x : A) t i ] i=1..n : A Γ ⊢ t.l i : A i Γ ⊢ t : A Γ , x : A ⊢ u : A i Γ ⊢ t.l i ⇐ ς (x : A) u : A [ l i : A i ] i=1..n+m <: [ l i : A i ] i=1..n Γ ⊢ t : A Γ ⊢ t : B Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  11. . . . . . . . . . . . . . . . . . . . Example: Encoding of booleans "then" and "else" methods are updated before "if" is selected TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . 11 / 24 . . . . . Bool A := [if : A, then : A, else : A] true A := [if = ς (self : A) self.then, then = ς (self : A) self.then, else = ς (self : A) self.else] false A := [if = ς (self : A) self.else, then = ς (self : A) self.then, else = ς (self : A) self.else] if A b then t else e := ((b.then ⇐ t).else ⇐ e).if Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  12. . . . . . . . . . . . . . . . . . Subtyping example RomCell := [ get : nat ] PromCell := PromCell <: RomCell myCell : PromCell := [ get = 0, TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 / 24 [ get : nat, set : nat → RomCell ] set = ς (self : PromCell) λ (n : nat) self.get ⇐ n ] myCell.set(42).get ↣ ∗ 42 Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  13. . . . . . . . . . . . . . . . . . . . Types and objects are translated as association lists The operational semantics is translated to rewrite rules Subtyping is explicit TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . 13 / 24 Translation scheme from simply-typed ς -calculus to λ Π -calculus modulo Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  14. . . . . . . . . . . . . . . . . . . Explicit subtyping Convertibility is a symmetric relation We cannot rewrite A to B whenever A <: B because that would make both types equal Hence we ask the user to provide explicit coercions (subtyping annotations) TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . 14 / 24 In the λ Π -calculus modulo, each term has at most one type modulo the rewrite system + β conversion Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  15. . . . . . . . . . . . . . . . . . . Translation of types Types are translated by normalized association lists Equality and subtyping relations on types are decidable: A <: (l, B 1 ) :: B 2 TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . 15 / 24 . . . . . A = A ֒ → true []= ( _ , _ ) :: _ ֒ → false A <: [] ֒ → true ( _ , _ ) :: _ = [] ֒ → false ֒ → B 1 = assoc A l ∧ A <: B 2 (l 1 , A 1 ) :: B 1 = (l 2 , A 2 ) :: B 2 ֒ → l 1 = l 2 ∧ A 1 = A 2 ∧ B 1 = B 2 Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

  16. . . . . . . . . . . . . . . . . Translation of objects Objects are also translated by association lists with labels in the same order than in the corresponding type an object of type A is something of the form sublists are not well-typed objects to construct objects, we need to consider (ill-typed) objects defined on subsets of dom(A) to coerce objects, we need to consider (ill-typed) objects with methods typed by (assoc B). TYPES 2014, May 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 / 24 [l = ς (x : A) (t : assoc A l)] l ∈ dom(A) ⇒ A pre-object of type (A, f, D) is something of the form [l = ς (x : A) (t : f l)] l ∈ D Ali Assaf, Raphaël Cauderlier , Catherine Dubois Objects and subtyping in the λ Π -calculus modulo

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