denotational semantics
play

Denotational Semantics 812 lectures for Part II CST 2010/11 Marcelo - PowerPoint PPT Presentation

Denotational Semantics 812 lectures for Part II CST 2010/11 Marcelo Fiore Course web page: http://www.cl.cam.ac.uk/teaching/1011/DenotSem/ 1 Lecture 1 Introduction 2 What is this course about? General area. Formal methods :


  1. x ⊑ x x ⊑ y y ⊑ z x ⊑ z x ⊑ y y ⊑ x x = y 23

  2. Domain of partial functions, X ⇀ Y 24

  3. Domain of partial functions, X ⇀ Y Underlying set: all partial functions, f , with domain of definition dom ( f ) ⊆ X and taking values in Y . 24

  4. Domain of partial functions, X ⇀ Y Underlying set: all partial functions, f , with domain of definition dom ( f ) ⊆ X and taking values in Y . Partial order: f ⊑ g dom ( f ) ⊆ dom ( g ) and iff ∀ x ∈ dom ( f ) . f ( x ) = g ( x ) graph ( f ) ⊆ graph ( g ) iff 24

  5. Monotonicity • A function f : D → E between posets is monotone iff ∀ d, d ′ ∈ D. d ⊑ d ′ ⇒ f ( d ) ⊑ f ( d ′ ) . x ⊑ y ( f monotone ) f ( x ) ⊑ f ( y ) 25

  6. Least Elements Suppose that D is a poset and that S is a subset of D . An element d ∈ S is the least element of S if it satisfies ∀ x ∈ S. d ⊑ x . • Note that because ⊑ is anti-symmetric, S has at most one least element. • Note also that a poset may not have least element. 26

  7. Pre-fixed points Let D be a poset and f : D → D be a function. An element d ∈ D is a pre-fixed point of f if it satisfies f ( d ) ⊑ d . The least pre-fixed point of f , if it exists, will be written fix ( f ) It is thus (uniquely) specified by the two properties: f ( fix ( f )) ⊑ fix ( f ) (lfp1) ∀ d ∈ D. f ( d ) ⊑ d ⇒ fix ( f ) ⊑ d. (lfp2) 27

  8. Proof principle 2. Let D be a poset and let f : D → D be a function with a least pre-fixed point fix ( f ) ∈ D . For all x ∈ D , to prove that fix ( f ) ⊑ x it is enough to establish that f ( x ) ⊑ x . 28

  9. Proof principle 2. Let D be a poset and let f : D → D be a function with a least pre-fixed point fix ( f ) ∈ D . For all x ∈ D , to prove that fix ( f ) ⊑ x it is enough to establish that f ( x ) ⊑ x . f ( x ) ⊑ x fix ( f ) ⊑ x 28

  10. Proof principle 1. f ( fix ( f )) ⊑ fix ( f ) 2. Let D be a poset and let f : D → D be a function with a least pre-fixed point fix ( f ) ∈ D . For all x ∈ D , to prove that fix ( f ) ⊑ x it is enough to establish that f ( x ) ⊑ x . f ( x ) ⊑ x fix ( f ) ⊑ x 28

  11. Least pre-fixed points are fixed points If it exists, the least pre-fixed point of a mononote function on a partial order is necessarily a fixed point. 29

  12. Thesis ⋆ All domains of computation are complete partial orders with a least element. 30

  13. Thesis ⋆ All domains of computation are complete partial orders with a least element. All computable functions are continuous. 30

  14. Cpo’s and domains A chain complete poset, or cpo for short, is a poset ( D, ⊑ ) in which all countable increasing chains d 0 ⊑ d 1 ⊑ d 2 ⊑ . . . have least upper bounds, � n ≥ 0 d n : � ∀ m ≥ 0 . d m ⊑ d n (lub1) n ≥ 0 � ∀ d ∈ D . ( ∀ m ≥ 0 . d m ⊑ d ) ⇒ d n ⊑ d. (lub2) n ≥ 0 A domain is a cpo that possesses a least element, ⊥ : ∀ d ∈ D . ⊥ ⊑ d. 31

  15. ⊥ ⊑ x ( i ≥ 0 and � x n � a chain ) x i ⊑ � n ≥ 0 x n ∀ n ≥ 0 . x n ⊑ x ( � x i � a chain ) � n ≥ 0 x n ⊑ x 32

  16. Domain of partial functions, X ⇀ Y 33

  17. Domain of partial functions, X ⇀ Y Underlying set: all partial functions, f , with domain of definition dom ( f ) ⊆ X and taking values in Y . 33

  18. Domain of partial functions, X ⇀ Y Underlying set: all partial functions, f , with domain of definition dom ( f ) ⊆ X and taking values in Y . Partial order: f ⊑ g dom ( f ) ⊆ dom ( g ) and iff ∀ x ∈ dom ( f ) . f ( x ) = g ( x ) graph ( f ) ⊆ graph ( g ) iff 33

  19. Domain of partial functions, X ⇀ Y Underlying set: all partial functions, f , with domain of definition dom ( f ) ⊆ X and taking values in Y . Partial order: f ⊑ g dom ( f ) ⊆ dom ( g ) and iff ∀ x ∈ dom ( f ) . f ( x ) = g ( x ) graph ( f ) ⊆ graph ( g ) iff Lub of chain f 0 ⊑ f 1 ⊑ f 2 ⊑ . . . is the partial function f with dom ( f ) = � n ≥ 0 dom ( f n ) and � if x ∈ dom ( f n ) , some n f n ( x ) f ( x ) = undefined otherwise 33

  20. Domain of partial functions, X ⇀ Y Underlying set: all partial functions, f , with domain of definition dom ( f ) ⊆ X and taking values in Y . Partial order: f ⊑ g dom ( f ) ⊆ dom ( g ) and iff ∀ x ∈ dom ( f ) . f ( x ) = g ( x ) graph ( f ) ⊆ graph ( g ) iff Lub of chain f 0 ⊑ f 1 ⊑ f 2 ⊑ . . . is the partial function f with dom ( f ) = � n ≥ 0 dom ( f n ) and � if x ∈ dom ( f n ) , some n f n ( x ) f ( x ) = undefined otherwise Least element ⊥ is the totally undefined partial function. 33

  21. Some properties of lubs of chains Let D be a cpo. 1. For d ∈ D , � n d = d . 2. For every chain d 0 ⊑ d 1 ⊑ . . . ⊑ d n ⊑ . . . in D , � � d n = d N + n n n for all N ∈ N . 34

  22. 3. For every pair of chains d 0 ⊑ d 1 ⊑ . . . ⊑ d n ⊑ . . . and e 0 ⊑ e 1 ⊑ . . . ⊑ e n ⊑ . . . in D , if d n ⊑ e n for all n ∈ N then � n d n ⊑ � n e n . 35

  23. 3. For every pair of chains d 0 ⊑ d 1 ⊑ . . . ⊑ d n ⊑ . . . and e 0 ⊑ e 1 ⊑ . . . ⊑ e n ⊑ . . . in D , if d n ⊑ e n for all n ∈ N then � n d n ⊑ � n e n . ∀ n ≥ 0 . x n ⊑ y n ( � x n � and � y n � chains ) � n x n ⊑ � n y n 35

  24. Diagonalising a double chain Lemma. Let D be a cpo. Suppose that the doubly-indexed family of elements d m,n ∈ D ( m, n ≥ 0 ) satisfies m ≤ m ′ & n ≤ n ′ ⇒ d m,n ⊑ d m ′ ,n ′ . ( † ) Then � � � d 0 ,n ⊑ d 1 ,n ⊑ d 2 ,n ⊑ . . . n ≥ 0 n ≥ 0 n ≥ 0 and � � � d m, 0 ⊑ d m, 1 ⊑ d m, 3 ⊑ . . . m ≥ 0 m ≥ 0 m ≥ 0 36

  25. Diagonalising a double chain Lemma. Let D be a cpo. Suppose that the doubly-indexed family of elements d m,n ∈ D ( m, n ≥ 0 ) satisfies m ≤ m ′ & n ≤ n ′ ⇒ d m,n ⊑ d m ′ ,n ′ . ( † ) Then � � � d 0 ,n ⊑ d 1 ,n ⊑ d 2 ,n ⊑ . . . n ≥ 0 n ≥ 0 n ≥ 0 and � � � d m, 0 ⊑ d m, 1 ⊑ d m, 3 ⊑ . . . m ≥ 0 m ≥ 0 m ≥ 0 Moreover     �  � � �  �  =  . d m,n d k,k = d m,n m ≥ 0 n ≥ 0 n ≥ 0 m ≥ 0 k ≥ 0 36

  26. Continuity and strictness • If D and E are cpo’s, the function f is continuous iff 1. it is monotone, and 2. it preserves lubs of chains, i.e. for all chains d 0 ⊑ d 1 ⊑ . . . in D , it is the case that � � f ( d n ) = f ( d n ) in E . n ≥ 0 n ≥ 0 37

  27. Continuity and strictness • If D and E are cpo’s, the function f is continuous iff 1. it is monotone, and 2. it preserves lubs of chains, i.e. for all chains d 0 ⊑ d 1 ⊑ . . . in D , it is the case that � � f ( d n ) = f ( d n ) in E . n ≥ 0 n ≥ 0 • If D and E have least elements, then the function f is strict iff f ( ⊥ ) = ⊥ . 37

  28. Tarski’s Fixed Point Theorem Let f : D → D be a continuous function on a domain D . Then • f possesses a least pre-fixed point, given by � f n ( ⊥ ) . fix ( f ) = n ≥ 0 • Moreover, fix ( f ) is a fixed point of f , i.e. satisfies � � f fix ( f ) = fix ( f ) , and hence is the least fixed point of f . 38

  29. [ [ while B do C ] ] [ [ while B do C ] ] = fix ( f [ ] ) [ B ] ] , [ [ C ] = � n ( ⊥ ) n ≥ 0 f [ [ B ] ] , [ [ C ] ] = λs ∈ State .  ] k ( s ) ] k ( s )) = false [ [ C ] if k ≥ 0 is such that [ [ B ] ]([ [ C ]    ] i ( s )) = true for all 0 ≤ i < k and [ [ B ] ]([ [ C ]    ] i ( s )) = true for all i ≥ 0 if [ [ B ] ]([ [ C ] undefined 39

  30. Lecture 3 Constructions on Domains 40

  31. Discrete cpo’s and flat domains For any set X , the relation of equality ( x, x ′ ∈ X ) def x ⊑ x ′ ⇔ x = x ′ makes ( X, ⊑ ) into a cpo, called the discrete cpo with underlying set X . 41

  32. Discrete cpo’s and flat domains For any set X , the relation of equality ( x, x ′ ∈ X ) def x ⊑ x ′ ⇔ x = x ′ makes ( X, ⊑ ) into a cpo, called the discrete cpo with underlying set X . def = X ∪ {⊥} , where ⊥ is some element not in X . Then Let X ⊥ ( d, d ′ ∈ X ⊥ ) def d ⊑ d ′ ⇔ ( d = d ′ ) ∨ ( d = ⊥ ) makes ( X ⊥ , ⊑ ) into a domain (with least element ⊥ ), called the flat domain determined by X . 41

  33. Binary product of cpo’s and domains The product of two cpo’s ( D 1 , ⊑ 1 ) and ( D 2 , ⊑ 2 ) has underlying set D 1 × D 2 = { ( d 1 , d 2 ) | d 1 ∈ D 1 & d 2 ∈ D 2 } and partial order ⊑ defined by 2 ) def ( d 1 , d 2 ) ⊑ ( d ′ 1 , d ′ ⇔ d 1 ⊑ 1 d ′ 1 & d 2 ⊑ 2 d ′ 2 . ( x 1 , x 2 ) ⊑ ( y 1 , y 2 ) x 1 ⊑ 1 y 1 x 2 ⊑ 2 y 2 42

  34. Lubs of chains are calculated componentwise: � � � ( d 1 ,n , d 2 ,n ) = ( d 1 ,i , d 2 ,j ) . n ≥ 0 i ≥ 0 j ≥ 0 If ( D 1 , ⊑ 1 ) and ( D 2 , ⊑ 2 ) are domains so is ( D 1 × D 2 , ⊑ ) and ⊥ D 1 × D 2 = ( ⊥ D 1 , ⊥ D 2 ) . 43

  35. Continuous functions of two arguments Proposition. Let D , E , F be cpo’s. A function f : ( D × E ) → F is monotone if and only if it is monotone in each argument separately: ∀ d, d ′ ∈ D, e ∈ E. d ⊑ d ′ ⇒ f ( d, e ) ⊑ f ( d ′ , e ) ∀ d ∈ D, e, e ′ ∈ E. e ⊑ e ′ ⇒ f ( d, e ) ⊑ f ( d, e ′ ) . Moreover, it is continuous if and only if it preserves lubs of chains in each argument separately: � � f ( d m , e ) = f ( d m , e ) m ≥ 0 m ≥ 0 � � f ( d , e n ) = f ( d, e n ) . n ≥ 0 n ≥ 0 44

  36. • A couple of derived rules: x ⊑ x ′ y ⊑ y ′ ( f monotone ) f ( x, y ) ⊑ f ( x ′ , y ′ ) f ( � m x m , � n y n ) = � k f ( x k , y k ) 45

  37. Function cpo’s and domains Given cpo’s ( D, ⊑ D ) and ( E, ⊑ E ) , the function cpo ( D → E, ⊑ ) has underlying set ( D → E ) def = { f | f : D → E is a continuous function } def and partial order: f ⊑ f ′ ⇔ ∀ d ∈ D . f ( d ) ⊑ E f ′ ( d ) . 46

  38. Function cpo’s and domains Given cpo’s ( D, ⊑ D ) and ( E, ⊑ E ) , the function cpo ( D → E, ⊑ ) has underlying set ( D → E ) def = { f | f : D → E is a continuous function } def and partial order: f ⊑ f ′ ⇔ ∀ d ∈ D . f ( d ) ⊑ E f ′ ( d ) . • A derived rule: f ⊑ ( D → E ) g x ⊑ D y f ( x ) ⊑ g ( y ) 46

  39. Lubs of chains are calculated ‘argumentwise’ (using lubs in E ): � � f n = λd ∈ D. f n ( d ) . n ≥ 0 n ≥ 0 If E is a domain, then so is D → E and ⊥ D → E ( d ) = ⊥ E , all d ∈ D . 47

  40. Lubs of chains are calculated ‘argumentwise’ (using lubs in E ): � � f n = λd ∈ D. f n ( d ) . n ≥ 0 n ≥ 0 • A derived rule: � � � ( � m x m ) = � n f n k f k ( x k ) If E is a domain, then so is D → E and ⊥ D → E ( d ) = ⊥ E , all d ∈ D . 47

  41. Continuity of composition For cpo’s D, E, F , the composition function � � ◦ : ( E → F ) × ( D → E ) − → ( D → F ) defined by setting, for all f ∈ ( D → E ) and g ∈ ( E → F ) , � � g ◦ f = λd ∈ D. g f ( d ) is continuous. 48

  42. Continuity of the fixpoint operator Let D be a domain. By Tarski’s Fixed Point Theorem we know that each continuous function f ∈ ( D → D ) possesses a least fixed point, fix ( f ) ∈ D . Proposition. The function fix : ( D → D ) → D is continuous. 49

  43. Lecture 4 Scott Induction 50

  44. Scott’s Fixed Point Induction Principle Let f : D → D be a continuous function on a domain D . For any admissible subset S ⊆ D , to prove that the least fixed point of f is in S , i.e. that fix ( f ) ∈ S , it suffices to prove ∀ d ∈ D ( d ∈ S ⇒ f ( d ) ∈ S ) . 51

  45. Chain-closed and admissible subsets Let D be a cpo. A subset S ⊆ D is called chain-closed iff for all chains d 0 ⊑ d 1 ⊑ d 2 ⊑ . . . in D � � � ( ∀ n ≥ 0 . d n ∈ S ) ⇒ ∈ S d n n ≥ 0 If D is a domain, S ⊆ D is called admissible iff it is a chain-closed subset of D and ⊥ ∈ S . 52

  46. Chain-closed and admissible subsets Let D be a cpo. A subset S ⊆ D is called chain-closed iff for all chains d 0 ⊑ d 1 ⊑ d 2 ⊑ . . . in D � � � ( ∀ n ≥ 0 . d n ∈ S ) ⇒ ∈ S d n n ≥ 0 If D is a domain, S ⊆ D is called admissible iff it is a chain-closed subset of D and ⊥ ∈ S . A property Φ( d ) of elements d ∈ D is called chain-closed (resp. admissible ) iff { d ∈ D | Φ( d ) } is a chain-closed (resp. admissible ) subset of D . 52

  47. Building chain-closed subsets (I) Let D, E be cpos. Basic relations: • For every d ∈ D , the subset ↓ ( d ) def = { x ∈ D | x ⊑ d } of D is chain-closed. 53

  48. Building chain-closed subsets (I) Let D, E be cpos. Basic relations: • For every d ∈ D , the subset ↓ ( d ) def = { x ∈ D | x ⊑ d } of D is chain-closed. • The subsets { ( x, y ) ∈ D × D | x ⊑ y } and { ( x, y ) ∈ D × D | x = y } of D × D are chain-closed. 53

  49. Example (I): Least pre-fixed point property Let D be a domain and let f : D → D be a continuous function. ∀ d ∈ D. f ( d ) ⊑ d = ⇒ fix ( f ) ⊑ d 54

  50. Example (I): Least pre-fixed point property Let D be a domain and let f : D → D be a continuous function. ∀ d ∈ D. f ( d ) ⊑ d = ⇒ fix ( f ) ⊑ d Proof by Scott induction. Let d ∈ D be a pre-fixed point of f . Then, x ∈ ↓ ( d ) ⇒ x ⊑ d = = ⇒ f ( x ) ⊑ f ( d ) ⇒ f ( x ) ⊑ d = = ⇒ f ( x ) ∈ ↓ ( d ) Hence, fix ( f ) ∈ ↓ ( d ) . 54

  51. Building chain-closed subsets (II) Inverse image: Let f : D → E be a continuous function. If S is a chain-closed subset of E then the inverse image f − 1 S = { x ∈ D | f ( x ) ∈ S } is an chain-closed subset of D . 55

  52. Example (II) Let D be a domain and let f, g : D → D be continuous functions such that f ◦ g ⊑ g ◦ f . Then, f ( ⊥ ) ⊑ g ( ⊥ ) = ⇒ fix ( f ) ⊑ fix ( g ) . 56

  53. Example (II) Let D be a domain and let f, g : D → D be continuous functions such that f ◦ g ⊑ g ◦ f . Then, f ( ⊥ ) ⊑ g ( ⊥ ) = ⇒ fix ( f ) ⊑ fix ( g ) . Proof by Scott induction. � � Consider the admissible property Φ( x ) ≡ f ( x ) ⊑ g ( x ) of D . Since f ( x ) ⊑ g ( x ) ⇒ g ( f ( x )) ⊑ g ( g ( x )) ⇒ f ( g ( x )) ⊑ g ( g ( x )) we have that f ( fix ( g )) ⊑ g ( fix ( g )) . 56

  54. Building chain-closed subsets (III) Logical operations: • If S, T ⊆ D are chain-closed subsets of D then S ∪ T S ∩ T and are chain-closed subsets of D . • If { S i } i ∈ I is a family of chain-closed subsets of D indexed by a set I , then � i ∈ I S i is a chain-closed subset of D . • If a property P ( x, y ) determines a chain-closed subset of D × E , then the property ∀ x ∈ D. P ( x, y ) determines a chain-closed subset of E . 57

  55. Example (III): Partial correctness Let F : State ⇀ State be the denotation of while X > 0 do ( Y := X ∗ Y ; X := X − 1) . For all x, y ≥ 0 , F [ X �→ x, Y �→ y ] ↓ = ⇒ F [ X �→ x, Y �→ y ] = [ X �→ 0 , Y �→ ! x · y ] . 58

  56. Recall that F = fix ( f ) where f : ( State ⇀ State ) → ( State ⇀ State ) is given by � if x ≤ 0 ( x, y ) f ( w ) = λ ( x, y ) ∈ State . w ( x − 1 , x · y ) if x > 0 59

  57. Proof by Scott induction. We consider the admissible subset of ( State ⇀ State ) given by   ∀ x, y ≥ 0 .     S = w w [ X �→ x, Y �→ y ] ↓     ⇒ w [ X �→ x, Y �→ y ] = [ X �→ 0 , Y �→ ! x · y ] and show that w ∈ S = ⇒ f ( w ) ∈ S . 60

  58. Lecture 5 PCF 61

  59. PCF syntax Types τ ::= nat | bool | τ → τ 62

  60. PCF syntax Types τ ::= nat | bool | τ → τ Expressions 0 | succ ( M ) | pred ( M ) M ::= 62

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