CORNELL CS 611 - Lecture 21 Denotational Semantics of REC

Unformatted text preview:

CS611 Lecture 21 Denotational Semantics of REC 18 October 2006Lecturer: Dexter Kozen1 A Metalanguage for Domain ConstructionsLast time we did several constructions that required us to check that various domains were CPOs and thatvarious associated operations were continuous. How can we avoid doing this kind of check over and overagain? One solution is to create an abstract metalanguage consisting of some basic operations that willallow us to do domain constructions (like function spaces, direct products, etc.) and that will ensure thatthe domains that are constructed are CPOs and the associated functions are continuous. We can composethese c onstructions to create more complicated domains from simpler ones and always be assured that thedesired mathematical prope rties hold.The simplest objects will be the discrete CPOs Z, N and U for the integers, the natural numbers, andthe unit domain, respectively. The unit domain contains a single element unit. These all have the discreteorder, meaning that if x v y, then x = y.For any domain A, we can construct a new domain A⊥, which is A adjoined with a new element ⊥below all the previous elements. Note that ⊥ is intended to be a new element, so we can actually iteratethis operation. The associated operations are the natural embedding D → D⊥and the lifting operation(·)∗: (D → E⊥) → (D⊥→ E⊥) defined by(d)∗(x)4=(d(x), if x 6= ⊥,⊥, if x = ⊥.Both these op e rations are continuous.Given CPOs D and E, we can form the product D×E consisting of all ordered pairs hd, ei with d ∈ D ande ∈ E, ordered componentwise. This is the set-theoretic Cartesian product of D and E with hd, ei v hd0, e0iiff d v d0and e v e0. This is a CPO, and it is easy to check thatFd∈X, e∈Yhd, ei = hFX,FY i. Alongwith the product constructor come the projections π1and π2defined by π1(hd, ei) = d and π2(hd, ei) = e,which are continuous. If f : C → D and g : C → E, then the function hf, gi : C → D × E defined byhf, gi4= λx. hf(x), g(x)i is continuous if f and g are. This is the unique function satisfying the equationsf = π1◦ hf, gi and g = π2◦ hf, gi. The binary product can be generalized to an arbitrary productQx∈XDxwith associated projections πy:Qx∈XDx→ Dy.Given CPOs D and E, we can form the sum (or coproduct) D + E, corresponding to the disjoint unionof D and E. We would like to take the union of the sets D and E, but we need to mark the elem ents tomake sure we can tell which set they originally came from in case D and E have a nonempty intersection.To do this, we defineD + E4= {in1(d) | d ∈ D} ∪ {in2(e) | e ∈ E},where in1and in2are any one-to-one functions with disjoint ranges; for example, we could take in1(x) = h1, xiand in2(x) = h2, xi. We define ini(x) v inj(y) iff i = j and x v y. Any chain in D + E must be completelycontained in {in1(x) | x ∈ D} or {in2(x) | x ∈ E}, so D + E is a CPO. The associated operations are theinjections in1: D → D + E and in2: E → D + E, which are continuous. If f : D → C and g : E → C, thenwe can combine f and g into a function f + g : D + E → C using a case construct:f + g4= λx. case x of in1(y) → f(y) | in2(y) → g(y).This is continuous if f and g are, and it is the unique function satisfying the equations f = (f + g) ◦ in1andg = (f + g) ◦ in2. As with products and projections, the binary coproduct can be generalized to an arbitrarycoproductPx∈XDxwith associated injections iny: Dy→Px∈XDx.Finally, given CPOs D and E, we can define the CPO [D → E ] of all continuous functions from D to Ewith the pointwise ordering. The corresponding operations are:11. apply : [D → E ] × D → E that applies a given function to a given argument;2. compose : [E → F ] × [D → E ] → [D → F ];3. curry : [D × E → F ] → [D → [E → F ]];4. uncurry : [D → [E → F ]] → [D × E → F ]; and most importantly,5. fix : [D → D ] → D, defined by λg ∈ [D → D ].Fgn(⊥), that takes a function and returns its leastfixpoint. To apply fix, D must have a bottom element ⊥.All these functions are continuous.2 Denotational Semantics for REC2.1 REC Syntaxp ::= let d in ed ::= f1(x1, . . . , xa1) = e1...fn(x1, . . . , xan) = ene ::= n | x | e1⊕ e2| let x = e1in e2| ifp e0then e1else e2| fi(e1, . . . , eai)The functions in d are mutually recursive. It is reasonable to expect that under most semantics, let f1(x1) =f1(x1) in f1(0) will loop infinitely, but let f1(x1) = f1(x1) in 0 will halt and return 0.For example,letf1(n, m) = ifp m2− n then 1 else (n − m(n div m)) · f1(n, m + 1)f2(n) = ifp f1(n, 2) then n else f2(n + 1)inf2(1000)In this REC program, f2(n) finds the first prime number p ≥ n. The value of n − m(n div m is positiveiff m do e s not divide n.2.2 CBV Denotational Semantics for RECThe meaning function is [[e]] ∈ FEnv → Env → Z⊥, where FEnv and Env denote the sets of variableenvironments and function environments, respectively, as used in REC.ρ ∈ Env = Var → Zϕ ∈ FEnv = (Za1→ Z⊥) × · · · × (Zan→ Z⊥)Here Var is a countable set of variables, Z is the set of integers, which are the values that can b e boundto a variable in an environment, and Zm= Z × Z × · · · × Z| {z }m times.2[[n]] ϕ ρ4= n[[x]] ϕ ρ4= ρ(x)[[e1⊕ e2]] ϕ ρ4= let v1∈ Z = [[e1]] ϕ ρ inlet v2∈ Z = [[e2]] ϕ ρ inv1⊕ v2= [[e1]] ϕ ρ ⊕⊥[[e2]] ϕ ρ[[let x = e1in e2]] ϕ ρ4= let y ∈ Z = [[e1]] ϕ ρ in[[e2]] ϕ ρ[y/x][[ifp e0then e1else e2]] ϕ ρ4= let v0∈ Z = [[e0]] ϕ ρ inif v0> 0 then [[e1]] ϕ ρ else [[e2]] ϕ ρ[[fi(e1, . . . , eai)]] ϕ ρ4= let v1∈ Z = [[e1]] ϕ ρ in...let vai∈ Z = [[eai]] ϕ ρ in(πiϕ)hv1, . . . , vaiiThe meaning of a program let d in e is[[let d in e]]4= [[e]] ϕ ρ,where ρ is some initial environment containing default values for the variables, andϕ = fix λψ ∈ FEnv. hλv1∈ Z, . . . , va1∈ Z. [[e1]] ψ ρ[v1/x1, . . . , va1/xa1],...λv1∈ Z, . . . , van∈ Z. [[en]] ψ ρ[v1/x1, . . . , van/xan]i.For this fixpoint to exist, we need to know that FEnv a pointed CPO. But FEnv is a product, and aproduct is a pointed CPO when each factor …


View Full Document

CORNELL CS 611 - Lecture 21 Denotational Semantics of REC

Download Lecture 21 Denotational Semantics of REC
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 21 Denotational Semantics of REC and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 21 Denotational Semantics of REC 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?