records
play

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


  1. 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 – update( r, l, a ): • Type for “open” (extendable) objects r . l := a • Basic Reduction { x 1 = a 1 ; . . . ; x n = a n } . x i → a i where x i is not equal to any x j for j > i . 1 2

  2. Basic Operations Basic Operations Another definition: • Objects • Objects } ∆ self . { | x 1 = m 1 [ self ]; . . . ; x n = m n [ self ] | = } ∆ self . { | x 1 = m 1 [ self ]; . . . ; x n = m n [ self ] | = { x 1 = λself.m 1 [ self ]; . . . ; x n = λself.m n [ self ] } λself. { x 1 = m 1 [ self ]; . . . ; x n = m 1 [ self ] } • Method Application apply method( obj ; l ): • Method Application apply method( obj ; l ): obj ◦ x ∆ = ( obj . x ) obj obj ◦ x ∆ = ( obj obj ) . x • Method Update update method( obj ; l ; self.m ): • Method Update update method( obj ; l ; self.m ): obj ◦ x := σ self .m [ self ] ∆ = obj . x := λ self .m [ self ] obj ◦ x := σ self .m [ self ] ∆ = λ self . ( obj self ) . x := m [ self ] 3 4 Basic Reduction Definition of type If o = We want to define a type { | x 1 = m 1 [ self ]; . . . ; x n = m n [ self ] | } Obj = Self . { | x 1 : A 1 [ Self ]; . . . ; x n : A n [ Self ] | } then o ◦ x i → m i [ o/ self ] such that obj ∈ Obj obj ◦ x i ∈ A i [ Obj ] where x i is not equal to any x j for j > i . 5 6

  3. � � � Definition of type Definition of type Definition. Let i X.N ( X ) = � { T : U i | T ⊆ N ( T ) } N ( X ) = { x 1 : X → A 1 [ X ]; . . . ; x n : X → A n [ X ] } Rule. N is a function from U i to U i . obj ∈ X.N ( X ) A i is monotone obj ◦ x i ∈ A i [ X.N ( X )] Lemma. If X ⊆ N ( X ) and o ∈ X then o ◦ x i ∈ A i ( X ). 7 8 Problem 1: How to prove that something is in this type? Problem 2: This type is not extendable Must find X ⊆ N ( X ). Example Idea: • a ∆ = { | move = self | } ∈ { | move : Self | } X 0 = Top, X 1 = N ( X 0 ), X 2 = N ( X 1 ), . . . , X = � X n • b ∆ = { | move = a | } ∈ { | move : Self | } • c ∆ = update method( b ; x ; λ self . 1) / ∈ { | move : Self ; x : Z | } Then X ⊆ N ( X ) because c ◦ move ◦ x is undefined. • d ∆ = update method( a ; x ; λ self . 1) ∈ { | move : Self ; x : Z | } For example, we can already prove So, a is extendable, but b is not. { | x = 1; y = self ◦ x | } ∈ { | x : Z ; y : Z | } because { | x = 1; y = self ◦ x | } ∈ N ( N ( X )). 9 10

  4. � � � � � � � � � � � � Problem 3: We want to update fields Extendable Objects: First Take Example. Naive definition: � obj ∆ X.N ( X ) = { T : U i | ∀ X ⊆ T.X ⊆ N ( X ) } = { | x = 1; y = self ◦ x | | x : Z ; y : N | } ∈ { } obj ◦ x := − 1 / ∈ { | x : Z ; y : N | } We expect the rule: Γ ⊢ obj ∈ X.N 1 ( X ) Γ; X : U i ; X ⊆ N 1 ( X ) ⊢ obj ∈ N 2 ( X ) X. ( N 1 ( X ) � N 2 ( X )) We define type of open objects with guards P X.N ( X ), where a Γ ⊢ obj ∈ guard is a property of types that allows updates: P ( X ) ⇒ ∀ a : Z . ∀ obj ∈ X.obj ◦ x := a ∈ X Unfortunately when we try to prove this we get unprovable subgoal U i ∈ U i . A type X is a “good extension” of P X.N ( X ) if P ( X ) ∧ X ⊆ N ( X ) 11 12 Main Rules Assume that all A i ’s are monotone and continuous functions from Formal definition U i to U i . N 1 ( X ) = { x 1 : X → A 1 [ X ]; . . . ; x n : X → A n [ X ] } N 2 ( X ) = { x n +1 : X → A n +1 [ X ]; . . . ; x m : X → A m [ X ] } P ( X ) : U i → P i +1 Inheritance: ∆ � P N = { T : U i +1 |∀ X : U P . ∃ Y : U P [ X ∩ T ; X ] . Y ⊆ N ( Y ) } Γ ⊢ obj ∈ P X.N 1 ( X ) Γ; X : U i ; P ( X ); X ⊆ N 1 ( X ) ⊢ o ∈ N 2 ( X ) Γ; X : U i ; P ( X ); X ⊆ N 1 ( X ) ⊢ P ( N 2 ( X )) ∆ P X. ( N 1 ( X ) � N 2 ( X )) where U P = { X : U i | P ( X ) } Γ; obj ∈ Closing: and U P [ A ; B ] ∆ = { X : U P | A ⊆ X ⊆ B } . P X.N ( X ) ⊆ X.N ( X ) Method Application: obj ∈ X.N ( X ) obj ◦ x i ∈ A i [ X.N ( X )] 13 14

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