Corrected Inference for Simple Objects
Prerequisites. Direct starred prerequisites: chapter 4, chapter 13. No later core chapter depends on this route.
Consider
This is the correction made by Wand’s 1988 corrigendum to the 1987 simple- object inference system. The repaired result is an effectively generated finite complete set of typings. It is not a principal-type theorem under an unnamed restriction. The later record-concatenation calculus and Rémy’s unitary record calculus will be named separately when they enter.
Rows remember presence
Fix a countable set of labels. A semantic row is a finite partial map from labels to types. Write
Definition 26.1 — The corrected row-expression fragment¶
Type and row expressions are
A finite family
Referenced from 6 locations
The distinction between one most general unifier and a finite complete set is load bearing. A unitary problem has one most general solution. A finitary problem may require several incomparable most general branches.
The typing constraints for the record primitives are read directly from their operations. With
Lemma 26.2 — Constraint characterization¶
For the simply typed lambda calculus with integers, addition, null records, selection, and right-biased update, a substitution solves the syntax-directed constraints of a term exactly when it supplies a typing derivation for that term.
Referenced from 3 locations
Proof of Lemma 26.2 — Constraint characterization
Proof. Induct on the term. Variables equate an occurrence variable with its binder variable. Application generates
Exercise 26.1¶
Generate constraints for
Referenced from 3 locations
The invalid decomposition
The original unification step treated update as an injective constructor:
The repair determines which of the two input rows already contains
Lemma 26.3 — Four-way overwrite decomposition¶
The equation
Referenced from 6 locations
Proof of Lemma 26.3 — Four-way overwrite decomposition
Proof. Suppose (26.3) holds. At label
Conversely, in every table row the two inputs agree away from
Exercise 26.2¶
For each row of the table in lemma 26.3, choose concrete finite rows and calculate both sides of (26.3) at
Referenced from 3 locations
The shared-variable termination case
Branching alone does not repair termination. If both sides contain the same row variable, repeated decomposition can reproduce a problem of the same size. The representative equation is
Definition 26.4 — Presence obligations¶
The obligation
Referenced from 6 locations
Lemma 26.6 — Termination measure for the corrected row phase¶
Consider the row-specific phase whose steps are rigid-constructor decomposition, the four-way overwrite split, replacement of a shared-variable equation by canonical presence obligations, and discharge or rejection of one such obligation. Order its states lexicographically by the total number of constructors in active row equations and then by the number of unresolved atomic obligations. Every step in this phase strictly decreases the order.
Referenced from 4 locations
Proof of Lemma 26.6 — Termination measure for the corrected row phase
Proof. Ordinary decomposition removes one active type or row constructor and adds only its proper subexpressions, so the first component decreases. A four-way overwrite split removes the two compared update heads before solving a branch, which also decreases the first component. The shared-variable case removes its active equation and adds only atomic presence obligations; atomic obligations contribute no constructors to the first component. Discharging or rejecting an atomic obligation leaves the first component fixed and decreases the second. No rule adds an active equation after entering the atomic phase. Lexicographic order on pairs of natural numbers is well founded, so the row-specific phase has no infinite branch. Ordinary variable elimination is outside this phase and uses the original unification algorithm’s halting measure. ◻
Exercise 26.3¶
Show that direct substitution in
Referenced from 3 locations
The counterexample has two generators
Retain the full countable label universe of section 26.1. The program mentions only
Proposition 26.7 — No principal scheme for W¶
In the corrected 1987 row system over its countable label universe,
Referenced from 4 locations
Proof of Proposition 26.7 — No principal scheme for W
Proof. Both displayed schemes type
For completeness, consider any typing of
It remains to exclude one generator. A row expression whose instances include both the empty row and a row with an
The proposition is the smallest witness against the published principal- types claim. It is not a counterexample to decidable typability.
Theorem 26.8 — Corrigendum boundary: finite complete sets¶
For every program of Wand’s 1987 simple-object system, the corrected row-equation procedure effectively generates a finite complete set of type schemes. Consequently typability in that system is decidable. The theorem does not assert that the set has one member.
Referenced from 4 locations
Proof of Theorem 26.8 — Corrigendum boundary: finite complete sets
Proof. This is the corrected result stated on page 132 of Wand’s one-page 1988 corrigendum [Wan88]: the published principal-type claim is withdrawn there, and the replacement is the effective finite complete set constructed by the corrected branching procedure. The imported algorithm replaces invalid decomposition (26.2) by the four cases of lemma 26.3, unions the unifier sets returned by those branches, and treats the shared-variable equations of definition 26.4 separately. By lemma 26.6, the row-specific repair introduces no new infinite branch. The corrigendum’s imported halting argument combines this special treatment with the original measure for the other unification steps. Each equation creates only finitely many branches. The resulting scheme family is finite, every returned scheme types the term, and every typing factors through one returned branch. Those are exactly the soundness and completeness clauses of definition 26.1. The source supplies no theorem selecting one branch as principal. ◻
A separately named successor calculus
Wand’s later record-concatenation calculus starts from a different operation. For semantic records
Lemma 26.9 — Concatenation constraints are exact¶
A substitution satisfies (26.7) for every label exactly when its result row is the right-biased concatenation of its two input rows.
Referenced from 3 locations
Proof of Lemma 26.9 — Concatenation constraints are exact
Proof. Fix
Expanding the positive Boolean combination of equations into disjunctive normal form yields finitely many conjunctions. Ordinary unification returns a most general unifier for every solvable conjunction. Their union is a finite complete set, not a single principal solution.
Theorem 26.10 — Finite complete sets for record concatenation¶
In Wand’s 1991 finite-label record-concatenation calculus, every closed term has an effectively generable finite set of type schemes whose substitution instances are exactly the term’s typings. Typability is decidable.
Referenced from 4 locations
Proof of Theorem 26.10 — Finite complete sets for record concatenation
Proof. This is Wand’s finite-label theorem for record concatenation. Constraint characterization reduces typing to a positive Boolean formula. Its atoms are ordinary equations and the cases in (26.7). Finite
With an unbounded label set, the same paper replaces infinite enumeration by extension constraints and returns pairs consisting of a finite constraint set and a type scheme. That theorem belongs to the successor calculus; it is not a missing clause of the 1988 corrigendum.
Exercise 26.4¶
Take
Referenced from 3 locations
Rémy’s theorem is not the corrigendum
Rémy assigns every label a presence descriptor in a sorted equational algebra. For record extension and selection, without Wand’s right-biased concatenation operation and without the incompletely formalized recursive object extensions, that algebra has decidable unitary unification. The ordinary Hindley–Milner reduction then gives principal typings.
Thus three claims have three signatures:
| system | operation boundary | inference result |
|---|---|---|
| Wand 1987 plus 1988 correction | simple objects and overwrite rows | finite complete sets; decidable typability |
| Wand 1991 | right-biased record concatenation | finite complete sets; decidable typability |
| Rémy 1991 | sorted rows with extension and selection | unitary unification and principal typings |
The last row cannot be used to replace either of the first two. Adding recursive objects or concatenation changes the equation theory on which unitarity depends.
Exercise 26.5¶
Classify each claim as belonging to the corrected 1987 system, the 1991 concatenation system, or Rémy’s sorted record calculus: one most general row unifier; a four-way overwrite split; one disjunction per concatenated field; principal typing for extension and selection; finite complete type sets.
Referenced from 3 locations
The chapter exports lemma 26.3, lemma 26.5, the exact imported result theorem 26.8, and the separately named successor theorem theorem 26.10. It exports no unrestricted principal-type theorem for simple objects and no theorem that transfers Rémy’s unitary result to recursive objects or record concatenation.
Sources.
The counterexample, four overwrite cases, shared-variable termination repair, and finite-complete-set correction are from [Wan88]; the invalid claim being corrected is in [Wan87]. The finite-label concatenation theorem and its exact disjunctive constraints are from [Wan91]. Rémy’s separate unitary boundary is from [Ré91].
Suggested first pass.
Problems exercise 26.6, exercise 26.7, and exercise 26.10.
Exercise 26.6¶
Derive both
Referenced from 4 locations
Exercise 26.7¶
Let
Referenced from 4 locations
Exercise 26.9¶
For
Referenced from 3 locations
Exercise 26.10¶
Practical project.corrected-row-unifier Implement the finite one-label overwrite step, including all four presence branches and the shared-variable special case. Maintain the invariant that every returned branch denotes only solutions of the input equation and that every concrete solution selects a returned branch. Run the exact counterexample boundary from proposition 26.7 on a bounded two-label corpus: accept empty and PASS lines and final summary in appendix E.