Logic & kernel theory

Deduction

This page defines contexts, judgments, and the inference rules of the kernel as a natural-deduction calculus, derives the defined connectives, and proves the structural theorems the kernel depends on: dependency tracking (strengthening), export, transport, type instantiation, weakening and strengthening, of contexts and of theories, and the comparison of contexts by their entries. Soundness with respect to models is on the semantics page.

Throughout, a theory \(T\) is fixed (until the last section, which moves a derivation to a larger or a smaller theory). Terms are compared up to \(=_E\), equality modulo β, ACU, and literal arithmetic for the canonical signature of \(T\) (Definition C-1). The kernel represents every term it uses in \(T\) in canonical form for that signature, lifting stored contents when they are used, so comparing up to \(=_E\) is comparing canonical forms by identity (Theorems C-6 and C-7): each rule matches its premises, and builds its conclusion, up to \(=_E\). δ and ζ steps happen only in the rule (Conv) below, which names its unfolding set.

Contexts and judgments

Definition D-1 (contexts). A context \(\Gamma\) is a finite sequence of entries, each either a local declaration \(\ell: \tau\) or a hypothesis \(h: A\), such that every local and hypothesis name occurs once, every \(\tau\) is well formed, and every \(A\) is a bound-closed proposition whose locals are declared earlier in \(\Gamma\). \(L_\Gamma\) is the local typing of \(\Gamma\). A context \(\Gamma'\) extends \(\Gamma\) when \(\Gamma\) is a prefix of \(\Gamma'\); \(\Gamma \sqsubseteq \Gamma'\) means \(\Gamma\) is a subsequence of \(\Gamma'\). The entries of \(\Gamma\), \(\operatorname{ent}(\Gamma)\), are the set of its locals and of its hypotheses' propositions, without names or order. Like every term, an entry's proposition is compared up to \(=_E\): the kernel stores it canonical for the signature of the theory in which it was assumed, and lifts it when it is used in a theory with a larger canonical signature.

Definition D-2 (judgments). A judgment \(\Gamma \vdash A\) consists of a context and a bound-closed proposition \(A\) with \([\,]; L_\Gamma \vdash A: \mathsf{Prop}\).

The rules

The connectives are the logic core's constants; \(\forall x{:}\tau.\, P\) is notation for \(\mathsf{forall}[\tau](\lambda{:}\tau.\, P)\) and \(a = b\) for \(\mathsf{eq}[\tau](a, b)\). A term written in a rule must be well typed in the context where it appears, with the type the rule requires.

Hypotheses, theorems, truth, falsity.

\[ \dfrac{(h: A) \in \Gamma}{\Gamma \vdash A}\;(\mathrm{Hyp}) \qquad \dfrac{d \text{ is an axiom, theorem, or definition equation of } T \text{ with statement } A}{\Gamma \vdash A[\bar\alpha_A:= \bar\tau]}\;(\mathrm{Use}) \qquad \dfrac{}{\Gamma \vdash \mathsf{True}}\;(\top\mathrm I) \qquad \dfrac{\Gamma \vdash \mathsf{False}}{\Gamma \vdash Q}\;(\bot\mathrm E) \]

The equation of a definition \(c:= b\) is \(c[\bar\alpha_c] = b\).

(Use) with term arguments is derivable. When \(A[\bar\alpha_A:= \bar\tau]\) is \(\forall x_1{:}\sigma_1.\, \cdots\, \forall x_k{:}\sigma_k.\, B\) and \(t_1, \dots, t_k\) are terms of \(\Gamma\) of the types the quantifiers require, \(\Gamma \vdash B\{x_1, \dots, x_k:= t_1, \dots, t_k\}\) follows by (Use) and \(k\) steps of \((\forall\mathrm E)\). The bridge-rule expansion writes it as one step, (Use) at \(\bar\tau\) and \(\bar t\) (sequents, Definition Q-13). Spelled out in the rules of this page, it is \(1 + k\) rule instances.

Implication and conjunction.

\[ \dfrac{\Gamma, h: A \vdash B}{\Gamma \vdash A \to B}\;(\to\mathrm I) \qquad \dfrac{\Gamma \vdash A \to B \qquad \Gamma \vdash A}{\Gamma \vdash B}\;(\to\mathrm E) \qquad \dfrac{\Gamma \vdash A \qquad \Gamma \vdash B}{\Gamma \vdash A \land B}\;(\land\mathrm I) \qquad \dfrac{\Gamma \vdash A \land B}{\Gamma \vdash A}\;(\land\mathrm E_1) \qquad \dfrac{\Gamma \vdash A \land B}{\Gamma \vdash B}\;(\land\mathrm E_2) \]

In \((\to\mathrm I)\), \(h\) is the last entry of the premise's context.

Disjunction.

