Programming Languages (CSC-302 99S)

Assignment 3: Denotational Semantics

Assigned: Friday, February 26, 1999
Due: Monday, March 8, 1999

You need only do problem 1 (all parts) on the semantics of SIMPLE. Problem 2 will serve as extra credit.

1. The Semantics of SIMPLE

In defining the semantics of SIMPLE, we decided on types for a number of the semantic functions and also began defining many of those functions. In this problem, you will consider how to develop semantic functions for some of the remainder of the language.

Here are the types of the semantic functions.

meaningProg : Prog -> Input -> Output
meaningSL : SL -> Cont -> Env -> Input -> Output
meaningStat : Stat -> Cont -> Env -> Input -> Output
meaningExp : Exp -> Env -> N
meaningNum : Num -> N

(note that meaningNum is built-in).

Here are the corresponding semantic domains.

Input = N* (lists of natural numbers)
Output = N* (lists of natural numbers)
Env = Ide -> N (functions from symbols to natural numbers)
Cont = Env -> Input -> Output 

You may also wish to refer to the class outline that gives an overview of the SIMPLE semantics.

1.a. The Meanings of Conditionals

SIMPLE has two kinds of conditionals.

Stat => if E then L1 else L2 fi
Stat => if E then L fi

Write equations that define the semantics of these two statements.

1.b. The Syntax of Case Statements

Suppose we decide to extend SIMPLE with a simple case statement of the following form:

case (E) of
  Num1: S1 ;
  Num2: S2 ;
  Numn: Sn

Show how we'd extend the abstract syntax to incorporate this new kind of statement.

1.c. The Semantics of Case Statements

Write equations that define the semantics of the new case statement.

1.d. The Meanings of Expressions

Define meaningExp, the semantic function for SIMPLE expressions. Recall that the abstract syntax for expressions is as follows.

Exp => E1 + E2
    |  E1 - E2
    |  E1 * E2
    |  E1 / E2
    |  I
    |  N
    |  (E)
  E is an element of Exp
  I is an element of Ide
  N is an element of Num

1.e. Assignment Expressions

In some languages (such as C and its descendants) it is possible to use an assignment statement as an expression, as in

while (x := x+1) do ... od

What changes would we have to make to the SIMPLE semantics to incorporate assignment expressions? Note that you need not describe changes to the concrete syntax, but just to the abstract syntax, semantic domains, and semantic functions.

2. The Semantics of Scheme

2.a. The semantics of let

A close reading of the Scheme semantics suggests that there's no formal description of what happens with let. Why not?

2.b. The confusion of call/cc

Describe, in English, what's happening in the definition of cwcc in the left column of p. 43 of the Scheme semantics.

Disclaimer Often, these pages were created ``on the fly'' with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at

Source text last modified Wed Mar 3 09:19:50 1999.

This page generated on Wed Mar 3 09:21:49 1999 by SiteWeaver. Validate this page's HTML.

Contact our webmaster at