Consider a language with numerals, booleans, +++, <<< and if-then-else under standard small-step rules. The operators +++ and <<< compute only on two numerals and reduce their operands left to right, and S-IfT and S-IfF fire only when the guard is the boolean true or false. Which of the following expressions are stuck or reduce to a stuck expression? Select all that apply.
if 3 then 1 else 2\text{if } 3 \text{ then } 1 \text{ else } 2if 3 then 1 else 2
if true then 1 else (true+1)\text{if true then } 1 \text{ else } (\text{true} + 1)if true then 1 else (true+1)
if (1<2) then 5 else 6\text{if } (1 < 2) \text{ then } 5 \text{ else } 6if (1<2) then 5 else 6
false+4\text{false} + 4false+4
(1<2)+3(1 < 2) + 3(1<2)+3
Unlock full course notes by signing up
Checking determinism by distinct successors
A draft machine specification has configurations tick(n)\operatorname{tick}(n)tick(n), where nnn is a nonnegative integer, and a terminal configuration halt\operatorname{halt}halt. Its complete transition rules are:
A relation satisfies the determinism condition when each configuration has at most one distinct successor configuration. Count distinct successors, rather than applicable rules.
Following the store through sequential assignments
A store assigns a current value to each variable. Write σ(x)\sigma(x)σ(x) for the value of xxx in store σ\sigmaσ. An assignment evaluates its right-hand expression in the current store and then replaces only the named variable:
The notation σ[x↦v]\sigma[x\mapsto v]σ[x↦v] means the same store except that xxx now holds vvv. Commands separated by semicolons execute in the displayed order, each receiving the store returned by its predecessor.
Big-step tree size versus small-step length
A language has these big-step rules: B-Val, the axiom v⇓vv \Downarrow vv⇓v for any numeral or boolean; B-Plus, which from e1⇓n1e_1 \Downarrow n_1e1⇓n1 and e2⇓n2e_2 \Downarrow n_2e2⇓n2 concludes e1+e2⇓n1+n2e_1 + e_2 \Downarrow n_1 + n_2e1+e2⇓n1+n2; and B-Lt, which has the same two premises and concludes e1<e2⇓be_1 < e_2 \Downarrow be1<e2⇓b, where bbb is true exactly when n1<n2n_1 < n_2n1<n2. Its small-step rules reduce operands left to right, one computation rule per transition.
For the expression (4+1)<(2+2)(4 + 1) < (2 + 2)(4+1)<(2+2), find:
the final value, written true or false;
Counting paths and outcomes under choice
A command language includes assignments, sequencing, and choose(C,D). A choice executes exactly one of its two commands. Its operational rules are:
Here σ\sigmaσ records the current value of xxx, and σ′\sigma'σ′ records the resulting value. Assignment evaluates its expression using the current value and replaces xxx with the result. A semicolon executes the next command using that updated value.