Records Records { x 1 = a 1 ; . . . ; x n = a n } Definition of - - PowerPoint PPT Presentation

records
SMART_READER_LITE
LIVE PREVIEW

Records Records { x 1 = a 1 ; . . . ; x n = a n } Definition of - - PowerPoint PPT Presentation

Records Records { x 1 = a 1 ; . . . ; x n = a n } Definition of Objects Record Types in Type Theory { x 1 : A 1 ; . . . ; x n : A n } Basic Operations select( r, l ): Reduction System r . l Type for close objects


slide-1
SLIDE 1

Records

  • Records

{x1 = a1; . . . ; xn = an}

  • Record Types

{x1 : A1; . . . ; xn : An}

  • Basic Operations

– select(r, l): r.l – update(r, l, a): r.l := a

  • Basic Reduction

{x1 = a1; . . . ; xn = an}.xi → ai where xi is not equal to any xj for j > i.

2

Definition of Objects in Type Theory

  • Reduction System
  • Type for “close” objects
  • Type for “open” (extendable) objects

1

slide-2
SLIDE 2

Definition of type

We want to define a type Obj = Self .{ |x1 : A1[Self ]; . . . ; xn : An[Self ]| } such that

  • bj ∈ Obj
  • bj◦xi ∈ Ai[Obj]

6

Basic Reduction

If o = { |x1 = m1[self]; . . . ; xn = mn[self]| } then

  • ◦xi → mi[o/self ]

where xi is not equal to any xj for j > i.

5

Basic Operations

Another definition:

  • Objects

self .{ |x1 = m1[self]; . . . ; xn = mn[self]| } ∆ = λself.{x1 = m1[self]; . . . ; xn = m1[self]}

  • Method Application apply method(obj; l):
  • bj◦x ∆

= (obj obj).x

  • Method Update update method(obj; l; self.m):
  • bj◦x := σself .m[self ] ∆

= λself .(objself ).x := m[self ]

4

Basic Operations

  • Objects

self .{ |x1 = m1[self]; . . . ; xn = mn[self]| } ∆ = {x1 = λself.m1[self]; . . . ; xn = λself.mn[self]}

  • Method Application apply method(obj; l):
  • bj◦x ∆

= (obj.x) obj

  • Method Update update method(obj; l; self.m):
  • bj◦x := σself .m[self ] ∆

= obj.x := λself .m[self ]

3

slide-3
SLIDE 3

Problem 2: This type is not extendable

Example

  • a ∆

= { |move = self | } ∈ { |move : Self | }

  • b ∆

= { |move = a| } ∈ { |move : Self | }

  • c ∆

= update method(b; x; λself .1) / ∈ { |move : Self ; x : Z| } because c◦move◦x is undefined.

  • d ∆

= update method(a; x; λself .1) ∈ { |move : Self ; x : Z| } So, a is extendable, but b is not.

10

Problem 1: How to prove that something is in this type?

Must find X ⊆ N(X). Idea: X0 = Top, X1 = N(X0), X2 = N(X1), . . . , X = Xn Then X ⊆ N(X) For example, we can already prove { |x = 1; y = self ◦x| } ∈ { |x : Z; y : Z| } because { |x = 1; y = self ◦x| } ∈ N(N(X)).

9

Definition of type

Definition.

  • i X.N(X) =
  • {T : Ui | T ⊆ N(T)}

Rule.

  • bj ∈
  • X.N(X)

Ai is monotone

  • bj◦xi ∈ Ai[
  • X.N(X)]

8

Definition of type

Let N(X) = {x1 : X → A1[X]; . . . ; xn : X → An[X]} N is a function from Ui to Ui.

  • Lemma. If X ⊆ N(X) and o ∈ X then o◦xi ∈ Ai(X).

7

slide-4
SLIDE 4

Main Rules

Assume that all Ai’s are monotone and continuous functions from Ui to Ui. N1(X) = {x1 : X → A1[X]; . . . ; xn : X → An[X]} N2(X) = {xn+1 : X → An+1[X]; . . . ; xm : X → Am[X]} P(X) : Ui → Pi+1 Inheritance: Γ ⊢ obj ∈

  • P X.N1(X)

Γ; X : Ui; P(X); X ⊆ N1(X) ⊢ o ∈ N2(X) Γ; X : Ui; P(X); X ⊆ N1(X) ⊢ P(N2(X)) Γ; obj ∈

  • P X.(N1(X) N2(X))

Closing:

  • P X.N(X) ⊆
  • X.N(X)

Method Application:

  • bj ∈
  • X.N(X)
  • bj◦xi ∈ Ai[
  • X.N(X)]

14

Formal definition

  • P N

=

  • {T : Ui+1|∀X : UP. ∃Y : UP[X ∩ T; X]. Y ⊆ N(Y )}

where UP

= {X : Ui|P(X)} and UP[A; B] ∆ = {X : UP|A ⊆ X ⊆ B}.

13

Problem 3: We want to update fields

Example.

  • bj ∆

= { |x = 1; y = self ◦x| } ∈ { |x : Z; y : N| }

  • bj◦x := −1 /

∈ { |x : Z; y : N| } We define type of open objects with guards

  • P X.N(X), where a

guard is a property of types that allows updates: P(X) ⇒ ∀a : Z.∀obj ∈ X.obj◦x := a ∈ X A type X is a “good extension” of

  • P X.N(X) if

P(X) ∧ X ⊆ N(X)

12

Extendable Objects: First Take

Naive definition:

  • X.N(X) =
  • {T : Ui | ∀X ⊆ T.X ⊆ N(X)}

We expect the rule: Γ ⊢ obj ∈

  • X.N1(X)

Γ; X : Ui; X ⊆ N1(X) ⊢ obj ∈ N2(X) Γ ⊢ obj ∈

  • X.(N1(X) N2(X))

Unfortunately when we try to prove this we get unprovable subgoal Ui ∈ Ui.

11