\[ \dfrac{\Gamma \vdash A}{\Gamma \vdash A \lor B}\;(\lor\mathrm I_1) \qquad \dfrac{\Gamma \vdash B}{\Gamma \vdash A \lor B}\;(\lor\mathrm I_2) \qquad \dfrac{\Gamma \vdash A \lor B \qquad \Gamma \vdash A \to C \qquad \Gamma \vdash B \to C}{\Gamma \vdash C}\;(\lor\mathrm E) \]

Universal quantification.

\[ \dfrac{\Gamma, \ell: \tau \vdash P}{\Gamma \vdash \mathsf{forall}[\tau](\lambda{:}\tau.\, \operatorname{abs}^0_\ell P)}\;(\forall\mathrm I) \qquad \dfrac{\Gamma \vdash \mathsf{forall}[\tau](f) \qquad t: \tau}{\Gamma \vdash \mathrm{app}(f, t)}\;(\forall\mathrm E) \]

In \((\forall\mathrm I)\), \(\ell: \tau\) is the last entry of the premise's context. Since every entry of \(\Gamma\) precedes \(\ell\), no hypothesis of \(\Gamma\) mentions \(\ell\): the usual side condition holds by construction. In \((\forall\mathrm E)\), when \(f = \lambda{:}\tau.\, B\) the conclusion is \(B\{0:= t\}\), by β.

Equality.

\[ \dfrac{t: \tau}{\Gamma \vdash t = t}\;(\mathrm{Refl}) \qquad \dfrac{\Gamma \vdash s = t}{\Gamma \vdash t = s}\;(\mathrm{Sym}) \qquad \dfrac{\Gamma \vdash s = t \qquad \Gamma \vdash t = u}{\Gamma \vdash s = u}\;(\mathrm{Trans}) \]
\[ \dfrac{\Gamma \vdash f = g \qquad \Gamma \vdash a_i = b_i \;(1 \le i \le n)}{\Gamma \vdash f(a_1, \dots, a_n) = g(b_1, \dots, b_n)}\;(\mathrm{Cong}) \qquad \dfrac{\Gamma, \ell: \tau \vdash s = t}{\Gamma \vdash \lambda{:}\tau.\, \operatorname{abs}^0_\ell s = \lambda{:}\tau.\, \operatorname{abs}^0_\ell t}\;(\xi) \qquad \dfrac{P: \tau \to \mathsf{Prop} \qquad \Gamma \vdash a = b \qquad \Gamma \vdash \mathrm{app}(P, a)}{\Gamma \vdash \mathrm{app}(P, b)}\;(\mathrm{Subst}) \]

In \((\xi)\), \(\ell: \tau\) is the last entry of the premise's context.

Conversion and weakening.

