CMSC330_10/29 - Semantics

CMSC 330 — Fall 2026 · October 29, 2026 · 182 players · Max 10 pts

Questions & Results

Q1 of 10Multiple ChoiceAccuracy45s · 1 pt

What does an operational semantics define?

A The grammar that determines which strings are valid programs
17
B How programs execute, often on an abstract machine
123
✓ Correct
C How source text is split into tokens
2
D The types that each expression may have
4
146 / 182 answered · 84% correct
Q2 of 10Multiple ChoiceAccuracy45s · 1 pt

In an inference rule

H1   H2   ...   Hn
------------------
        C

what are H1, …, Hn called?

A Conclusions
B Axioms
6
C Premises: facts that must be established before C holds
155
✓ Correct
D Derivations
1
162 / 182 answered · 96% correct
Q3 of 10Multiple ChoiceAccuracy45s · 1 pt

What is an inference rule with no premises called?

A An axiom
165
✓ Correct
B A judgment
5
C A derivation
D An environment
170 / 182 answered · 97% correct
Q4 of 10Multiple ChoiceAccuracy60s · 1 pt

In the substitution-based Let rule

e1 ⇒ v1     e2{v1/x} ⇒ v2
--------------------------
 let x = e1 in e2 ⇒ v2

what does e2{v1/x} mean?

A e2 with every occurrence of v1 replaced by x
26
B e2 evaluated in the empty environment
3
C e2 divided by v1/x
1
D e2 with every occurrence of x replaced by v1
144
✓ Correct
174 / 182 answered · 83% correct
Q5 of 10Multiple ChoiceAccuracy75s · 1 pt
type exp =
  | Ident of id
  | Num of int
  | Plus of exp * exp
  | Let of id * exp * exp

Using the lecture's subst function, what does this return?

subst 4 "x" (Plus (Ident "x", Let ("x", Num 1, Ident "x")))
A Plus (Num 4, Let ("x", Num 1, Num 4))
46
B Plus (Num 4, Let ("x", Num 1, Ident "x"))
120
✓ Correct
C Plus (Num 4, Let ("x", Num 4, Num 4))
4
D Plus (Ident "x", Let ("x", Num 1, Num 4))
4
174 / 182 answered · 69% correct
Q6 of 10Multiple ChoiceAccuracy60s · 1 pt

Using the substitution-based interpreter, what happens when we evaluate this?

eval (Plus (Ident "y", Num 1))
A It raises Failure: there is no rule for an unbound Ident, so no value exists
166
✓ Correct
B It returns 1, treating y as 0
1
C It returns Plus (Ident "y", Num 1) unchanged
10
D It returns 2
2
179 / 182 answered · 93% correct
Q7 of 10Multiple ChoiceAccuracy45s · 1 pt

A derivation tree for e ⇒ v has the same shape as which of the following?

A The token list produced by the scanner
2
B The recursive call tree of the interpreter's eval
158
✓ Correct
C The environment used during evaluation
11
D The grammar's parse table
3
174 / 182 answered · 91% correct
Q8 of 10Multiple ChoiceAccuracy60s · 1 pt
let a : env = extend (extend [] "x" 0) "y" 2
let r = lookup (extend a "x" 5) "x"

What is the value of r?

A 0
3
B 2
16
C It raises Failure because x is defined twice
4
D 5
155
✓ Correct
178 / 182 answered · 87% correct
Q9 of 10Multiple ChoiceAccuracy60s · 1 pt

In the environment-style Let rule

A; e1 ⇒ v1     ?; e2 ⇒ v2
--------------------------
A; let x = e1 in e2 ⇒ v2

which environment replaces the ? when evaluating e2?

A A
33
B The empty environment •
8
C A, x:v1
123
✓ Correct
D x:v1 only
14
178 / 182 answered · 69% correct
Q10 of 10Multiple ChoiceAccuracy60s · 1 pt

Using the environment-based interpreter, what does this expression evaluate to?

let x = 5 in (let x = 1 in x) + x
A 2
5
B 10
C It raises Failure: undefined
4
D 6
173
✓ Correct
182 / 182 answered · 95% correct

Score Distribution

1
2
2
5
5
13
18
45
48
43
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
182
Average Score
8.1
High Score
10
Max Possible
10