administration
play

Administration Homework 2 due in one week (25 th ) Gunter, - PDF document

Administration Homework 2 due in one week (25 th ) Gunter, Mitchell, Stoy placed on reserve in CS 611 Engineering library Advanced Programming Languages Andrew Myers Cornell University Lecture 11 Fixed Points and CPOs 18 Sep 00 CS


  1. Administration • Homework 2 due in one week (25 th ) • Gunter, Mitchell, Stoy placed on reserve in CS 611 Engineering library Advanced Programming Languages Andrew Myers Cornell University Lecture 11 Fixed Points and CPOs 18 Sep 00 CS 611 Fall '00 -- Andrew Myers, Cornell University 2 Last time Problem: while • Denotational semantics: meaning function �� while b do c � σ = if ¬ �� b � σ then σ �� e � maps language syntax e into domain else �� while b do c � ( �� c � σ) with ‘intrinsic’ meaning • Defined semantics for IMP through � b , f b � � while b do c , f w � � c , f c � meaning functions �� a � , �� a � , �� c � � � � � � � � � � � � � � � � � � � � while b do c , λσ . if f b σ then σ else f w ( f c σ) � • Meaning functions defined as syntax- � � � � � � directed translation • No finite proof tree for � � while b do c , f � � ! � � � � � a 0 , f 0 � � a 1 , f 1 � • Definitions of denotations will be total if �� a 0 +a 1 � = λσ . �� a 0 � σ + �� a 1 � σ � a 0 +a 1 , λσ . f 0 σ + f 1 σ � based on structural induction CS 611 Fall '00 -- Andrew Myers, Cornell University 3 CS 611 Fall '00 -- Andrew Myers, Cornell University 4 Denotation of while Approximations �� while b do c � is solution to • Consider sequence of approximations to denotation of while : x = Γ ( x ) with 1. λσ .if ¬ �� b � σ then σ else … (works for 0 iterations) Γ = λ f ∈Σ ⊥ →Σ ⊥ . if ¬ �� b � σ then σ else f ( � ) 2. λσ. if ¬ �� b � σ then σ else if ¬ �� b ��� c � σ then �� c � σ else … Idea: �� while b do c � σ = (0 or 1 iterations) fix ( Γ ) 3. λσ. if ¬ �� b � σ then σ else if ¬ �� b ��� c � σ then �� c � σ else = fix ( λ f ∈Σ ⊥ →Σ ⊥ . if ¬ �� b � σ then σ else f ( �� c � σ)) if ¬ �� b ��� c ��� c � σ then �� c ��� c � σ else … (0-2 iterations) • What fixed point do we want (least)? • How do we define least fixed point operator fix ? • “limit” of this sequence is denotation of while CS 611 Fall '00 -- Andrew Myers, Cornell University 5 CS 611 Fall '00 -- Andrew Myers, Cornell University 6 1

  2. Orderings Partial orders • A partial-order is • Fixed points of denotation of while differ –a set of elements S only in case of non-termination –an relation x � y that is • We want �� while true do skip � σ = ⊥ • reflexive: x � x • Idea: define ordering on fixed points of Γ • transitive: ( x � y ∧ y � z ) � x � z such that least fixed point is the one we • anti-symmetric: ( x � y ∧ y � x ) � x = y want –two elements may be incomparable • Compare to inductive definitions • Examples ( S , � ) –ordering was ⊆ (Z, ≤ ) (Z,=)? (Z, <)? –doesn’t work here: how to order elements of ( 2 S , ⊆ ) ( 2 S , � ) Σ ⊥ →Σ ⊥ ? ( S , � ) CS 611 Fall '00 -- Andrew Myers, Cornell University 7 CS 611 Fall '00 -- Andrew Myers, Cornell University 8 Hasse diagram: 2 {a,b,c} , ⊆ LUBs and Chains ⊆ ⊆ ⊆ • Given a subset B ⊆ S , y is an upper bound y of B if ∀ x ∈ B . x � y {a,b,c} x � y • y is a least upper bound ( � B) if y � z for {b,c} x {a,c} all upper bounds z … • A chain is a sequence of elements {c} x 2 x 0 , x 1 , x 2 , … such that x 0 � x 1 � x 2 � … {a,b} x 1 � = ⊆ • For any finite chain x 0 ,…, x n , x n is LUB x 0 {b} {a} • What about infinite chains? { } CS 611 Fall '00 -- Andrew Myers, Cornell University 9 CS 611 Fall '00 -- Andrew Myers, Cornell University 10 Complete partial orders Information content • We consider one domain element to be • A complete partial order (cpo) is a partial less than another if it gives less order in which every chain has a least information upper bound • Non-termination gives less information • Examples ( S , � ) than any store ( � � x ) ( 2 S , ⊆ ) • Stores σ are incomparable unless equal ( ω ∪ { ∞ }, ≤ ) … σ 1 σ 2 σ 3 σ 4 … ([0,1], ≤ ) Σ � : cpo? ( S ,=)? ( S , � )? � • Recall: trying to find least fixed point in • cpo may have least element � : pointed Σ � →Σ � ; how to order functions ? CS 611 Fall '00 -- Andrew Myers, Cornell University 11 CS 611 Fall '00 -- Andrew Myers, Cornell University 12 2

  3. Pointwise ordering Back to while • Functions are ordered on their results • Γ = λ f ∈Σ ⊥ →Σ ⊥ . if ¬ �� b � σ then σ else f ( �� c � σ) • Approximations to denotation of while : • Given f ∈ D → E, g ∈ D → E, E cpo, 1. Γ(⊥) = λσ. if ¬ �� b � σ then σ else ⊥ = f � D → E g � ∀ x ∈ D . f ( x ) � E g ( x ) 2. Γ(Γ(⊥)) = λσ. if ¬ �� b � σ then σ else • Example ( Z → Z ⊥ ) if ¬ �� b ��� c � σ then �� c � σ else ⊥ λ x ∈ Z . if x = 0 then ⊥ else x 3. Γ(Γ(Γ(⊥))) = λσ. if ¬ �� b � σ then σ else � if ¬ �� b ��� c � σ then �� c � σ else λ x ∈ Z . x if ¬ �� b ��� c ��� c � σ then �� c ��� c � σ else ⊥ • D → E is pointed cpo if E is pointed: • Denotation of while is � n ∈ω Γ n ( ⊥ ) ⊥ D → E = λ x ∈ D . ⊥ E • Gives �� while true do skip � = ⊥ Σ ⊥ →Σ ⊥ = λ σ ∈Σ ⊥ . ⊥ CS 611 Fall '00 -- Andrew Myers, Cornell University 13 CS 611 Fall '00 -- Andrew Myers, Cornell University 14 Fixed points • Want to show � n ∈ω Γ n (⊥) is solution to equation x = Γ ( x ) • Not true for arbitrary Γ! • Consider: Γ( x ) = if x = � then 1 0 1 else if x = 1 then � � else if x = 0 then 0 Need: monotonicity ( Γ n (⊥) not a chain!) • Consider a monotonic function: R � {- � , � } Γ( x ) = if x ≤ 0 then tan -1 (x) else 1 Need: continuity ( Γ(0) ≠ 0 ) CS 611 Fall '00 -- Andrew Myers, Cornell University 15 3

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