System architecture

One judgment for sequent and natural-deduction rows

This page gives the reasons for the unified judgment that the bridge-rule expansion expands. The normative content is on the theory and specification pages:

  • the unified judgment \(E \Vdash_T \varphi\) and its agreement with the closure: the sequents page, Definition Q-18 and Proposition Q-29;
  • the expansion and its bounds: Definition Q-13 and Theorem Q-25 there;
  • (Weak) by entries, (Transport), and (InstType): the deduction page;
  • the bridge-rule gate's obligation: KC1.14.

The problem

The kernel has one logic and two rule families over two judgment forms. A sequent row \(\Gamma \vdash^{V}_{T} \varphi\) stores a set \(\Gamma\) of hypotheses and a set \(V\) of free locals (Definition Q-1). A natural-deduction row lies in a context, an ordered chain of frames whose entries are named locals and hypotheses (Definitions D-1 and LC-7).

The bridge between them is the closure: a sequent means \(J(s) = \;\vdash \operatorname{cl}(s)\) in the empty context (Definition Q-3). An expansion through the closure proves every row in three phases: Open each premise's closure into the standard context (\(|V_i|\) forall_elim and \(|\Gamma_i|\) imp_elim), apply the rule's core, and Close the result again (\(|\Gamma|\) imp_intro, \(|V|\) generalizations, and export). A row then expands to \(\Theta(|V| + |\Gamma| + \sum_i (|V_i| + |\Gamma_i|))\) rule instances, although the row itself is \(O(1)\) in the DAG: \(V\) and \(\Gamma\) are interned sets, shared by id (TD1.2). inst by a declared scheme is worse: when the premise's sort hypotheses are not witnessed, it copies the premise's whole cone. The cost is not in the logic, since each rule's core is \(O(1)\). It is in moving every intermediate result in and out of the empty context.

The design

Unify the judgment, not the rules. A sequent row is read in place, as a natural-deduction judgment whose context contains its locals as fixed entries and its hypotheses as assumed entries, and is never closed per row: \(\operatorname{E}(s) \Vdash \varphi\) with \(\operatorname{E}(s) = V \cup \Gamma\) (Definition Q-18). Every sequent rule is then a fixed-size combination of natural-deduction rules, the rule's core plus one weakening per premise to align contexts (Definition Q-13). Closure stays what it is for: the statement of a thm, the witness of a declaration, and the reading of a Proven proof (Definitions Q-12 and LC-21).

The stored rows need not change. \(\operatorname{E}(s) \Vdash \varphi\) holds exactly when \(J(s)\) is derivable, with the same declarations, home, and sort hypotheses (Proposition Q-29), and a row's fields already determine \(\operatorname{E}(s)\) and \(\varphi\). TD1.8's layouts, the checker's decisions, and ST9 libraries are the same under either reading.

Weakening compares entries. (Weak) of the deduction page asks only that the target context contain the source's entries, in any order that makes it a context, and Theorem D-3 shows that it adds no strength. One rule covers the three ways contexts must be aligned:

  • hypothesis-set union: a premise in \(\operatorname{E}(s_i)\) moves into \(\operatorname{E}(s) \supseteq \operatorname{E}(s_i)\) by one (Weak) step;
  • exchange: absThm's eigenvariable \(v\) must be the last entry for \((\xi)\). A realization of an entry set in which no hypothesis mentions \(v\) can be reordered to put \(v\) last, and the reordering is a (Weak) step between equal entry sets. The eigenvariable condition of absThm is exactly the condition that such a reordering exists;
  • duplicate propositions: deductAntisym with \(A \in \Gamma\) assumes \(A\) a second time under a fresh name; inclusion of entry sets ignores names.

(Transport) and (InstType) are primitive. Both are admissible (Theorem D-5 and Corollary D-6a). As primitives, the row inst with an empty type substitution is one (Transport), and inst with a type substitution is one (InstType) followed by one (Transport). (InstType) is HOL Light's INST_TYPE with contexts. The alternative, declaring each premise as a Proven scheme and using it at the substitution, adds one declaration per row, needs a cone-copying fallback when the premise's sort hypotheses are not witnessed, and would add a private declaration to the expansion's theory for most steps of an Isabelle article that cite a theorem.

The result. With these rules, every row expands to at most nine rule instances, or \(1 + 2\lvert\Gamma\rvert\) for a use row that peels \(\lvert\Gamma\rvert\) antecedents, counting (Use) with term arguments once (Definition Q-13). A DAG of \(n\) rows whose use rows peel \(a_1, \dots, a_k\) antecedents expands to at most \(9n + 2\sum_j a_j\) instances, plus the operand lists the rows already store. On the rows of the corpus articles that the classical profile accepts and of six OpenTheory packages, the closure-based expansion averaged 11.3 instances per row, at most 44, with \(|V|\) and \(|\Gamma|\) at most 5; the difference grows with \(|V| + |\Gamma|\).

The checker keeps its native checks: they read stored sets by id and merge sorted lists, and the expansions are what those checks mean, not what they run. The bridge-rule gate relates the two, through an implementation independent of the checker: a row passes its check exactly when it is an instance of its rule (Theorem Q-26), and an instance's expansion is a derivation with the row's records (Theorem Q-25). br_expand.mojo writes the expansions, and br_reference.mojo judges them with (Weak) by entries, (Transport), and (InstType) as native rules (KC1.14).

Risks

  1. Realization cost. A context that realizes an entry set costs one frame per entry. Built in the canonical order (the canonical closure, Definition Q-3d), realizations can share the frames of their common prefix, but a row whose entry set inserts a hypothesis before existing ones in structural order needs that suffix again. Routine whole-corpus runs depend on this cost staying near-linear in the DAG.
  2. Trusted primitives in the judge. (Weak) by entries, (Transport), and (InstType) are small, but they are code in the component whose value is independence (G16). Each needs adversarial review and tests against Theorems D-3, D-5, and D-6.
  3. Sort hypotheses. An expansion must record the sort hypotheses of the native check, or ones redundant for the row (Theorem Q-25). A difference between the two would fail the bridge-rule gate, not soundness.
  4. Names of duplicate hypotheses. Entry sets compare propositions, while contexts name hypotheses, so two entries for one proposition are two frames. (Hyp) may cite either, and the expansion must pick one deterministically (G1).
judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub