Proof production, metaprogramming, levels, and generated actions
appendix sectionrules
Proof production, metaprogramming, levels, and generated actions
Tactic validations and replay
A goal is 𝑔=(Γ∣𝐺). A validation from 𝑔1,…,𝑔𝑛 to 𝑔 is a partial meta-level function 𝑉 satisfying (Γ𝑖⊢𝑝𝑖:𝐺𝑖forevery𝑖)⟹Γ⊢𝑉(𝑝1,…,𝑝𝑛):𝐺. The primitive validations are tacticsubgoalsvalidation𝖾𝗑𝖺𝖼𝗍(𝑞)()()↦𝑞𝗂𝗇𝗍𝗋𝗈(Γ,𝑥:𝐴∣𝐵)𝑝↦𝜆𝑥.𝑝𝗌𝗉𝗅𝗂𝗍(Γ∣𝐴),(Γ∣𝐵)(𝑝,𝑞)↦(𝑝,𝑞)𝖺𝗌𝗌𝗎𝗆𝗉𝗍𝗂𝗈𝗇()()↦𝑥where𝑥:𝐺isfirstinΓ. Sequencing composes a first validation 𝑉 with the subgoal validations 𝑊𝑖 as (⃗𝑞1,…,⃗𝑞𝑛)↦𝑉(𝑊1(⃗𝑞1),…,𝑊𝑛(⃗𝑞𝑛)). A successful replay must end by checking Γ⊢𝑝:𝐺 for its completed proof term in the unchanged kernel. The tactic semantics has separate success and failure judgments, 𝑇@𝑔⇓(⃗ℎ,𝑉) and 𝖿𝖺𝗂𝗅𝗌(𝑇,𝑔). Choice therefore commits to its left branch only on success:
𝑇@𝑔⇓(⃗ℎ,𝑉)
(𝑇𝗈𝗋𝖾𝗅𝗌𝖾𝑈)@𝑔⇓(⃗ℎ,𝑉)
Tac-Or-Left
𝖿𝖺𝗂𝗅𝗌(𝑇,𝑔)𝑈@𝑔⇓(⃗ℎ,𝑉)
(𝑇𝗈𝗋𝖾𝗅𝗌𝖾𝑈)@𝑔⇓(⃗ℎ,𝑉)
Tac-Or-Right
𝖿𝖺𝗂𝗅𝗌(𝑇,𝑔)𝖿𝖺𝗂𝗅𝗌(𝑈,𝑔)
𝖿𝖺𝗂𝗅𝗌(𝑇𝗈𝗋𝖾𝗅𝗌𝖾𝑈,𝑔)
Tac-Or-Fail
For a state 𝑆=(𝑔1,…,𝑔𝑛;𝑉), a repeat step evaluates 𝑇 on 𝑔1, composes its validation into 𝑉, and is admitted only when the lexicographic measure (𝑐(𝑔1),𝑛) strictly decreases. The closure has Rep-Done exactly when the state is empty, the first tactic application fails, or no successful application decreases the measure, and Rep-More for one decreasing step followed by the closure. Thus 𝗋𝖾𝗉𝖾𝖺𝗍(𝑇)@𝑔⇓(⃗ℎ,𝑉)⟺𝖱𝖾𝗉𝑇((𝑔;𝑝↦𝑝),(⃗ℎ;𝑉)).
Certified simplification and reflection
A database entry is a typed equality 𝑞:𝖨𝖽𝐴(ℓ,𝑟) oriented only when its well-founded measure decreases after every admitted instantiation. The contextual rewriting judgment is generated by
𝗋𝗈𝗈𝗍𝐷(𝑡)=(𝑟𝜌,𝑞𝜌)
𝖱𝗐(Γ;=;𝑡;𝑟𝜌;𝑞𝜌)
Rw-Root
Γ⊢𝑡:𝐴Γ⊢𝗋𝖾𝖿𝗅𝖾𝗑𝑅:∏𝑥:𝐴𝑅𝑥𝑥
𝖱𝗐(Γ;𝑅;𝑡;𝑡;𝗋𝖾𝖿𝗅𝖾𝗑𝑅𝑡)
Rw-Atom
𝖱𝗐(Γ;𝑅𝐴⇒𝑅𝐵;𝑓;𝑓′;𝑣𝑓)𝖱𝗐(Γ;𝑅𝐴;𝑎;𝑎′;𝑣𝑎)
𝖱𝗐(Γ;𝑅𝐵;𝑓𝑎;𝑓′𝑎′;𝑣𝑓𝑎𝑎′𝑣𝑎)
Rw-App
𝖱𝗐(Γ,𝑥:𝐴,𝑦:𝐴,𝑝:𝑅𝐴𝑥𝑦;𝑅𝐵;𝑏;𝑏′;𝑣)
𝖱𝗐(Γ;𝑅𝐴⇒𝑅𝐵;𝜆𝑥.𝑏;𝜆𝑦.𝑏′;𝜆𝑥.𝜆𝑦.𝜆𝑝.𝑣)
Rw-Lam
Here 𝑅𝐴⇒𝑅𝐵 is the binary respectful relation: its witness maps 𝑥,𝑦,𝑝:𝑅𝐴𝑥𝑦 to a proof of 𝑅𝐵(𝑓𝑥)(𝑓′𝑦). It is not the pointwise unary relation. The substitution rule composes an 𝑅-certificate with a checked implication into a relation 𝑆. Reflection reifies a commutative-monoid expression, computes its finite multiplicity map, and accepts the result only after the kernel checks the produced equality proof.
Hygienic and phase-indexed expansion
A raw binder is 𝑎𝛽, and a raw reference 𝑎𝜔𝛽 carries both its stable occurrence token 𝜔 and its lexical target token 𝛽. An expanded reference has the form 𝑎𝑆[𝑜;𝗌𝗋𝖼(𝜔)] or 𝑎𝑆[𝑜;𝗇𝖾𝗐(𝑜𝑡)]: 𝑆 is its finite scope set, 𝑜 is its resolved origin, and the final marker records copied provenance or a declared constructed target. Transformer output marks every node as substituted or constructed; substituted syntax retains caller scopes, whereas constructed syntax receives a fresh introduction scope. Each free constructed reference declares a target origin, and expansion rejects an unresolved, ambiguous, or provenance-mismatched reference. The source judgment 𝐸0;Γ⊢𝗌𝗋𝖼𝑛𝑟:𝐴 includes
𝐸0(𝛽)=𝑜𝑠Γ(𝑜𝑠)=𝐴@𝑛
𝐸0;Γ⊢𝗌𝗋𝖼𝑛𝑎𝜔𝛽:𝐴
Src-Var
𝛽∉dom𝐸0𝑜𝑠𝖿𝗋𝖾𝗌𝗁𝐸0,𝛽↦𝑜𝑠;Γ,𝑜𝑠:𝐴@𝑛⊢𝗌𝗋𝖼𝑛𝑟:𝐵
𝐸0;Γ⊢𝗌𝗋𝖼𝑛𝜆(𝑎𝛽:𝐴).𝑟:𝐴→𝐵
Src-Lam
𝐸0;Γ⊢𝗌𝗋𝖼𝑛𝑟1:𝐴→𝐵𝐸0;Γ⊢𝗌𝗋𝖼𝑛𝑟2:𝐴
𝐸0;Γ⊢𝗌𝗋𝖼𝑛𝑟1𝑟2:𝐵
Src-App
Src-Macro checks only a declared source arity and type together with the argument typings. It does not trust a transformer contract. After expansion, the staged target checker and provenance judgment independently check the output, as required by definition 116.11. The core phase rules are
Γ⊢𝑛+1𝑒:𝐴
Γ⊢𝑛𝗊𝗎𝗈𝗍𝖾(𝑒):𝖢𝗈𝖽𝖾(𝐴)
Q-Quote
Γ⊢𝑛𝑒:𝖢𝗈𝖽𝖾(𝐴)
Γ⊢𝑛+1𝗌𝗉𝗅𝗂𝖼𝖾(𝑒):𝐴
Q-Splice
(𝑥:𝐴@𝑛)∈Γ
Γ⊢𝑛𝑥:𝐴
Q-Var
Generated commands expose a scoped declaration and a closed ordinary term; only that term crosses the kernel boundary.
First-class level rules
The principal noncumulative calculus adds
Γ𝖼𝗍𝗑
Γ⊢𝖫𝖾𝗏𝖾𝗅:U0
Level
Γ𝖼𝗍𝗑
Γ⊢0:𝖫𝖾𝗏𝖾𝗅
L-Zero
Γ⊢𝑡:𝖫𝖾𝗏𝖾𝗅
Γ⊢𝑡+:𝖫𝖾𝗏𝖾𝗅
L-Suc
Γ⊢𝑡:𝖫𝖾𝗏𝖾𝗅Γ⊢𝑢:𝖫𝖾𝗏𝖾𝗅
Γ⊢𝑡⊔𝑢:𝖫𝖾𝗏𝖾𝗅
L-Join
Γ⊢𝑡:𝖫𝖾𝗏𝖾𝗅
Γ⊢U𝑡:U𝑡+
L-Univ
Join is associative, commutative, idempotent, and has zero as left identity; successor preserves join and satisfies 𝑡⊔𝑡+≡𝑡+. Explicit lifts have
Γ⊢𝐴:U𝑡
Γ⊢𝖫𝗂𝖿𝗍𝑢𝐴:U𝑡⊔𝑢
Lift-F
Γ⊢𝑎:𝐴
Γ⊢𝗅𝗂𝖿𝗍𝑎:𝖫𝗂𝖿𝗍𝑢𝐴
Lift-I
Γ⊢𝑏:𝖫𝗂𝖿𝗍𝑢𝐴
Γ⊢𝗅𝗈𝗐𝖾𝗋𝑏:𝐴
Lift-E
The beta rule contracts lower after lift; the extensional eta rule identifies two lifted terms when their lowerings are equal.
Sort abstraction and elimination
SortPoly judgments have shape Σ∣Θ∣Γ⊢𝑡:𝐴, with prenex sort and level variables in Θ. Sort variables have no constraints in the principal system. Every case rule retains the premise Σ∣Θ⊢𝖾𝗅𝗂𝗆(𝐼,𝑠𝑃)𝖺𝗅𝗅𝗈𝗐𝖾𝖽. Same-sort elimination is the universal clause
Θ⊢𝑠𝗌𝗈𝗋𝗍(𝐼𝖽𝖾𝖼𝗅𝖺𝗋𝖾𝖽𝖺𝗍𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇𝗌𝗈𝗋𝗍𝑠)∈Σ
Σ∣Θ⊢𝖾𝗅𝗂𝗆(𝐼,𝑠)𝖺𝗅𝗅𝗈𝗐𝖾𝖽
Same-Sort
Ground policies may add only their stated clauses, such as singleton elimination from 𝖯𝗋𝗈𝗉. Monomorphization duplicates each global declaration at all well-formed ground instantiations and deletes only the sort binders; it retains level binders and constraints. The independent subStraTT boundary instead enforces dependency strata:
Δ⊢Γ
Δ;Γ⊢∗:𝑘∗
DT-Type
Δ;Γ⊢𝐴:𝑗∗Δ;Γ,𝑥:𝑗𝐴⊢𝐵:𝑘∗𝑗<𝑘
Δ;Γ⊢∏𝑥:𝑗𝐴:𝐵:𝑘∗
DT-Pi
Δ;Γ⊢𝑏:𝑘∏𝑥:𝑗𝐴𝐵Δ;Γ⊢𝑎:𝑗𝐴𝑗<𝑘
Δ;Γ⊢𝑏𝑎:𝑘𝐵[𝑎/𝑥]
DT-AppTy
The bounded SortPoly comparison puts edges 𝖾𝖽𝗀𝖾Θ(𝑠,𝑡) in the sort context. Validity requires: every ground path is already generated by ground edges; a reflexive initial ground sort lies below each ground sort incident with a nonground edge; and every dominated sort variable has a reflexive dominant ground sort above every other ground predecessor. Only a valid context admits the dominant ground substitution and the proved preservation, principality, monomorphization, and conditional equiconsistency package.
Coercion paths and insertion
The generated paths contain identities, declared edges, and composition: 𝗉𝗋𝗈𝗀𝗂𝖽𝐴=𝜆𝑥.𝑥,𝗉𝗋𝗈𝗀𝑞∘𝑝=𝜆𝑥.𝗉𝗋𝗈𝗀𝑞(𝗉𝗋𝗈𝗀𝑝𝑥). Path coherence requires equal cast programs for every pair of parallel paths. Insertion occurs only at the synthesis-to-checking boundary:
(𝑥:𝐴)∈Γ
Γ⊢𝑥⇒𝐴⇝𝑥
Coe-Var
Γ⊢𝑒1⇒∏𝑥:𝐴𝐵⇝𝑡1Γ⊢𝑒2⇐𝐴⇝𝑡2
Γ⊢𝑒1𝑒2⇒𝐵[𝑡2/𝑥]⇝𝑡1𝑡2
Coe-App
Γ,𝑥:𝐴⊢𝑒⇐𝐵⇝𝑡
Γ⊢𝜆𝑥.𝑒⇐∏𝑥:𝐴𝐵⇝𝜆𝑥.𝑡
Coe-Lam
Γ⊢𝑒⇒𝐴⇝𝑡𝑝∈𝖢𝗈𝖾(𝐴,𝐵)
Γ⊢𝑒⇐𝐵⇝𝗉𝗋𝗈𝗀𝑝𝑡
Coe-Insert
Annotations and pairs retain the syntax-directed rules printed in definition 119.6; no other rule consumes a path. The determinacy proof additionally assumes that target definitional equality is stable under substitution and that dependent products are injective: equality of Π𝑥:𝐴1.𝐵1 and Π𝑥:𝐴2.𝐵2 yields equality of the domains and, after context conversion, equality of the codomains. Path coherence alone cannot discharge the Coe-App case.
Generated positive action
Positive descriptions are generated by 𝟏,𝐊(𝐴),𝐗,×,+, and dependent sum. Their action is structural: constants are fixed, the parameter clause applies 𝑓, products act componentwise, sums preserve the injection, and dependent sums preserve their first component. Indexed descriptions replace 𝐗 by 𝐗(𝑗) and apply the corresponding family map 𝑓𝑗. The judgmental functor equations are 𝗆𝖺𝗉𝐹(𝗂𝖽)(𝑥)≡𝑥,𝗆𝖺𝗉𝐹(𝑓)(𝗆𝖺𝗉𝐹(𝑔)(𝑥))≡𝗆𝖺𝗉𝐹(𝑓∘𝐹𝐹𝑔)(𝑥). On a neutral 𝑛, weak-head reduction compacts the second equation to one outer map; the identity equation remains conversion and is not oriented as an expanding reduction. Constructor-headed inputs use only the structural computation equations. Neutral identity and composition are the deliberate definitional-equality delta Desc-Map-Id/Desc-Map-Comp; the latter may be oriented as weak-head reduction only on a neutral argument. Generated action commutes with every well-typed simultaneous substitution, and this substitution lemma proves that constructor computation, the two equality rules, and neutral compaction remain well typed after substitution. Dependent sums act by (𝑔,𝑓)(𝑥,𝑦)=(𝑔(𝑥),𝑓(𝑥)(𝑦)); their identity and composition laws reduce by projection and pair computation rather than by the neutral delta.