Prerequisites. Direct starred prerequisites: none. No later core chapter depends on this route.
Fix a well-formed context Γ. Let 𝐴,𝐵,𝐶,𝐷 be types in Γ, with primitive declared casts Γ⊢𝑎:𝐴→𝐵, Γ⊢𝑏:𝐴→𝐶, Γ⊢𝑐:𝐵→𝐷, and Γ⊢𝑑:𝐶→𝐷. After weakening the four casts to Γ,𝑥:𝐴, subsumption derives that 𝑥 may be used at 𝐷, but it suppresses which program is run. Cast insertion can produce either 𝑐(𝑎(𝑥)) or 𝑑(𝑏(𝑥)). If those terms are observably different, source typing is ambiguous. The calculus must make equality of parallel coercion paths a hypothesis, not a hope.
The framework fixes coercive subtyping together with completion and conservativity. A type theory 𝑇 is specified in a logical framework. A finite set 𝑅 of basic subtyping rule schemata derives judgments Γ⊢𝐴<𝑐𝐵:𝖳𝗒𝗉𝖾, read “𝑐 coerces 𝐴 to 𝐵”. Three systems are distinguished: 𝑇[𝑅]0 adds only the subtyping judgments to 𝑇; 𝑇[𝑅] additionally allows coercive application and coercive definition; 𝑇[𝑅]0𝐾 adds subkinding. The source coherence conditions on 𝑅 are the three clauses of Luo’s definition, stated in 𝑇[𝑅]0:
if Γ⊢𝐴<𝑐𝐵:𝖳𝗒𝗉𝖾 then Γ⊢𝐴𝗍𝗒𝗉𝖾, Γ⊢𝐵𝗍𝗒𝗉𝖾, and Γ⊢𝑐:𝐴→𝐵;
Γ⊢𝐴<𝑐𝐴:𝖳𝗒𝗉𝖾 is derivable for no Γ, 𝐴, 𝑐;
if Γ⊢𝐴<𝑐𝐵:𝖳𝗒𝗉𝖾 and Γ⊢𝐴<𝑐′𝐵:𝖳𝗒𝗉𝖾, then Γ⊢𝑐≡𝑐′:𝐴→𝐵.
The subtyping judgment of 𝑇[𝑅]0 is closed under judgmental equality of its two type arguments, so a coercion between 𝐴 and 𝐵 is also a coercion between any 𝐴′ and 𝐵′ for which Γ⊢𝐴′≡𝐴𝗍𝗒𝗉𝖾 and Γ⊢𝐵′≡𝐵𝗍𝗒𝗉𝖾. All completion and conservativity results below use exactly that signature.
Clause 2 of convention 119.1 forbids a declared edge from a type to itself, while a usable calculus still needs an identity cast and composition of casts. The two demands are reconciled by separating the declared edges from the paths generated over them.
Write 𝜎:Γ⇒Δ for a well-typed simultaneous substitution that assigns, in Γ, a term to every variable declared in Δ. A coercion signature consists of a dependent type theory 𝑇 and a finite set 𝑅 of declared-edge schemata𝑟=(Δ;𝐴,𝐵,𝑐), where Δ is a well-formed context, Δ⊢𝐴𝗍𝗒𝗉𝖾, Δ⊢𝐵𝗍𝗒𝗉𝖾, and Δ⊢𝑐:𝐴→𝐵. Every well-typed instance must satisfy Luo’s irreflexivity condition: for every 𝜎:Γ⇒Δ, the judgment Γ⊢𝐴[𝜎]≡𝐵[𝜎]𝗍𝗒𝗉𝖾 is not derivable. The instance of 𝑟 along 𝜎 is written 𝑟[𝜎], and its declared cast is 𝑐[𝜎].
The context-indexed coercion-path judgment 𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐵) is generated by the following rules.
Γ𝖼𝗍𝗑Γ⊢𝐴𝗍𝗒𝗉𝖾
𝗂𝖽𝐴∈𝖢𝗈𝖾Γ(𝐴,𝐴)
Coe-Id
𝑟=(Δ;𝐴0,𝐵0,𝑐)∈𝑅𝜎:Γ⇒Δ
𝑟[𝜎]∈𝖢𝗈𝖾Γ(𝐴0[𝜎],𝐵0[𝜎])
Coe-Edge
𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐵)𝑞∈𝖢𝗈𝖾Γ(𝐵,𝐶)
𝑞∘𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐶)
Coe-Comp
𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐵)Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾Γ⊢𝐵≡𝐵′𝗍𝗒𝗉𝖾
𝑝∈𝖢𝗈𝖾Γ(𝐴′,𝐵′)
Coe-Conv
Each path 𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐵) names a target term 𝗉𝗋𝗈𝗀𝑝 in Γ, its cast program, defined by 𝗉𝗋𝗈𝗀𝗂𝖽𝐴:=𝜆𝑥.𝑥,𝗉𝗋𝗈𝗀𝑟[𝜎]:=𝑐[𝜎]for𝑟=(Δ;𝐴0,𝐵0,𝑐),𝗉𝗋𝗈𝗀𝑞∘𝑝:=𝜆𝑥.𝗉𝗋𝗈𝗀𝑞(𝗉𝗋𝗈𝗀𝑝𝑥). The endpoint-conversion clause changes only the typing derivation of 𝗉𝗋𝗈𝗀𝑝, not its term. Two paths 𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐵) and 𝑞∈𝖢𝗈𝖾Γ(𝐴′,𝐵′) are parallel in Γ when Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾 and Γ⊢𝐵≡𝐵′𝗍𝗒𝗉𝖾. The signature is path coherent when, for every well-formed Γ, all four well-formed endpoints 𝐴,𝐴′,𝐵,𝐵′, and every such pair of parallel paths, Γ⊢𝗉𝗋𝗈𝗀𝑝≡𝗉𝗋𝗈𝗀𝑞:𝐴→𝐵 after converting the type of 𝗉𝗋𝗈𝗀𝑞 along the two endpoint equalities.
For example, if 𝑎 and 𝑐 are the declared instances from the opening diamond, the left route is a path in the same context: 𝑎∈𝖢𝗈𝖾Γ(𝐴,𝐵)𝑐∈𝖢𝗈𝖾Γ(𝐵,𝐷)𝑐∘𝑎∈𝖢𝗈𝖾Γ(𝐴,𝐷)Coe−Comp. Its cast program is 𝜆𝑥.𝑐(𝑎(𝑥)). The derivation does not remain well scoped after replacing Γ by another context; it must first be transported by a substitution.
The context index is load bearing. It records the free variables on which a declared cast may depend and makes weakening under a binder a mathematical operation rather than an implicit change of scope.
For every 𝜎:Γ⇒Δ, there is a path 𝑝[𝜎]∈𝖢𝗈𝖾Γ(𝐴[𝜎],𝐵[𝜎]) satisfying Γ⊢𝗉𝗋𝗈𝗀𝑝[𝜎]≡𝗉𝗋𝗈𝗀𝑝[𝜎]:𝐴[𝜎]→𝐵[𝜎].
If Δ,𝑧:𝐶 is a well-formed extension, then the weakening of 𝑝 belongs to 𝖢𝗈𝖾Δ,𝑧:𝐶(𝐴,𝐵), where 𝐴, 𝐵, and 𝗉𝗋𝗈𝗀𝑝 are weakened along the projection Δ,𝑧:𝐶⇒Δ.
If Δ and Δ′ have the same variables in the same order and corresponding declaration types are judgmentally equal after each preceding context conversion, then the identity variable list gives a well-typed substitution 𝜄:Δ′⇒Δ. Hence 𝑝[𝜄]∈𝖢𝗈𝖾Δ′(𝐴[𝜄],𝐵[𝜄]), and its cast program is judgmentally equal to 𝗉𝗋𝗈𝗀𝑝[𝜄].
Proof of Lemma 119.3 — Structural stability of coercion paths
Proof. Prove clauses 1 and 2 simultaneously by induction on the derivation of 𝑝∈𝖢𝗈𝖾Δ(𝐴,𝐵). For Coe-Id, target lambda introduction gives the required function, and substitution produces 𝗂𝖽𝐴[𝜎]. For a declared Coe-Edge instance 𝑟[𝜏], where 𝑟=(Ξ;𝐴0,𝐵0,𝑐), the schema typing judgment substituted along 𝜏:Δ⇒Ξ gives Δ⊢𝑐[𝜏]:𝐴0[𝜏]→𝐵0[𝜏]. Substitution along 𝜎 produces the declared instance 𝑟[𝜏∘𝜎], and the substitution-composition law identifies its cast with 𝑐[𝜏][𝜎].
For Coe-Comp, the two typing induction hypotheses and target application and lambda introduction type the composite cast. The two substitution induction hypotheses, followed by lambda and application congruence, identify (𝑞∘𝑝)[𝜎] with 𝑞[𝜎]∘𝑝[𝜎]. In the Coe-Conv case, substitution stability of judgmental equality converts the substituted source and target endpoints; the cast term is unchanged. These are all four generators.
Clause 3 is clause 2 at the projection substitution. For clause 4, pointwise context conversion makes the identity variable list well typed; apply clause 2 to that substitution. No free variable is introduced or discarded without one of these substitutions. ◻
Path coherence is the path-closed form of clause 3 of convention 119.1; the requirement that a declared edge join distinct types is clause 2. Clause 1 is the well-formedness demanded of every instance of a schema in 𝑅. The identity and composite paths are generated rather than declared, so admitting them does not violate clause 2: they are the coercions that 𝑇[𝑅] derives, not the basic rules whose irreflexivity the source requires.
The opening diamond violates path coherence unless the signature contains a derivation Γ⊢𝜆𝑥.𝑐(𝑎(𝑥))≡𝜆𝑥.𝑑(𝑏(𝑥)):𝐴→𝐷. Declaring only unique declared edges does not help: the two composites use different edges and remain parallel.
Two judgments and where a cast may be inserted
The source language is subsumptive: it records that a term may be used at a supertype and says nothing about which program is run.
The shortest route to a program annotates each Sub step with its path and reads off 𝗉𝗋𝗈𝗀𝑝. That recipe is not coherent, and the failure is not the diamond of the chapter opening.
Take a target theory with judgmental function 𝜂, closed base types 𝐴, 𝐴′, 𝐵, and closed declared-edge schemata 𝜄:𝐴→𝐴′,𝜎:𝐴×𝐵→𝟐,𝜏:𝐴′×𝐵→𝟐, with 𝗉𝗋𝗈𝗀𝜄:=𝜆𝑥.𝑎′ for a fixed 𝑎′:𝐴′, 𝗉𝗋𝗈𝗀𝜎:=𝜆𝑧.𝗍𝗍, and 𝗉𝗋𝗈𝗀𝜏:=𝜆𝑧.𝖿𝖿. In every well-formed context Δ, each set 𝖢𝗈𝖾Δ(𝑋,𝑌) generated by instances of these three closed schemata is either empty or contains the single edge together with its composites with identities. The target 𝛽𝜂-laws identify those identity composites with the single edge, so the signature is path coherent in every context. Weakening the three paths to Γ=𝑥:𝐴,𝑦:𝐵, the source term (𝑥,𝑦) has two annotated derivations of Γ⊢(𝑥,𝑦):𝟐:
form the pair at 𝐴×𝐵, then use Sub along 𝜎, yielding 𝗉𝗋𝗈𝗀𝜎(𝑥,𝑦)≡𝗍𝗍;
use Sub along 𝜄 on the first component, form the pair at 𝐴′×𝐵, then use Sub along 𝜏, yielding 𝗉𝗋𝗈𝗀𝜏(𝗉𝗋𝗈𝗀𝜄𝑥,𝑦)≡𝖿𝖿.
Since 𝗍𝗍≡𝖿𝖿 fails, path coherence alone does not make annotated subsumption derivation independent. The two final paths are 𝜎∈𝖢𝗈𝖾Γ(𝐴×𝐵,𝟐) and 𝜏∈𝖢𝗈𝖾Γ(𝐴′×𝐵,𝟐), which are not parallel: the interior Sub step changed the type at which the pair rule concluded. Coherence therefore requires controlling where a cast may be inserted, not only which casts are equal.
The control is bidirectional. Insertion is confined to the one place where a type is supplied from outside, so every structural rule concludes at the type its own premises determine.
The elaboration judgments are synthesis Γ⊢𝑒⇒𝐴⇝𝑡 and checking Γ⊢𝑒⇐𝐴⇝𝑡, where 𝑡 is a term of 𝑇.
(𝑥:𝐴)∈Γ
Γ⊢𝑥⇒𝐴⇝𝑥
Coe-Var
Γ⊢𝑒⇐𝐴⇝𝑡
Γ⊢(𝑒:𝐴)⇒𝐴⇝𝑡
Coe-Ann
Γ⊢𝑒1⇒∏𝑥:𝐴𝐵⇝𝑡1Γ⊢𝑒2⇐𝐴⇝𝑡2
Γ⊢𝑒1𝑒2⇒𝐵[𝑡2/𝑥]⇝𝑡1𝑡2
Coe-App
Γ⊢𝑒1⇒𝐴⇝𝑡1Γ⊢𝑒2⇒𝐵⇝𝑡2
Γ⊢(𝑒1,𝑒2)⇒𝐴×𝐵⇝(𝑡1,𝑡2)
Coe-Pair
Γ,𝑥:𝐴⊢𝑒⇐𝐵⇝𝑡
Γ⊢𝜆𝑥.𝑒⇐∏𝑥:𝐴𝐵⇝𝜆𝑥.𝑡
Coe-Lam
Γ⊢𝑒⇒𝐴⇝𝑡𝑝∈𝖢𝗈𝖾Γ(𝐴,𝐵)
Γ⊢𝑒⇐𝐵⇝𝗉𝗋𝗈𝗀𝑝𝑡
Coe-Insert
Coe-Insert is the only rule that consumes a coercion path, and it is the only rule that changes mode. Every other rule concludes at a type built from the types its premises produce.
Reading the two judgments back into definition 119.4 erases the target terms and replaces each Coe-Insert by Sub, so every elaboration derivation has an underlying subsumptive derivation.
Proof of Theorem 119.7 — Elaboration type preservation
Proof. Simultaneous rule induction on the two derivations. Coe-Var is the target variable rule and Coe-Ann is its premise unchanged. For Coe-App the two induction hypotheses give Γ⊢𝑡1:∏𝑥:𝐴𝐵 and Γ⊢𝑡2:𝐴, and target application derives Γ⊢𝑡1𝑡2:𝐵[𝑡2/𝑥]. For Coe-Pair the two induction hypotheses and product introduction derive Γ⊢(𝑡1,𝑡2):𝐴×𝐵. For Coe-Lam the induction hypothesis in the extended context and Π-introduction derive Γ⊢𝜆𝑥.𝑡:∏𝑥:𝐴𝐵. For Coe-Insert the induction hypothesis gives Γ⊢𝑡:𝐴, while clause 1 of lemma 119.3 gives Γ⊢𝗉𝗋𝗈𝗀𝑝:𝐴→𝐵; target application derives Γ⊢𝗉𝗋𝗈𝗀𝑝𝑡:𝐵. These are all six rules. ◻
Assume the coercion signature is path coherent, target definitional equality is a congruence stable under substitution, and dependent products are injective in every well-formed context: from Γ⊢∏𝑥:𝐴1𝐵1≡∏𝑥:𝐴2𝐵2𝗍𝗒𝗉𝖾 one may derive Γ⊢𝐴1≡𝐴2𝗍𝗒𝗉𝖾 and, after context conversion, Γ,𝑥:𝐴1⊢𝐵1≡𝐵2𝗍𝗒𝗉𝖾. Let Γ1 and Γ2 have the same variables in the same order, with corresponding declaration types judgmentally equal after each preceding context conversion. For every such pair of contexts:
if Γ1⊢𝑒⇒𝐴1⇝𝑡1 and Γ2⊢𝑒⇒𝐴2⇝𝑡2, then, after converting the second judgment into Γ1, one has Γ1⊢𝐴1≡𝐴2𝗍𝗒𝗉𝖾 and Γ1⊢𝑡1≡𝑡2:𝐴1;
if Γ1⊢𝑒⇐𝐵1⇝𝑡1, Γ2⊢𝑒⇐𝐵2⇝𝑡2, and Γ1⊢𝐵1≡𝐵2𝗍𝗒𝗉𝖾 after context conversion, then Γ1⊢𝑡1≡𝑡2:𝐵1.
Proof. The strengthened context and expected-type clauses are the induction invariant needed under lambdas and when two applications synthesize judgmentally equal, but not syntactically identical, domains. Proceed by simultaneous induction on the two pairs of derivations. In the calculations below, judgments from Γ2 are compared in Γ1 by the ordinary target context-conversion rule. A coercion path from Γ2 is transported along the identity variable substitution supplied by clause 4 of lemma 119.3; therefore its cast program is compared in Γ1, not in an unmentioned ambient context. In each synthesis case the source term’s outermost constructor selects the rule, so both derivations end in the same rule of definition 119.6.
Coe-Var: both derivations read corresponding declarations for the same variable. Pointwise context equality gives Γ1⊢𝐴1≡𝐴2𝗍𝗒𝗉𝖾, and 𝑡1=𝑡2=𝑥.
Coe-Ann: both conclude at the written annotation, so 𝐴1=𝐴2, and the strengthened clause 2 for the premises, with reflexivity of the written type, gives Γ1⊢𝑡1≡𝑡2:𝐴1.
Coe-Pair: clause 1 for the two component premises gives Γ1⊢𝐴′1≡𝐴′2𝗍𝗒𝗉𝖾, Γ1⊢𝐵′1≡𝐵′2𝗍𝗒𝗉𝖾 and componentwise equality of the elaborated components. Product congruence gives Γ1⊢𝐴′1×𝐵′1≡𝐴′2×𝐵′2𝗍𝗒𝗉𝖾 and pair congruence closes the terms.
Coe-App: clause 1 for the function premise gives Γ1⊢∏𝑥:𝐴1𝐵1≡∏𝑥:𝐴2𝐵2𝗍𝗒𝗉𝖾 and Γ1⊢𝑡f1≡𝑡f2:∏𝑥:𝐴1𝐵1. Injectivity of Π gives Γ1⊢𝐴1≡𝐴2𝗍𝗒𝗉𝖾 and Γ1,𝑥:𝐴1⊢𝐵1≡𝐵2𝗍𝗒𝗉𝖾, so the two argument premises check at judgmentally equal types and the strengthened clause 2 gives Γ1⊢𝑡a1≡𝑡a2:𝐴1. Stability of equality under substitution gives Γ1⊢𝐵1[𝑡a1/𝑥]≡𝐵2[𝑡a2/𝑥]𝗍𝗒𝗉𝖾, and application congruence closes the terms.
For clause 2 there is exactly one checking rule per source constructor. If the source is 𝜆𝑥.𝑒, both derivations use Coe-Lam, so Γ𝑖⊢𝐵𝑖≡∏𝑥:𝐴𝑖𝐶𝑖𝗍𝗒𝗉𝖾 for 𝑖∈{1,2}. Dependent-Π injectivity applied to the assumed Γ1⊢𝐵1≡𝐵2𝗍𝗒𝗉𝖾 gives Γ1⊢𝐴1≡𝐴2𝗍𝗒𝗉𝖾 and, after context conversion, Γ1,𝑥:𝐴1⊢𝐶1≡𝐶2𝗍𝗒𝗉𝖾. The body contexts Γ1,𝑥:𝐴1 and Γ2,𝑥:𝐴2 are pointwise judgmentally equal, so the strengthened induction hypothesis applies directly to the body derivations. Lambda congruence gives equality at 𝐵1.
Every other source term uses Coe-Insert. The two derivations synthesize 𝐴1 and 𝐴2 with paths 𝑝∈𝖢𝗈𝖾Γ1(𝐴1,𝐵1) and 𝑞∈𝖢𝗈𝖾Γ2(𝐴2,𝐵2). Transport clause 4 of lemma 119.3 gives a path 𝑞𝜄∈𝖢𝗈𝖾Γ1(𝐴2[𝜄],𝐵2[𝜄]), whose cast is the context conversion of 𝗉𝗋𝗈𝗀𝑞. Clause 1 gives Γ1⊢𝐴1≡𝐴2𝗍𝗒𝗉𝖾 and Γ1⊢𝑢1≡𝑢2:𝐴1; the expected-type premise gives Γ1⊢𝐵1≡𝐵2𝗍𝗒𝗉𝖾, where the right-hand endpoints abbreviate their substitutions along 𝜄. Hence 𝑝 and 𝑞𝜄 are parallel in the exact sense of definition 119.2. Path coherence gives Γ1⊢𝗉𝗋𝗈𝗀𝑝≡𝗉𝗋𝗈𝗀𝑞𝜄:𝐴1→𝐵1 after endpoint conversion. Application congruence and conversion of the second result from 𝐵2 to 𝐵1 give Γ1⊢𝗉𝗋𝗈𝗀𝑝𝑢1≡𝗉𝗋𝗈𝗀𝑞𝜄𝑢2:𝐵1. The cast-program equality in clause 4 of lemma 119.3 identifies the last term with the context conversion of 𝗉𝗋𝗈𝗀𝑞𝑢2, which is the required conclusion. ◻
Under the hypotheses of lemma 119.8, if Γ⊢𝑒⇐𝐴⇝𝑡1 and Γ⊢𝑒⇐𝐴⇝𝑡2, then Γ⊢𝑡1≡𝑡2:𝐴. Consequently a source program elaborated at a fixed expected type has one target program up to definitional equality.
Proof. This is clause 2 of lemma 119.8 with 𝐵1=𝐵2=𝐴 and reflexivity of target conversion. ◻
Three hypotheses carry the theorem, and none is decorative. Deleting path coherence refutes it at the opening diamond: with 𝐴=𝟏, 𝐷=𝟐, one composite constantly 𝗍𝗍 and the other constantly 𝖿𝖿, both composites are parallel paths whose casts are not equal. Deleting the mode restriction refutes it at remark 119.5, where the signature is path coherent. Deleting injectivity of Π breaks the Coe-App case, because the two argument premises would no longer be known to check at judgmentally equal types.
★☆☆ List the two elaboration derivations for the opening diamond at the expected type 𝐷. State the exact function equality needed to apply theorem 119.9; equality only at one chosen input is not enough.
★★☆ In remark 119.5, attempt both elaborations in definition 119.6 with expected type 𝟐. Name the rule whose premise fails in the second attempt, and give the annotation the source programmer must write to obtain the 𝖿𝖿 program.
Function space is contravariant in its domain and covariant in its codomain. Fix types 𝐴1,𝐴2 in Γ, a type 𝐵1(𝑦) in Γ,𝑦:𝐴1, and a type 𝐵2(𝑥) in Γ,𝑥:𝐴2. Given 𝑝∈𝖢𝗈𝖾Γ(𝐴2,𝐴1) and a path 𝑞𝑥∈𝖢𝗈𝖾Γ,𝑥:𝐴2(𝐵1(𝗉𝗋𝗈𝗀𝑝𝑥),𝐵2(𝑥)), define 𝖺𝗋𝗋(𝑝,𝑞)(𝑓):=𝜆𝑥.𝗉𝗋𝗈𝗀𝑞𝑥(𝑓(𝗉𝗋𝗈𝗀𝑝𝑥)). The dependency in the source of 𝑞𝑥 is forced by typing. Replacing it by 𝐵1(𝑥) is ill formed unless 𝑝 is the identity or an additional transport is provided.
Records are the same calculation in declaration order, with both fields covariant. For types 𝐴,𝐴′ in Γ, take the source record type 𝖱𝖾𝖼1:=(𝑛:ℕ,𝑣:𝖵𝖾𝖼𝐴𝑛) and the target 𝖱𝖾𝖼2:=(𝑚:ℕ,𝑤:𝖵𝖾𝖼𝐴′𝑚). A fieldwise cast is given by a path 𝑝∈𝖢𝗈𝖾Γ(ℕ,ℕ) for the first field and a path 𝑞𝑛∈𝖢𝗈𝖾Γ,𝑛:ℕ(𝖵𝖾𝖼𝐴𝑛,𝖵𝖾𝖼𝐴′(𝗉𝗋𝗈𝗀𝑝𝑛)) for the second. Here 𝑝 is weakened from Γ to Γ,𝑛:ℕ by lemma 119.3. The record cast is 𝗋𝖾𝖼(𝑝,𝑞)(𝑟):=(𝗉𝗋𝗈𝗀𝑝(𝑟.𝑛),𝗉𝗋𝗈𝗀𝑞𝑟.𝑛(𝑟.𝑣)). The index 𝗉𝗋𝗈𝗀𝑝𝑛 in the target type of 𝑞𝑛 is the record analogue of the occurrence 𝐵1(𝗉𝗋𝗈𝗀𝑝𝑥) above: the later field’s type must be read at the already coerced earlier field.
Two instances show why that index cannot be simplified to 𝑛. With 𝑝=𝗂𝖽ℕ and a declared edge 𝛼:𝐴→𝐴′, the family 𝑞𝑛:=𝗆𝖺𝗉𝛼 with 𝗆𝖺𝗉𝛼:𝖵𝖾𝖼𝐴𝑛→𝖵𝖾𝖼𝐴′𝑛 applying 𝛼 to every entry gives 𝗋𝖾𝖼(𝗂𝖽,𝑞)(𝑟)=(𝑟.𝑛,𝗆𝖺𝗉𝛼(𝑟.𝑣)), and the length is unchanged. With 𝗉𝗋𝗈𝗀𝑝:=𝗌𝗎𝖼, the same 𝑞𝑛 is ill typed: 𝗆𝖺𝗉𝛼(𝑟.𝑣) has type 𝖵𝖾𝖼𝐴′(𝑟.𝑛) where the second field of the result is required at 𝖵𝖾𝖼𝐴′(𝗌𝗎𝖼(𝑟.𝑛)). No path built from 𝛼 repairs this, because every such path preserves the length index; the second field must be supplied a cast that is already indexed by 𝗉𝗋𝗈𝗀𝑝𝑛.
Let Γ𝖼𝗍𝗑, Γ⊢𝐴1𝗍𝗒𝗉𝖾, Γ⊢𝐴2𝗍𝗒𝗉𝖾, Γ,𝑦:𝐴1⊢𝐵1(𝑦)𝗍𝗒𝗉𝖾, and Γ,𝑥:𝐴2⊢𝐵2(𝑥)𝗍𝗒𝗉𝖾. Suppose 𝑝,𝑝′∈𝖢𝗈𝖾Γ(𝐴2,𝐴1) satisfy Γ⊢𝗉𝗋𝗈𝗀𝑝≡𝗉𝗋𝗈𝗀𝑝′:𝐴2→𝐴1, and suppose 𝑞𝑥∈𝖢𝗈𝖾Γ,𝑥:𝐴2(𝐵1(𝗉𝗋𝗈𝗀𝑝𝑥),𝐵2(𝑥)),𝑞′𝑥∈𝖢𝗈𝖾Γ,𝑥:𝐴2(𝐵1(𝗉𝗋𝗈𝗀𝑝′𝑥),𝐵2(𝑥)). Assume the fiber cast programs satisfy Γ,𝑥:𝐴2⊢𝗉𝗋𝗈𝗀𝑞𝑥≡𝗉𝗋𝗈𝗀𝑞′𝑥:𝐵1(𝗉𝗋𝗈𝗀𝑝𝑥)→𝐵2(𝑥) after conversion along the first equality. Then Γ⊢𝖺𝗋𝗋(𝑝,𝑞)≡𝖺𝗋𝗋(𝑝′,𝑞′):∏𝑦:𝐴1𝐵1(𝑦)→∏𝑥:𝐴2𝐵2(𝑥).
Proof of Proposition 119.10 — Coherence of the dependent function cast
Proof. Fix 𝑓:∏𝑦:𝐴1𝐵1(𝑦) and 𝑥:𝐴2. Function congruence gives Γ,𝑥:𝐴2⊢𝑓(𝗉𝗋𝗈𝗀𝑝𝑥)≡𝑓(𝗉𝗋𝗈𝗀𝑝′𝑥):𝐵1(𝗉𝗋𝗈𝗀𝑝𝑥). After the stipulated fiber conversion, congruence with the equal fiber casts gives equality of the two bodies at 𝐵2(𝑥). Lambda congruence first closes over 𝑥, then over 𝑓, yielding equality of the casts. ◻
Completion and conservativity
Adding every composite coercion as a declared edge is called coercion completion. A tempting argument says that uniqueness of the declared edges already makes every inserted coercion unique. Soloviev and Luo identify the missing step in Sections 4–5.3: coercion completion acts on derivations, and the premises reconstructed from two derivations of the same judgment need not have literally identical contexts or kinds. The completion proof must first show that the relevant presupposed judgments match up to equality in 𝑇, and then use coherence to preserve that matching while rebuilding each rule. Their Section 4 also leaves open a simple general syntactic condition on arbitrary rules of 𝑇 and 𝑅 that would make this reconstruction work. The theorem below therefore applies to their displayed logical- framework systems and coherent rule sets; it does not license arbitrary completion.
For the systems 𝑇[𝑅], 𝑇[𝑅]0, and 𝑇[𝑅]0𝐾, if the basic rule set 𝑅 satisfies the three coherence conditions of convention 119.1, then the coercion completion transformation Θ is defined on every derivation of 𝑇[𝑅], and any two derivations of the same judgment have 𝑇-equal images; on a derivation in 𝑇[𝑅]0𝐾 it leaves the final judgment unchanged. Consequently, a judgment of 𝑇[𝑅] that is not of subtyping or subkinding form is derivable in 𝑇 exactly under the unchanged-completion condition proved below.
Proof of Theorem 119.11 — Completion and conservativity at the source signature
Proof. We reconstruct the two inductions. For a derivation 𝑑, write pre(𝑑) for the derivations of all presuppositions of its conclusion: context validity; kind formation for a displayed kind; typing of both sides of an equality; and, for 𝐴<𝑐𝐵, the typings of 𝐴, 𝐵, and 𝑐:𝐴→𝐵. Structural induction on 𝑑 proves the following extraction invariant:
If Θ(𝑑) is defined, then Θ is defined on every member of pre(𝑑), and the image extracted from 𝑑 is 𝑇-equal to the image obtained from the separately extracted presupposition.
For a variable or primitive formation rule the extracted derivation is the corresponding premise or an identity derivation. Weakening and context replacement use equality of the prefix contexts. For product formation, abstraction, application, and substitution, apply the induction hypotheses to the domain and codomain presuppositions and rebuild the same logical-framework rule after context replacement. Equality formation uses the two endpoint extractions; equality typing uses those plus the type extraction. A basic subtyping rule uses coherence clause 1 to obtain the three required typings. Coercive application extracts the function typing, argument typing, coercion typing, and the equalities that align their independently reconstructed contexts and kinds; after those replacements, ordinary application derives 𝑓(𝑐(𝑘)). Coercive definition has the same four obligations under its binder. These are all rule families of 𝑇[𝑅], so the extraction invariant holds.
We next prove, by induction on the sum of the heights of 𝑑 and 𝑑′, that whenever they derive the same validity, kind-formation, or term-typing judgment and both images are defined, their images are 𝑇-equal. If the last rules agree, apply the induction hypothesis to corresponding premises and congruence to the rebuilt conclusion. The possible unequal last rules are structural rules, equality conversion, and coercive versus ordinary application or two coercive applications. Structural and conversion cases are reduced to smaller derivations by the extraction invariant and transitivity of 𝑇-equality. An ordinary application compared with a coercive one would give, after the smaller comparisons, both equality and a proper subtyping judgment between the same endpoint kinds; coherence clauses 1 and 2 exclude that case. If both are coercive applications, the smaller comparisons identify their source and target kinds. Coherence clause 3 identifies their coercions, and application congruence identifies the completed conclusions. The coercive-definition comparison uses that argument under lambda congruence. Thus all three classes of presupposed judgment have derivation-independent images.
Totality of Θ now follows by structural induction on 𝑑. Images of the premises exist by induction. To rebuild the last rule, the extraction invariant reduces each missing context or kind equality to a comparison of two presupposed judgments; the preceding derivation-independence lemma supplies that equality. The coercive-application and coercive-definition cases use the same comparison and coherence clause 3 for their coercion. Hence every reconstruction obligation is discharged. A derivation already in 𝑇[𝑅]0𝐾 contains no coercive application or definition to replace, and the deterministic context-alignment convention inserts no change at its conclusion; therefore its final judgment is unchanged.
For conservativity, let 𝑑 derive a non-subtyping, non-subkinding judgment 𝐽 in 𝑇[𝑅]. If 𝐽 has an unchanged completion, then Θ(𝑑) is literally a 𝑇-derivation of 𝐽. Conversely, a 𝑇-derivation contains no coercive rule and is fixed by Θ. For a subtyping or subkinding conclusion the identical argument lands in 𝑇[𝑅]0 or 𝑇[𝑅]0𝐾, respectively. Derivation independence shows that the existence of one unchanged derivation is equivalent to every derivation being unchanged. This proves both assertions.
The proof uses the complete source rule classification and its three coherence clauses. It proves no path coherence for a different target calculus, licenses no insertion outside definition 119.6, and supplies no generic map law. ◻
The restriction matters exactly at the opening diamond. If its composites are not equal, completion records two different coercions from 𝐴 to 𝐷, clause 3 of convention 119.1 fails, and insertion is not derivation independent.
Sources
The coercive-subtyping framework follows Luo [Luo99]. Completion and conservativity follow Soloviev and Luo [SL02], especially Theorems 5.8 and 6.1 on printed p. 23.
Suggested first pass.
None of these problems is a prerequisite for a later chapter. Begin with exercise 119.3, then complete exercise 119.6.
★★☆ Derive the function cast for (𝐴1→𝐵1)<:(𝐴2→𝐵2). Give the domain and codomain paths, mark the contravariant occurrence, and type every intermediate application.
★★★ For 𝖱𝖾𝖼1 and 𝖱𝖾𝖼2 above, write both fieldwise casts in full and type every projection and application. Then take 𝗉𝗋𝗈𝗀𝑝:=𝗌𝗎𝖼, display the type at which the second field is required, and give the ill-typed term obtained by reusing 𝗆𝖺𝗉𝛼 there.
★★☆ In Soloviev and Luo’s paper, read Sections 4–5.4. For the ordinary dependent application rule, state the two equality obligations that may fail after completing its premises separately. Then name the lemma and the coherence consequence used to restore those obligations, and state the generality question that the source leaves open. The answer must distinguish coherence of basic coercions from equality of arbitrary completed premises.
★★★Practical project.coherent-coercion-path-checker Implement in Agda or Kappa a finite coercion graph whose edges carry symbolic cast programs. Enumerate the simple paths between a source and a target, normalize each composite by associativity and by deletion of identities, and reject a source/target pair whose normalized programs differ. Maintain the invariant that every accepted source/target pair has exactly one normalized program. On the inputs chain, coherent-diamond, and bad-diamond, print unique, coherent, and rejected: parallel-casts respectively. A mutation that compares only path length must fail the last oracle. The program checks a finite graph; it does not decide judgmental equality in a dependent target theory.