Sequents¶
The kernel checks an article step as one proof row. As in OpenTheory, a
step takes theorems with hypotheses, written \(\Gamma \vdash \varphi\), and
returns one: from \(\Gamma_1 \vdash a = b\) and \(\Gamma_2 \vdash b = c\),
trans returns \(\Gamma_1 \cup \Gamma_2 \vdash a = c\). This page defines
these sequents and the closed judgment that each one denotes. It states
the sequent rules and the declaration forms with all their side
conditions. For each rule it proves admissibility: if the premises'
judgments are derivable by the rules of the deduction page,
so is the conclusion's. The sequent rules therefore add no logical
strength.
For each rule the page also gives:
- the bounded derivation in the deduction rules that the bridge-rule expansion generates for a row of the rule, as the trusted base requires of every rule the kernel adds;
- the local check that the checker runs on a row of the rule, with the proof that the check accepts exactly the rule's instances.
The natural-deduction rules stay for authoring. The local checking page proves soundness by induction on the commit sequence. For a row of a sequent rule, its induction step is the admissibility theorem of this page. Results are numbered Q.
Conventions¶
| Notation | Meaning |
|---|---|
| \(T\), \(\Sigma\), \(N\) | a theory, its canonical signature, and \(N_\Sigma\) (Definition C-4) |
| \(\tau_\ell\) | the type of the local \(\ell\), fixed with the local's binding site (K1.5) |
| \(\operatorname{locs}(t)\) | the locals that occur in \(t\) |
| \(\operatorname{TV}(t)\), \(\operatorname{tv}(t)\) | the type variables of the annotations and type arguments of \(t\); those of them with a nonempty sort (Definition Y-13) |
| \(\operatorname{srt}(\alpha)\) | the sort of the type variable \(\alpha\) (Definition Y-11) |
| \(\operatorname{home}_\Sigma(t)\), \(\operatorname{home}(\tau)\) | the home theory of a term for \(\Sigma\), and of a type (K1.6) |
| \(T_d^{+}\) | \(\operatorname{par}(d) \cup \{d\}\), the theory just after the declaration \(d\) |
| \(\forall_\ell P\) | \(\mathsf{forall}[\tau_\ell](\lambda{:}\tau_\ell.\, \operatorname{abs}^0_\ell P)\) |
| \(A \to B\) | \(\mathsf{imp}(A, B)\); the arrow associates to the right |
| \(\operatorname{Eq}(a, b)\) | \(N(\mathsf{eq}[\tau](a, b))\), for \(a\) and \(b\) of type \(\tau\) |
| \(\lambda_v t\) | \(N(\lambda{:}\tau_v.\, \operatorname{abs}^0_v t)\) |
Terms are the locally nameless terms of the syntax page: bound variables are de Bruijn indices and locals are atoms that name their binding sites. Two terms are compared by identity, which for canonical terms is \(=_E\) (Theorem C-6).
Sequents and their judgments¶
Definition Q-1 (sequents). A sequent \(s = \Gamma \vdash^{V}_{T} \varphi\) with sort hypotheses \(S\) consists of:
- a theory \(T\), its theory;
- a finite set \(V\) of locals, its free locals, whose types are well formed in \(T\);
- a finite set \(\Gamma\) of terms, its hypotheses, and a term \(\varphi\), its conclusion. These are its parts. Each part is bound-closed, canonical for \(\Sigma(T)\), has type \(\mathsf{Prop}\) under the local typing \(\ell \mapsto \tau_\ell\), and has its locals in \(V\);
- a finite set \(S\) of sorts (Definition Y-13).
\(\operatorname{TV}(s)\) is the union of \(\operatorname{TV}\) of the parts and of the types \(\tau_\ell\) for \(\ell \in V\), and \(\operatorname{tv}(s)\) its subset of variables with a nonempty sort. \(V\) may hold locals that occur in no part (see free locals that occur nowhere).
\(\Gamma\) is a set of canonical nodes, so two hypotheses that are \(=_E\)-equal are one hypothesis. A row stores \(\Gamma\), \(V\) and \(S\) as sorted, deduplicated id lists (DAG storage); the order of a stored list has no meaning.
Definition Q-2 (orders, closed forms, row closure, acceptance). Canonical nodes are ordered by termbank's structural order (T1.6), a strict total order on distinct nodes. Let \(s\) have \(k\) free locals and \(n\) hypotheses. An order \(\pi\) lists \(V\) as \(\ell_1, \dots, \ell_k\), and an order \(\sigma\) lists \(\Gamma\) as \(A_1, \dots, A_n\).
- \(\operatorname{abs}^d_\pi t\) replaces \(\ell_i\) by \(\#(d + k - i)\) and a
bound variable \(\#j\) with \(j \ge d\) by \(\#(j + k)\), with \(d + 1\) under
the body of a λ or a
let; \(\operatorname{abs}_\pi = \operatorname{abs}^0_\pi\). - \(F_\pi(Y) = \mathsf{forall}[\tau_1](\lambda{:}\tau_1.\, \cdots\, \mathsf{forall}[\tau_k](\lambda{:}\tau_k.\, Y) \cdots)\), with \(\tau_i = \tau_{\ell_i}\).
- The closed form of a part \(P\) under \(\pi\) is \(c_\pi(P) = N(\operatorname{abs}_\pi P)\).
- \(\operatorname{cl}_{\pi,\sigma}(s) = N(\forall_{\ell_1} \cdots \forall_{\ell_k}.\; A_1 \to \dots \to A_n \to \varphi)\).
- The binding order \(\pi_b\) lists \(V\) by binding depth, shallowest first; the locals of \(V\) lie on one chain, so their depths differ.
- Row closure. \(\operatorname{cl}_r(s) = \operatorname{cl}_{\pi_b,\sigma_c}(s)\), where \(\sigma_c\) lists \(\Gamma\) by the structural order of the closed forms \(c_{\pi_b}(A)\).
- Acceptance. A closed term \(t\) accepts \(s\) when \(t = \operatorname{cl}_{\pi_b,\sigma}(s)\) for some order \(\sigma\).
Lemma Q-2b (closed forms). For bound-closed, well-typed \(t\), \(R\), \(P\), \(A\), \(B\) with their locals in \(V\), and any orders \(\pi\), \(\sigma\):
- \(\operatorname{abs}_\pi t = \operatorname{abs}^0_{\ell_k}(\cdots \operatorname{abs}^0_{\ell_1} t \cdots)\).
- \(\forall_{\ell_1} \cdots \forall_{\ell_k} R = F_\pi(\operatorname{abs}_\pi R)\).
- \(c_\pi(P)\) contains no local, and \(\operatorname{lb}(c_\pi(P)) \le k\).
- If \(A\), \(B\) are canonical and \(c_\pi(A) = c_\pi(B)\), then \(A = B\).
- \(N(F_\pi(Y)) = F_\pi(N(Y))\) and \(N(X \to Y) = N(X) \to N(Y)\); hence \(\operatorname{cl}_{\pi,\sigma}(s) = F_\pi(c_\pi(A_1) \to \dots \to c_\pi(A_n) \to c_\pi(\varphi))\).
- Renaming. Let \(\rho : V \to V'\) be a bijection and \(\theta\) a sort-preserving bijection of type variables with \(\tau_{\rho\ell} = \theta(\tau_\ell)\), and let \(s'\) be the sequent row of \(T\) whose parts are \(N(\theta(P[\rho]))\). Then \(c_{\rho\circ\pi}(N(\theta(P[\rho]))) = N(\theta(c_\pi(P)))\) and \(\operatorname{cl}_{\rho\circ\pi,\sigma'}(s') = N(\theta(\operatorname{cl}_{\pi,\sigma}(s)))\), where \(\sigma'\) lists the images of \(\sigma\)'s hypotheses in the same positions.
Proof. (1) Induction on \(k\): after the first \(k - 1\) abstractions
\(\ell_i\) stands at \(\#(d + k - 1 - i)\) at depth \(d\); \(\operatorname{abs}^0_{\ell_k}\)
(Definition S-10) raises the variables loose at depth \(d\) by one and maps
\(\ell_k\) to \(\#d\). (2) Induction on \(k\), with \(\pi^- = (\ell_2, \dots, \ell_k)\):
\(\forall_{\ell_1}\) of \(F_{\pi^-}(\operatorname{abs}_{\pi^-} R)\) is
\(\mathsf{forall}[\tau_1](\lambda{:}\tau_1.\, F_{\pi^-}(\operatorname{abs}^{k-1}_{\ell_1}(\operatorname{abs}_{\pi^-} R)))\),
because abstraction commutes with \(\mathsf{forall}\) and raises its index
under each of the \(k - 1\) λs, and types hold no local or bound variable;
\(\operatorname{abs}_{\pi^-} R\) has loose bound at most \(k - 1\), so
\(\operatorname{abs}^{k-1}_{\ell_1}\) maps \(\ell_1\) to \(\#(k - 1)\) and leaves
the rest. (3) Every local of \(P\) is replaced, and \(N\) adds none (Theorem
C-6(1)). (4) \(\operatorname{abs}_\pi A =_E \operatorname{abs}_\pi B\)
(Theorem C-6(2)), so the two closures \(F_\pi(\operatorname{abs}_\pi A)\),
\(F_\pi(\operatorname{abs}_\pi B)\) are \(=_E\). Peel both at
\(\ell_1, \dots, \ell_k\) (Lemma Q-2(3), \(u_i = \ell_i\)): equal canonical
forms of \(\mathsf{forall}[\tau](\lambda{:}\tau.\, Y)\) and
\(\mathsf{forall}[\tau](\lambda{:}\tau.\, Y')\) give \(N(Y) = N(Y')\) by (5),
and \(Y\{0 := \ell_i\} =_E Y'\{0 := \ell_i\}\) by Lemma C-9(1). So
\(A =_E B\), and both are canonical (Theorem C-6(3)). (5) \(\mathsf{forall}\)
and \(\mathsf{imp}\) are neither ACU instances nor bound to literal
operations, a constant applied to a λ is no β-redex, and \(N\) commutes with
λ (Definition C-3; the proof of Lemma Q-2(4)); then (2). (6) Induction on
\(P\): \(\rho\circ\pi\) lists \(\rho\ell_1, \dots, \rho\ell_k\), so both
abstractions replace corresponding locals by the same index, and \(\theta\)
commutes with abstraction because types hold no local or bound variable.
Renaming locals and type substitution respect \(=_E\) (Lemma C-9(1); the
soundness of inst for type variables), so
\(N(\theta(P[\rho])) =_E \theta(P[\rho])\), and Theorem C-6(2) gives the
closed forms; (5) assembles the closures in the same positions. \(\square\)
Definition Q-3 (closure, judgment, standard context). The closure of \(s\), \(\operatorname{cl}(s)\), is the row closure \(\operatorname{cl}_r(s)\) of Definition Q-2:
the quantifiers in binding order, outermost first, and the hypotheses in
the structural order of their closed forms, outermost first. The
canonical closure \(K(s)\) is that of Definition Q-3d; a Proven's
statement is \(K\) of its proof's sequent. The judgment of \(s\), \(J(s)\), is \(\vdash \operatorname{cl}(s)\) in the empty
context of \(T\), with sort hypotheses \(S\). The standard context of \(s\) is
with \(V\) in binding order and \(\Gamma\) in that order, a context of \(T\) (Definition D-1): its names occur once, its types are well formed, and each hypothesis mentions only locals declared before it.
\(\operatorname{cl}(s)\) is the closed form of a HOL theorem in the article reader's representation (Definition OT-5 on the OpenTheory page): quantifiers in binding order, hypotheses in closed-form order without repetitions.
Lemma Q-1 (abstraction respects \(=_E\)). For all terms \(a\), \(b\), every local \(\ell\), and all \(j, k \ge 0\):
Consequently, if \(t =_{E} u\), then \(\operatorname{abs}^j_\ell t =_E \operatorname{abs}^j_\ell u\), and \(N(\lambda{:}\tau_\ell.\, \operatorname{abs}^0_\ell t) = N(\lambda{:}\tau_\ell.\, \operatorname{abs}^0_\ell u)\). In particular \(N(\forall_\ell P)\) depends only on the \(=_E\)-class of \(P\). This holds for every canonical signature.
Proof. The identity is proved by induction on \(b\), generalizing \(k\), with Definitions S-8 to S-10. For \(\#i\) with \(i = k\), the left side is \(\operatorname{abs}^{j+k}_\ell({\uparrow^k_0} a)\) and the right side is \({\uparrow^k_0}(\operatorname{abs}^j_\ell a)\); these are equal by an induction on \(a\), generalizing the cutoff, that compares the two cases \(i \ge j\) and \(i < j\) of each bound variable of \(a\). For \(i > k\) both sides are \(\#i\) when \(i \ge j + k + 1\) and \(\#(i-1)\) otherwise. For \(i < k\) both are \(\#i\). The local \(\ell\) becomes \(\#(j+k)\) on both sides, other locals, constants and literals are fixed, and a binder raises \(k\) by one on both sides.
For the consequence, follow the proof of Lemma C-9(1). \(\operatorname{abs}^j_\ell\) commutes with every constructor and raises \(j\) under binders, so it maps a generator instance at a position inside \(m\) binders to an instance of the same equation at the same position:
- (A), (C), (U), (V): the equations are schematic. Their heads, units and types are untouched, and whether a spine is an ACU instance depends only on its head and \(\Sigma\).
- (L): literals contain no local.
- β and ζ: the identity with \(k = 0\) at depth \(j + m\).
Abstraction preserves types (Theorem T-4(3), at depth \(j\)), so the image of a chain of steps on well-typed terms is such a chain. The equation for \(N\) follows by Theorem C-6(2). \(\square\)
Lemma Q-2 (closures and their instances).
- Renaming. If \(\ell' \notin \operatorname{locs}(t)\) and \(\tau_{\ell'} = \tau_\ell\), then \(\operatorname{abs}^j_\ell t = \operatorname{abs}^j_{\ell'}(t[\ell := \ell'])\); hence \(\forall_\ell P = \forall_{\ell'} P[\ell := \ell']\).
- Inversion. If \(\ell \notin \operatorname{locs}(b)\) and \(\operatorname{lb}(b) \le j + 1\), then \(\operatorname{abs}^j_\ell(b\{j := \ell\}) = b\).
- Instantiation. Let \(B\) be bound-closed, \(\ell_1, \dots, \ell_k\) distinct locals, and \(u_1, \dots, u_k\) bound-closed terms with \(u_i : \tau_{\ell_i}\). Put \(X_0 = \forall_{\ell_1} \cdots \forall_{\ell_k} B\) and, for \(X_{i-1} = \mathsf{forall}[\tau](\lambda{:}\tau.\, Y)\), put \(X_i = Y\{0 := u_i\}\). Then \(X_k = B[\ell_1 := u_1, \dots, \ell_k := u_k]\), the simultaneous substitution. Since \((\forall\mathrm E)\) concludes \(\mathrm{app}(\lambda{:}\tau.\,Y, u) =_\beta Y\{0 := u\}\), \(k\) steps of \((\forall\mathrm E)\) from \(\vdash N(X_0)\) conclude \(B[\ell_1 := u_1, \dots, \ell_k := u_k]\) up to \(=_E\).
-
Peeling. Let \(X\) be a closed term, canonical for \(\Sigma\). To peel \(X\) at locals \(\ell_1, \dots, \ell_k\), in any order \(\pi\), and a count \(n\):
- for \(i = 1, \dots, k\), require \(X = \mathsf{forall}[\tau_{\ell_i}](\lambda{:}\tau_{\ell_i}.\, Y)\) and set \(X := N(Y\{0 := \ell_i\})\);
- then \(n\) times, require \(X = B \to X'\), record \(B\), and set \(X := X'\).
For a sequent \(s\) with free locals listed by \(\pi\) and \(n\) hypotheses, and any order \(\sigma\) of them, \(X = \operatorname{cl}_{\pi,\sigma}(s)\) exactly when the peel succeeds, records the hypotheses of \(s\) in the order \(\sigma\), and ends with the conclusion of \(s\).
Proof. (1) and (2) are inductions on \(t\) and \(b\) that raise \(j\) under binders. In (2), a bound variable \(\#i\) of \(b\) has \(i \le j\); \(\#j\) becomes \(\ell\) and then \(\#j\) again, and \(\ell\) does not occur in \(b\) otherwise.
(3) By (1), choose fresh locals \(\ell'_i\) of the same types that occur in neither \(B\) nor any \(u_j\), and write \(B' = B[\ell_1 := \ell'_1, \dots]\). Then \(X_0 = \forall_{\ell'_1} \cdots \forall_{\ell'_k} B'\). For distinct locals \(\ell'\) and \(\ell''\) with \(\ell' \notin \operatorname{locs}(u)\) and \(u\) bound-closed, \((\operatorname{abs}^j_{\ell'} t)[\ell'' := u] = \operatorname{abs}^j_{\ell'}(t[\ell'' := u])\), by an immediate induction. With Lemma S-4, induction on \(i\) gives \(X_i = \forall_{\ell'_{i+1}} \cdots \forall_{\ell'_k} B'[\ell'_1 := u_1] \cdots [\ell'_i := u_i]\). No \(u_j\) contains an \(\ell'_i\), so the sequential substitution \(X_k\) is the simultaneous one.
(4) Let \(X = \operatorname{cl}_{\pi,\sigma}(s)\) and write \(R\) for the raw closure inside \(N\). The constants \(\mathsf{forall}\) and \(\mathsf{imp}\) are neither ACU instances nor bound to literal operations, and an application of a constant to a λ is no β-redex. So \(N\) acts below them: \(N(\mathsf{forall}[\tau](\lambda{:}\tau.\, P)) = \mathsf{forall}[\tau](\lambda{:}\tau.\, N(P))\), and \(N(A \to P) = A \to N(P)\) for canonical \(A\). Hence \(X\) has the required outer form. Its body is \(Y = N(\operatorname{abs}^0_{\ell_1} P_1)\), where \(P_1\) is the rest of the raw closure. By Lemma C-9(1) and Lemma S-4, \(N(Y\{0 := \ell_1\}) = N(P_1[\ell_1 := \ell_1]) = N(P_1)\). Induction on the layers then yields the hypotheses in order and \(\varphi\).
Conversely, let the peel succeed. Write \(X_{i-1}\) for the term before layer \(i\), with body \(Y\). \(X_0\) is closed, so \(\ell_i\) does not occur in \(Y\), and \(\operatorname{lb}(Y) \le 1\). By (2), \(\operatorname{abs}^0_{\ell_i}(Y\{0 := \ell_i\}) = Y\). By Lemma Q-1 and \(X_i =_E Y\{0 := \ell_i\}\), \(N(\lambda{:}\tau_{\ell_i}.\, \operatorname{abs}^0_{\ell_i} X_i) = N(\lambda{:}\tau_{\ell_i}.\, Y) = \lambda{:}\tau_{\ell_i}.\, Y\). The last step holds because a subterm of a canonical term is canonical: β-normality and A-canonicity hold at every node (Definition C-3, Theorem C-6(3)). So \(X_{i-1} = N(\forall_{\ell_i} X_i)\). Together with the implication layers, induction gives \(X = N(\forall_{\ell_1} \cdots \forall_{\ell_k}.\, B_1 \to \dots \to B_n \to \varphi)\), which is \(\operatorname{cl}_{\pi,\sigma}(s)\) when the \(B_i\) are the hypotheses of \(s\) in the order \(\sigma\). A chain \(B_1 \to \dots \to B_n \to \varphi\) determines the \(B_i\) when \(n\) and \(\varphi\) are fixed, so no other list of hypotheses gives the same \(X\). \(\square\)
Proposition Q-3 (the closure is well defined). For every sequent \(s\) of \(T\):
- \(\operatorname{cl}(s)\) is a closed proposition of \(T\), canonical for \(\Sigma\), and it depends only on the content of \(s\): not on ids, not on the order of stored lists, and not on the order of commits;
- \(\operatorname{TV}(\operatorname{cl}(s)) = \operatorname{TV}(s)\), so \(J(s)\) has the sorted type variables \(\operatorname{tv}(s)\) of Definition Y-13;
- \(\operatorname{home}_\Sigma(\operatorname{cl}(s))\) is the join of the root theory, of \(\operatorname{home}_\Sigma(A)\) for every part \(A\), and of \(\operatorname{home}(\tau_\ell)\) for every \(\ell \in V\);
- the kernel's constructors compute \(\operatorname{cl}(s)\) from the
inside out:
impfor each hypothesis, thenabstractandforallfor each local, each returning \(N\) of what it builds (Theorem C-7); Proposition Q-3c lists where it computes \(\operatorname{cl}_r\), acceptance and \(K\).
Unlike \(\operatorname{cl}(s)\), \(K(s)\) does not depend on how the locals of \(V\) are bound or named, nor on the names of its type variables (Theorem Q-3a).
Proof. (1) Every local of a part is in \(V\) and is abstracted, so the closure is closed. It has type \(\mathsf{Prop}\) by Theorem T-4(3), since \(\mathsf{imp}: \mathsf{Prop} \to \mathsf{Prop} \to \mathsf{Prop}\) and \(\mathsf{forall}[\tau]: (\tau \to \mathsf{Prop}) \to \mathsf{Prop}\). It is canonical by definition. \(\pi_b\) is a strict total order of \(V\), because the locals of \(V\) lie on one chain at distinct depths; the closed forms contain no local and are distinct (Lemma Q-2b), and the structural order is total on distinct nodes. The order of closed forms depends only on content, except for its last tie-break, the head indices, which separates only same-named declarations of sibling theories (Requirement O). Every part of \(s\) mentions only declarations of \(T\), and a theory declares a name once (Definition T-1), so the tie-break never decides between two closed forms of \(s\). \(N\) is a function (Theorem C-6(3)).
(2) and (3) Abstraction keeps a β-normal term β-normal: it changes a head only when a local head becomes a bound variable. It creates no unit and no literal, since locals are neither, and it changes no spine's head or argument count. So \(N\) applied to an abstracted canonical term only sorts ACU arguments again. The closure therefore holds the same constants, type constructors, literal kinds, annotations and ACU spines of three or more arguments as the parts, and adds \(\mathsf{forall}\), \(\mathsf{imp}\) (root theory) and the binder types \(\tau_\ell\). A part's home already includes the homes of its locals' types (K1.6); the binder types add those of the locals of \(V\) that occur in no part.
(4) By Theorem C-7 and Theorem C-6(2) for \(\mathsf{imp}\), and by Lemma Q-1 for each abstraction: \(N\) of a term assembled from \(N\) of its pieces is \(N\) of the term assembled from the pieces. \(\square\)
Lemma Q-4 (opening and closing). Let \(s\) be a sequent of \(T\) with \(V\) listed as \(\ell_1, \dots, \ell_k\) and \(\Gamma\) as \(A_1, \dots, A_n\), in any orders \(\pi\) and \(\sigma\). In this lemma \(\operatorname{cl}(s)\) stands for \(\operatorname{cl}_{\pi,\sigma}(s)\), and \(\operatorname{ctx}(s)\) lists \(V\) and \(\Gamma\) in those orders.
- Closing. If \(\operatorname{ctx}(s) \vdash \varphi\) is derivable in \(T\), so is \(\vdash \operatorname{cl}(s)\). Apply \((\to\mathrm I)\) to \(h_n, \dots, h_1\) and then \((\forall\mathrm I)\) to \(\ell_k, \dots, \ell_1\). Each entry is the last of its context when its rule applies.
- Opening. Let \(\vdash \operatorname{cl}(s)\) be derivable in \(T\). Let \(\Delta\) be a context of \(T\), and \(\mu\) a map from \(V\) to bound-closed terms of \(\Delta\) with \(\mu(\ell) : \tau_\ell\). Let each \(A \in \Gamma\) have a derivation of \(\Delta \vdash A[\mu]\), where \(t[\mu] = N(t[\ell_1 := \mu(\ell_1), \dots, \ell_k := \mu(\ell_k)])\). Then \(\Delta \vdash \varphi[\mu]\) is derivable: weaken to \(\Delta\) (Theorem D-3), apply \((\forall\mathrm E)\) with \(\mu(\ell_1), \dots, \mu(\ell_k)\), then \((\to\mathrm E)\) with the derivations of \(A_1[\mu], \dots, A_n[\mu]\).
- \(J(s)\) is derivable exactly when \(\operatorname{ctx}(s) \vdash \varphi\) is.
- Regrouping. Let \(\ell'_1, \dots, \ell'_m\) list, once each, a set \(V' \supseteq V\) of locals whose types are well formed in \(T\). Let \(B_1, \dots, B_p\) be a sequence whose elements are exactly those of \(\Gamma\), each at least once. Then \(\vdash \operatorname{cl}(s)\) gives \(\vdash N(\forall_{\ell'_1} \cdots \forall_{\ell'_m}.\, B_1 \to \dots \to B_p \to \varphi)\), and conversely when \(V' = V\).
These derivations use no declaration, introduce only the terms \(\mu(\ell)\) and the locals of \(V'\), and mention only the parts of \(s\), their instances under \(\mu\), \(\mathsf{imp}\) and \(\mathsf{forall}\).
Proof. (1) The conclusions of \((\to\mathrm I)\) and \((\forall\mathrm I)\) are built up to \(=_E\), and the canonical form of the result is \(\operatorname{cl}(s)\) by Proposition Q-3(4). (2) By Lemma Q-2(3), the \(k\) steps conclude, up to \(=_E\), \((A_1 \to \dots \to \varphi)[\ell_1 := \mu(\ell_1), \dots]\), which is \(A_1[\mu] \to \dots \to \varphi[\mu]\) up to \(=_E\) (Lemma C-9(1)). The terms are well typed by Theorem T-4(2). Each \((\to\mathrm E)\) then matches its antecedent up to \(=_E\). (3) is (1) and (2) with \(\Delta = \operatorname{ctx}(s)\), \(\mu\) the identity, and (Hyp). (4) Open in the context \(\ell'_1{:}\tau_{\ell'_1}, \dots, \ell'_m{:}\tau_{\ell'_m}, h'_1{:}B_1, \dots, h'_p{:}B_p\). Two of its hypotheses may have one proposition, which Definition D-1 allows. Then close in the new order. For the converse, open the regrouped closure in \(\operatorname{ctx}(s)\) and close by (1). \(\square\)
Theorem Q-5 (closures across signatures). Let \(s\) be a sequent of \(T\), and \(T'\) a theory with \(\Sigma \subseteq \Sigma' = \Sigma(T')\) in which every type \(\tau_\ell\) and every part of \(s\) is well typed. Let \(s'\) be \(s\) read in \(T'\): hypotheses \(\{N_{\Sigma'}(A) \mid A \in \Gamma\}\), conclusion \(N_{\Sigma'}(\varphi)\), free locals \(V\). Then:
- \(N_{\Sigma'}(\operatorname{cl}(s)) = N_{\Sigma'}\big(\forall_{\ell_1} \cdots \forall_{\ell_k}.\; N_{\Sigma'}(A_1) \to \dots \to N_{\Sigma'}(A_n) \to N_{\Sigma'}(\varphi)\big)\), with \(\pi = \pi_b\) and the \(A_i\) in the closed-form order of \(s\);
- this equals \(\operatorname{cl}(s')\) exactly when \(A \mapsto N_{\Sigma'}(A)\) is injective on \(\Gamma\) and keeps the structural order of the closed forms;
- in every case, \(\vdash N_{\Sigma'}(\operatorname{cl}(s))\) and \(\vdash \operatorname{cl}(s')\) are interderivable in \(T'\).
Proof. (1) By Lemma C-9(4), \(N_{\Sigma'}(N_\Sigma(R)) = N_{\Sigma'}(R)\) for the raw closure \(R\). Each part \(A\) is \(=_{E_{\Sigma'}}\) to \(N_{\Sigma'}(A)\) (Theorem C-6(1) in \(\Sigma'\)). Replace the parts from the inside out, using congruence for \(\mathsf{imp}\) and Lemma Q-1 in \(\Sigma'\) for each abstraction, and apply Theorem C-6(2). (2) The right side of (1) peels to the list \(N_{\Sigma'}(A_1), \dots, N_{\Sigma'}(A_n)\) (Lemma Q-2(4) in \(\Sigma'\)), and \(\operatorname{cl}(s')\) peels to the lifted set in its own structural order without repetitions. The two lists are equal exactly under the stated condition. (3) Lemma Q-4(4) in \(T'\). \(\square\)
The canonical closure¶
A Proven's statement is the canonical closure \(K(s)\) of its proof's
sequent: a closure in orders of \(V\) and \(\Gamma\) that the sequent itself
determines, under a renaming of its type variables. It depends neither on
how the locals of \(V\) are bound or named nor on the names of its type
variables (Theorem Q-3a).
Lemma Q-2c (what renaming changes). Let \(P\) be canonical, \(\rho\) an injective, type-respecting map of \(\operatorname{locs}(P)\) to locals as in Lemma Q-2b(6), and \(\theta\) a sort-preserving bijection of type variables. Then \(N(\theta(P[\rho]))\) and \(\theta(P[\rho])\) differ only in the order of the term arguments of ACU spines.
Proof. Renaming a local by a local, or a type variable by a type variable, creates no β-redex and changes no head, unit, literal or argument count. A-normalization (Definition C-3) applies \(\kappa_c\) and \(\mathrm{mk}_c\) to the renamed multisets of atoms. No two distinct atoms become equal, since both maps are injective, and no atom becomes a unit or a literal, so only the sort of \(\mathrm{mk}_c\) acts. \(\square\)
So the shape of a sequent, with each ACU spine's term arguments read as a multiset and type variables read without their names, is the same for every renaming. Refinement reads exactly that shape.
Definition Q-3d (the canonical closure). Let \(m\) be the number of type variables of \(s\), and \(\circledast = 2^{32}\) and \(\vartheta = 2^{32} + 1\) two edge labels.
- The statement graph \(G(s)\). Its vertices are the nodes of \(\varphi\) and of every \(A \in \Gamma\) with all their descendants, type nodes included; the local atom of every \(\ell \in V\), also when it occurs in no part; and the type node \(\tau_\ell\) of every \(\ell \in V\) with its descendants. Each node is one vertex. An edge goes from a node to its child at position \(i\), labelled \(i\), except that the term arguments of an ACU spine with two or more term arguments (C1.1) carry the label \(\circledast\); a partial application with one term argument is an ordinary application. An edge labelled \(\vartheta\) goes from a local atom to its type node.
- Marks and labels. The mark \(m(v)\) has bit 0 when \(v\) is \(\varphi\)'s node and bit 1 when \(v\) is a hypothesis's node. The label is \(L(v) = (m(v), \kappa(v), b(v))\): \(\kappa = 0\) and \(b\) empty for a local atom of \(V\); \(\kappa = 1\) and \(b = (\text{argument count})\) for a type variable; \(\kappa = 2\) and \(b = (\text{head key}, \text{head name}, \text{payload}, \text{argument count})\) for any other node, with the payload \((0, \text{value})\) when immediate, \((1, \text{bytes})\) when pooled, and \((2)\) under a head without one. No label reads a type variable's name, a local's name, depth or row, or a structural hash; a local's type enters through its \(\vartheta\) edge. Tuples and lists compare lexicographically, a proper prefix first; integers unsigned; byte strings by unsigned bytes, a proper prefix first; a multiset is the ascending list of its elements.
- Refinement. The initial colour \(c_0(v)\) is the dense rank of \(L(v)\): the number of distinct labels below it. A round gives \(v\) the dense rank of \((c(v), D(v), M(v), U(v))\), where \(D(v)\) lists \((\text{label}, c(w))\) over \(v\)'s out-edges other than \(\circledast\) in position order, the \(\vartheta\) edge last; \(M(v)\) is the multiset of \(c(w)\) over its \(\circledast\) edges; and \(U(v)\) the multiset of \((c(u), \text{label})\) over its in-edges \(u \to v\). Since \(c(v)\) leads, cells only split and keep their order. Rounds stop when a round makes no new colour; the result is stable. Individualizing \(x\) in its cell \(C\) gives \(v\) the dense rank of \((c(v), 1)\) for \(v \in C \setminus \{x\}\) and of \((c(v), 0)\) otherwise, then refines to stability.
- The search. A node of the search is a stable colouring. Its target cell is the non-singleton cell of local atoms with the least colour; when there is none, the non-singleton cell of hypothesis nodes with the least colour; when \(m > 6\) and there is none, the non-singleton cell of type-variable vertices with the least colour. Without one the node is a leaf \(\lambda = (\pi, \sigma)\): \(\pi\) lists the locals and \(\sigma\) the hypotheses by colour, least first, and for \(m > 6\), \(\nu\) lists the type variables by colour. At a target cell the search individualizes each member in turn, refines and searches the result, depth first: a member's subtree is searched completely before the next member is considered. Members are visited in the structural order of their nodes; the locals of \(s\) lie on one chain at distinct depths and its hypotheses are distinct nodes, so this order reads no row id.
- Twins. Two locals \(\ell, \ell'\) of a target cell are twins when \(\tau_\ell = \tau_{\ell'}\) and the transposition \((\ell\ \ell')\) maps \(s\) to itself: \(N(\varphi[(\ell\ \ell')]) = \varphi\) and \(\{N(A[(\ell\ \ell')]) \mid A \in \Gamma\} = \Gamma\). Twinship is an equivalence, since \((a\ c) = (a\ b)(b\ c)(a\ b)\). Only the first member of a twin class, its representative, is searched. Cells of hypotheses or type variables have no twins.
- Automorphism pruning. When a leaf's candidate equals the candidate of earlier leaves, the map that sends an earlier leaf's \(i\)-th local and \(j\)-th hypothesis to this leaf's is recorded, once for every earlier leaf with that candidate. For \(m > 6\) it is extended to the type-variable vertices by \(\theta_2^{-1} \circ \theta_1\), where \(\theta_i\) is leaf \(i\)'s whole renaming of type variables (item 7). At a node, a member \(y\) of the target cell is skipped when an automorphism generated by the recorded maps that fix every vertex the node individualized maps onto \(y\) a member the node has searched. Members skipped as twins or by orbit do not count as searched.
- Candidates. For \(m \le 6\) the candidate of a leaf is \(X_\lambda = I_5(\operatorname{cl}_{\pi,\sigma}(s))\), with \(I_5\) the statement key of Definition I-5: the least renaming of the type variables onto \(?0, \dots, ?(m - 1)\) in the structural order for \(1 \le m \le 6\), the identity for \(m = 0\). For \(m > 6\) it is \(X_\lambda = I_5(N(\theta_\nu(\operatorname{cl}_{\pi,\sigma}(s))))\), where \(\theta_\nu\) renames the type variables onto \(?0, \dots, ?(m - 1)\) in the colour order \(\nu\), and \(I_5\) is then the first-occurrence renaming.
- The canonical closure. \(K(s)\) is the least candidate in the structural order over the leaves of the search without automorphism pruning; pruning changes the set of visited leaves, not this minimum (Lemma Q-2g). \(\lambda^* = (\pi^*, \sigma^*)\) is the first visited leaf whose candidate is \(K(s)\), and \(\theta^*\) the renaming that gives that candidate: for \(m \le 6\) the one \(I_5\) used, the first permutation in lexicographic order of first-occurrence indices when several give the key; for \(m > 6\), \(\theta_\nu\) followed by the first-occurrence renaming.
\(K(s)\) is not the least closure over all orders of \(V\) and \(\Gamma\): refinement excludes orders. \(P(g(x_0, y_0) + g(x_1, y_1))\) has an order outside the leaves whose closure is smaller. An independent implementation follows items 1 to 8 exactly; a search over all orders computes another function.
Lemma Q-2d (twin pruning is exact). If \(\ell, \ell'\) are twins in the target cell of a node, the leaves under \(\ell'\) are \((\sigma_t \circ \pi, \sigma_t(\sigma))\) for the leaves \((\pi, \sigma)\) under \(\ell\), with \(\sigma_t = (\ell\ \ell')\), and they have the same candidates.
Proof. Map each vertex of \(G(s)\) to the vertex of \(G(s')\) it becomes under a pair \((\rho, \theta)\) of Lemma Q-2b(6): a local atom to \(\rho\)'s, a node \(P\) to \(N(\theta(P[\rho]))\). By Lemma Q-2c this is a bijection that keeps labels, marks and edge labels, \(\circledast\) edges read as multisets. Colours are computed from these alone, so the stable colouring of \(s'\) is that of \(s\) transported, ranks included, and so is every individualization (equivariance). \(\sigma_t\) keeps types, so it is such a pair with \(\theta\) the identity and \(s' = s\). It fixes every individualized vertex, which are singletons outside the cell, and maps the cell to itself, so it maps the node's colouring to itself, the colouring after individualizing \(\ell\) to the one after \(\ell'\), and so on down. Lemma Q-2b(6) gives equal closures, hence equal candidates. \(\square\)
Lemma Q-2g (automorphism pruning is exact). For every \(m\):
- if two leaves \(\lambda_1\), \(\lambda_2\) have one candidate, the map \(\gamma\) with \(\gamma(\pi_1(i)) = \pi_2(i)\) and \(\gamma(\sigma_1(j)) = \sigma_2(j)\), with the sort-preserving \(\theta = \theta_2^{-1} \circ \theta_1\) on the type variables, is a renaming of \(s\) onto itself in the sense of Lemma Q-2b(6);
- if such a \((\gamma, \theta)\) fixes every vertex a node individualized and maps a member \(y'\) of its target cell to \(y\), the leaves under \(y\) are the images of those under \(y'\), with the same candidates; so do compositions of such maps.
Proof. (1) The candidates are \(N(\theta_i(\operatorname{cl}_{\pi_i,\sigma_i}(s)))\) with \(\theta_i\) the leaf's whole renaming. Peeling the common term at \(k\) binders and \(n\) antecedents (Lemma Q-2(4)), as in the converse of Theorem Q-3a with \(s' = s\), makes the parts correspond under \(\gamma\) and \(\theta_2^{-1} \circ \theta_1\). (2) As Lemma Q-2d, by equivariance under \((\gamma, \theta)\): labels never read a type variable's name, so the colouring, type-variable vertices included, is transported. The image of a leaf's closure is its \(\theta\)-image. For \(m \le 6\), \(I_5\) gives it the same candidate, because \(I_5\) minimizes over every renaming. For \(m > 6\), the image leaf's colour order is \(\nu\) transported, so its renaming \(\theta_\nu \circ \theta^{-1}\) takes the \(\theta\)-image to the same term \(N(\theta_\nu(\operatorname{cl}))\), and \(I_5\) then gives the same candidate. \(\square\)
Without the type-variable search, the first-occurrence renaming is not invariant under \(\theta\), because \(N\) sorts ACU spines by names that \(\theta\) changes: \(t = \forall{:}\mathsf{Nat}.\,\forall{:}\mathsf{Nat}.\, S(\mathrm{sum}(G[b](\#0), G[a](\#1)))\) and \(\theta = (a\ b)\) give first-occurrence renamings of \(t\) and \(\theta t\) that differ. That is why the search individualizes type variables for \(m > 6\).
Lemma Q-2e (when there is one leaf). Suppose no \(\circledast\) edge lies on a path from a part's node to a local atom, and \(n \le 1\). Then two locals that occur in a part never share a stable colour. Locals that occur in no part share a colour only with such locals, and those of one type are twins. So the search has one leaf when, besides, no two locals that occur in no part have different types and one colour. It has one leaf when \(k \le 1\) and \(n \le 1\) and, for \(m > 6\), refinement leaves every type variable in its own cell.
Proof. The marks single out the roots (\(n \le 1\)). Let two local atoms \(x\), \(y\) that occur in parts share a stable colour, and take a root path \(p_0 \to \cdots \to p_j = x\) with edge labels \(i_1, \dots, i_j\), none \(\circledast\). Stability gives \(y\) an in-edge \((q_{j-1}, i_j)\) with \(q_{j-1}\) coloured as \(p_{j-1}\), and so on up to \(q_0\) coloured as \(p_0\), a root, hence \(q_0 = p_0\). Going down, \(q_1\) is child \(i_1\) of \(p_0\), which is \(p_1\), and so on: \(y = x\). A local in no part has only its \(\vartheta\) edge, so its colour differs from every local in a part; two such locals of one type are swapped by a transposition that fixes \(s\). \(\square\)
Theorem Q-3a (canonicity). Let \(s\), \(s'\) be sequent rows of one theory and \((\rho, \theta)\) as in Lemma Q-2b(6), with \(\theta\) any sort-preserving bijection of type variables, \(s' = (\rho, \theta)(s)\). Then \(K(s') = K(s)\). Conversely, if \(K(s) = K(s')\) and \(s\), \(s'\) have equal \(k\) and equal \(n\), then \(s'\) is such a renaming of \(s\).
Proof. By equivariance (Lemma Q-2d), target cells, twin classes and individualizations correspond, so the leaves of \(s'\) are \((\rho \circ \pi, \sigma')\) for the leaves \((\pi, \sigma)\) of \(s\); where the two searches pick different representatives of a twin class, Lemma Q-2d gives the same candidates. By Lemma Q-2b(6) their closures are \(N(\theta(\operatorname{cl}_{\pi,\sigma}(s)))\). For \(m \le 6\), \(I_5\) takes the least over every bijection onto \(?0, \dots, ?(m - 1)\), and renaming by \(\theta\) first permutes that set, so the candidates are equal; for \(m > 6\) the type-variable vertices correspond too, the leaf's colour-order renaming absorbs \(\theta\), and the candidates are equal as in Lemma Q-2g(2). Both minima range over one set. Conversely, \(K(s) = N(\theta_1(\operatorname{cl}_{\pi,\sigma}(s))) = \operatorname{cl}_{\pi,\sigma}(N(\theta_1 s))\) for the minimizing leaf and renaming \(\theta_1\) (Lemma Q-2b(6) with \(\rho\) the identity), and likewise for \(s'\). Peel the common term at \(k\) binders and \(n\) antecedents (Lemma Q-2(4)): the parts of \(\theta_1 s\) and \(\theta_1' s'\) correspond under \(\pi' \circ \pi^{-1}\), so \(s'\) is the renaming of \(s\) by \((\pi' \circ \pi^{-1}, \theta_1'^{-1} \circ \theta_1)\). \(\square\)
Without "equal \(k\) and \(n\)" the converse fails: \((\{x\}; \emptyset \vdash A\,x \to B\,x)\) and \((\{x\}; \{A\,x\} \vdash B\,x)\) have one closure.
Theorem Q-3e (Definition I-5).
- For \(1 \le m \le 6\), \(I_5(K(s)) = K(s)\): a
Provendeclared with \(K(s)\), its type parameters those of \(K(s)\) in first-occurrence order, is in key form. - For every \(m\), \(K\) is idempotent: for the sequent \(o\) that opens \(K(s)\) at \(k\) binders and \(n\) antecedents, \(K(o) = K(s)\).
Proof. (1) \(K(s) = I_5(c)\) for a closure \(c\). For any \(t\) with \(m\) type variables, \(I_5(I_5(t)) = \min_{\theta'} N(\theta'(N(\theta_0 t))) = \min_{\theta'} N(\theta'\theta_0 t)\), because type substitution respects \(=_E\) and canonical forms are unique (Theorem C-6(2)); and \(\theta' \circ \theta_0\) ranges over every bijection from \(t\)'s type variables onto \(?0, \dots, ?(m - 1)\) as \(\theta'\) does. So \(I_5\) is idempotent. (2) \(o\) is a renaming of \(s\) by Lemma Q-2(4) and the proof of Theorem Q-3a, with equal \(k\) and \(n\); Theorem Q-3a gives \(K(o) = K(s)\). \(\square\)
For \(m > 6\), \(I_5\) renames by first occurrence, and the first-occurrence renaming of a spine already renamed so can re-sort it, so (1) fails in general: \(I_5(K(s)) \ne K(s)\). The library keys only one to six type parameters and writes a statement with more as declared, so nothing relies on (1) there. (2) holds for every \(m\).
Theorem Q-3b (soundness). \(K(s) = \operatorname{cl}_{\pi^*,\sigma^*}(N(\theta^* s))\), a closure of a type renaming of \(s\) in strict total orders of \(V\) and \(\Gamma\). For any two orders, \(\vdash \operatorname{cl}_{\pi,\sigma}(s)\) and \(\vdash \operatorname{cl}_{\pi',\sigma'}(s)\) are derivable from each other in \(T\), with no declaration and no other terms than the parts of \(s\), \(\mathsf{imp}\) and \(\mathsf{forall}\) (Lemma Q-4(4) with \(V' = V\)), and \(\vdash N(\theta c)\) follows from \(\vdash c\) by type instantiation. So \(\operatorname{cl}_r(s)\), every accepted statement and \(K(s)\) are derivable from each other.
Proof. As stated: the proofs of Lemma Q-2(4), Proposition Q-3 and Lemma Q-4 use only that the orders are strict total orders of \(V\) and \(\Gamma\) determined by \(s\), and that \(\operatorname{ctx}(s)\) lists every local before every hypothesis, so the admissibility theorems and Theorem LC-12 hold with their proofs. \(\square\)
Determinism. \(K(s)\) is a function of the sequent's content and not of its type variables' names. \(\lambda^*\) and the order of the work are functions of the sequent's content, names included: the visiting order is the structural order's, which reads no row id within one sequent. Neither is invariant under renaming: the structural order reads hashes and so names, and the visiting order decides which automorphisms are found first. The work is bounded by \(W(s)\) (Proposition Q-3c), a function of the statement's shape alone, so an allowance of at least \(W(s)\) completes in every naming (CG2), unless the search meets one of the implementation's bounds on its stack and on its recorded automorphisms (Proposition Q-3c), which refuse without deciding.
Well-definedness with ACU. Each candidate is \(I_5\) of \(N\) of a raw closure, a canonical term (Theorem C-6), and \(K(s)\) is the least of finitely many. The ACU order inside a closure is computed after abstraction, on terms without locals; refinement reads ACU arguments as multisets and never reads that order. Nothing is defined as a fixed point.
Proposition Q-3c (the kernel's computation). The kernel computes:
| Site | Computes |
|---|---|
a Proven declaration (the theory pass) |
\(\mathit{stmt} = K(s)\) for the cited proof's own sequent, else MISMATCH |
a use row |
acceptance: \(\mathit{stmt}\) peels at \(k\) binders of the types of \(\pi_b\) and \(n\) antecedents, whose set is \(\{c_{\pi_b}(A)\}\), and then \(c_{\pi_b}(\varphi)\); else MISMATCH |
| a sequent premise of a natural-deduction row | \(\operatorname{cl}_r(s)\) |
use and premises need no search. Each computation may meet an unchecked
row, so it refuses malformed input itself: locals of \(V\) off one chain, or
two at one depth (SCOPE); two hypotheses with one closed form
(MISMATCH, Lemma Q-2b(4)); and what the engine raises (ILL_TYPED,
LIMIT). Closed forms are taken under the signature of the site, so two
hypotheses distinct and canonical under an earlier signature that a later
ACU declaration normalizes to one closed form are refused MISMATCH there:
a producer rebuilds such a proof under the later signature. A twin test only swaps locals of one type, so it raises no
ILL_TYPED.
Every step is charged one unit as the engine charges, and an exhausted
allowance refuses with LIMIT (CG2). With \(L\) the leaves visited, the work
is at most: \(|G|\) rounds of refinement, each \(O((|G| + |E|)\log(|G| + |E|))\),
at each of at most \((k + n + m)\,L + 1\) search nodes; \(|C|^2\) twin tests per
target cell of locals, each \(O(|s|)\) engine steps; one union per recorded
automorphism and cell member for the orbit tests; and at each leaf one
closure, \(O((k + n)\,|s|)\) engine steps with its normalization, then \(I_5\)
with up to \(720\) renamings for \(m \le 6\), or one colour-order and one
first-occurrence renaming for \(m > 6\), and structural comparisons. \(W(s)\)
is this sum with \(L = k!\,n!\) (times \(m!\) for \(m > 6\)) and the engine's
bound for each normalization; it depends on \(k\), \(n\), \(m\), \(|G|\), \(|E|\) and
\(|s|\) alone. Pruning does not lower \(W(s)\): a cell that refinement cannot
split and whose members no automorphism relates still costs up to
\(k!\,n!\) leaves, and such a statement is refused with LIMIT when its
charge exceeds the caller's allowance. By Lemma Q-2e no search is needed
for \(k \le 1\) and \(n \le 1\), nor without hypothesis sets of two or more, ACU
spines over locals, or unused locals of different types.
The kernel's search (checker_closure.mojo) runs on an explicit stack
(G2), one level per individualized vertex, so its depth is at most
\(k + n\), plus \(m\) when \(m > 6\). Its charges count the graph's
vertices, edges and label words; each comparison of a dense ranking and
each move of a multiset sort; each member of a cell scan; each union-find
step of the orbit tests; each pair of a recorded automorphism; and the
engine's own charges for the closures, substitutions and statement keys it
builds. Two bounds of the implementation lie outside \(W(s)\): a search
that would hold more than \(2^{12}\) levels on its stack is refused with
LIMIT, which needs \(k + n + m \ge 2^{12}\), and one whose recorded
automorphisms would hold more than \(2^{24}\) vertex words is refused with
CAPACITY. Both refusals are undecided, never a rejection
(KC1.5). Which automorphisms are
recorded depends on the visiting order, so whether the second bound is met
can depend on names.
Rule L1 in the construction engine. Acceptance fixes a use row's
quantifier order to the sequent's binding order, while a provider is
matched to a sequent by \(K\); the construction engine joins the two. A
statement \(t\) has the shape \((k, n)\) when it peels at \(k\) leading binders
into \(n\) distinct antecedents: \((j, 0)\) for \(j\) up to its number of leading
\(\forall\), and \((k_0, j)\) for \(j\) up to the number of implications after all
\(k_0\) of them. For a shape, \(o_{k,n}(t)\) is the sequent that opens \(t\) at
fresh locals \(u_1, \dots, u_k\), fixed in binder order (\(u_1\) over a given
frame, each next one over the previous one's frame), and \(n\) antecedents.
The engine's index has one entry per provider \(d\) and shape \((k, n)\) of its
statement, the key \((K(o_{k,n}(t)), k, n)\), with the minimizing leaf
\(\lambda_o\) and renaming \(\theta_o\) beside it; the first provider of a key
wins. A sequent \(q\) with \(k\) locals and \(n\) hypotheses is looked up by
\((K(q), k, n)\). The index and its lookups write nothing to the bank: an
entry is computed lazily, on the first lookup of its shape, with \(o\) opened
in the engine's scratch at locals that only its view answers, and it is
filed under the structural hash of \(K(o)\); a lookup computes \(K(q)\) in the
scratch and recomputes \(K(o)\) for each provider filed under \(K(q)\)'s hash,
in declaration order, so that a hash collision costs work but never a wrong
provider. The bank, and a library written from it, therefore do not depend
on which shapes were looked up. Each \(K\) is charged to the call that
computes it, and the entries are logged with the engine's other caches, so
a truncation of the engine undoes them; after a commit they are computed
again on the next lookup of their shape. axiom declares \(K(q)\) and
deduplicates by the key: an earlier axiom with the key \((K(q), k, n)\) is
returned. When the provider's statement accepts \(q\), the row is
use d on \(q\). Otherwise the engine fixes \(u_1, \dots, u_k\) under the
reserved names \(\cdot\mathrm{open}\cdot 1, \dots, \cdot\mathrm{open}\cdot k\)
over its top frame, on whose chain the locals of \(q\) lie, builds use d on
\(o = o_{k,n}(t)\), and on it an inst row with the type map
\(\theta = \theta_q^{-1} \circ \theta_o\) and the local map
\(\rho(u_{\pi_o(i)}) = \ell_{\pi_q(i)}\). Both rows lie at \(u_k\)'s frame. A
second resolution with the same statement over the same top finds the same
binding sites, and so shares the locals and the use row.
Proposition Q-3f (the row is accepted and concludes \(q\)). Let \(q\) have \(k\) locals and \(n\) hypotheses, and \((K(q), k, n)\) be the key of \(t\)'s entry. Then:
use don \(o\) is accepted: \(N(t) = \operatorname{cl}_{\pi_b(o),\sigma}(o)\), with \(\pi_b(o) = (u_1, \dots, u_k)\) and \(\sigma\) the order of \(t\)'s antecedents;- \(q = N(\theta(o[\rho]))\): \(\Gamma_q = \{N(\theta(B[\rho])) \mid B \in \Gamma_o\}\) and \(\varphi_q = N(\theta(\varphi_o[\rho]))\);
- the
instrow passes its checks and concludes \(q\).
Proof. (1) \(o\) opens \(t\) in binder order, so closing it in that order
gives \(N(t)\) back (Lemma Q-2(4), Lemma Q-2b(5)). (2) By Lemma Q-2b(6) with
the identity on locals,
\(K(q) = \operatorname{cl}_{\pi_q,\sigma_q}(N(\theta_q q))\) and
\(K(o) = \operatorname{cl}_{\pi_o,\sigma_o}(N(\theta_o o))\). They are equal,
so peeling both at \(k\) binders and \(n\) antecedents (Lemma Q-2(4)) makes the
parts of \(N(\theta_q q)\) and \(N(\theta_o o)\) correspond under
\(\pi_q \circ \pi_o^{-1}\); apply \(\theta_q^{-1}\). (3) The locals \(\rho\) maps
are the distinct \(u\)'s, the locals of \(o\) (Proposition LC-30); \(\rho(u)\)
has type \(\theta(\tau_u)\) by (2); the \(u\)'s are fixed in a chain over a
frame on whose chain \(q\)'s locals lie, so those lie on \(u_k\)'s chain; and
inst is sound (Theorem Q-19), so the row concludes the instance (2)
gives. \(\square\)
The unified judgment¶
Definition Q-18 (entry sets and the unified judgment). An entry set \(E\) of \(T\) is a finite set of locals and canonical propositions of \(\Sigma\) that holds the locals of each of its propositions. A context realizes \(E\) when its entries (Definition D-1) are exactly \(E\). \(E \Vdash_T \varphi\) holds when \(\Delta \vdash \varphi\) is derivable in \(T\) for a context \(\Delta\) that realizes \(E\); by (Weak), which compares entries, every realization then derives it. A row \(s\) denotes \(\operatorname{E}(s) \Vdash \varphi\), with \(\operatorname{E}(s) = V \cup \Gamma\). \(\operatorname{ctx}(s)\) realizes \(\operatorname{E}(s)\), and so does every reordering of it that keeps each hypothesis after its locals.
Proposition Q-29 (the readings agree). For every sequent \(s\), \(\operatorname{E}(s) \Vdash \varphi\) holds exactly when \(J(s)\) is derivable, with the same declarations, home and sort hypotheses.
Proof. \(\operatorname{ctx}(s)\) realizes \(\operatorname{E}(s)\), and Lemma Q-4(3) gives the equivalence. Opening and closing introduce only the parts of \(s\) and the core connectives (Lemma Q-4), so the records agree. \(\square\)
\(J(s)\) is the reading that statements need (thm, the witnesses of
Definition Q-12, a Proven proof by Definition LC-21); a Proven states
\(K(s)\), and \(\vdash K(s)\) and \(J(s)\) are derivable from each other
(Theorem Q-3b). The unified
judgment is the reading the bridge-rule expansion expands (Definition Q-13). It
uses no closure, so a premise is never reopened.
Rows and records¶
Definition Q-4 (rows and records). A sequent row holds a sequent \(s = \Gamma \vdash^V_T \varphi\), its sort hypotheses \(S\), and its record:
- its context \(\beta\), a context of \(T\) (K1.5) on whose chain every local of \(V\) is fixed; \(T\) is the theory of \(\beta\), and \(\operatorname{sig}(T)\) is the row's signature;
- its home theory \(H\);
- its declarations \(D\), the declaration part of its dependency set (K1.7). The local part of the dependency set is \(V\), and its sort part is \(S\).
Consider a row that concludes an instance of a sequent rule (Definitions Q-7 to Q-10). Let its premise rows be \(s_1, \dots, s_m\), with records \((\beta_i, H_i, D_i)\) and sort hypotheses \(S_i\). Let its operands and its extra declarations \(E\) be those of Definition Q-11. Its record and sort hypotheses are then:
- (R1) Placement. \(\beta\) extends the context of every premise (K1.5). The scope of every operand term, and the frame of every local of \(V\), lie on the chain of \(\beta\). Definition Q-10 replaces this for LIFT.
- (R2) Lost variables.
\(\mathrm{In} = \bigcup_i \operatorname{TV}(s_i) \cup \bigcup \operatorname{TV}(o)\)
over the operand terms and types \(o\); Definition Q-8 gives the
exception for
inst. \(\mathrm{Lost} = \mathrm{In} \setminus \operatorname{TV}(s)\). - (R3) Home. \(H\) is the join of \(\operatorname{sig}(T)\); the \(H_i\); \(\operatorname{home}_\Sigma(A)\) for every part \(A\) of \(s\); \(\operatorname{home}(\tau_\ell)\) for \(\ell \in V\); the homes of the operands; and \(T_d^{+}\) for \(d \in E\).
- (R4) Sort hypotheses. A sort is redundant for \(s\) when it is entailed by \(\operatorname{srt}(\beta)\) for some \(\beta \in \operatorname{tv}(s)\) (Definition Y-9), or witnessed in \(H\) (Definition Y-12a). Then \(S = \bigcup_i S_i \cup \{\operatorname{srt}(\alpha) \mid \alpha \in \mathrm{Lost},\ \operatorname{srt}(\alpha) \ne \emptyset \text{ and not redundant for } s\}\).
- (R5) Declarations. \(D = \bigcup_i D_i \cup E \cup W\). Here \(W\) holds, for each \(\alpha \in \mathrm{Lost}\) whose sort is witnessed in \(H\) and entailed by no sort of \(\operatorname{tv}(s)\), the instance declarations of that witness (Definition Y-13).
Rules (R2) to (R5) are Definition Y-13 and K1.7 applied to a sequent rule
as one step, as Y-13 applies them to export and transport. Lemma Q-7
shows that the joins of (R3) lie in \(T\), so they are theories (Lemma T-8).
Definition Q-5 (established rows). A row \((s, S, \beta, H, D)\) is established when:
- (E1) \(\vdash \operatorname{cl}(s)\) has a derivation \(\mathcal D\) in \(T\) by the rules of the deduction page and the class rules (Definition Y-14), with \(\operatorname{home}(\mathcal D) \sqsubseteq H\) and \(\operatorname{decls}(\mathcal D) \subseteq D\) (Definitions D-4, D-5, and Y-11 for the membership declarations);
- (E2) for every theory \(T^* \sqsupseteq H\) and every ground model \(M\) of \(T^*\) in which each sort of \(S\) has a ground type belonging to it, \(J(s)\) is valid in \(M\) (Definitions Y-6 and Y-12);
- (E3) \(\operatorname{sig}(T) \sqsubseteq H \sqsubseteq T\), and \(H\) includes \(\operatorname{home}_\Sigma(A)\) for every part \(A\) and \(\operatorname{home}(\tau_\ell)\) for every \(\ell \in V\).
By (E1), (E3) and Theorems D-8 and D-7, \(J(s)\) is derivable in every
theory that includes \(H\). (E2) is what Theorem Y-8 states of a derived
judgment with sort hypotheses \(S\). A derivation in (E1) may cite Proven
declarations by (Use); \(\operatorname{decls}\) is shallow, as K1.7's
summaries are.
Closed sequents and closed judgments. A sequent with \(V = \Gamma = \emptyset\) has \(\operatorname{cl}(s) = \varphi\): it is the closed judgment \(\vdash \varphi\) of \(T\) with sort hypotheses \(S\). The two readings across row kinds are Definition LC-21 of the local checking page:
- a natural-deduction rule that cites a sequent row \(s\) receives \(J(s)\): the conclusion \(\operatorname{cl}(s)\), which the check rebuilds in scratch (Proposition Q-3(4)), in the empty context of \(T\), with no hypotheses and no locals, declarations \(D\), sort hypotheses \(S\) and home \(H\). It never receives \(\varphi\) in the context \(\beta\): the hypotheses \(\Gamma\) are not entries of \(\beta\), so that reading would lose them;
- a sequent rule cites a natural-deduction row \(p\) only when \(p\) has no hypotheses and no locals in its dependency set. It then receives the sequent \(\emptyset \vdash^{\emptyset}_{T_p} A_p\), with \(p\)'s sort hypotheses, home and declarations, and \(p\)'s frame as its context.
Both readings denote the same judgment, so the induction of the soundness
theorem covers rows of both kinds. A sequent with free locals or
hypotheses becomes a closed statement only through \(J(s)\): a Proven
declaration whose proof is the row, which states \(K(s)\) (Definition Q-12,
Theorem Q-3b), or a natural-deduction row that cites it.
The sequent rules¶
Definition Q-6 (conventions of the rules). In Definitions Q-7 to Q-9, \(s_1\) and \(s_2\) are the premise rows, \(T\) is the row's theory, and \(\Sigma\) its canonical signature.
- Premises. Each premise has a theory \(T_i \sqsubseteq T\) (by (R1)) with \(\operatorname{sig}(T_i) = \operatorname{sig}(T)\), so its parts are canonical for \(\Sigma\). A premise with another signature is first moved by LIFT (Definition Q-10).
- Operands. Every operand term is bound-closed and canonical for \(\Sigma\), with \(\operatorname{home}_\Sigma \sqsubseteq T\). Every operand type, and the type of every operand local, is well formed in \(T\).
- Free locals. Each rule names a required set \(V_r\), and the row's
\(V\) must contain it. The locals of \(V \setminus V_r\) are the row's
retained locals. The row stores \(V\) as the local part of its
dependency set, so the retained locals have no operand slot of their
own; (R2) and (R3) count them among the operands. For
use, \(V = V_r\). They hold the variables that the article's raw syntax has and the canonical parts lost (Definition OT-5). - Equational premises. A rule that reads a premise \(s_i\) as an equation takes its sides \((a, b)\) and their type \(\tau\) from \(\varphi_i = \mathsf{eq}[\tau](a, b)\). If \(\varphi_i\) is \(\mathsf{True}\) or \(\mathsf{False}\), the premise is trivial: the row stores no sides for it, and Definition Q-16 gives the rule's conclusion. Otherwise \(s_i\) is not an equation, and the rule does not apply.
Lemma Q-6 (equations). For canonical \(a\) and \(b\) of type \(\tau\), \(\operatorname{Eq}(a, b) = \mathsf{eq}[\tau](a, b)\), unless \(a\) and \(b\) are literals of the kind whose carrier is \(\tau\). Then \(\operatorname{Eq}(a, b)\) is \(\mathsf{True}\) if \(a = b\) and \(\mathsf{False}\) otherwise. Hence an equational premise has \(\varphi_i = \operatorname{Eq}(a, b)\), and its sides are determined by \(\varphi_i\) unless \(\varphi_i\) is \(\mathsf{True}\) or \(\mathsf{False}\). Sides of a function type are never literals.
Proof. \(\mathsf{eq}\) is a constant of the logic core. It is no ACU
instance (Definition T-6, condition 2) and no unit, since a unit has a
type headed by a constructor. The only literal operation it is bound to is
EQ, which every kind binds implicitly to \(\mathsf{eq}[C_k]\)
(K1.3). The term
\(\mathsf{eq}[\tau](a, b)\) is β-normal, because its head is a constant and
its arguments are canonical. By Definition C-3 its only possible A-step is
step 2 at the root, the evaluation of EQ. That step needs both arguments
to be literals of the kind with carrier \(\tau\), and it gives \(\mathsf{True}\)
exactly when they are identical (requirements L1 and L5). Literal carriers
are headed by type constructors (Definition T-7), so they are not function
types. \(\square\)
Definition Q-7 (the inference rules). Each rule concludes a sequent of \(T\) with free locals \(V \supseteq V_r\):
The premises are listed in the article's stack order, deepest first, as the article backend reads them. Sets are of canonical nodes, so \(\cup\) merges and \(\setminus\) removes by identity. The side conditions are:
| Rule | Operands | Side conditions | \(V_r\) |
|---|---|---|---|
refl |
a term \(t\) | none | \(\operatorname{locs}(t)\) |
betaConv |
a term \(c\), the canonical form of the article's redex \((\lambda v.\, u)\, w\), which \(N\) contracts | none | \(\operatorname{locs}(c)\) |
assume |
a term \(\varphi\) | \(\varphi : \mathsf{Prop}\) | \(\operatorname{locs}(\varphi)\) |
sym |
the sides \((a, b)\) of \(s_1\) | \(s_1\) is an equation | \(V_1\) |
trans |
the sides \((a, b)\) of \(s_1\) and \((b', c)\) of \(s_2\) | \(b' = b\) by identity | \(V_1 \cup V_2\) |
appThm |
the sides \((f, g)\) of \(s_1\) and \((x, y)\) of \(s_2\) | \(f, g : \sigma \to \tau\) and \(x, y : \sigma\) | \(V_1 \cup V_2\) |
absThm |
a local \(v\); the sides \((s, t)\) of \(s_1\) | eigenvariable: \(v \notin \operatorname{locs}(A)\) for every \(A \in \Gamma\) | \(V_1 \setminus \{v\}\) |
eqMp |
the sides \((A, B)\) of \(s_1\) | \(A, B : \mathsf{Prop}\); \(\varphi_2 = A\) by identity | \(V_1 \cup V_2\) |
deductAntisym |
none | none | \(V_1 \cup V_2\) |
proveHyp |
none | none; \(A\) need not be a hypothesis of \(s_2\) | \(V_1 \cup V_2\) |
A trivial premise has no sides, and Definition Q-16 replaces the
conclusion and side conditions above for a row that has one. In appThm, \(f(x)\) is
\(\mathrm{app}(f, x)\), which merges spines (Definition S-5). betaConv is
refl at the canonical form of the redex: the kernel builds
\((\lambda v.\, u)\, w\) already contracted, so both sides of the article's
theorem are \(c\). The two tags differ only in provenance. In absThm, \(v\)
may be absent from \(V_1\); the eigenvariable condition concerns the
canonical hypotheses only.
Definition Q-16 (trivial premises). Let a row of sym, trans,
appThm, absThm or eqMp have a trivial premise (Definition Q-6(4)).
By Lemma Q-6 the article's sides of that premise were literals of one
kind, equal for \(\mathsf{True}\) and distinct for \(\mathsf{False}\), and
the row stores none of them
(TD1.8). The row is an
instance of its rule when its hypotheses, \(V_r\), (R1) and (R2) to (R5)
are those of Definition Q-7, and its conclusion is given by the first
line of this table that applies:
| Case | Conclusion \(\varphi\) |
|---|---|
absThm, \(\varphi_1 = \mathsf{False}\) |
the rule's own shape: \(\operatorname{Eq}(\lambda{:}\tau_v.\, A,\, \lambda{:}\tau_v.\, B)\) at a type \(\tau_v \to \sigma\), canonical for \(\Sigma\), in which \(v\) does not occur, with its locals in \(V\) |
| a trivial premise is \(\mathsf{False}\) | any proposition of \(T\): canonical for \(\Sigma\), of type \(\mathsf{Prop}\), with its locals in \(V\) |
sym, \(\varphi_1 = \mathsf{True}\) |
\(\mathsf{True}\) |
trans, \(\varphi_1 = \mathsf{True}\) |
\(\varphi_2\) |
trans, \(\varphi_2 = \mathsf{True}\) |
\(\varphi_1\) |
eqMp, \(\varphi_1 = \mathsf{True}\) |
\(\varphi_2\) |
absThm, \(\varphi_1 = \mathsf{True}\) |
\(\operatorname{Eq}(u, u)\), where \(u = \lambda{:}\tau_v.\, a\) for a literal \(a\); the check reads \(u\) from \(\varphi\) |
appThm, \(\varphi_2 = \mathsf{True}\) |
\(\operatorname{Eq}\big(N(f(x)), N(g(x))\big)\), where \((f, g)\) are the sides of \(s_1\) and \(x\) is a term operand of the row: a literal of type \(\sigma\) |
The side conditions of Definition Q-7 that name the sides of a trivial
premise are dropped: the middle term of trans, \(\varphi_2 = A\) in
eqMp. appThm keeps \(f, g : \sigma \to \tau\), and its operand \(x\) has
type \(\sigma\). \(\varphi_1\) of appThm is never trivial, since sides of a
function type are never literals (Lemma Q-6). Every row that the article
makes with literal sides is an instance: each line gives the canonical
form of the article's conclusion, and the general \(\mathsf{False}\) line
admits whatever the article concluded. That line makes the conclusion of such a row a
stored value rather than a function of the premises (Corollary Q-27).
Definition Q-8 (instantiation). For a type substitution \(\theta\) and a map \(\mu\) from locals to terms, let \(t[\theta; \mu] = N\big((t\theta)[\mu]\big)\). Here \(t\theta\) applies \(\theta\) to every annotation and type argument (Lemma S-5), and \([\mu]\) replaces every local \(\ell\) by \(\mu(\ell)\) at once. Then
with these conditions:
- \(\theta\) is given as a list of pairs \((\alpha, \theta(\alpha))\) with distinct \(\alpha\); \(\operatorname{dom} \theta\) is the set of listed variables. Each \(\theta(\alpha)\) is well formed in \(T\), and \(\theta\) is admissible in \(T\): \(\theta(\alpha) : \operatorname{srt}(\alpha)\) for every listed \(\alpha\) (Definition Y-11).
- \(\mu\) is given as a list of pairs \((\ell, \mu(\ell))\) with distinct \(\ell\), each a local of \(V_1\), and is the identity elsewhere. The listed locals are the premise's own, not instantiated copies: the producer composes OpenTheory's two stages, as below. For every \(\ell \in V_1\), \(\mu(\ell)\) has type \(\tau_\ell\theta\), so a local whose type \(\theta\) moves must be listed.
- \(V_r = \bigcup_{\ell \in V_1} \operatorname{locs}(\mu(\ell))\).
- In (R2), \(\mathrm{In} = (\operatorname{TV}(s_1) \setminus \operatorname{dom}\theta) \cup \bigcup_{\alpha \in \operatorname{dom}\theta \cap \operatorname{TV}(s_1)} \operatorname{TV}(\theta(\alpha)) \cup \bigcup_{\ell \in V_1} \operatorname{TV}(\mu(\ell))\). A variable that \(\theta\) moves is instantiated, not lost.
\((t\theta)[\mu]\) is well typed when \(t\) is: Theorem T-5 types \(t\theta\) with each local \(\ell\) at \(\tau_\ell\theta\), and Theorem T-4(2), iterated through fresh locals, types the simultaneous substitution.
subst is inst with the empty list for \(\theta\): term
instantiation. Type instantiation is inst with a list \(\theta\) and a
map \(\mu\) that sends each local \(\ell\) to a local of type \(\tau_\ell\theta\).
The article's subst command, whose substitution has a type part and a
term part, is one inst row. OpenTheory applies the type part first
(Definition OT-4), so \(\mu(\ell) = \sigma(\rho(\ell))\), where \(\rho(\ell)\)
is the local of type \(\tau_\ell\theta\) that the type part makes of \(\ell\)
and \(\sigma\) is the term part. \(M(\theta)\) is the set of instance and
class-relation declarations that the memberships
\(\theta(\alpha) : \operatorname{srt}(\alpha)\) use
(K2.8).
Definition Q-9 (declarations used as sequents).
use: \(d\) is an axiom, aProventheorem, a fact of a type definition or specification (K2.6), or the equation of a definition or an instance definition (K2.7), visible in \(T\). Its type parameters \(\bar\alpha_d\) are stored with it (K1.3), \(\lvert\bar\tau\rvert = \lvert\bar\alpha_d\rvert\), and \(\bar\tau\) is admissible (Definition Y-11). At a function-type argument the statement is instantiated in the signature of \(d\)'s parent and then lifted, as K1.8'susedoes (K2.9). \(V_r = V\): the row stores \(V\) and the number of hypotheses, and these split the closure into quantifiers, hypotheses and conclusion. The statement accepts the sequent (Definition Q-2): it is \(\operatorname{cl}_{\pi_b,\sigma}(\Gamma \vdash^{V}_{T} \varphi)\) for some order \(\sigma\) of \(\Gamma\), its quantifiers in the binding order of \(V\) and its antecedents in any order.ofClass: \(\tau : \{c\}\) in \(T\) (Definition Y-9); \(V_r = \emptyset\).
Definition Q-10 (LIFT). Let \(T'\) be the row's theory and \(\Sigma' = \Sigma(T')\):
with \(H_1 \sqsubseteq T'\) and \(V_r = V_1\). Placement (R1) becomes: the context \(\beta'\) is any context of \(T'\) on whose chain every local of \(V\) is fixed. It need not extend the premise's context, so a closed sequent moves to any theory that includes its home. \(\operatorname{sig}(T) \sqsubseteq H_1 \sqsubseteq T'\) by (E3), so \(\Sigma \subseteq \Sigma'\), and LIFT never removes declarations from the signature. Lifting may merge two hypotheses and may change their order; Theorem Q-5 relates the closures.
Definition Q-11 (operands and extra declarations).
| Rule | Operand terms, types and locals (homes in (R3), variables in (R2)) | Extra declarations \(E\) |
|---|---|---|
refl, betaConv, assume |
\(t\), \(c\), \(\varphi\); the retained locals | none |
sym, trans, eqMp |
the retained locals | none |
appThm |
\(x\) when \(\varphi_2 = \mathsf{True}\) (Definition Q-16); the retained locals | none |
absThm |
\(v\); the retained locals | none |
deductAntisym |
the retained locals | \(\{\mathsf{propext}\}\) |
proveHyp |
the retained locals | none |
inst |
\(\theta(\alpha)\) and \(\mu(\ell)\); the retained locals | \(M(\theta)\) |
use |
\(\bar\tau\) | \(\{d\} \cup M(\bar\tau)\) |
ofClass |
\(\tau\); the retained locals | \(\{\text{the class } c\} \cup M(\tau : \{c\})\) |
| LIFT | the retained locals | none |
propext is the logic core's axiom
(K1.4). \(M(\bar\tau)\) and
\(M(\tau : \{c\})\) are the membership declarations as for \(M(\theta)\).
Declarations¶
An article's declaration commands extend the theory with declarations of
the existing forms. A declaration row is checked by the checker's theory
pass under exactly the conditions that K1.3 and K2.6 to K2.9 state. The
theorems a command pushes are sequent rows, almost all of them use rows.
A witness is a Proven declaration of a closed judgment derived from the
article's premise sequent.
Definition Q-12 (declaration forms). Let \(s\) be the premise sequent of a command, where it has one.
| Command | Declaration row | Its conditions | Sequent rows it adds |
|---|---|---|---|
axiom \(\Gamma\) \(\varphi\) |
none, when a declaration \(d\) of \(T\) has the Rule L1 key \((K(s), k, n)\) (Proposition Q-3f); otherwise, in an import theory only, Axiom(judgment.stmt.\(\langle\)sid\(\rangle\), \(K(s)\)) |
Axiom (K1.3): closed, of type \(\mathsf{Prop}\) |
use \(d\) \(\bar\tau\) concluding \(s = \Gamma \vdash^V_T \varphi\), \(V\) the article variables of \(\Gamma\) and \(\varphi\), when \(d\)'s statement accepts \(s\); otherwise use \(d\) on the opened statement and an inst row onto \(s\) (Proposition Q-3f) |
thm \(s\) \(\Gamma\) \(\varphi\) |
Proven\((n, K(s))\) citing the proof of \(s\), or none when a declaration already has the key \((K(s), k, n)\) |
Proven (K1.3, K1.9): \(H(s)\) is included in the parent; each sort of \(S\) is witnessed there and removed (Definition Y-13); the statement is \(K(s)\) of the proof's own sequent, read in the parent's signature |
none |
defineConst \(c\) \(t\) |
Definition\((c, \sigma, t)\), not transparent |
K1.3: \(t\) closed, \(t : \sigma\), \(\operatorname{TV}(t) \subseteq \operatorname{TV}(\sigma)\), mentions neither \(c\) nor anything undeclared | use of the equation at \(\bar\alpha_c\): \(\emptyset \vdash^{\emptyset} \operatorname{Eq}(c[\bar\alpha_c], t)\) |
defineConstList \((c_i, v_i)\) \(s\) |
Specification\((\bar c, w)\), \(w\) = Proven\((W)\) |
K2.6 and Definition Y-2. \(\Gamma = \{\operatorname{Eq}(v_i, t_i)\}\) with distinct locals \(v_i\) and closed \(t_i\), \(\operatorname{locs}(\varphi) \subseteq \{\bar v\}\), and \(W = \forall_{v_1} \cdots \forall_{v_k}.\, \operatorname{Eq}(v_1, t_1) \to \dots \to \operatorname{Eq}(v_k, t_k) \to \varphi\) in the command's order | use of the fact: \(\emptyset \vdash^{\emptyset} N(\varphi[\bar c / \bar v])\) |
defineTypeOp, defineSortedTypeOp |
TypeDefinition\((\kappa, \mathit{abs}, \mathit{rep}, \bar\alpha, P, w)\), \(w\) = Proven\((\vdash \exists x.\, P\,x)\) |
K2.6 and Definition Y-1; \(s = \emptyset \vdash^{V} N(P\,u)\) with \(P\) closed; the sorted form's parameters carry sorts | use of the first fact with \(V = \{a\}\): \(\emptyset \vdash^{\{a\}} \operatorname{Eq}(\mathit{abs}(\mathit{rep}\,a), a)\); use of the second with \(V = \{r\}\): \(\emptyset \vdash^{\{r\}} \operatorname{Eq}(N(P\,r), \operatorname{Eq}(\mathit{rep}(\mathit{abs}\,r), r))\); for article version 6, then sym and absThm rows |
defineInstance \(c\) \(\bar\tau\) \(t\) |
InstanceDefinition\((c, \bar\tau, t)\) |
K2.7, Definitions Y-3 and Y-5b | use of its equation: \(\emptyset \vdash^{\emptyset} \operatorname{Eq}(c[\bar\tau], t)\) |
ofClass \(\tau\) \(c\) |
none | none | ofClass \(\tau\) \(c\) |
instance \(\kappa\) \(\bar S\) \(c\) \(s\) |
Instance\((\kappa, \bar S, c, w)\) |
K2.8 and Definition Y-10: \(w\) states exactly \(\mathsf{of\_class}_c(\mathsf{TYPE}[\kappa(\alpha_1^{S_1}, \dots)])\); coregularity | none |
classRelation \(c\) \(d\) \(s\) |
ClassRelation\((c, d, w)\) |
K2.8 and Definition Y-10a: \(w\) states \(\mathsf{of\_class}_c(\mathsf{TYPE}[\alpha]) \to \mathsf{of\_class}_d(\mathsf{TYPE}[\alpha])\); acyclic; coregular | none |
The witnesses are made as follows:
- Exact closures. When \(\operatorname{cl}(s)\) is the required
statement, the witness is the
Provendeclared from \(s\). It states \(K(s)\), which for \(k = 0\) and \(n \le 1\) is \(\operatorname{cl}(s)\) with its type variables renamed (Definition Q-3d(7)), as the witness conditions allow (K2.8). This holds forinstancewith \(V = \Gamma = \emptyset\). It also holds forclassRelationwith either \(\Gamma = \emptyset\) or \(\Gamma = \{\mathsf{of\_class}_c(\mathsf{TYPE}[\alpha])\}\), whose closures coincide. - Reordered or instantiated closures. Otherwise the witness's judgment is derived from \(J(s)\) by natural-deduction rows. These rows use Lemma Q-4(4) to reorder; (∀E) with closed terms of their types to instantiate the locals of \(V\) that the statement lacks (the classical profile's choice constant supplies them, as Algorithm OT-6 does); and (∃I) of Theorem D-1 for a type definition's witness.
- Raw predicates. Where a type definition's predicate differs from the
article's raw predicate, because canonical construction erased a type
parameter, the reader conjoins a provable guard. The pushed theorems
then follow from the kernel's facts by a fixed derivation with
propext, emitted as sequent rows (Algorithm OT-6).
Instance order. Isabelle exports a type's instances by class name, so
an instance can come before the instance in its superclass that the
coregularity of a pair needs (Lemma Y-4c): vec :: cancel_semigroup_add
after vec :: ab_semigroup_add and before vec :: semigroup_add. The
producer declares an instance where the article puts it, unless, judged
by the classes, it would fail coregularity there. A held instance is
declared right after the instance that resolves the conflict, and one
still held at the article's end is declared there. Every declaration is
checked as usual; only the place changes. Rows after a held instance are
checked in a theory without it. A theory with fewer arities proves less,
so a row that needs a held arity is refused, never accepted.
A Proven declaration's proof may be a sequent row \(s\) itself, with free
locals and hypotheses. The theory pass requires the row's signature to be
the parent's signature theory, builds \(K(s)\) in scratch in that signature
(Definition Q-3d, Proposition Q-3c), and compares it with the stored
statement by identity; \(\vdash K(s)\) and \(J(s)\) are derivable from each
other (Theorem Q-3b). \(\beta\) plays no part, and the context of \(J(s)\) is
empty whatever \(\beta\) is.
Definition Q-17 (rows of the declaration kinds). The proof-node kinds that TD1.8 names after declaration commands are rows of the rules above. Write \(d\) for the declaration operand and \(\bar\alpha_d\) for its stored type parameters.
| Kind | Rule | Conditions |
|---|---|---|
axiom, defineConst, defineConstList, defineTypeOp, defineSortedTypeOp, defineInstance, with part \(N\) |
use of the statement of part \(N\) of \(d\) (Definition I-1's part numbering, 0 for the declaration itself) at \(\bar\tau = \bar\alpha_d\) |
those of use (Definition Q-9); \(d\) is of the form the kind names, and for axiom an Axiom or a Proven declaration, since Definition Q-12 lets an axiom command use any declaration that states its statement; \(V\) and \(\lvert\Gamma\rvert\) are the row's stored ones |
ofClass with \(\tau\) and \(c\) |
ofClass \(\tau\) \(c\) |
Definition Q-9 |
thm with \(p\) and \(d\) |
use of \(d\) at \(\bar\alpha_d\) with \(V = \Gamma = \emptyset\): it concludes \(\emptyset \vdash K(s)\), closed, not \(p\)'s sequent \(s\) |
\(d\) is a Proven declaration whose proof is \(p\) |
instance, classRelation, with part 0 |
use of \(d\)'s witness \(w\), a Proven declaration, at \(\bar\alpha_w\) |
\(d\) is of the form the kind names; \(E = \{w\} \cup M(\bar\alpha_w)\) |
These layouts give no type arguments, so a use at others, such as an
axiom that matches a declaration only up to a renaming of its type
variables, is the row at \(\bar\alpha_d\) followed by an inst row.
\(\bar\alpha_d\) is admissible, since each variable belongs to its own sort.
Every row of this table is therefore admissible by Theorems Q-20 and
Q-21. Definition Q-12 shows that thm, instance and classRelation
need no pushed row; the readings above only give every kind of TD1.8 a
rule.
The other commands make no sequent:
| Command | Declaration row |
|---|---|
typeOp, const of an undeclared name in standard OpenTheory, declareTypeOp, declareConst |
TypeConstructor, Constant (K1.3) |
overloadedConst |
OverloadedConstant (K2.7) |
defineClass |
Class (K2.8) |
definitionThm \(c\) |
none; it adds use of \(c\)'s equation at its parameters |
sortedVarType, the term commands, the stack and dictionary commands, pragma, source |
none; the producer builds canonical terms and records provenance |
Admissibility¶
Each theorem below states that a row of a rule is established when its
premise rows are (Definition Q-5). For every rule, (E3) is Lemma Q-7 and
(E2) is Theorem Q-23. The proofs give (E1), through Lemma Q-8 except for
inst, use, ofClass and LIFT.
Lemma Q-7 (records are well formed). Let a row satisfy the conditions of its rule and (R1), and let its premise rows satisfy (E3). Then:
- every join in (R3) is included in \(T\), so \(H\) is a theory and \(\operatorname{sig}(T) \sqsubseteq H \sqsubseteq T\);
- the parts of \(s\) are bound-closed, canonical for \(\Sigma\), of type \(\mathsf{Prop}\), and have their locals in \(V\), so \(s\) is a sequent;
- (E3) holds. In (R3), the homes of the hypotheses and of the types of the premises' free locals add nothing to the other terms of the join, so a check may omit them.
Proof. (1) \(H_i \sqsubseteq T_i \sqsubseteq T\) by (E3) and (R1). Operand
homes are included in \(T\) (Definition Q-6(2)). Every \(d \in E\) is visible
in \(T\): propext is in the root theory, \(d\) in use by its condition,
and the declarations of \(M\) are used by a membership decided in \(T\). The
type of a local of \(V\) is well formed in \(T\). Finally
\(\operatorname{sig}(T) \sqsubseteq T\), and the root theory is included in
\(\operatorname{sig}(T)\) (K1.3).
(2) Every part is either a premise part or a term the rule builds with the
canonical constructors from premise parts, operands and the core
constants \(\mathsf{eq}\), \(\mathsf{imp}\), \(\mathsf{forall}\),
\(\mathsf{TYPE}\) and the class predicate. In use, the parts are the
peeled pieces of a closed statement. Theorem C-7 makes the built terms
canonical, and Theorems T-4 and T-5 make them well typed. \(N\) never adds a
local: every generator of Definition C-1 has the locals of its right side
among those of its left side. So the locals of a built part lie among
those of its inputs: \(V_r\) covers them in every rule, and for absThm,
\(\operatorname{locs}(\lambda_v s) = \operatorname{locs}(s) \setminus \{v\}\).
(3) Canonical construction adds only symbols of \(\Sigma\) (a folded
literal), of the root theory (\(\mathsf{True}\) or \(\mathsf{False}\) from
EQ, LT and LE), and ACU declarations of \(\Sigma\) for its spines,
all in \(\operatorname{sig}(T)\) (Definitions C-1 and C-3). A hypothesis of
\(s\) is therefore a premise hypothesis, with home included in some \(H_i\), or
is built from premise parts and operands. In use, the hypotheses are
pieces of \(\operatorname{stmt}(d)\) instantiated at \(\bar\tau\): their homes
lie in \(T_d^{+}\) joined with the homes of \(\bar\tau\) and
\(\operatorname{sig}(T)\). The conclusion's home and the homes of new
locals' types are terms of the join. \(\square\)
Lemma Q-8 (the expansion frame). Let a row \(s\) satisfy the conditions of its rule and (R1) to (R5), and let its premises be established. Let \(\mathcal D\) derive \(\operatorname{ctx}(s) \vdash \varphi\) in \(T\) from these leaves only:
- the judgments \(J(s_i)\), moved to \(T\) by Theorem D-7;
- (Use) of declarations in \(E\);
- the rules of the deduction page.
Let every term that \(\mathcal D\) introduces be an operand, a part of \(s\) or of a premise, or a term built from these by the canonical constructors, together with fresh locals of operand types. Then \(s\) satisfies (E1).
Proof. Close \(\mathcal D\) by Lemma Q-4(1). Its declarations are those of the premises' derivations, at most \(D_i\) by (E1), and those of \(E\), so they lie in \(D\). Every component of its home (Definition D-5) lies in \(H\):
- the root theory and \(\operatorname{sig}(T)\);
- the declarations of \(D\): those of \(D_i\) lie in \(H_i\), and those of \(E\) in their \(T_d^{+}\);
- the symbols of its propositions and introduced terms, which are those of the premises (in \(H_i\)), the operands, the parts of \(s\) (Lemma Q-7) and the core constants;
- the types of its locals, which are those of \(V\) and operand types.
Theorem D-7 leaves a premise derivation's home unchanged. \(\square\)
Theorem Q-9 (refl and betaConv are admissible). A row of
refl \(t\) or betaConv \(c\) is established.
Proof. The locals of \(t\) lie in \(V\), so \(t\) is a term of
\(\operatorname{ctx}(s)\). (Refl) gives \(t = t\), whose canonical form is
\(\operatorname{Eq}(t, t)\). Apply Lemma Q-8. betaConv is the same at
\(c\). \(\square\)
Theorem Q-10 (assume is admissible). A row of assume \(\varphi\) is
established.
Proof. \(\operatorname{ctx}(s)\) ends with \(h_1{:}\varphi\), and (Hyp) gives \(\varphi\). Apply Lemma Q-8. \(\square\)
Theorem Q-11 (sym is admissible). Proof. Open \(s_1\) in
\(\operatorname{ctx}(s)\) by Lemma Q-4(2), with \(\mu\) the identity and
(Hyp) for \(\Gamma_1 = \Gamma\); this needs \(V_1 \subseteq V\). That gives
\(\operatorname{Eq}(a, b)\), which is \(a = b\) up to \(=_E\) (Theorem C-6(1)).
(Sym) gives \(b = a\), whose canonical form is \(\operatorname{Eq}(b, a)\).
Apply Lemma Q-8. \(\square\)
Theorem Q-12 (trans is admissible). Proof. Open both premises in
\(\operatorname{ctx}(s)\) (\(V_1 \cup V_2 \subseteq V\), and
\(\Gamma_1 \cup \Gamma_2 = \Gamma\)). (Trans) on \(a = b\) and \(b = c\), whose
middle terms are identical, gives \(a = c\), whose canonical form is
\(\operatorname{Eq}(a, c)\). Apply Lemma Q-8. \(\square\)
Theorem Q-13 (appThm is admissible). Proof. Open both premises in
\(\operatorname{ctx}(s)\). (Cong) with \(n = 1\) on \(f = g\) and \(x = y\)
gives \(f(x) = g(y)\), well typed because \(f, g : \sigma \to \tau\) and
\(x, y : \sigma\). By Theorem C-6(2) its canonical form is
\(\operatorname{Eq}(N(f(x)), N(g(y)))\). Apply Lemma Q-8. \(\square\)
Theorem Q-14 (absThm is admissible). Proof. Let \(v'\) be a fresh
local of type \(\tau_v\). Then \(\Delta = \operatorname{ctx}(s), v'{:}\tau_v\)
is a context of \(T\). Let \(\mu\) send \(v\) to \(v'\) and every other local of
\(V_1\) to itself; these are terms of \(\Delta\), because
\(V_1 \setminus \{v\} \subseteq V\). For \(A \in \Gamma\),
\(v \notin \operatorname{locs}(A)\) by the eigenvariable condition, so
\(A[\mu] = A\), an entry of \(\Delta\). Lemma Q-4(2) gives
\(\Delta \vdash s[v := v'] = t[v := v']\) up to \(=_E\). \((\xi)\) applies,
since \(v'\) is the last entry, and gives
\(\operatorname{ctx}(s) \vdash \lambda{:}\tau_v.\, \operatorname{abs}^0_{v'}(s[v := v']) = \lambda{:}\tau_v.\, \operatorname{abs}^0_{v'}(t[v := v'])\).
By Lemma Q-2(1) these sides are \(\lambda{:}\tau_v.\, \operatorname{abs}^0_v s\)
and \(\lambda{:}\tau_v.\, \operatorname{abs}^0_v t\), and by Lemma Q-1 the
canonical form is \(\operatorname{Eq}(\lambda_v s, \lambda_v t)\). Apply
Lemma Q-8.
Without the eigenvariable condition, a hypothesis \(A\) that mentions \(v\) would become \(A[v := v']\), which mentions \(v'\) and cannot precede it in \(\Delta\). \((\xi)\) would then not apply: this is the condition that the deduction page satisfies by construction. \(\square\)
Theorem Q-15 (eqMp is admissible). Proof. Open both premises in
\(\operatorname{ctx}(s)\). They give \(A = B\) and \(A\), since \(\varphi_2 = A\).
(Subst) with \(P = \lambda x{:}\mathsf{Prop}.\, x\) applies:
\(\mathrm{app}(P, A) =_\beta A\), and its conclusion
\(\mathrm{app}(P, B) =_\beta B\). Apply Lemma Q-8. \(\square\)
Theorem Q-16 (deductAntisym is admissible). Proof. Write
\(\Delta = \operatorname{ctx}(s)\). \(\Gamma_2 \subseteq \Gamma \cup \{A\}\),
so \(s_2\) opens in \(\Delta, h_A{:}A\), which gives \(B\); \((\to\mathrm I)\)
gives \(\Delta \vdash A \to B\). Likewise
\(\Gamma_1 \subseteq \Gamma \cup \{B\}\) gives \(\Delta \vdash B \to A\). (Use)
of \(\mathsf{propext}\), \((\forall\mathrm E)\) with \(A\) and \(B\), and
\((\to\mathrm E)\) twice give \(\Delta \vdash A = B\), whose canonical form is
\(\operatorname{Eq}(A, B)\). The derivation uses \(\mathsf{propext} \in E\).
Apply Lemma Q-8. \(\square\)
Theorem Q-17 (proveHyp is admissible). Proof. Write
\(\Delta = \operatorname{ctx}(s)\). \(\Gamma_1 \subseteq \Gamma\), so \(s_1\)
opens in \(\Delta\) and gives \(\Delta \vdash A\). Open \(s_2\) in \(\Delta\),
supplying that derivation for the hypothesis \(A\) if \(A \in \Gamma_2\), and
(Hyp) for the others, which lie in \(\Gamma\). This gives \(B\). Apply
Lemma Q-8. \(\square\)
Theorem Q-28 (trivial premises are admissible). A row of Definition Q-16 is established.
Proof. In every rule \(\Gamma \supseteq \Gamma_i\). In every rule but
absThm, \(V \supseteq V_i\), so each premise opens in
\(\operatorname{ctx}(s)\) by Lemma Q-4(2). In absThm, \(V \supseteq V_1
\setminus \{v\}\) only: \(V_r\) drops \(v\).
- A premise of a rule other than
absThmconcludes \(\mathsf{False}\): \((\bot\mathrm E)\) with \(Q = \varphi\), a term of \(\operatorname{ctx}(s)\) because its locals lie in \(V\), gives \(\varphi\). absThmwith \(\mathsf{False}\). Write \(\varphi = \operatorname{Eq}(F, G)\) with \(F = \lambda{:}\tau_v.\, A\) and \(G = \lambda{:}\tau_v.\, B\) of type \(\tau_v \to \sigma\). Let \(p, q\) be fresh locals of type \(\tau_v \to \sigma\), \(v'\) a fresh local of type \(\tau_v\), and \(\Delta = \operatorname{ctx}(s), p, q, v'\). Open \(s_1\) in \(\Delta\) at \(\mu(v) = v'\), the identity elsewhere. Its hypotheses are unchanged, by the eigenvariable condition, as in Theorem Q-14. The opening gives \(\mathsf{False}\), and \((\bot\mathrm E)\) gives \(p(v') = q(v')\). \((\xi)\) at \(v'\), the last entry, gives \(\lambda x.\, p(x) = \lambda x.\, q(x)\). Then \((\forall\mathrm I)\) at \(q\) and at \(p\), and \((\forall\mathrm E)\) with \(F\) and \(G\), give \(\lambda x.\, F(x) = \lambda x.\, G(x)\), which is \(\varphi\) up to β, since \(v\) does not occur in \(\varphi\).
With any conclusion, this case would not be admissible. The deduction
page lets types be empty, and opening \(s_1\) in \(\operatorname{ctx}(s)\)
needs a term of type \(\tau_v\), which the logic core does not have at a
type variable. For example, with
\(\Gamma = \{\forall y{:}\alpha.\, Q\,y,\; \neg\exists y{:}\alpha.\, Q\,y\}\),
\(\Gamma \vdash^{\{v\}} \mathsf{False}\) holds, while
\(\Gamma \vdash^{\emptyset} \mathsf{False}\) fails where \(\alpha\) is
empty. The equation of two abstractions over \(v\) holds there too, since
any two functions from an empty type are equal; the derivation above
proves it without a term of type \(\tau_v\).
- sym with \(\mathsf{True}\): \((\top\mathrm I)\). trans and eqMp with
a \(\mathsf{True}\) premise: the other premise, opened, is the conclusion.
- absThm with \(\mathsf{True}\): (Refl) at the closed term \(u\), whose
canonical form is \(\operatorname{Eq}(u, u)\).
- appThm with \(\varphi_2 = \mathsf{True}\): (Cong) with \(n = 1\) on the
opened \(f = g\) and (Refl) at \(x\) gives \(f(x) = g(x)\), well typed by the
conditions; \(s_2\) is not used. Its canonical form is the conclusion
(Theorem C-6(2)).
Every introduced term is \(\varphi\), \(u\), \(x\), or \(F\) and \(G\), parts or operands, with fresh locals of the types \(\tau_v\) and \(\tau_v \to \sigma\), both built from operand types and \(\varphi\)'s. Apply Lemma Q-8. \(\square\)
Theorem Q-18 (subst is admissible and derived). A row of
inst \(\theta\) \(\mu\) with \(\theta\) empty is established, by a fixed
derivation from \(J(s_1)\).
Proof. The values \(\mu(\ell)\), \(\ell \in V_1\), are terms of \(\operatorname{ctx}(s)\), since their locals lie in \(V_r \subseteq V\). Lemma Q-4(2) opens \(s_1\) at \(\mu\): for \(A \in \Gamma_1\), the hypothesis \(A[\emptyset; \mu]\) of \(s\) is an entry of \(\operatorname{ctx}(s)\). The result is \(\varphi[\emptyset; \mu]\). Apply Lemma Q-8. \(\square\)
Theorem Q-19 (inst is admissible). A row of inst \(\theta\) \(\mu\)
is established. It is derived from (InstType) and (Transport) (Definition
Q-13). (InstType) is primitive on the deduction page, but admissible
there (Corollary D-6a), so inst adds no strength. The proof below gives
the admissibility directly: it rewrites the whole derivation of \(J(s_1)\)
(Theorem D-6), so it is not a fixed derivation from \(J(s_1)\).
Proof. (E1) Let \(\mathcal D_1\) derive \(\vdash \operatorname{cl}(s_1)\); by
Theorem D-7 it is a derivation in \(T\). \(\theta\) is admissible, so Theorem
D-6 applies, with its remark on sorted variables, and gives
\(\mathcal D_1\theta\), a derivation of \(\vdash N(\operatorname{cl}(s_1)\theta)\).
This is the closure instantiated as the kernel builds it (subst_types,
Theorem C-7).
For each \(\ell \in V_1\), choose a fresh local \(\ell^\theta\) of type \(\tau_\ell\theta\). By Lemma S-5, abstraction commutes with \(\theta\), and by Lemma Q-2(1) the instantiated closure is, up to \(=_E\), the closure over the \(\ell^\theta\) of the hypotheses \(A\theta[\ell := \ell^\theta]\) and of \(\varphi\theta[\ell := \ell^\theta]\), in the order of \(s_1\). This uses Lemma C-9(3), which holds when \(\theta\) moves no carrier of a class-level ACU declaration to a function type. Open it as in Lemma Q-4(2), with the values \(\mu(\ell)\) for the \(\ell^\theta\). They are terms of \(\operatorname{ctx}(s)\) of the right types, and give the hypotheses \(A[\theta; \mu] \in \Gamma\) and the conclusion \(\varphi[\theta; \mu]\). Close by Lemma Q-4(1).
In the exceptional case, Theorem D-6 replaces each (A), (C) or (U) step at such a declaration by (Use) of the law the declaration cites, with congruence. In the same way, the opened antecedents may differ from the \(A[\theta; \mu]\) by rearrangements of a spine at a function type. The cited laws prove those rearrangements (Definition Y-15 and Theorem Y-7's argument), following the equations step of Theorem C-12, and (Subst) moves along them. These laws are declarations of \(\operatorname{sig}(T)\), which Definition D-4 counts in every derivation.
The declarations of \(\mathcal D_1\theta\) are those of \(\mathcal D_1\) and
the membership declarations of its instantiated (Use) and of_class
steps. Such a membership descends through the original type, using the
original arities, down to a variable \(\alpha^{S'}\) of it. There
\(\theta(\alpha) : S'\) follows from \(\theta(\alpha) : \operatorname{srt}(\alpha)\),
because \(\operatorname{srt}(\alpha)\) entails \(S'\), by the same arities: an
arity for a class \(c_0 \le c \le c'\) serves \(c'\) (Definition Y-9). Hence
\(\operatorname{decls}(\mathcal D_1\theta) \subseteq D_1 \cup M(\theta)\).
Its home adds to that of \(\mathcal D_1\) only the symbols of the
\(\theta(\alpha)\) and the theories after \(M(\theta)\), all in \(H\) by (R3).
The opening and closing steps are covered as in Lemma Q-8. \(\square\)
Theorem Q-20 (use is admissible). Proof. (Use) in the empty
context of \(T\), at the admissible \(\bar\tau\), concludes
\(\vdash N(\operatorname{stmt}(d)[\bar\alpha_d := \bar\tau])\). For a
function-type argument it goes through the parent's signature (K2.9), as
in Theorem D-6. By the rule's condition this is
\(\vdash \operatorname{cl}_{\pi_b,\sigma}(s)\) for some order \(\sigma\), and
Lemma Q-4(4) with \(V' = V\) derives \(\vdash \operatorname{cl}(s)\) from it
with no declaration and no other terms than the parts of \(s\),
\(\mathsf{imp}\) and \(\mathsf{forall}\) (Theorem Q-3b). Its declarations are \(\{d\} \cup M(\bar\tau)\) (Definition Y-11), and its
home lies in \(T_d^{+}\) joined with the homes of \(\bar\tau\), the theories
after \(M(\bar\tau)\), and \(\operatorname{sig}(T)\): all in \(H\). \(\square\)
Theorem Q-21 (ofClass is admissible). Proof. The rule of_class
of Definition Y-14, in the empty context of \(T\), concludes
\(\vdash \mathsf{of\_class}_c(\mathsf{TYPE}[\tau])\), whose canonical form
is the conclusion of \(s\). Its declarations are \(M(\tau : \{c\})\); its home
is the class's theory, the homes of \(\tau\), and the theories after
\(M(\tau : \{c\})\). \(\square\)
Theorem Q-22 (LIFT is admissible). If \(s_1\) is established, so is its LIFT \(s'\) to \(T'\).
Proof. (E1) By (E1) and (E3) for \(s_1\), Theorem D-8 gives a derivation of \(\vdash \operatorname{cl}(s_1)\) in \(H_1\), since its context is empty. Theorem D-7 moves it to \(T'\). By Corollary C-9a, \(\operatorname{cl}(s_1) =_{E_{\Sigma'}} N_{\Sigma'}(\operatorname{cl}(s_1))\), so (Conv) with the empty unfolding set gives \(\vdash N_{\Sigma'}(\operatorname{cl}(s_1))\). Theorem Q-5(3) gives \(\vdash \operatorname{cl}(s')\). The declarations are those of \(\mathcal D_1\); the home adds \(\operatorname{sig}(T')\), which is in \(H\) by (R3). (E3) holds because a lifted part's home lies in that of the original part joined with \(\operatorname{sig}(T')\). \(\square\)
Theorem Q-23 (sort hypotheses). Let a row \(s\) of any sequent rule satisfy (R1) to (R5) and (E1), and let its premise rows satisfy (E2). Then \(s\) satisfies (E2).
Proof. Let \(T^* \sqsupseteq H\), and let \(M\) be a ground model of \(T^*\) in which each sort of \(S\) has a ground type. For each premise, \(H_i \sqsubseteq H \sqsubseteq T^*\) and \(S_i \subseteq S\), so \(J(s_i)\) is valid in \(M\). Fix a sort-respecting ground substitution \(\gamma\) for \(\operatorname{TV}(s)\) and a valuation. Extend \(\gamma\) to every \(\alpha \in \mathrm{Lost}\):
- if \(\operatorname{srt}(\alpha)\) is entailed by \(\operatorname{srt}(\beta)\) with \(\beta \in \operatorname{tv}(s)\), let \(\gamma(\alpha) = \gamma(\beta)\), which belongs to \(\operatorname{srt}(\alpha)\), since a class's predicate is a conjunct of its subclasses' (Definition Y-8);
- if it is witnessed in \(H\), let \(\gamma(\alpha)\) be a ground type of \(H\) in that sort (Lemma Y-4a). That type belongs to the sort in \(M\) by Lemma Y-4, because the reduct of \(M\) to \(H\) is a ground model of \(H\);
- otherwise \(\operatorname{srt}(\alpha) \in S\), which has a ground type in \(M\) by assumption; and an empty sort takes any ground type.
The frame derivations of Theorems Q-9 to Q-18 and Q-28 and the steps of Theorems Q-20 to Q-22 introduce no type variable outside \(\mathrm{In} \cup \operatorname{TV}(s)\). Their leaves \(J(s_i)\) are valid in \(M\). Every other step is a rule instance in \(H\), by the argument of Theorem D-8, and therefore in \(T^*\). Theorem Y-8 treats each step at the extended ground instance, and each step is valid there, so \(J(s)\) holds at \(\gamma\).
For inst, argue from \(J(s_1)\) directly. For \(\alpha \in \operatorname{dom}\theta\),
\(\theta(\alpha) : \operatorname{srt}(\alpha)\) holds through
\(M(\theta) \subseteq D\), whose theories lie in \(H \sqsubseteq T^*\); so
\(\theta\) followed by \(\gamma\) is sort-respecting for \(\operatorname{TV}(s_1)\)
(Lemma Y-4). Then \(J(s_1)\) at that substitution, under the valuation that
sends \(\ell\) to the value of \(\mu(\ell)\), is \(J(s)\) at \(\gamma\), up to
conversion and the propositional regrouping of Lemma Q-4. Conversion is
valid at ground instances (Theorem Y-8(1)), and \(\Sigma \subseteq \Sigma(T^*)\)
since \(\operatorname{sig}(T) \sqsubseteq H\). The variables that
canonicalization drops are in \(\mathrm{Lost}\), extended as above. \(\square\)
This is Theorem Y-5's argument applied to a sequent rule as one step.
Without (R4), a premise whose conclusion holds vacuously at a sort without
types could be turned into a conclusion that fails, as Theorem Y-5's
example of use shows.
Theorem Q-24 (declarations). Each declaration command adds declarations of the existing forms, checked by the theory pass under the conditions of K1.3 and K2.6 to K2.9, and sequent rows, each of which is established when its premises are.
Proof. The declaration forms and their conditions are the existing
ones, and they preserve the models of their parents (Theorems M-5, Y-1,
Y-2 and Y-3, and Theorem Y-6 for classes and instances). A Proven
witness cites a judgment derived from \(J(s)\): by Lemma Q-4(4), by
(∀E) with closed terms, and by (∃I) of Theorem D-1. Its home is included
in the parent, and its sort hypotheses are witnessed there, as K1.3 and
Definition Y-13 require; so it is derivable in the parent (Theorems D-8
and D-7). The pushed rows are instances of use, ofClass, sym and
absThm, established by Theorems Q-20, Q-21, Q-11 and Q-14. \(\square\)
The bridge-rule expansion¶
The bridge-rule expansion turns every accepted row of a sequent rule into a derivation by the rules of the deduction page. An independent reference checker checks that derivation. The expansion reads each row as the unified judgment \(\operatorname{E}(s) \Vdash \varphi\) of Definition Q-18, never as its closure, so each row expands to a bounded number of rule instances over its premises' judgments (one judgment for sequent and ND rows). It keeps the case split of Lemma Q-6: the rules read an equation's sides from the stored proposition, which literal evaluation may have turned into \(\mathsf{True}\) or \(\mathsf{False}\).
Definition Q-13 (the expansion). Let \(s\) be a row of \(T\), and \(o_i\) premise \(i\)'s judgment \(\operatorname{E}(s_i) \Vdash \varphi_i\). For a natural-deduction premise this is its claim, read by Definition LC-21(2). Write \(W(o)\) for one (Weak) step moving \(o\) into \(\operatorname{E}(s)\), or into \(\operatorname{E}(s)\) with the extra entries stated. The expansion of \(s\) is the derivation in the table. It ends in \(\operatorname{E}(s) \Vdash \varphi\), with \(\varphi\) \(s\)'s stored conclusion, and its last column bounds its rule instances.
| Rule | Case | Expansion | Instances |
|---|---|---|---|
refl \(t\), betaConv \(c\) |
(Refl) | 1 | |
assume \(\varphi\) |
(Hyp) | 1 | |
sym |
an equation | \(W(o_1)\); (Sym) | 2 |
| \(\varphi_1 = \mathsf{True}\) | \((\top\mathrm I)\) | 1 | |
| \(\varphi_1 = \mathsf{False}\) | \(W(o_1)\); \((\bot\mathrm E)\) at \(\varphi\) | 2 | |
trans |
two equations | \(W(o_1)\); \(W(o_2)\); (Trans) | 3 |
| one premise \(\mathsf{True}\) | \(W\) of the other | 1 | |
| a premise \(\mathsf{False}\) | \(W\) of it; \((\bot\mathrm E)\) at \(\varphi\) | 2 | |
appThm |
two equations | \(W(o_1)\); \(W(o_2)\); (Cong), \(n = 1\) | 3 |
| \(\varphi_2 = \mathsf{True}\), operand \(x\) | \(W(o_1)\); (Refl) at \(N(f(x))\); (Subst) with \(P = N(\lambda h{:}\sigma{\to}\tau.\, \mathsf{eq}[\tau](N(f(x)), h(x)))\) | 3 | |
| \(\varphi_2 = \mathsf{False}\) | \(W(o_2)\); \((\bot\mathrm E)\) at \(\varphi\) | 2 | |
absThm \(v\) |
an equation | \(W(o_1)\) into \(\operatorname{E}(s) \cup \{v\}\), \(v\) last; \((\xi)\) at \(v\); \(W\) when \(v \in V\) | 3 |
| \(\varphi_1 = \mathsf{True}\) | (Refl) at \(u\) | 1 | |
| \(\varphi_1 = \mathsf{False}\), \(\varphi = \operatorname{Eq}(F, G)\) at \(\tau_v \to \sigma\) | \(W(o_1)\) into \(\operatorname{E}(s) \cup \{p, q, v\}\), \(v\) last, for fresh \(p, q : \tau_v \to \sigma\); \((\bot\mathrm E)\) at \(p(v) = q(v)\); \((\xi)\) at \(v\); \((\forall\mathrm I)\) at \(q\), then \(p\); \((\forall\mathrm E)\) with \(F\), then \(G\); \(W\) when \(v \in V\) | 8 | |
eqMp |
an equation | \(W(o_1)\); \(W(o_2)\); (Subst) with \(N(\lambda x{:}\mathsf{Prop}.\, x)\) | 3 |
| \(\varphi_1 = \mathsf{True}\) | \(W(o_2)\) | 1 | |
| \(\varphi_1 = \mathsf{False}\) | \(W(o_1)\); \((\bot\mathrm E)\) at \(\varphi\) | 2 | |
deductAntisym |
\(W(o_2)\) into \(\operatorname{E}(s) \cup \{A\}\); \((\to\mathrm I)\); \(W(o_1)\) into \(\operatorname{E}(s) \cup \{B\}\); \((\to\mathrm I)\); (Use) of \(\mathsf{propext}\) at \(A\), \(B\); \((\to\mathrm E)\) twice; after each \((\to\mathrm I)\) whose hypothesis is in \(\Gamma\), a \(W\) back into \(\operatorname{E}(s)\) | 9 | |
proveHyp |
\(A \notin \Gamma\) | \(W(o_1)\); \(W(o_2)\) into \(\operatorname{E}(s) \cup \{A\}\); \((\to\mathrm I)\); \((\to\mathrm E)\) | 4 |
| \(A \in \Gamma\) | \(W(o_2)\) | 1 | |
inst \(\emptyset\) \(\mu\) |
(Transport) of \(o_1\) along \(\mu\), each hypothesis to its image, an entry of \(\operatorname{E}(s)\) | 1 | |
inst \(\theta\) \(\mu\) |
(InstType) of \(o_1\) at \(\theta\); (Transport) along \(\mu\) | 2 | |
use \(d\) \(\bar\tau\) |
(Use) at \(\bar\tau\) and the locals of \(V\) in binding order (with term arguments); then (Hyp) and \((\to\mathrm E)\) for each of the \(\lvert\Gamma\rvert\) antecedents, in the statement's order | \(1 + 2\lvert\Gamma\rvert\) | |
ofClass \(\tau\) \(c\) |
of_class |
1 | |
| LIFT to \(T'\) | (Transport) into \(\operatorname{E}(s)\) in \(T'\), each hypothesis to its lift, an entry | 1 |
The declaration kinds of Definition Q-17 expand as the use or ofClass
row they are read as. The use line counts (Use) with term arguments
once. That rule is derivable: it is (Use) followed by one
\((\forall\mathrm E)\) per local of \(V\) (the deduction page). In the
deduction page's rules, the use line therefore takes
\(1 + \lvert V\rvert + 2\lvert\Gamma\rvert\) instances. A row with a \(\mathsf{False}\) premise in another
position than the table names is the table's \(\mathsf{False}\) line for
that premise. \((\to\mathrm I)\) removes its hypothesis from the entry
set. When that hypothesis is also in \(\Gamma\), a realization holds it
twice (Definition D-1 allows it), and one (Weak) restores the entry
set. A (Transport) step sends each hypothesis of its premise to an entry
of its target, which counts as (Hyp) there, so the step needs no premise
per hypothesis.
Theorem Q-25 (the expansions are derivations). Let a row \(s\) satisfy its rule's conditions and (R1) to (R5), and let each \(o_i\) hold. Then the expansion of Definition Q-13 is a derivation of \(\operatorname{E}(s) \Vdash \varphi\) by the rules of the deduction page. Moreover:
- its declarations lie in \(D\);
- its home lies in \(H\);
- each of its sort hypotheses is in \(S\) or redundant for \(s\).
The independent bridge-rule judge checks these three relations, the rule instances and the final judgment, and that each row's instances stay within the bound.
Proof. Each line applies the rules of the deduction page under their side conditions.
- (Weak). Every (Weak) step is an inclusion of entry sets that the
rule's conditions give: \(V \supseteq V_r \supseteq V_i\) and
\(\Gamma \supseteq \Gamma_i\); for
absThm, \(V \cup \{v\} \supseteq V_1\); fordeductAntisymandproveHyp, \(\Gamma \cup \{A\} \supseteq \Gamma_2\) and \(\Gamma \cup \{B\} \supseteq \Gamma_1\). InabsThm, \((\xi)\) removes \(v\), so when \(V\) retains \(v\) a last (Weak) restores it. - Discharged entries. Each entry that \((\to\mathrm I)\),
\((\forall\mathrm I)\) or \((\xi)\) discharges can be placed last in a
realization (Definition Q-18). For a hypothesis that always holds. For
absThm's \(v\) it holds because no hypothesis mentions \(v\) (the eigenvariable condition). For \(p\) and \(q\) it holds because they are fresh. - Equational premises. By Lemma Q-6, each is an equation, or
\(\mathsf{True}\) with identical sides, or \(\mathsf{False}\) with distinct
literal sides. In the \(\mathsf{True}\) case the rule's step is the
identity on the conclusion, and in the \(\mathsf{False}\) case
\((\bot\mathrm E)\) gives the conclusion. In
appThmwith \(s_2\) \(\mathsf{True}\), \(y = x\), and the motive \(P\) gives \(N(P(f)) = \operatorname{Eq}(N(f(x)), N(f(x)))\), the conclusion of (Refl), and \(N(P(g)) = \varphi\). (Refl) at the literal \(x\) itself would fold to \(\mathsf{True}\), which (Cong) cannot take. InabsThmwith \(\mathsf{False}\), the derivation is Theorem Q-28's: \(p(v) = q(v)\) is an equation that no fold changes, and \((\forall\mathrm E)\) with \(F\) and \(G\) gives \(\varphi\) up to β. deductAntisymandproveHypare Theorems Q-16 and Q-17 without the opening.inst. (Transport) applies Theorem D-5's map \(\mu\), whose values are terms of \(\operatorname{E}(s)\), since their locals lie in \(V_r \subseteq V\). Each hypothesis \(A[\theta; \mu]\) of \(s\) is an entry. (InstType) is Corollary D-6a. Its hypotheses and conclusion are canonical forms, also when \(\theta\) moves a class-level ACU carrier to a function type. There the cited-law steps lie inside the derivation that Corollary D-6a's proof builds, not in the expansion. (Transport) along \(\mu\) then gives \(A[\theta; \mu]\) and \(\varphi[\theta; \mu]\) up to \(=_E\) (Lemma C-9(1)).useandofClass. They are Theorems Q-20 and Q-21, with the peel of Lemma Q-2(4) done by \((\to\mathrm E)\).- LIFT. It is Theorem Q-22: (Transport) to \(T'\) maps each hypothesis to its lift, which is \(=_E\) to it there (Corollary C-9a).
The records are those of Lemma Q-8 and Theorems Q-9 to Q-23 and Q-28, since the expansion introduces only parts, operands, the core constants, \(F\) and \(G\), and fresh locals of operand types. By Proposition Q-29, \(\operatorname{E}(s) \Vdash \varphi\) is \(J(s)\). \(\square\)
Obligation (the checks equal their expansions). For each sequent rule, the check of Definition Q-15 passes on a row exactly when the row is an instance of the rule (Theorem Q-26), and every instance's expansion is a derivation of its judgment with its records (Theorem Q-25). The checker runs the checks, never the expansions. The bridge-rule gate and its fixture tests run both, through an implementation independent of the checker, and require them to agree (KC1.14).
The other direction: writing an OpenTheory article¶
Definition Q-13 expands a sequent row into the deduction page's rules.
Writing an OpenTheory article (version 6; Article.write) goes the
other way: each row becomes OpenTheory primitives. A sequent rule is the
primitive of the same name. A natural-deduction row is written as one
primitive, a chain of primitives, no command, or an instance of a
schema, as the table below says. A schema is a theorem with hypotheses
over variables \(p, q : \mathsf{bool}\). The article proves each
schema it uses once, from the classical profile's definitions of the
connectives, by HOL Light's derivations. It instantiates the schema by
subst and discharges its hypotheses by proveHyp. The definitions are
profile statements, so their axioms resolve to the profile when the
article is read: the article assumes nothing beyond its theorems'
imports. The writer is untrusted. Every written article is read back by
the checking converter, which pins each theorem's statement identity and
the article's assumptions.
| Authoring rule | Written as | Schema the preamble proves | From the profile's definitions |
|---|---|---|---|
truth |
TRUTH | \(\vdash \top\) | \(\top = ((\lambda p.\, p) = (\lambda p.\, p))\) |
hypothesis |
assume |
none | none |
and_intro |
CONJ, proveHyp twice |
\(\{p, q\} \vdash p \wedge q\) | \(\top\), \(\wedge = \lambda p\, q.\, (\lambda f.\, f\,p\,q) = (\lambda f.\, f\,\top\,\top)\) |
and_left, and_right |
CONJUNCT1, CONJUNCT2 | \(\{p \wedge q\} \vdash p\), \(\{p \wedge q\} \vdash q\) | \(\top\), \(\wedge\) |
imp_intro |
DISCH: CONJ, CONJUNCT1, deductAntisym, IMPI |
\(\{(p \wedge q) = p\} \vdash p \Rightarrow q\) | \(\top\), \(\wedge\), \(\Rightarrow = \lambda p\, q.\, (p \wedge q) = p\) |
imp_elim |
MP, proveHyp twice |
\(\{p \Rightarrow q, p\} \vdash q\) | \(\top\), \(\wedge\), \(\Rightarrow\) |
forall_intro |
GEN: EQT_INTRO, absThm, proveHyp |
\(\{p\} \vdash p = \top\); \(\{P = (\lambda x.\, \top)\} \vdash \forall P\) | \(\top\), \(\forall = \lambda P.\, P = (\lambda x.\, \top)\) |
forall_elim |
SPEC, proveHyp, a conversion to the β-normal form, eqMp |
\(\{\forall P\} \vdash P\, y\) | \(\top\), \(\forall\) |
or_left, or_right |
DISJ1, DISJ2, proveHyp |
\(\{p\} \vdash p \vee q\), \(\{q\} \vdash p \vee q\) | \(\top\), \(\wedge\), \(\Rightarrow\), \(\forall\), \(\vee = \lambda p\, q.\, \forall r.\, (p \Rightarrow r) \Rightarrow (q \Rightarrow r) \Rightarrow r\) |
or_elim |
DISJ_CASES, proveHyp three times |
\(\{p \vee q, p \Rightarrow r, q \Rightarrow r\} \vdash r\) | \(\top\), \(\wedge\), \(\Rightarrow\), \(\forall\), \(\vee\) |
false_elim |
CONTR, proveHyp |
\(\{\bot\} \vdash q\) | \(\top\), \(\forall\), \(\bot = \forall p.\, p\) |
eq_refl (Refl) |
refl (TRUTH when the canonical conclusion is \(\top\)) |
none, or \(\vdash \top\) | none, or \(\top\) |
eq_sym (Sym) |
sym |
none | none |
eq_trans (Trans) |
trans |
none | none |
eq_apply (Cong) |
appThm of \(\vdash f = g\) with each \(\vdash a_i = b_i\), then a β conversion of each side to the row's canonical application, joined by sym and trans |
none | none |
eq_abstract (ξ) |
absThm |
none | none |
eq_subst (Subst) |
appThm of \(\vdash P = P\) (refl) with \(\vdash a = b\), a β conversion of each side joined by sym and trans, then eqMp with the premise for \(a\) |
none | none |
export |
for each entry of the premise's chain up to the outer frame, innermost first: DISCH of a hypothesis the premise uses, GEN of a local it uses (as imp_intro and forall_intro) |
those of imp_intro and forall_intro |
\(\top\), \(\wedge\), \(\Rightarrow\), \(\forall\) |
transport |
subst of the map's locals, proveHyp of each hypothesis the premise uses by its pair's judgment, and a β conversion of the conclusion |
none | none |
natural-deduction lift |
no command: the premise's theorem | none | none |
use of a declaration's fact (axiom, defineConst, defineConstList, defineTypeOp, defineSortedTypeOp, defineInstance) |
axiom of the fact, resolved to its provider on reading |
none | none |
thm (use of a Proven by its proof) |
the premise's theorem, when the row's closed conclusion \(K(s)\) is its premise's sequent; a thm row of an open sequent concludes \(\emptyset \vdash K(s)\) and is not written |
none | none |
convert |
the premise's theorem when \(Q\) is its claim; else a conversion of each side to \(D_U\), trans, sym, eqMp |
none | the definitions of \(U\) |
The ∀ schemas are proved at the definition's type variable \(\alpha\), with
\(P : \alpha \to \mathsf{bool}\) and \(y : \alpha\). An instance substitutes
\(\alpha := \tau\) first, then \(P := \lambda x.\, \varphi\) (and \(y := t\)).
forall_intro's absThm is sound because the rule's eigenvariable
condition keeps \(x\) out of the hypotheses. forall_elim converts
\((\lambda x.\, \varphi)\, t\) to its β-normal form, the row's
conclusion, one betaConv per redex (below). The schema variables' names
avoid every local the bank names.
The ∨ and ⊥ schemas are derived from the earlier ones. DISJ1 and DISJ2 discharge \(p \Rightarrow r\) and \(q \Rightarrow r\) by DISCH (one of them vacuously) and generalize over \(r\) by GEN. DISJ_CASES and CONTR specialize the definitions' ∀ by SPEC, at \(r\) and at \(q\). Every SPEC inside a schema has a β-normal result.
A natural-deduction row reads a sequent premise as its row closure
(Definition LC-21(1)): ⇒ over its hypotheses in the structural order of
their closed forms, the last innermost, then ∀ over its locals in binding
order, the last innermost. The
writer proves the closure from the sequent's theorem. Each hypothesis is
discharged by DISCH. Each local is generalized by GEN at its type: EQT,
absThm, then GEN's instance. That order is sound, because once every
hypothesis is discharged no local is free in one. The closure's term is
built as plain nodes, and the row reads its premise through it.
A use row's declaration is always an import's, the profile's or the
core's: an export carries Proven declarations only. Its fact is written
as an axiom, and the read-back resolves the statement to the
declaration's provider, so the article assumes nothing new. convert to
its premise's claim is that premise's theorem. This always holds when no
definition is unfolded, because both sides are canonical. A convert to
another term \(Q\) is written as \(\vdash A = D_U(A)\) and
\(\vdash Q = D_U(Q)\), joined by trans and sym, then eqMp with the
premise. The witnesses of classes, instances and class relations, and a
class predicate's definition, are refused.
A conversion proves \(\vdash t = t'\), where \(t'\) is the β-normal form
of \(t\) with the definitions of \(U\) unfolded. It works by congruence
(appThm under applications, absThm under abstractions) and by two
kinds of step:
- β: one
betaConvper redex. The reduced term is normalized again. - δ: a constant \(c[\bar\tau]\) of \(U\) becomes its definition's
equation \(c[\bar\alpha] = b\), written as an
axiomthat the read-back resolves to the definition, and instantiated bysubstat \(\bar\alpha := \bar\tau\). The body is then normalized.
The intermediate terms are interned as plain nodes in the write's own bank. The kernel's \(N\) also puts ACU spines in canonical order (Definition C-4). A term that needs this does not come out as the row's, and the read-back refuses the article.
The natural-deduction use, of_class and unconstrain, and the
sequent ofClass, are not written, and an export that uses one is refused
(ST5.1).
A β conversion of a side that is an ACU spine or a literal does not reach
the row's canonical term, and the read-back refuses the article. Over
profile none the connectives have no definitions, so rows that need a
schema are refused there too.
Local checks¶
A row's check reads stored data and verified facts, and compares. It never reads a proof below its premises: the premises' fields are trusted as stored, because each premise row is checked on its own. That is the induction step of the soundness theorem.
Definition Q-14 (what a check reads).
| Read | Source | Used for |
|---|---|---|
| each premise row's context, theory, signature, \(\Gamma_i\), \(\varphi_i\), \(V_i\), \(S_i\), \(H_i\), \(D_i\) | the premise rows, below the row in the commit sequence | every rule |
| the row's stored fields and operands | the row | comparison |
| for each operand term and each part, for \(\operatorname{sig}(T)\): its type, canonicity, home, scope, locals, and sorted type variables | verified facts (checker), established by the check if absent | side conditions, \(V_r\), (R1) to (R5) |
| inclusion, joins, \(\operatorname{sig}(T)\), membership with its declarations, witnessing with its declarations, sort entailment, canonical-signature data | the checked theory snapshot | (R1), (R3) to (R5), inst, use, ofClass, LIFT, construction |
| context extension, the frame of a local | termbank's contexts (DAG storage) |
(R1) |
| a declaration's statement and type parameters | the declaration row | use |
Definition Q-15 (the check of a row). Every row's check performs the common steps:
- C1. The premise rows exist below the row. Each is a sequent row, or a natural-deduction row with no hypotheses and no locals in its dependency set, read as a closed sequent (Definition LC-21); any other premise refuses. Each premise's context is extended by \(\beta\), and \(\operatorname{sig}(T_i) = \operatorname{sig}(T)\); LIFT checks Definition Q-10 instead. The row's stored signature is \(\operatorname{sig}(T)\), the snapshot's answer for the theory of \(\beta\).
- C2. Each operand has a fact for \(\operatorname{sig}(T)\): canonical, bound-closed, of the type the rule requires, with home included in \(T\) and scope on \(\beta\)'s chain. Each operand local's frame is on \(\beta\)'s chain.
- C3. \(V_r \subseteq V\), by a merge of sorted lists. Every local of \(V\) has its frame on \(\beta\)'s chain and its type's home included in \(T\).
- C4 to C6. \(H\), \(D\) and \(S\) equal the values of (R3), (R5) and (R4). Joins are interned theory ids; \(D\) and \(S\) are merged sorted lists; \(\mathrm{Lost}\) is a difference of sorted sets of type variables, taken from the facts; redundancy is answered by the snapshot. The stored dependency set holds exactly \(D\), \(S\) and \(V\), and no hypothesis item: a sequent's hypotheses are its hypothesis set, \(\Gamma\).
Then the rule's own step. A structural step compares ids and merges sorted sets; its conclusion is at most one canonical node over stored ids, found by one lookup. A rebuild step builds terms in scratch with the construction engine, maps the result to ids by read-only lookups, and compares by id; a lookup miss refuses.
| Rule | Rule-specific checks | Conclusion and hypotheses compared | Kind |
|---|---|---|---|
refl, betaConv |
none | \(\Gamma = \emptyset\); \(\varphi = \operatorname{Eq}(t, t)\) | structural |
assume |
\(\varphi\) has type \(\mathsf{Prop}\) | \(\Gamma = \{\varphi\}\) | structural |
sym |
sides of \(s_1\) (Definition Q-6(4)) | \(\Gamma = \Gamma_1\); \(\varphi = \operatorname{Eq}(b, a)\) | structural |
trans |
sides; \(b' = b\) | \(\Gamma = \Gamma_1 \cup \Gamma_2\); \(\varphi = \operatorname{Eq}(a, c)\) | structural |
appThm |
sides; type facts \(f : \sigma \to \tau\), \(x : \sigma\) | \(\Gamma = \Gamma_1 \cup \Gamma_2\); \(\varphi = \operatorname{Eq}(N(f(x)), N(g(y)))\) | rebuild when a head is a λ or the spine is ACU or literal; else structural |
absThm |
\(v\) is a local; \(v \notin \operatorname{locs}(A)\) for each \(A \in \Gamma_1\), from the locals facts | \(\Gamma = \Gamma_1\); \(\varphi = \operatorname{Eq}(\lambda_v s, \lambda_v t)\) | rebuild (abstraction) |
eqMp |
sides \((A, B)\); \(\varphi_2 = A\) | \(\Gamma = \Gamma_1 \cup \Gamma_2\); \(\varphi = B\) | structural |
deductAntisym |
none | \(\Gamma = (\Gamma_1 \setminus \{\varphi_2\}) \cup (\Gamma_2 \setminus \{\varphi_1\})\); \(\varphi = \operatorname{Eq}(\varphi_1, \varphi_2)\) | structural |
proveHyp |
none | \(\Gamma = \Gamma_1 \cup (\Gamma_2 \setminus \{\varphi_1\})\); \(\varphi = \varphi_2\) | structural |
inst |
admissibility of each pair of \(\theta\) (snapshot); \(\mu(\ell) : \tau_\ell\theta\) for every \(\ell \in V_1\), with \(\tau_\ell\theta\) built and looked up | \(\Gamma\) equals the sorted, deduplicated ids of \(A[\theta; \mu]\), \(A \in \Gamma_1\); \(\varphi = \varphi_1[\theta; \mu]\) | rebuild |
use |
\(d\) visible in \(T\) and of a usable kind; \(\lvert\bar\tau\rvert = \lvert\bar\alpha_d\rvert\); admissibility | \(N(\operatorname{stmt}(d)[\bar\alpha_d := \bar\tau])\) accepts \(s\) (Definition Q-2): peeled at \(V\) in binding order and \(\lvert\Gamma\rvert\) antecedents (Lemma Q-2(4)), its binder types are those of \(V\), its antecedents are the closed forms of \(\Gamma\) in any order, and the rest is the closed form of \(\varphi\) | rebuild |
ofClass |
\(\tau : \{c\}\) (snapshot) | \(\Gamma = \emptyset\); \(\varphi = N(\mathsf{of\_class}_c(\mathsf{TYPE}[\tau]))\) | structural |
| LIFT | \(H_1 \sqsubseteq T'\); every local of \(V\) on \(\beta'\)'s chain | \(\Gamma\) equals the sorted, deduplicated ids of \(N_{\Sigma'}(A)\), \(A \in \Gamma_1\); \(\varphi = N_{\Sigma'}(\varphi_1)\) | rebuild, or facts of lifts |
A row with a trivial premise is checked against Definition Q-16: its
hypotheses as in this table, its conclusion by the first line of that
definition's table that applies. The False line checks only that
\(\varphi\)'s fact is canonical, of type \(\mathsf{Prop}\), with its locals in
\(V\), and for absThm that \(\varphi\) is an equation at a type
\(\tau_v \to \sigma\) whose sides are abstractions over \(\tau_v\) and in
which \(v\) does not occur. The absThm \(\mathsf{True}\) line reads \(u\) from
\(\varphi\) and checks that its body is a literal. In inst, the listed variables of \(\theta\), and the listed
locals of \(\mu\), are distinct, and the listed locals lie in \(V_1\). The
declaration kinds are checked as the rules Definition Q-17 names.
Requirement Q-R1 (facts). A fact of a bound-closed node \(t\) for a signature theory gives exactly: the type of \(t\); whether \(t\) is canonical for that signature; \(\operatorname{home}_\Sigma(t)\); the innermost frame that fixes a local of \(t\); \(\operatorname{locs}(t)\); and \(\operatorname{tv}(t)\). The checks above need the locals and the sorted type variables of a term, as K1.6 and K2.8 record them.
Requirement Q-R2 (engine and lookups). The construction engine computes, in scratch, the canonical forms that the constructors of Theorem C-7 compute, including the instantiation at function types of K2.9. Every comparison of two nodes that the engine makes while it builds (a unit, an ACU argument, a literal) decides equality of the terms they denote, whether each is a stored row or a scratch node (Lemma LC-6). A scratch result maps to the id of the stored node with the same content, below the checked row, or to nothing. Hash-consing is exact (Requirement S-R2), so equal ids mean equal terms.
Requirement Q-R3 (snapshot). The checked theory snapshot answers inclusion and joins (Lemma T-9), signature theories (Definitions T-1 and Y-15a), membership with the declarations it uses (Definition Y-9), witnessing with the declarations of the witness (Definition Y-12a), and sort entailment, exactly as those definitions state.
Theorem Q-26 (the checks are exact). Assume Requirements Q-R1 to Q-R3, and that the premise rows' fields form sequents and records. A row of a sequent rule passes its check if and only if it is an instance of the rule. That is: the row's operands are admissible parameters of the rule, and its stored \(\Gamma\), \(\varphi\), \(V\), \(S\), \(\beta\), \(H\) and \(D\) are those that Definitions Q-4, Q-7 to Q-11, Q-16 and Q-17 give for its premises and operands.
Proof. Each condition of the rule and of (R1) to (R5) is decided by exactly one step of the check, and each step decides its condition exactly:
- Identity. Two stored terms are equal exactly when their ids are equal
(Requirement S-R2). So a comparison of ids decides equality of parts,
the middle terms of
trans, and \(\varphi_2 = A\) ineqMp. - Trivial premises. \(\mathsf{True}\) and \(\mathsf{False}\) are single nodes, so whether a premise is trivial, and which line of Definition Q-16 applies, are comparisons of ids.
- Sets. A finite set has one sorted, deduplicated list. Merging two such lists computes their union, removing one id computes a difference, and a merge decides inclusion. So \(\Gamma\), \(V_r \subseteq V\), \(D\) and \(S\) are decided exactly.
- Built terms. The engine computes the rule's canonical term (Theorem C-7, Requirement Q-R2). If that term equals the stored part, every subterm of it is a stored node below the part (Lemma LC-1(3)), so the bottom-up mapping, with lookups bounded by the checked row, finds each node and ends at the part's id. If the mapping misses or ends at another id, the term differs from the stored part (Lemma LC-6), and the refusal is correct. For a set of rebuilt hypotheses, the check sorts and deduplicates the found ids and compares lists. This computes the set \(\{A[\theta; \mu]\}\) exactly, merging coinciding images.
use. By Lemma Q-2b(5), \(N(\operatorname{stmt}(d)[\bar\alpha_d := \bar\tau])\) accepts \(s\) exactly when it is \(F_{\pi_b}(B_1 \to \dots \to B_n \to C)\) with the binder types of \(V\) in binding order, \(\{B_1, \dots, B_n\} = \{c_{\pi_b}(A) \mid A \in \Gamma\}\), and \(C = c_{\pi_b}(\varphi)\). The closed forms are distinct (Lemma Q-2b(4)), so the check peels \(k\) binders and \(n\) antecedents, compares the sorted antecedents by identity with the sorted closed forms of \(\Gamma\) and the rest with \(c_{\pi_b}(\varphi)\), and builds only these closed forms in scratch, never \(\operatorname{cl}(s)\), which need not be stored.- Facts and the snapshot. Facts decide typing, canonicity, scope, homes
and locals (Requirement Q-R1). The snapshot decides inclusion, joins,
membership, witnessing and entailment (Requirement Q-R3). Context
extension and frames are
termbank's answers. So C1 to C3, the side conditions, and (R3) to (R5) are decided exactly.
Hence the check passes exactly when every condition holds, which is when
the row is an instance. Exhausting the budget refuses (LIMIT) and
never accepts. \(\square\)
Corollary Q-27 (rows are determined by premises and operands). For
every sequent rule other than use, the conclusion, the hypotheses, the
sort hypotheses, the home and the declarations of a row are functions of
its premises' fields and its operands, except the conclusion of a row
with a \(\mathsf{False}\) premise (Definition Q-16), and the sort
hypotheses, home and declarations that depend on it. The operands include
the retained locals, the context, and the operand \(x\) of appThm with a
\(\mathsf{True}\) premise; \(V\) is \(V_r\) together with the retained locals.
For use, they are functions of \(d\), \(\bar\tau\), \(V\) and
\(\lvert\Gamma\rvert\). ST9 stores them all
the same, so that every check on load is local.
Proof. Definitions Q-4, Q-7 to Q-11 and Q-16 define each field as a function of these inputs, with the stated exception. \(\square\)
Edge cases¶
Discharging hypotheses¶
Hypotheses are canonical nodes, and sets are compared by identity:
deductAntisymremoves \(B\) from \(\Gamma_1\) and \(A\) from \(\Gamma_2\). A hypothesis that is \(=_E\) to \(B\) is the node \(B\), so it is removed too. OpenTheory removes only α-equivalent hypotheses. The kernel's conclusion may therefore have fewer hypotheses than the article's; it is still derivable (Theorem Q-16), and its closure is the one the reader gives the article's theorem, since the reader also forms hypotheses canonically (Definition OT-5).- When \(A = B\), the conclusion is \(\operatorname{Eq}(A, A)\), which is \(\mathsf{eq}[\mathsf{Prop}](A, A)\), and both removals take the same node.
- When \(A \in \Gamma\), the derivation of Theorem Q-16 has two entries for \(A\) in \(\Delta, h_A{:}A\); Definition D-1 allows that (A09). The bridge-rule expansion adds the second entry by (Weak), and its \((\to\mathrm I)\) discharges that one.
proveHypremoves \(A\) from \(\Gamma_2\) only. If \(A \notin \Gamma_2\), the conclusion is \(\Gamma_1 \cup \Gamma_2 \vdash B\), and the hypotheses of \(\Gamma_1\) stay although nothing uses them.- Unused hypotheses are always part of the meaning: the closure discharges every hypothesis by \((\to\mathrm I)\), used or not. A sequent never loses a hypothesis silently. The reader keeps this by "checked weakening" (Definition OT-5).
- Merging. Instantiation and LIFT may map two hypotheses to one node. The set then shrinks, and the derivation uses one entry twice (Theorems Q-18, Q-19 and Q-22).
α-equivalence and capture¶
Bound variables are de Bruijn indices, so α-equivalent terms are one
node. The article's bound-variable names never reach a canonical term.
Every comparison that OpenTheory makes up to α-equivalence the kernel makes
by identity of canonical forms: the middle terms of trans, the
proposition of eqMp, and the removals above. That comparison is \(=_E\),
which is coarser than α-equivalence, so the kernel accepts every step
OpenTheory accepts, and some more, each by a derivation.
Substitution for locals cannot capture: its values are bound-closed, and
locals are not indices (Definition S-11). inst therefore renames no
bound variable. Type instantiation creates new locals, of the instantiated
types, rather than retyping old ones: a local's type and name are part of
its binding site. OpenTheory's variables are pairs of a name and a type, so
the producer maps each such pair to one local; a mismatch only makes a
step fail.
The eigenvariable condition of absThm is checked on the canonical
hypotheses. A variable that occurs in an article hypothesis only inside
a redex, and disappears from its canonical form, does not block absThm.
The producer may be stricter.
Free locals that occur nowhere¶
\(V\) is explicit, and only absThm and inst remove locals from it. A
local that occurs in no part stays a quantifier of the closure. Dropping
it would turn \(\vdash \forall x{:}\tau.\, P\) into \(\vdash P\), which needs a
term of type \(\tau\) for (∀E). The logic core has no closed term of type
\(\alpha\). The rules of the deduction page remain sound when types may be
empty and contexts are valued vacuously, and in that reading
\(\forall x{:}\alpha.\, ((\forall y{:}\alpha.\, Q\,y) \to \exists y{:}\alpha.\, Q\,y)\)
holds while \((\forall y{:}\alpha.\, Q\,y) \to \exists y{:}\alpha.\, Q\,y\)
fails. So the sequent keeps the local.
Such locals arise in two ways:
- from
transthrough a middle term, which drops its locals from the parts but not from \(V\); - from canonical construction, which contracts the article's redexes. The producer then keeps the article's variables as retained locals, as Definition OT-5 requires.
absThm removes its variable by \((\xi)\), whose binder carries the type
(Theorem Q-14). inst replaces each local by a term, whose locals it
keeps (Theorem Q-18). A declaration witness that needs a closed statement
instantiates the remaining locals with closed terms; the classical
profile's choice constant supplies them (Definition Q-12).
Canonical forms in conclusions¶
Every conclusion is \(N_\Sigma\) of the term the rule builds, so the signature's equations apply:
- ACU spines. An ACU spine in a conclusion is flattened, its arguments
are sorted, and its units are removed.
appThmwith \(f = c(a)\), a partial application of an ACU constant, gives the sorted spine \(c(a, x)\). - Literal folding. Literal arguments are folded:
appThmwith \(f = \mathit{add}(1)\) and \(x = 1\) gives \(2\). - Comparisons.
EQevaluates an equation between literals of a kind's carrier to \(\mathsf{True}\) or \(\mathsf{False}\).reflof a literal concludes \(\mathsf{True}\),assumeof \(1 + 1 = 2\) assumes \(\mathsf{True}\), andtransthrough a non-literal middle term may conclude \(\mathsf{False}\). Definition Q-16 lets every equational rule take such a premise without stored sides; onlyappThmwith a \(\mathsf{True}\) second premise needs its argument \(x\) as an operand. The bridge-rule expansion splits on the three cases (Theorem Q-25). - Hypothesis order. The row closure orders hypotheses by their closed
forms, which contain no local; acceptance takes any order. A
Proven's statement is \(K\) of its proof's sequent, so its statement identity is the same for two proofs whose sequents are renamings of each other with equal \(k\) and \(n\) (Theorem Q-3a).
The signature is fixed per row: every premise has the row's signature (Definition Q-6(1)). A premise from a smaller signature first passes through LIFT, which recomputes its parts for the larger one, may merge or reorder its hypotheses (Theorem Q-5), and records the sorts of variables that lifting loses. The reverse direction does not exist: \(\Sigma \subseteq \Sigma'\) in every LIFT.
Homes and sort hypotheses after inst¶
Homes. Instantiation adds to the home:
- the homes of the types \(\theta(\alpha)\) and of the terms \(\mu(\ell)\);
- the theories after the instance and class-relation declarations \(M(\theta)\) that make \(\theta\) admissible. They are also added to \(D\) (Definition Y-11), so the result is never used where those memberships fail (Theorem D-8).
Sort hypotheses. A variable that \(\theta\) moves is instantiated, not
lost, so \(\operatorname{srt}(\alpha)\) is not recorded for it: the
conclusion keeps \(S_1\), as Theorem D-6's remark says. A sort is recorded
only for a variable of a \(\theta(\alpha)\) or a \(\mu(\ell)\) that canonical
construction drops, or for a variable of \(s_1\) that \(\theta\) does not move
and that disappears. This happens when a unit is removed or a redex is
contracted, and it is the use clause of Definition Y-13. inst
applies to a premise whose sort hypotheses are not witnessed: it carries
them (Theorem Q-23).
Canonical forms. \(\theta\) may make a spine an ACU spine that was not one: \(c[\tau]\) with \(\tau : S\) for a class-level declaration at \(S\). The conclusion is then sorted anew, and the derivation is Theorem D-6's (Lemma C-9(3)). Conversely, \(\theta\) may move a class-level carrier to a function type, where the spine stops being ACU and is read nested to the right in its stored order (Definitions Y-14 and Y-15). The derivation then needs the cited laws. Corollary D-6a's derivation contains them, so (InstType) concludes the canonical form and the bridge-rule expansion needs no extra step. Theorem Q-19 gives a second derivation, through the closure. These laws are declarations of \(\operatorname{sig}(T)\), so \(D\) is unchanged.
Placement¶
A row's context \(\beta\) extends its premises' contexts (R1), as K1.8
places a rule's result. The locals of \(V\) are therefore usable in
\(\beta\)'s theory, and the bridge-rule expansion can realize \(\operatorname{E}(s)\)
by assuming the hypotheses in \(\beta\). \(\beta\) plays no part in \(J(s)\).
Entries of \(\beta\) that are not in \(V\) are unused, and export skips them
(Theorem D-4). LIFT is the one rule that may change the chain: it may move
a sequent to a sibling theory that includes its home, as Theorems D-8 and
D-7 allow, provided the new context fixes the locals of \(V\).
Summary¶
| Rule | Rules of the expansion (Definition Q-13) | \(E\) | Check | Admissibility |
|---|---|---|---|---|
refl, betaConv |
(Refl) | none | structural | Theorem Q-9 |
assume |
(Hyp) | none | structural | Theorem Q-10 |
sym |
(Sym) | none | structural | Theorem Q-11 |
trans |
(Trans) | none | structural | Theorem Q-12 |
appThm |
(Cong) | none | rebuild or structural | Theorem Q-13 |
absThm |
\((\xi)\) at \(v\) | none | rebuild | Theorem Q-14 |
eqMp |
(Subst) with the identity on \(\mathsf{Prop}\) | none | structural | Theorem Q-15 |
deductAntisym |
\((\to\mathrm I)\) twice, (Use) of propext, \((\to\mathrm E)\) |
propext |
structural | Theorem Q-16 |
proveHyp |
\((\to\mathrm I)\), \((\to\mathrm E)\) | none | structural | Theorem Q-17 |
| trivial premises | \((\bot\mathrm E)\), \((\top\mathrm I)\), (Refl), (Cong); for absThm, \((\xi)\), \((\forall\mathrm I)\), \((\forall\mathrm E)\) |
none | structural, or rebuild for appThm and absThm |
Theorem Q-28 |
subst |
(Transport) | none | rebuild | Theorem Q-18 (derived) |
inst |
(InstType), (Transport) | \(M(\theta)\) | rebuild | Theorem Q-19 |
use |
(Use), (Hyp), \((\to\mathrm E)\) | \(d\), \(M(\bar\tau)\) | rebuild (peel) | Theorem Q-20 |
ofClass |
of_class |
the class, \(M\) | structural | Theorem Q-21 |
| LIFT | (Transport) | none | rebuild | Theorem Q-22 |
| sort hypotheses of every rule | Definition Y-13 as one step | witnesses | merges | Theorem Q-23 |
| declaration commands | existing declaration forms | their own | theory pass | Theorem Q-24 |
| declaration kinds of TD1.8 | as use or ofClass (Definition Q-17) |
as those rules | as those rules | Theorems Q-20 and Q-21 |