Held: Wednesday, May 6, 1998
V in Val Numeric constants I in Id Variables E in Exp Expressions S in Sta Statements L in SL Statement Lists P in Prog Programs
Prog ::= L
SL ::= S
| S ; L
Stat ::= I = E
| if E then L fi
| if E then L0 else L1 fi
| while E do L od
| read(I)
| write(E)
Exp ::= E0 + E1
| E0 * E1
| E0 - E1
| E0 / E1
| (E)
| V
| I
meaningProg, meaningStat,
meaningExp, and meaningSL.
N Natural numbers U = Id -> N Environments I = N* Input O = N* Output
meaningProg :: Prog -> I -> O
C = U -> I -> O
meaningStat. To determine
the meaning of a statement, we need its environment, input, and
continuation. The result is output.
meaningStat : Stat -> U -> I -> C -> O
meaningSL : SL -> C-> U -> I -> -> O
meaningExp? It might be useful to specify what happens
with the expression, or it might be useful just to give a value. In
either case, we need the environment (since the expression may contain
variables). Rather than using continuations, we'll just have
the meaning of an expression be a value.
meaningExp : Exp -> U -> N
meaningProg[[SL]] = meaningSL[[SL]] cleanup basicEnv basicEnv : U basicEnv = \x . undefined cleanup = \env . \inp . nil
\var . body
for lambda var . body
meaningProg[[SL]] = \inp . meaningSL[[SL]] cleanup basicEnv inp
meaningSL[[S]] = \cont . \env . \inp . meaningS[[S]] env inp cont
meaningSL[[S;L]] = \cont . \env . \inp . meaningS[[S]] env inp meaningSL[[L]]
t -> a, b,
which means "if t then a else b".
car and cdr.
meaningStat[[read(I)]] =
\env . \inp . \cont .
cont (setenv env I (car inp)) (cdr inp)
setenv : U -> Id -> N -> U
setenv env id num =
\x . (x == id) -> num , (env id)
cons operation. (See the Scheme specification for a
more formal version.)
meaningStat[[write(E)]] =
\env . \inp . \cont .
cons (meaningExp[[E]] env) (cont env inp)
meaningStat[[I = E]] =
\env . \inp . \cont .
cont (setenv env I (meaningExp[[E]] env)) inp
meaningStat[[while E do L od]] = F(E,L) s.t.
F(E,L) :: U -> I -> C -> O
F(E,L) env inp cont =
((meaningExp[[E]] env) == 0) -> cont env inp,
meaningSL(L) env inp (\e . \i . F(E,L) e i cont)
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.
Source text last modified Thu May 7 20:29:45 1998.
This page generated on Mon May 11 08:30:22 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu