Questions & Results
Q1 of 10Multiple ChoiceAccuracy45s · 1 pt
What does an operational semantics define?
A The grammar that determines which strings are valid programs B How programs execute, often on an abstract machine✓ Correct C How source text is split into tokens D The types that each expression may have 146 / 182 answered · 84% correct
Q2 of 10Multiple ChoiceAccuracy45s · 1 pt
In an inference rule
H1 H2 ... Hn
------------------
C
what are H1, …, Hn called?
C Premises: facts that must be established before C holds✓ Correct 162 / 182 answered · 96% correct
Q3 of 10Multiple ChoiceAccuracy45s · 1 pt
What is an inference rule with no premises called?
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 B e2 evaluated in the empty environment D e2 with every occurrence of x replaced by v1✓ 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)) B Plus (Num 4, Let ("x", Num 1, Ident "x"))✓ Correct C Plus (Num 4, Let ("x", Num 4, Num 4)) D Plus (Ident "x", Let ("x", Num 1, Num 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✓ Correct B It returns 1, treating y as 0 C It returns Plus (Ident "y", Num 1) unchanged 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 B The recursive call tree of the interpreter's eval✓ Correct C The environment used during evaluation D The grammar's parse table 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?
C It raises Failure because x is defined twice 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?
B The empty environment • 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
C It raises Failure: undefined 182 / 182 answered · 95% correct
Score Distribution
Score (points) →