A compiler developer tests three proposed unification traces over finite types. The base types Int\mathrm{Int}Int and Bool\mathrm{Bool}Bool are distinct, and List\mathrm{List}List and Pair\mathrm{Pair}Pair are constructors.
Each displayed state is the complete set of equations: there are no separately stored bindings. A transition is valid only if it preserves exactly the same solutions for all variables appearing in the initial state. Several sound rewrites may be combined in one transition. Each numbered state results from one transition from the preceding state.
For each trace, enter the number of its first invalid transition. Enter 000 if every transition is valid. Use exact integers.
Trace A
Initial state:
Trace B
Trace C
Unlock full course notes by signing up
Classify finite-type constraints
A solver accepts only finite types with rigid constructors and distinct base types Int, Bool, and Char. Classify each independent equation below. Variables are reset for every row. Enter exactly success for a solvable equation, clash for a constructor conflict, or occurs for an occurs-check failure.
Preserve the freedom in an equation
For the sole type equation x=yx=yx=y, consider these substitutions, with unlisted variables unchanged and zzz a fresh variable:
Which statements are true under structural equality of finite types? Select all that apply.
Check repeated substitution
A compiler represents a substitution SSS by the following bindings:
Each application is simultaneous: replace variables in the input expression once, but do not apply SSS again inside a replacement inserted during that application. Constructors remain unchanged. Write Sn(t)S^n(t)Sn(t) for applying SSS to ttt exactly nnn times.
Detect a cycle hidden by earlier bindings
A compiler's finite-type solver processes these constraints in the displayed order. Arrow(X,Y) denotes a function from X to Y, and all constructors are rigid:
After processing the first two equations, fully propagate their bindings into the right side of the third equation. Give that right-side expression using Pair, List, and Arrow notation. Then identify the outcome by entering success, constructor clash, or occurs check failure.