Audit preservation of solutions

A compiler developer tests three proposed unification traces over finite types. The base types Int\mathrm{Int} and Bool\mathrm{Bool} are distinct, and List\mathrm{List} and Pair\mathrm{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 00 if every transition is valid. Use exact integers.


Trace A


Initial state:


{a=Int, b=List(a)}.\{a=\mathrm{Int},\ b=\mathrm{List}(a)\}.


  1. {a=Int, b=List(Int)}\{a=\mathrm{Int},\ b=\mathrm{List}(\mathrm{Int})\}
  2. {b=List(Int)}\{b=\mathrm{List}(\mathrm{Int})\}

Trace B


Initial state:


{Pair(a,b)=Pair(c,List(c)), d=Bool}.\{\mathrm{Pair}(a,b)=\mathrm{Pair}(c,\mathrm{List}(c)),\ d=\mathrm{Bool}\}.


  1. {a=c, b=List(c), d=Bool}\{a=c,\ b=\mathrm{List}(c),\ d=\mathrm{Bool}\}
  2. {c=a, b=List(a), d=Bool}\{c=a,\ b=\mathrm{List}(a),\ d=\mathrm{Bool}\}
  3. {c=Int, a=Int, b=List(Int), d=Bool}\{c=\mathrm{Int},\ a=\mathrm{Int},\ b=\mathrm{List}(\mathrm{Int}),\ d=\mathrm{Bool}\}

Trace C


Initial state:


{List(a)=List(b), b=Int, c=c}.\{\mathrm{List}(a)=\mathrm{List}(b),\ b=\mathrm{Int},\ c=c\}.


  1. {a=b, b=Int, c=c}\{a=b,\ b=\mathrm{Int},\ c=c\}
  2. {a=Int, b=Int, c=c}\{a=\mathrm{Int},\ b=\mathrm{Int},\ c=c\}
  3. {a=Int, b=Int}\{a=\mathrm{Int},\ b=\mathrm{Int}\}
TraceFirst invalid transition
A
B
C

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Unification Questions: