The two-sorted grammar is 𝜏::=𝛼∣𝖭𝖺𝗍∣𝖡𝗈𝗈𝗅∣𝖲𝗍𝗋𝗂𝗇𝗀∣𝜏→𝜏∣𝖱𝖾𝖼(𝜌)∣𝖵𝖺𝗋(𝜌),𝜌::=𝜉∣𝜖𝜌∣{ℓ:𝜏∣𝜌}. A lacks predicate is 𝜌\ℓ. Normalize it by 𝜖𝜌\ℓ⇓⊤,{𝑚:𝜏∣𝜌}\ℓ⇓𝜌\ℓ(𝑚≠ℓ),{ℓ:𝜏∣𝜌}\ℓ⇓⊥,𝜉\ℓ⇓𝜉\ℓ. Predicate contexts are normalized finite sets of residual variable predicates. Entailment and strict row formation are
𝜉\ℓ∈𝑃
𝑃⊩𝜉\ℓ
L-Assume
𝑃⊩𝜖𝜌\ℓ
L-Empty
𝑃⊩𝜌\ℓ𝑚≠ℓ
𝑃⊩{𝑚:𝜏∣𝜌}\ℓ
L-Extend
𝑃⊢𝜉𝗋𝗈𝗐
Row-Var
𝑃⊢𝜖𝜌𝗋𝗈𝗐
Row-Empty
𝑃⊢𝜌𝗋𝗈𝗐𝑃⊢𝜏𝗍𝗒𝗉𝖾𝑃⊩𝜌\ℓ
𝑃⊢{ℓ:𝜏∣𝜌}𝗋𝗈𝗐
Row-Ext
Type formation is
𝑃⊢𝜏𝗍𝗒𝗉𝖾𝑃⊢𝜐𝗍𝗒𝗉𝖾
𝑃⊢𝜏→𝜐𝗍𝗒𝗉𝖾
Ty-Arrow
𝑃⊢𝜌𝗋𝗈𝗐
𝑃⊢𝖱𝖾𝖼(𝜌)𝗍𝗒𝗉𝖾
Ty-Record
𝑃⊢𝜌𝗋𝗈𝗐
𝑃⊢𝖵𝖺𝗋(𝜌)𝗍𝗒𝗉𝖾
Ty-Variant
The type-variable and three base-type cases are axioms. Row equality exchanges adjacent distinct labels only; 𝑎≡𝑃𝑎′ additionally requires both sides formed under 𝑃. An admissible substitution 𝑆:𝑃→𝑄 is sorted, has 𝑄-formed images, normalizes 𝑃[𝑆], and satisfies 𝑄⊩𝗇𝖿(𝑃[𝑆]).
Qualified schemes are 𝜒::=𝑃⇒𝜏,𝜎::=∀¯𝛼¯𝜉.𝑃⇒𝜏. For 𝑋=ftv(𝑃,𝜏)∖ftv(Γ),𝑃𝗀={𝑝∈𝑃∣ftv(𝑝)⊆𝑋},𝑃𝗋=𝑃∖𝑃𝗀, put GenΓ(𝑃⇒𝜏)=∀𝑋.𝑃⇒𝜏. Qualified typing is
Γ(𝑥)=∀¯𝛼¯𝜉.𝑄⇒𝜏0𝑃⊩𝗇𝖿(𝑄[𝑇])𝑃⊢𝜏0[𝑇]𝗍𝗒𝗉𝖾
Γ⊢𝑞𝑥:𝑃⇒𝜏0[𝑇]
Q-Var
𝑐:∀¯𝛼¯𝜉.𝑄⇒𝜏0∈Σ0𝑃⊩𝗇𝖿(𝑄[𝑇])𝑃⊢𝜏0[𝑇]𝗍𝗒𝗉𝖾
Γ⊢𝑞𝑐:𝑃⇒𝜏0[𝑇]
Q-Const
Γ,𝑥:𝜏1⊢𝑞𝑒:𝑃⇒𝜏2
Γ⊢𝑞𝜆𝑥.𝑒:𝑃⇒𝜏1→𝜏2
Q-Lam
Γ⊢𝑞𝑒1:𝑃1⇒𝜏1→𝜏2Γ⊢𝑞𝑒2:𝑃2⇒𝜏1𝗇𝖿(𝑃1∪𝑃2)=𝑃
Γ⊢𝑞𝑒1𝑒2:𝑃⇒𝜏2
Q-App
Γ⊢𝑞𝑒1:𝑃1⇒𝜏1Γ,𝑥:GenΓ(𝑃1⇒𝜏1)⊢𝑞𝑒2:𝑃2⇒𝜏2𝗇𝖿(𝑃𝗋1∪𝑃2)=𝑃
Γ⊢𝑞𝗅𝖾𝗍𝑥=𝑒1𝗂𝗇𝑒2:𝑃⇒𝜏2
Q-Let
Γ⊢𝑞𝑒:𝑃⇒𝜏𝜏≡𝑃𝜏′
Γ⊢𝑞𝑒:𝑃⇒𝜏′
Q-Conv
The saturated record and variant terms add 𝑒::=⋯∣{}∣{ℓ=𝑒∣𝑒}∣𝑒.ℓ∣𝑒−ℓ∣⟨ℓ=𝑒⟩∣𝖾𝗆𝖻𝖾𝖽ℓ𝑒∣𝖼𝖺𝗌𝖾ℓ𝑒𝗈𝖿{⟨ℓ=𝑥⟩↦𝑒1;𝑦↦𝑒2}. Their complete typing rules are
Values and the complete source evaluation contexts are 𝑣::=𝑐∣𝜆𝑥.𝑒∣𝑅∣𝑉,𝑅::={}∣{ℓ=𝑣∣𝑅},𝑉::=⟨ℓ=𝑣⟩,𝐸::=[]∣𝐸𝑒∣𝑣𝐸∣𝗅𝖾𝗍𝑥=𝐸𝗂𝗇𝑒∣{ℓ=𝐸∣𝑒}∣{ℓ=𝑣∣𝐸}∣𝐸.ℓ∣𝐸−ℓ∣⟨ℓ=𝐸⟩∣𝖾𝗆𝖻𝖾𝖽ℓ𝐸∣𝖼𝖺𝗌𝖾ℓ𝐸𝗈𝖿{⟨ℓ=𝑥⟩↦𝑒1;𝑦↦𝑒2}. Besides beta and let, the primitive roots are {ℓ=𝑣∣𝑅}.ℓ⟶𝑣,{𝑚=𝑤∣𝑅}.ℓ⟶𝑅.ℓ(𝑚≠ℓ),{ℓ=𝑣∣𝑅}−ℓ⟶𝑅,{𝑚=𝑤∣𝑅}−ℓ⟶{𝑚=𝑤∣𝑅−ℓ}(𝑚≠ℓ),𝖾𝗆𝖻𝖾𝖽ℓ⟨𝑚=𝑣⟩⟶⟨𝑚=𝑣⟩(𝑚≠ℓ), together with matching case reduction to 𝑒1[𝑣/𝑥] and unequal-tag case reduction to 𝑒2[⟨𝑚=𝑣⟩/𝑦]. Compatibility is 𝐸⟨𝑒⟩⟶𝐸⟨𝑒′⟩.
Constrained insertion and solving have judgments 𝗂𝗇𝗌𝖾𝗋𝗍𝑃(ℓ:𝜏,𝜌)=(𝐼,𝑄,𝜌−),𝗌𝗈𝗅𝗏𝖾(𝑃;𝐸)=(𝑈,𝑄), and are mutually recursive. Insertion has four clauses: an open tail 𝜉 is replaced by {ℓ:𝜏∣𝜁}, adding 𝜁\ℓ; empty fails; a matching head solves its field-type equation; and a distinct head recurses on the tail and is reattached. Every fresh tail is global to the run.
The solver normalizes 𝑃 before every call, uses the empty and reflexive clauses first, then sorted variable elimination with occurs check, orientation, rigid type decomposition, empty-row cases, and finally row-extension exposure. The last clause is exactly 𝗂𝗇𝗌𝖾𝗋𝗍𝑃(ℓ:𝜏,𝑞)=(𝐼,𝑃1,𝑞−)𝗌𝗈𝗅𝗏𝖾(𝑃1;(𝜌[𝐼]≐𝑞−,𝐸[𝐼]))=(𝑉,𝑄)𝗌𝗈𝗅𝗏𝖾(𝑃;({ℓ:𝜏∣𝜌}≐𝑞,𝐸))=(𝐼;𝑉,𝑄). These clauses are tried in this order, and rigid subequations are prepended left to right. A variable–variable equation eliminates the left variable; the symmetric orientation is used only when the left side is not a variable.
Qualified W returns 𝖶𝑟(Γ,𝑒)=(𝑃,𝑆,𝜏). Its variable, constant, lambda, application, and let clauses are the HM clauses with qualified instantiation, normalized predicate unions, solver calls, and the residual 𝑃𝗋1 retained at let. The exact new clauses are: empty returns (∅,id,𝖱𝖾𝖼(𝜖𝜌)); extension infers payload then record and solves the record shape with a fresh tail lacking ℓ; selection and restriction solve against 𝖱𝖾𝖼({ℓ:𝛼∣𝜉}); injection introduces a fresh tail and its lacks predicate; embedding solves the old variant row and leaves the new payload type fresh; case solves the scrutinee shape, infers the matching branch, then the residual branch under all prior substitutions, and finally solves the branch-result equation. Its returned case substitution is 𝑆0;𝑈0;𝑆1;𝑆2;𝑉, in that order. These are precisely the clauses of definition 4.29; no effect-row equation is admitted here.
With a fixed total label order, lacks evidence is
𝑑𝜉,ℓ:𝜉\ℓ∈Δ
Δ⊢𝑑𝜉,ℓ:𝜉\ℓ
Ev-Assume
Δ⊢0:𝜖𝜌\ℓ
Ev-Empty
Δ⊢𝑑:𝜌\ℓℓ<𝑚
Δ⊢𝑑:{𝑚:𝜏∣𝜌}\ℓ
Ev-Before
Δ⊢𝑑:𝜌\ℓ𝑚<ℓ
Δ⊢𝑑+1:{𝑚:𝜏∣𝜌}\ℓ
Ev-After
The named syntax translation on row types is 𝗅𝖺𝗒(𝜉)=𝜉,𝗅𝖺𝗒(𝜖𝜌)=𝜖𝜌,𝗅𝖺𝗒({ℓ:𝜏∣𝜌})=𝗌𝗈𝗋𝗍({ℓ:𝗅𝖺𝗒(𝜏)∣𝗅𝖺𝗒(𝜌)}),𝗅𝖺𝗒(𝖱𝖾𝖼(𝜌))=𝖠𝗋𝗋𝖺𝗒(𝗅𝖺𝗒(𝜌)),𝗅𝖺𝗒(𝖵𝖺𝗋(𝜌))=𝖲𝗎𝗆(𝗅𝖺𝗒(𝜌)),𝗅𝖺𝗒(𝜏→𝜐)=𝗅𝖺𝗒(𝜏)→𝗅𝖺𝗒(𝜐). Let 𝖼𝖺𝗇𝖳𝗒 recursively sort every strict row index. Target type conversion is explicit:
Δ;Γ⊢𝑡:𝜃𝖼𝖺𝗇𝖳𝗒(𝜃)=𝖼𝖺𝗇𝖳𝗒(𝜃′)
Δ;Γ⊢𝑡:𝜃′
T-Conv
Target schemes are ∀𝑋.𝖮𝖿𝖿(𝑃)⇒𝜃, with explicit static instantiation and evidence abstraction:
Γ(𝑥)=𝜎
Δ;Γ⊢𝑥:𝜎
T-Var
𝑐:𝜃∈Σ0
Δ;Γ⊢𝑐:𝜃
T-Const
Δ;Γ⊢𝑡:∀𝑋.𝖮𝖿𝖿(𝑃)⇒𝜃𝑇sortedandformedΔ⊢¯𝑑:𝖮𝖿𝖿(𝑃[𝑇])
Δ;Γ⊢𝑡[𝑇]¯𝑑:𝜃[𝑇]
T-Inst
Δ,¯𝑑:𝖮𝖿𝖿(𝑃);Γ⊢𝑡:𝜃𝑋∩ftv(Δ,Γ)=∅
Δ;Γ⊢Λ𝑋.𝜆¯𝑑.𝑡:∀𝑋.𝖮𝖿𝖿(𝑃)⇒𝜃
T-Ev-Abs
Δ;Γ⊢𝑡1:𝜎Δ;Γ,𝑥:𝜎⊢𝑡2:𝜃
Δ;Γ⊢𝗅𝖾𝗍𝑥=𝑡1𝗂𝗇𝑡2:𝜃
T-Let
Writing a monotype as the corresponding empty scheme, the ordinary target rules are
Γ(𝑥)=𝜃
Δ;Γ⊢𝑥:𝜃
T-MVar
𝑐:𝜃∈Σ0
Δ;Γ⊢𝑐:𝜃
T-MConst
Δ;Γ,𝑥:𝜃⊢𝑡:𝜐
Δ;Γ⊢𝜆𝑥.𝑡:𝜃→𝜐
T-Lam
Δ;Γ⊢𝑡:𝜃→𝜐Δ;Γ⊢𝑢:𝜃
Δ;Γ⊢𝑡𝑢:𝜐
T-App
The nullary array rule and six saturated evidence-carrying data rules are
Δ;Γ⊢[]:𝖠𝗋𝗋𝖺𝗒(𝜖𝜌)
T-Empty
Δ⊢𝑑:𝜌\ℓΔ;Γ⊢𝑟:𝖠𝗋𝗋𝖺𝗒({ℓ:𝛼∣𝜌})
Δ;Γ⊢𝗅𝗈𝗈𝗄𝗎𝗉𝑑𝑟:𝛼
T-Lookup
Δ⊢𝑑:𝜌\ℓΔ;Γ⊢𝑟:𝖠𝗋𝗋𝖺𝗒({ℓ:𝛼∣𝜌})
Δ;Γ⊢𝖽𝖾𝗅𝖾𝗍𝖾𝑑𝑟:𝖠𝗋𝗋𝖺𝗒(𝜌)
T-Delete
Δ⊢𝑑:𝜌\ℓΔ;Γ⊢𝑎:𝛼Δ;Γ⊢𝑟:𝖠𝗋𝗋𝖺𝗒(𝜌)
Δ;Γ⊢𝗂𝗇𝗌𝖾𝗋𝗍𝑑𝑎𝑟:𝖠𝗋𝗋𝖺𝗒({ℓ:𝛼∣𝜌})
T-Insert
Δ⊢𝑑:𝜌\ℓΔ;Γ⊢𝑎:𝛼
Δ;Γ⊢𝗍𝖺𝗀𝑑𝑎:𝖲𝗎𝗆({ℓ:𝛼∣𝜌})
T-Tag
Δ⊢𝑑:𝜌\ℓΔ;Γ⊢𝑢:𝖲𝗎𝗆(𝜌)
Δ;Γ⊢𝗐𝗂𝖽𝖾𝗇𝑑𝑢:𝖲𝗎𝗆({ℓ:𝛼∣𝜌})
T-Widen
Δ⊢𝑑:𝜌\ℓΔ;Γ⊢𝑢:𝖲𝗎𝗆({ℓ:𝛼∣𝜌})Δ;Γ⊢𝑓:𝛼→𝛽Δ;Γ⊢𝑔:𝖲𝗎𝗆(𝜌)→𝛽
Δ;Γ⊢𝗌𝗉𝗅𝗂𝗍𝑑𝑢𝑓𝑔:𝛽
T-Split
The target reductions use evidence as zero-based array/tag offsets and are the lookup, delete, insert, tag, widen, and split roots displayed in definition 7.51. Evidence-passing compilation accepts a principal result only when ftv(𝑃)⊆ftv(Γ,𝜏); this unambiguity side condition is part of the compiler interface, not the source typing judgment.