administration
play

Administration Homework 2 due on Monday Scribes needed CS 611 - PDF document

Administration Homework 2 due on Monday Scribes needed CS 611 Winskel2, Gunter available on reserve in Advanced Programming Languages Engineering library Andrew Myers Cornell University Lecture 13 Domain Constructions 22 Sep


  1. Administration • Homework 2 due on Monday • Scribes needed CS 611 • Winskel×2, Gunter available on reserve in Advanced Programming Languages Engineering library Andrew Myers Cornell University Lecture 13 Domain Constructions 22 Sep 00 CS 611 Fall '00 -- Andrew Myers, Cornell University 2 Fixed points Meta-language • Denotational semantics for IMP rely on • Idea: define restricted language for taking fixed point to define �� while � expressing mathematical functions • Fixed points occur in most language • All functions expressible in this language definitions: needed to deal with loops are continuous –control flow loops: while • Looks like a programming language (ML) –data loops: recursive functions, recursive data –not executed: just mathematical notation structures, recursive types –can talk about non-termination! • Only know how to find least fixed pts for –“evaluation” is lazy (vs. eager in ML) continuous functions f • Need easy way to ensure continuity CS 611 Fall '00 -- Andrew Myers, Cornell University 3 CS 611 Fall '00 -- Andrew Myers, Cornell University 4 “Types” for Meta-language Lifting • Meta-language contains domain • If D is a domain (for now: cpo), can “lift” declarations indicating the set of values by adding new bottom element to form meta-variables can take on, e.g. pointed cpo D � λ f ∈Σ ⊥ →Σ ⊥ . λσ∈Σ ⊥ . if ¬ �� b � σ then σ else f ( �� c � ) • cpo defined by underlying set plus complete ordering relation � • Domains will function as types for meta- language • Elements of D � are � d i � , � where d i ∈ D –but with precisely defined meaning, ordering • Ordering relation: relation, etc. � d i ��� d � i � d i � d i ⇔ D –T 1 * T 2 is not necessarily modeled by T 1 ×T 2 ! ��� d i � D � • Meta-language consists of domains and • Complete? associated operations � CS 611 Fall '00 -- Andrew Myers, Cornell University 5 CS 611 Fall '00 -- Andrew Myers, Cornell University 6 1

  2. Discrete cpos let • Various discrete cpos: booleans ( T ), natural • Useful syntax: given d ∈ D ⊥ numbers ( ω ), integers ( Z ), … let x = d in e ( λ x ∈ D . e ) * d ≡ • Corresponding functions over discrete cpos exist: + : Z → Z , ∧ : T → T • Expresses evaluation of e that is strict in d • Often want to lift discrete cpos to take fixed • Example: �� while � points; helpful to extend fcns to pointed cpos • If f ∈ D → E, then f ⊥ ∈ D ⊥ → E ⊥ , f * ∈ D ⊥ → E are f ⊥ = λ d ∈ D ⊥ . if d= ⊥ then ⊥ else f ( d ) = fix λ f ∈Σ ⊥ →Σ ⊥ . λσ � ∈Σ ⊥ . f * = λ d ∈ D ⊥ . if d= ⊥ then ⊥ else f ( d ) (if E pointed) let σ=σ � in if ¬ �� b � σ then σ else f ( �� c � ) • 2 + ⊥ 2 = 4, 3 + ⊥ ⊥ = ⊥ , ⊥ ∧ ⊥ true = true • If f continuous, are f ⊥ , f * ? CS 611 Fall '00 -- Andrew Myers, Cornell University 7 CS 611 Fall '00 -- Andrew Myers, Cornell University 8 Unit Products • Simplest cpo: empty set ( ∅ ) • If D 1 , D 2 are domains, then D 1 × D 2 is a product domain • Next simplest: unit domain ( U ) Hasse diagram • Underlying set: pairs � d 1 , d 2 � where d i ∈ D i –single element: u . u –ordering relation: reflexive • Ordering: –complete: only directed set is { u } � d 1 , d 2 � � � d � 1 , d � 2 � iff • Used to represent computations that d 1 � d � 1 & d 2 � d � 2 terminate but do not produce a value, D 1 D 2 • Extends to n -tuples D 1 × D 2 argument for functions that need no • Operations: argument –tupling: � d 1 ,…, d m � • Also building block for other domains –projection: π i � d 1 ,…, d m � = d i CS 611 Fall '00 -- Andrew Myers, Cornell University 9 CS 611 Fall '00 -- Andrew Myers, Cornell University 10 CPO? Sums • Is product domain a cpo if D 1 , D 2 are? • Sometimes want to allow values of one kind or another: D 1 + D 2 • Any chain � d 0 , d � 0 � �� d 1 , d � 1 � �� d 2 , d � 2 � � … D 1 D 2 • Elements of domain are must have LUB in D 1 × D 2 elements of D 1 or D 2 tagged • Definition of � : d 0 � d 1 � d 2 � … is chain in with origin: { in i ( d i ) | d i ∈ D i } D 1 , d � 0 � d � 1 � d � 2 � … is chain in D 2 D 1 + D 2 • If d � ∈ D 1 , d � � ∈ D 2 are respective LUBs, • Form of in i is irrelevant (could be λ d . � i , d � ) � d � , d � � � ∈ D 1 × D 2 is LUB of chain of pairs • Preserves ordering of individual domains: • Operations continuous? in i ( d i ) � in j ( d j ) iff i=j, d i � d j • Injection function in i is continuous π i � n ∈ω x n = � π i x n = � d in • Extends naturally to multi-domain sum � � x 1 n , …, x mn � = � � d 1 n , …, � d mn � • CPO, but not pointed CS 611 Fall '00 -- Andrew Myers, Cornell University 11 CS 611 Fall '00 -- Andrew Myers, Cornell University 12 2

  3. Sums, cont’d Continuous functions • Why tag? Distinguishes identical domains • Given cpos D , E , define D → E as domain of – T = U + U, true = in 1 ( u ), false = in 2 ( u ) continuous functions mapping D to E • Sums unpacked with case construction: (subset of E D ) case e of x 1 . e 1 | x 2 . e 2 ≡ case e of D 1 ( x 1 ). e 1 | D 2 ( x 2 ). e 2 • Pointwise ordering: f � g iff f ( d ) � g ( d ) • Given e = in i ( d i ), has value f i ( d i ) ∈ E where f i ∈ D i → E = ( λ x i ∈ D i . e i ) • Complete? • Continuous function of e if all f i continuous: � n ∈ω f n = λ d ∈ D . � n ∈ω f n ( d ) continuous? � case e n of … = case � e n of … ? � f i ( d in ) = f i ( � d in ) ( λ d ∈ D . � n ∈ω f n ( d )) ( � m ∈ω d m ) = • Also continuous function of each f i � m ∈ω ( λ d ∈ D . � n ∈ω f n ( d )) ( d m ) ? � case e of f 1 n | f 2 = case e of � f 1 n | f 2 = � f 1n ( d 1 ) CS 611 Fall '00 -- Andrew Myers, Cornell University 13 CS 611 Fall '00 -- Andrew Myers, Cornell University 14 Proof of Continuity Lemma ( λ d ∈ D . � n ∈ω f n ( d )) ( � m ∈ω d m ) = � n � m f n ( d m ) = � n f n ( d n ) = � m � n f n ( d m ) Let e nm = f n ( d m ) � m ∈ω ( λ d ∈ D . � n ∈ω f n ( d )) ( d m )? = � n ∈ω f n ( � m ∈ω d m ) n ≤ n � , m ≤ m � � e nm � e n � m � e 02 e 20 = � n ∈ω � m ∈ω f n ( d m ) e 01 e 10 n m e 00 = � n ∈ω f n ( d n ) e nm � e n � n � for n � = max( m , n ), so � n,m e nm � � n e nn = � m ∈ω � n ∈ω f n ( d m ) e nn � � m e nm , so � n e nn � � n � m e nm , � m � n e nm = � m ∈ω ( λ d ∈ D . � n ∈ω f n ( d )) ( d m ) � m e nm � � n,m e nm , so � n � m e nm � � n,m e nm CS 611 Fall '00 -- Andrew Myers, Cornell University 15 CS 611 Fall '00 -- Andrew Myers, Cornell University 16 Operations on functions Meta-Language • apply ∈ ( D → E ) × D → E = λ p .( π 1 p )( π 2 p ) • Have defined various constructs that we can use to define continuous functions • curry ∈ (( D × E ) → F ) → ( D → E → F ) • Constructs are a syntax for a meta-language in = λ f ∈ ( D × E ) → F . λ d ∈ D. λ e ∈ E.f � d,e � which only continuous functions can be defined • compose = · � · ∈ ( D → E )×( E → F ) → ( D → F ) • How do we know when expression λ x . e is = λ � f,g � . λ d ∈ D . f ( g ( d )) continuous? • Idea: use structural induction on form of e so • fix ∈ ( D → D ) → D ( D pointed) every syntacally valid e can be abstracted over any variable to produce continuous function = λ g ∈ D → D . � n g n ( � ) • Problem: structural induction � need to = � n λ g ∈ D → D . g n ( � ) (LUB of cont.fcns!) consider open terms e CS 611 Fall '00 -- Andrew Myers, Cornell University 17 CS 611 Fall '00 -- Andrew Myers, Cornell University 18 3

  4. Continuity in variables • Idea: consider a meta-language expression e to be implicitly function of its free variables • e is continuous in variable x if λ x . e is continuous for arbitrary values of other (non- x ) free variables in e • e is continuous in variables not free in e • structural induction: for each syntactic form, show that term is continuous in variables assuming sub-terms are CS 611 Fall '00 -- Andrew Myers, Cornell University 19 4

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