For each of program points 1, 2, 3, 4 and 5, please describe the environment in effect after evaluation has reached
that point. You may assume that the evaluation begins in an empty environment, and that the environment is cumu-
lative thereafter. The program points are supposed to indicate points at which all complete preceding declarations
have been fully evaluated. In describing the environments 1 through 4, you may use set notation, as done in class,
or you may use the update operator
+
. If you use set notation, no duplicate bindings should occur. The answer for
program point 5 should be written out fully in set notation.
Solution:
•
ρ
1
=
{
y
→
17
, x
→
3
.
9
}
•
ρ
2
=
{
x
→
4
}
+
ρ
1
=
{
x
→
4
, y
→
17
}
•
ρ
3
=
{
z
→
21
}
+
ρ
1
=
{
z
→
21
, y
→
17
, x
→
3
.
9
}
•
ρ
4
=
{
f
→
x
→
fun y -> x + y + z
, ρ
3
}
+
ρ
3
=
{
f
→
x
→
fun y -> x + y + z
, ρ
3
, z
→
21
, y
→
17
, x
→
3
}
•
{
z
→
63
, g
→
w
→
f w w
, ρ
4
, f
→
x
→
fun y -> x + y + z
, ρ
3
, y
→
17
, x
→
3
}
=
{
z
→
63
,
g
→
w
→
f w w
,
{
f
→
x
→
fun y -> x + y + z
,
{
z
→
21
, y
→
17
, x
→
3
.
9
}
,
z
→
21
, y
→
17
, x
→
3
}
,
f
→
x
→
fun y -> x + y + z
,
{
z
→
21
, y
→
17
, x
→
3
.
9
}
,
y
→
17
, x
→
3
}
2.
(20 pts) Below is a fragment of Ocaml code. Describe everything that is displayed on the screen (its observable