\[ \dfrac{\Gamma \vdash A \qquad A \equiv_U B}{\Gamma \vdash B}\;(\mathrm{Conv}) \qquad \dfrac{\Gamma \vdash A \qquad \operatorname{ent}(\Gamma) \subseteq \operatorname{ent}(\Gamma')}{\Gamma' \vdash A}\;(\mathrm{Weak}) \]

(Weak) asks only that \(\Gamma'\) contain the entries of \(\Gamma\), in any order that makes \(\Gamma'\) a context. This covers a subsequence (\(\Gamma \sqsubseteq \Gamma'\)), a reordering of entries that nothing depends on (such as moving a local that no hypothesis mentions to the end), and a second name for a hypothesis. Theorem D-3 shows that it adds no strength.

In (Conv), \(U\) is a set of transparent definitions and \(\equiv_U\) is conversion that unfolds only those (Definition C-1); since \(\equiv_U \subseteq \equiv\), every result below for \(\equiv\) holds for it.

Substitution and type instantiation.

\[ \dfrac{\Gamma \vdash A \qquad m: \Gamma \to \Gamma^*}{\Gamma^* \vdash A[m]}\;(\mathrm{Transport}) \qquad \dfrac{\Gamma \vdash A \qquad \theta \text{ admissible}}{\Gamma^\theta \vdash A\theta}\;(\mathrm{InstType}) \]

In (Transport), \(m\) maps each local of \(\Gamma\) to a bound-closed term of its type in \(\Gamma^*\), and each hypothesis \(h{:}B\) of \(\Gamma\) either to an entry of \(\Gamma^*\) whose proposition is \(B[m]\) or to a derivation of \(\Gamma^* \vdash B[m]\). An entry stands for its (Hyp) derivation, so the rule then has no premise for that hypothesis. Theorem D-5 states the conditions. In (InstType), \(\theta\) is a type substitution admissible in the theory (Definition Y-11). \(\Gamma^\theta\) replaces each local \(\ell{:}\tau\) of \(\Gamma\) by a fresh local \(\ell^\theta{:}\tau\theta\), and each hypothesis \(h{:}B\) by \(h{:}B\theta[\ell := \ell^\theta]\), and \(A\theta\) is read with the same renaming. These propositions are read canonically, so \(A\theta\) stands for \(N(A\theta)\). This includes the case where \(\theta\) moves the carrier of a class-level ACU declaration to a function type (Corollary D-6a). Both rules are admissible: Theorem D-5 for (Transport), and Corollary D-6a for (InstType). They are primitive so that the bridge-rule expansions stay bounded per row (sequents, Theorem Q-25): the kernel's transport method is (Transport), and (InstType) is the inst row's rule.

The base calculus, and the order of the proofs. The base calculus is the rules of this page without (Transport) and (InstType); it keeps (Weak). The theorems below are proved for it, by induction over base derivations, in this order: Theorem D-2, Lemma D-2a, Theorems D-3, D-4, D-7 and D-8, then Theorem D-5, Theorem D-6 and Corollary D-6a. None of these proofs meets a (Transport) or (InstType) node. Theorems D-5 and D-6a then eliminate the two rules. Take an uppermost instance of one of them, so that its premise derivation and the derivations its map uses are base derivations, and replace it by the base derivation the theorem gives for the same conclusion. Repeating this ends, because each step removes one instance and adds none. So every derivation becomes a base derivation of the same judgment, the two rules add no strength, and every theorem proved by induction over base derivations holds for derivations that use them. The same holds for (Use) with term arguments, which unfolds to (Use) and \((\forall\mathrm E)\).

Certificates. A checker admitted by an explicit, recorded action contributes the rule \(\Gamma \vdash A\) for each claim \(A\) it accepts. It is an axiom scheme whose soundness is the checker's correctness theorem; none is currently implemented.

Definition D-3 (derivability). \(\Gamma \vdash A\) is derivable in \(T\) when there is a finite tree of rule instances with conclusion \(\Gamma \vdash A\). The kernel's methods (K1.8) are these rules. Its transport and export methods are admissible rules: Theorems D-4 and D-5 show, by induction over derivations, that each of their results has a derivation.

Admissible rules and checkers. Strengthening (D-2), weakening (D-3), export (D-4), transport (D-5), type instantiation (D-6), theory weakening (D-7), and theory strengthening (D-8) are proved by induction over the rules of this page, and so are conservative definitions (Theorem M-5(2)) and conversion elimination (Theorem C-12). A rule that is merely derivable survives the addition of new rules; an admissible one may not [Sterling 2015, after Harper]. Certificates are the one way the rules can grow, so each admitted checker must come with a proof, on these pages, that it preserves these theorems:

  • each claim names its hypotheses, locals, and declarations, which Definitions D-4 and D-5 record for it;
  • the claims it accepts are closed under weakening, strengthening to those dependencies, substitution of bound-closed terms for locals, and type instantiation;
  • they are closed under change of theory: a claim accepted in \(T\) is accepted in every theory that contains the declarations it names and the signature theory of \(T\);
  • they are closed under the translation of Theorem M-5(2): if a claim is accepted in \(T + (c:= b)\), its translation, which replaces \(c\) by its body, is derivable in \(T\);
  • they are closed under the plain reading of Theorem C-12: the plain reading of a claim accepted in \(T\) has a plain derivation in \(T^-\) (Definition C-7).

Each of the inductions above then gains one case, discharged by that proof.

Defined connectives

The logic core defines \(\neg A:= A \to \mathsf{False}\), \(A \leftrightarrow B:= (A \to B) \land (B \to A)\), and

\[ \exists x{:}\tau.\, P \;:=\; \forall Q{:}\mathsf{Prop}.\; \big(\forall x{:}\tau.\, P \to Q\big) \to Q. \]

Theorem D-1 (derived rules). The following rules are derivable, where \(R\) is bound-closed and does not mention the quantified variable:

\[ \dfrac{\Gamma \vdash P\{0:= t\} \qquad t: \tau}{\Gamma \vdash \exists x{:}\tau.\, P}\;(\exists\mathrm I) \qquad \dfrac{\Gamma \vdash \exists x{:}\tau.\, P \qquad \Gamma \vdash \forall x{:}\tau.\, P \to R}{\Gamma \vdash R}\;(\exists\mathrm E) \qquad \dfrac{\Gamma, h: A \vdash \mathsf{False}}{\Gamma \vdash \neg A}\;(\neg\mathrm I) \qquad \dfrac{\Gamma \vdash \neg A \qquad \Gamma \vdash A}{\Gamma \vdash \mathsf{False}}\;(\neg\mathrm E) \]

Proof. \((\neg\mathrm I)\) and \((\neg\mathrm E)\) are \((\to\mathrm I)\) and \((\to\mathrm E)\) after unfolding \(\neg\) by (Conv).

\((\exists\mathrm E)\): unfold the first premise by (Conv) and apply \((\forall\mathrm E)\) with \(Q:= R\). Because \(R\) is bound-closed, instantiation yields \(\big(\forall x{:}\tau.\, P \to R\big) \to R\), and \((\to\mathrm E)\) with the second premise gives \(R\).

\((\exists\mathrm I)\): in the context \(\Gamma, q: \mathsf{Prop}, h: \forall x{:}\tau.\, P \to q\), \((\forall\mathrm E)\) on \(h\) with \(t\) gives \(P\{0:= t\} \to q\); (Weak) brings the premise \(P\{0:= t\}\) into this context, and \((\to\mathrm E)\) gives \(q\). Then \((\to\mathrm I)\) discharges \(h\), \((\forall\mathrm I)\) generalizes \(q\), and (Conv) folds the definition of \(\exists\). \(\square\)

Propositional extensionality. The logic core has one axiom, \(\mathsf{propext}: \forall P\, Q{:}\mathsf{Prop}.\, (P \to Q) \to (Q \to P) \to P = Q\). It is not a classical principle: it holds in every topos, where \(\mathsf{Prop}\) is the subobject classifier and the internal logic is intuitionistic [Lambek and Scott 1986; Mac Lane and Moerdijk 1992], so it does not prove excluded middle, and constructive profiles keep it. HOL Light has it as a primitive rule (DEDUCT_ANTISYM_RULE). With it, (Subst) replaces a proposition by an equivalent one inside any term; conversion elimination needs this for literal comparisons inside larger terms (Theorem C-12). Like every axiom, it is recorded in the dependencies of the judgments that use it. Two consequences are worth stating: from \(\Gamma \vdash A\), propext and \((\top\mathrm I)\) give \(\Gamma \vdash A = \mathsf{True}\); from \(\Gamma \vdash \neg A\), they give \(\Gamma \vdash A = \mathsf{False}\), using \((\bot\mathrm E)\).

Classical principles. A classical profile admits, as recorded axioms: excluded middle \(\forall P{:}\mathsf{Prop}.\, P \lor \neg P\); function extensionality \(\forall f\, g{:}\alpha \to \beta.\, (\forall x.\, f(x) = g(x)) \to f = g\); choice, as a constant \(\varepsilon[\alpha]: (\alpha \to \mathsf{Prop}) \to \alpha\) with \(\forall P\, x.\, P(x) \to P(\varepsilon(P))\); and infinity, as a type constructor \(\mathsf{ind}\) with an injective, non-surjective function \(\mathsf{ind} \to \mathsf{ind}\). These are the axioms of HOL Light [Harrison 2009]; Theorem M-3 shows they are jointly consistent.

They are not independent: choice, with function extensionality and the core's propositional extensionality, proves excluded middle [Diaconescu 1975], and HOL Light derives excluded middle from its choice axiom in this way. A profile may still list excluded middle among its axioms, for clarity. A constructive profile must leave out choice as well as excluded middle; the totalized operations of the analysis page (Definition A-1) use \(\varepsilon\), so they belong to classical profiles only.

Dependencies

Definition D-4 (dependencies of a derivation). For a derivation \(\mathcal D\) of \(\Gamma \vdash A\), define by recursion on \(\mathcal D\):

  • \(\operatorname{hyps}(\mathcal D)\): the hypotheses used by (Hyp) leaves and named by certificate steps, minus those discharged by \((\to\mathrm I)\) below them;
  • \(\operatorname{decls}(\mathcal D)\): the declarations used by (Use) leaves, the definitions in the unfolding sets \(U\) of (Conv) steps, the declarations a certificate's checker names, and the theory's canonical signature;
  • \(\operatorname{locs}(\mathcal D)\): the locals occurring in \(A\), in the propositions of \(\operatorname{hyps}(\mathcal D)\), in every term a rule introduces (\(t\) in (Refl) and \((\forall\mathrm E)\), \(Q\) in \((\bot\mathrm E)\), the other disjunct in \((\lor\mathrm I)\), \(P\) in (Subst), the target of (Conv)), and named by certificate steps, minus the locals generalized by \((\forall\mathrm I)\) and \((\xi)\) below.

These are exactly the sets the kernel records (K1.7), computed rule by rule from the premises.

Definition D-5 (home theory). The home theory \(\operatorname{home}(\mathcal D)\) of a derivation \(\mathcal D\) in \(T\) is the least theory included in \(T\) (Lemma T-8) that contains the root theory (the logic core), the signature theory \(\operatorname{sig}(T)\), the declarations of \(\operatorname{decls}(\mathcal D)\), and the declaration of every constant, type constructor, and literal kind that occurs in a proposition of a judgment of \(\mathcal D\) (not counting its context), in a hypothesis that a certificate step of \(\mathcal D\) names, in a term or type a rule of \(\mathcal D\) introduces, or in the type of a local occurring in any of these or named by a certificate step.

The kernel records, for each judgment, a theory that includes the home theory of its derivation, computed rule by rule as the join of its premises' and of the steps' contributions (K1.7). Every theory of the kernel includes the root theory (Definition T-1), so including it costs nothing; it makes the home theory contain the connectives that export introduces (Theorem D-5). The signature theory is included because canonical construction applies the ACU and literal laws without citing them: \((\forall\mathrm E)\) may re-sort a sum by commutativity, so a derivation depends on the whole canonical signature, not only on the declarations it names.

Theorem D-2 (strengthening). Let \(\mathcal D\) derive \(\Gamma \vdash A\), and let \(\Gamma'\) be the subsequence of \(\Gamma\) consisting of the local declarations in \(\operatorname{locs}(\mathcal D)\) and the hypotheses in \(\operatorname{hyps}(\mathcal D)\). Then \(\Gamma'\) is a context, and \(\Gamma' \vdash A\) is derivable using only the declarations in \(\operatorname{decls}(\mathcal D)\).

Proof. \(\Gamma'\) is a context: each hypothesis it keeps mentions only locals in \(\operatorname{locs}(\mathcal D)\), which precede it in \(\Gamma\) and are kept. The derivation is by induction on \(\mathcal D\). For a leaf, the subcontext contains what the leaf needs: (Hyp) its hypothesis and that hypothesis's locals, (Refl) the locals of \(t\), and a certificate step the hypotheses and locals its claim names, where the checker accepts it by its admission obligation. For a rule with premises \(\mathcal D_1, \dots, \mathcal D_k\) in the same context, each premise's subcontext \(\Gamma'_i\) is a subsequence of \(\Gamma'\), because \(\operatorname{hyps}\), \(\operatorname{locs}\), and \(\operatorname{decls}\) of the conclusion contain those of the premises (nothing is discharged); apply the induction hypothesis, then (Weak) to \(\Gamma'\), then the rule. For \((\to\mathrm I)\) with premise context \(\Gamma, h: A\): the premise's subcontext is a subsequence of \(\Gamma', h: A\), because \(A\)'s locals are in \(\operatorname{locs}\) of the conclusion \(A \to B\). Weaken to \(\Gamma', h: A\), where \(h\) is last, and apply \((\to\mathrm I)\). For \((\forall\mathrm I)\) and \((\xi)\) with premise context \(\Gamma, \ell: \tau\): the premise's subcontext is a subsequence of \(\Gamma', \ell: \tau\) (if \(\ell\) is unused it is simply absent, and we add it by (Weak)); \(\ell\) is last, so the rule applies. \(\square\)

Theorem D-2 is what makes the recorded dependencies meaningful: a judgment holds in any context that contains its dependencies. Export, transport, and the reuse of cached judgments rest on it.

Lemma D-2a (renaming a local). Let a base derivation \(\mathcal D\) derive \(\Gamma \vdash A\), let \(\ell{:}\tau\) be a local, and let \(\ell'{:}\tau\) be a local that occurs nowhere in \(\mathcal D\). Replacing \(\ell\) by \(\ell'\) throughout \(\mathcal D\) gives a base derivation of \(\Gamma[\ell:= \ell'] \vdash A[\ell:= \ell']\) with the same rules, size and declarations.

Proof. Induction on \(\mathcal D\). The renaming is injective and keeps types, so it keeps contexts as contexts, a last entry last, and the typing side conditions (Theorem T-4). The substitution operations commute with it: it is a substitution of a local for a local, and \(\operatorname{abs}^0_{\ell'}(t[\ell:= \ell']) = \operatorname{abs}^0_\ell t\). (Conv) and the comparisons of propositions are preserved, since \(=_E\) and \(\equiv_U\) are closed under substitution for locals (Lemma C-9(1)). Canonical forms can order an ACU spine differently after the renaming, because the binding depth, the name and the type enter the structural hash; they stay \(=_E\)-equal, which is all the rules compare. No rule names \(\ell\) except through its context and terms. \(\square\)

Export and transport

Theorem D-3 (weakening). If \(\Gamma \vdash A\) and \(\operatorname{ent}(\Gamma) \subseteq \operatorname{ent}(\Gamma')\), then \(\Gamma' \vdash A\) is derivable without (Weak).

Proof. Induction on the size of the base derivation, for all \(\Gamma'\) at once. For (Hyp) with \(h{:}B\) in \(\Gamma\), \(B\) is an entry of \(\Gamma'\) under some name \(h'\); use \(h'\). A local's type is fixed with the local (K1.5), so a local of \(\Gamma\) is the same entry in \(\Gamma'\). For (Weak) from \(\Gamma_0 \vdash A\) with \(\operatorname{ent}(\Gamma_0) \subseteq \operatorname{ent}(\Gamma)\), apply the induction hypothesis to the premise and \(\Gamma'\), since \(\operatorname{ent}(\Gamma_0) \subseteq \operatorname{ent}(\Gamma')\). For \((\to\mathrm I)\) with premise context \(\Gamma, h{:}B\), extend \(\Gamma'\) by \(h'{:}B\) for a name \(h'\) that \(\Gamma'\) does not use.

For \((\forall\mathrm I)\) and \((\xi)\) with premise context \(\Gamma, \ell{:}\tau\): if \(\ell\) is not a local of \(\Gamma'\), extend \(\Gamma'\) by \(\ell{:}\tau\). If it is, rename \(\ell\) in the premise's derivation to a local \(\ell'{:}\tau\) that occurs neither in it nor in \(\Gamma'\) (Lemma D-2a). This keeps the size. No entry of \(\Gamma\) mentions \(\ell\), because \(\ell\) is declared after them, so the premise becomes \(\Gamma, \ell'{:}\tau \vdash P[\ell:= \ell']\). Extend \(\Gamma'\) by \(\ell'{:}\tau\). The conclusion is unchanged, since \(\operatorname{abs}^0_{\ell'}(P[\ell:= \ell']) = \operatorname{abs}^0_\ell P\).

In each case the added entry is last, and inclusion of entries is kept. Every other rule keeps its context, and the induction hypothesis applies to its premises. \(\square\)

Theorem D-4 (export). Let \(\mathcal D\) derive \(\Gamma_0, E_1, \dots, E_m \vdash A\). Define \(A_m:= A\) and, for \(i = m, \dots, 1\):

\[ A_{i-1}:= \begin{cases} B \to A_i & E_i = (h: B),\; h \in \operatorname{hyps}(\mathcal D)\\ \mathsf{forall}[\tau](\lambda{:}\tau.\, \operatorname{abs}^0_\ell A_i) & E_i = (\ell: \tau),\; \ell \in \operatorname{locs}(\mathcal D)\\ A_i & \text{otherwise.} \end{cases} \]

Then \(\Gamma_0 \vdash A_0\) is derivable.

Proof. By Theorem D-2, \(A\) is derivable in the subcontext keeping only used entries. Process the kept entries after \(\Gamma_0\) from the last to the first. Each, when processed, is the last entry of the current context: a hypothesis is discharged by \((\to\mathrm I)\), a local generalized by \((\forall\mathrm I)\). When \(\ell\) is generalized, every kept hypothesis after it has already been discharged, and the entries before it cannot mention it. Finally, the remaining context is a subsequence of \(\Gamma_0\); apply Theorem D-3. \(\square\)

Exporting to the empty context yields a closed proposition \(\forall \bar\ell.\, \bar B \to A\), which Proven turns into a theorem (K1.9). This is how a result found under assumptions becomes a guarded theorem that any context can apply.

Theorem D-5 (transport is derivable). Let \(\mathcal D\) derive \(\Gamma \vdash A\), and let \(m\) map each local \(\ell \in \operatorname{locs}(\mathcal D)\) to a bound-closed term \(m(\ell)\) of type \(L_\Gamma(\ell)\) in a context \(\Gamma^*\) of a theory \(T^*\) that includes \(\operatorname{home}(\mathcal D)\), and each hypothesis \((h: B) \in \operatorname{hyps}(\mathcal D)\) to an entry of \(\Gamma^*\) whose proposition is \(B[m]\), or to a derivation of \(\Gamma^* \vdash B[m]\). Then \(\Gamma^* \vdash A[m]\) is derivable, where \([m]\) substitutes \(m(\ell)\) for each \(\ell\).

Proof. Export \(\mathcal D\) to the empty context (Theorem D-4), giving \(\vdash \forall \ell_1.\, \cdots\, B_1 \to \cdots \to A\) over the used entries in their order. Export adds only \((\to\mathrm I)\) and \((\forall\mathrm I)\) steps, whose propositions are built from the logic core's connectives, the propositions of \(\operatorname{hyps}(\mathcal D)\), and the types of the locals of \(\operatorname{locs}(\mathcal D)\), all of which Definition D-5 counts in \(\operatorname{home}(\mathcal D)\) (the logic core as part of the root theory); so this derivation's home theory is included in \(\operatorname{home}(\mathcal D)\). Restrict it to \(\operatorname{home}(\mathcal D)\) (Theorem D-8), move it to \(T^*\) (Theorem D-7), and weaken to \(\Gamma^*\). Eliminate the prefix in order: \((\forall\mathrm E)\) with \(m(\ell_j)\), which by Lemma S-4 substitutes \(m(\ell_j)\) for \(\ell_j\) in the rest; \((\to\mathrm E)\) with the derivation of \(B_j[m]\), which for an entry is (Hyp). Types are preserved by Theorem T-4. \(\square\)

The kernel implements transport directly for speed (K1.8), but by Theorem D-5 it adds no logical strength. The target's theory must include the home theory: in a theory that lacks a declaration \(\mathcal D\) uses, an axiom it relies on need not hold. It need not include \(T\): a judgment proved in one session from the profile's declarations alone moves to every other session of that profile.

Theorem D-6 (type instantiation). If \(\vdash A\) is derivable in the empty context, so is \(\vdash A\theta\), for every type substitution \(\theta\).

Proof. Apply \(\theta\) to every judgment of the derivation, including its contexts. Each rule instance remains a rule instance: (Use) instantiates a scheme further, its statement at a function type read in the declaration's parent's signature first (K2.9), which is the canonical form of the same instance; (Conv) is preserved because \(\equiv_U\) is closed under type substitution (Lemma C-9(3)), except for an (A), (C), or (U) step of a class-level ACU declaration whose carrier \(\theta\) moves to a function type, where the declaration does not apply (Definition Y-15): there the step becomes (Use) of the law it cites, at the instance \(\theta\) gives, which is admissible because the function type belongs to the sort, with congruence; the typing side conditions hold by Theorem T-5; and the substitution operations commute with \(\theta\) by Lemma S-5. \(\square\)

Corollary D-6a (type instantiation in a context). If \(\Gamma \vdash A\) is derivable and \(\theta\) is admissible, so is \(\Gamma^\theta \vdash A\theta\), with the renaming of (InstType). The hypotheses of \(\Gamma^\theta\) and the conclusion are read canonically, also when \(\theta\) moves the carrier of a class-level ACU declaration to a function type.

Proof. Run the proof of Theorem D-6 on a base derivation of \(\Gamma \vdash A\), in its context, without exporting it first. Apply \(\theta\) and the renaming \(\ell \mapsto \ell^\theta\) to every judgment, and read every proposition canonically. - A local \(\ell{:}\tau\) of a context becomes \(\ell^\theta{:}\tau\theta\), and a hypothesis \(h{:}B\) becomes \(h{:}N(B\theta[\ell:= \ell^\theta])\). So (Hyp) stays (Hyp), and the last entry of \((\to\mathrm I)\), \((\forall\mathrm I)\) and \((\xi)\) stays last. - (Weak) keeps its inclusion of entries, since entries are mapped uniformly. - Every other rule instance remains one, as in Theorem D-6. That includes the exception there: an (A), (C) or (U) step of a class-level ACU declaration whose carrier \(\theta\) moves to a function type becomes (Use) of the law it cites, with congruence.

The cited-law steps are inside this derivation, and its conclusion is the canonical form of \(A\theta\) in that case as well. Lemma S-5 commutes \(\theta\) with the substitution operations. Lemma C-9(3) is used only where Theorem D-6 uses it, which is outside the exception. \(\square\)

This justifies treating every theorem as a scheme over its type parameters, which is how (Use) applies Proven declarations. With sorted type variables, \(\theta\) must be admissible (Definition Y-11), and the instantiated derivation keeps the sort hypotheses of \(\mathcal D\) (Definition Y-13); keeping a hypothesis is always sound.

Moving between theories

Theorem D-7 (theory weakening). If \(\Gamma \vdash A\) is derivable in \(T\) and \(T \sqsubseteq T'\), then \(\Gamma \vdash A\) is derivable in \(T'\).

Proof. Induction on the derivation; every rule instance in \(T\) is a rule instance in \(T'\). The declarations of \(T\) are declarations of \(T'\), so (Use) applies unchanged. Typing is preserved: the rules (Const), (App), (ACU), and (Lit) of Definition T-4 only gain instances when the signature grows, an ACU instance keeps its declaration and unit because the global conditions of \(T'\) (Definition T-1) forbid a second ACU declaration whose type arguments unify with its own after renaming apart, and types stay unique by Theorem T-1 in \(T'\). Comparisons up to \(=_E\) are preserved, and so is (Conv), because \(=_{E_T} \subseteq\; =_{E_{T'}}\) and \(\equiv_U\) in \(T\) is included in \(\equiv_U\) in \(T'\): every generator in \(T\) is one in \(T'\), since the ACU declarations, literal kinds, and transparent definitions of \(T\) are those of \(T'\) (Lemma C-9(4) for the equations of Definition C-1). A certificate step is preserved by its checker's obligation for change of theory. The remaining rules mention no declaration. \(\square\)

Contexts are never rebuilt. When a judgment of \(T\) is used in \(T'\), the kernel lifts its proposition, and every hypothesis or stored content it uses (a declaration's statement, a definition's body), canonically for the signature of \(T'\) (lifting, K1.3); by Corollary C-9a the lifted terms are \(=_E\)-equal in \(T'\) to the originals, which is all this page's comparisons need. Theorem D-7 is what lets the kernel's context frames move to a theory that includes theirs (rebase, K1.5), so that a session's contexts follow its theory as it declares new symbols: each entry was well formed in the theory of its own frame, and stays well formed in every theory that includes it. It also lets transport target a context of a larger theory (Theorem D-5). With Theorem D-3, it lets the kernel compare contexts by their entries (Corollary D-9).

Theorem D-8 (theory strengthening). Let \(\mathcal D\) derive \(\Gamma \vdash A\) in \(T\), let \(H\) be a theory with \(\operatorname{home}(\mathcal D) \sqsubseteq H \sqsubseteq T\), and let \(\Gamma'\) be the subcontext of Theorem D-2. Then \(\Gamma'\) is a context of \(H\), and \(\Gamma' \vdash A\) is derivable in \(H\).

Proof. Since \(\operatorname{sig}(T) \sqsubseteq H \sqsubseteq T\), the canonical signatures of \(H\) and \(T\) are equal. By Theorem D-2, \(\Gamma' \vdash A\) has a derivation \(\mathcal D'\) in \(T\) with the same propositions and introduced terms as \(\mathcal D\), from declarations in \(\operatorname{decls}(\mathcal D)\); hence every declaration it mentions or uses is in \(H\). \(\Gamma'\) is a context of \(H\): its locals occur in \(\mathcal D\), so their types are in the language of \(H\), and its hypotheses are conclusions of (Hyp) leaves. Each rule instance of \(\mathcal D'\) is a rule instance in \(H\):

  • its typing side conditions hold in \(H\), because its terms are in the language of \(H\) and the canonical signatures agree (the remark after Lemma T-8);
  • (Use) cites a declaration of \(\operatorname{decls}(\mathcal D) \subseteq H\), with the same statement; with sorts, its substitution stays admissible in \(H\), and an of_class step stays valid, because the instance declarations their memberships use are in \(\operatorname{decls}(\mathcal D)\) (Definition Y-11);
  • (Conv) with unfolding set \(U \subseteq H\): by Corollary C-8a, \(A \equiv_U B\) holds exactly when \(N(\operatorname{unfold}_U(A)) = N(\operatorname{unfold}_U(B))\), and \(N\) depends only on the canonical signature, which \(H\) and \(T\) share;
  • a certificate step: its checker names declarations of \(\operatorname{decls}(\mathcal D) \subseteq H\), and its admission obligation makes it accept the claim in \(H\);
  • the remaining rules mention no declaration. \(\square\)

Because the canonical signatures agree, the kernel's canonical forms in \(H\) are those of \(T\): a judgment needs no lifting to move to its home theory. By Theorems D-8 and D-7 together, a judgment whose recorded home theory is \(H\) holds, in its strengthened context, in every theory that includes \(H\), whether or not that theory includes \(T\). This is what lets the kernel accept a judgment as a Proven declaration of any theory that includes its home, transport it there, and reuse it across sessions. The target need not include unrelated declarations from the original context theory.

Corollary D-9 (contexts are compared by their entries). Let \(\Gamma \vdash A\) be derivable in \(T\), and let \(\Delta\) be a context of a theory \(T' \sqsupseteq T\) whose entries extend those of \(\Gamma\), or more generally contain them as a subsequence (\(\Gamma \sqsubseteq \Delta\), Definition D-1). Then \(\Delta \vdash A\) is derivable in \(T'\).

Proof. Theorem D-7 moves the derivation to \(T'\), where \(\Gamma\) is still a context, since its entries were well formed in \(T \sqsubseteq T'\); Theorem D-3 weakens it to \(\Delta\). \(\square\)

This is how the checker compares contexts (the relation \(\preceq\) of local checking, Definition LC-7, which placement uses, Definition LC-9): a context is determined by its entries and its theory, never by the frames it was built from, and \(\Delta\) extends \(\Gamma\) when the entries of \(\Gamma\) are a prefix of those of \(\Delta\) and the theory of \(\Delta\) includes that of \(\Gamma\). A rule may therefore combine premises whose contexts have entries on one chain and theories of which one includes the others: its conclusion lies in the deepest entries at the largest theory, where every premise holds by Corollary D-9. Likewise, the hypothesis judgments given to transport must lie in contexts that the target extends. A frame without an entry, which rebase makes, never stacks on another (Definition LC-7(2)): rebasing a context whose innermost frame has no entry replaces that frame, so that rebasing changes only the theory, and contexts with the same entries and theory are the same.

judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub