Logic & kernel theory

Local checking

This page proves that the kernel may check a stored proof one row at a time, each row against the rows it references, in any order and in parallel, and that every statement below the verified watermark is derivable. It is the theory of the stateless kernel:

  • termbank stores an immutable DAG of rows in one commit sequence (DAG storage, TD1.x);
  • the kernel's pure checks read it (the checker, KC1.x);
  • a library publishes it (ST9, ST9.x).

The sequent rules of article steps, their reading as judgments, their admissibility theorems and their own local checks are on the sequents page (results Q-n). This page states what every check shares and gives the local checks of the rules of K1.8 and K2.8, of export, and of LIFT.

The argument has three parts.

  1. Facts are functions. The type, canonicity, home, and sorted variables of a (term, signature) pair do not depend on which check computes them, or when (Theorem LC-4).
  2. Checks are local. A row's check passes only when the row's claim follows from the claims of the rows it references by a rule of the deduction page or an admissible rule (Proposition LC-8). Induction on the commit sequence then gives soundness below the watermark (Theorem LC-12).
  3. Checks read only their cone. So they commute, and a chunk's verdict does not depend on scheduling (Theorems LC-16 and LC-18).

Requirement B-R1 of checking at the boundary becomes a theorem here, under the storage requirements LC-R1 to LC-R5 and LC-R8, which termbank must meet, and the trusted requirement LC-R6, which the kernel must meet. Workspaces add LC-R7.

The stored DAG

Definition LC-1 (rows). A row \(r\) has a kind \(\kappa(r)\), a sequence number \(\operatorname{seq}(r) \in \mathbb N\), scalar fields, and an ordered list \(\operatorname{ref}(r)\) of references to rows. The kinds, and what a row of each kind denotes:

Kind Content Denotes
type node a head (tvar, arrow, or a type-constructor declaration), a payload, arguments a type (Definition S-1); a sorted variable has its classes as arguments (K2.8)
term node a head (structural, or a constant or literal-kind declaration), a payload, arguments; structural hash, loose bound, flags a term (Definition S-4), read as termbank's data model and Requirement S-R3 read nodes
local a parent frame, a type node, a name a local \(\ell: \tau\) (K1.5)
set a strictly increasing list of tagged items a set of hypotheses (term nodes, for a sequent), or of locals, declarations, sorts, and hypotheses (assume frames, for a natural-deduction row) (K1.7, K2.8)
frame a parent frame, a theory, an entry (none, a local, or a proposition), and derived fields: depth, ancestor pointers, sorted variables a context (K1.5, Definition D-1); a frame with a proposition is an assume frame, and it is the hypothesis \(h: A_h\) it adds; Definition LC-7
declaration a form (K1.3, K2.6 to K2.8), a name, a segment and position, a parent theory, operand rows a declaration (Definition T-1)
theory a version vector of (segment, count) entries, a kind (extension, merge, or join), and for a join its ambient theory a theory (Lemma T-9); its signature theory is a snapshot answer
segment a base theory a declaration segment (K1.3)
proof a rule tag, premises, arguments, a conclusion, a frame, a signature, a hypothesis set, a dependency set, a home a claimed judgment (Definition LC-8)

\(\operatorname{ref}(r)\) holds the reference fields of \(r\) and one reference that storage resolves by index rather than by a field: a theory row references, for each entry (segment, \(k\)) with \(k \ge 1\), its generator, the declaration at position \(k\) of that segment. That declaration references its parent theory, so the cone of a theory row holds every declaration the theory counts. A term node with the head local references its local row through its payload, a field.

A head that names a declaration is a reference to the declaration's row, so the declarations a term mentions are among the rows it references.

Facts and snapshot entries are not rows. They are keyed values, published by verdicts (Definition LC-14): they take no sequence number, are found only by their keys, and no row references them. They lie outside the induction of Theorem LC-12, which never assumes anything of them beyond Lemma LC-11: each holds the value of its key.

Definition LC-2 (stores, cones, dependents). The base \(\mathcal B\) is the set of committed rows, and \(N = \lvert\mathcal B\rvert\). Its prefix of length \(n\) is \(D_n = \{\, r \in \mathcal B \mid \operatorname{seq}(r) < n \,\}\). The cone \(\operatorname{cone}(r)\) of a row is the least set that contains \(r\) and every row referenced by a member. The dependents of \(r\) are \(\operatorname{dep}(r) = \{\, r' \mid r \in \operatorname{cone}(r') \,\}\), and \(\operatorname{dep}(F) = \bigcup_{r \in F} \operatorname{dep}(r)\).

Definition LC-3 (content, deduplicated kinds). The content of a row is its kind, its scalar fields other than the sequence number, and its references, each taken as a row identity. The deduplicated kinds are pool entries, type and term nodes, sets, theories, locals (by binding site), frames, and proofs. Theory rows are deduplicated by their vector alone: the vector determines the theory (Lemma T-9), and the first row of a vector keeps the kind and ambient it records; in LC-R4 and Lemma LC-2 a theory row's content is read as its vector. Heads, segments, and declarations are fresh: each declaration makes a new row, so same-named declarations of sibling theories are different constants (Requirement S-R3). A local and its fix frame are committed together. Two fixes of one name and type over one frame are one local, and two assumptions of one proposition over one frame one hypothesis. Along a chain every entry is distinct (Lemma LC-25).

termbank must keep the following requirements. They are its part of the trusted base, and every theorem below assumes them.

Requirement Statement
LC-R1 (one commit sequence) \(\operatorname{seq}\) is a bijection from \(\mathcal B\) onto \(\{0, \dots, N - 1\}\). A commit appends rows with the next numbers, in order; \(N\) never decreases.
LC-R2 (references point down) For every row \(r\) and every \(r' \in \operatorname{ref}(r)\), \(\operatorname{seq}(r') < \operatorname{seq}(r)\), the index-resolved reference of Definition LC-1 included: a theory row is committed after its generators. A local node's payload is a field. A commit that would reference a row not yet committed is refused.
LC-R3 (immutability) The content of a committed row never changes, and no row of \(\mathcal B\) is removed. A reader of \(D_n\) needs no lock once \(n\) is published.
LC-R4 (exact deduplication) Two distinct rows of one deduplicated kind never have equal content. Hashes only find candidates; equality is decided by comparing contents exactly (G15), so the weak_hash build, where every hash collides, gives the same rows.
LC-R5 (watermark and publication) The watermark \(\omega \le N\) changes only when a verdict is applied (Definition LC-14) and never decreases. Facts and snapshot entries are inserted only from applied verdicts, under their exact keys, and are never overwritten or removed. A view \(V_n\) reads \(D_n\) and the published facts and entries; views given to sessions and callers have \(n \le \omega\).
LC-R8 (structural invariants at commit) termbank computes, at commit, a node's structural hash, loose bound, and flags from its content (T1.5), and refuses a node whose child count does not fit its head; it refuses a set whose items are not strictly increasing or not of their tags' kinds, a local row without a name, or that its fix frame does not follow, and a version vector whose entries are not strictly increasing by segment or count more declarations than the segment holds. It refuses a proof row whose kind is unassigned, CERTIFICATE or SEALED, or whose operands do not fit its kind's layout. Nodes, sets, pool entries, heads, segments and locals therefore pass without a check, and no check repeats these conditions (Definition LC-11).

Version vectors, sets, and the rows of a deduplicated kind are therefore interned exactly (K1.3, K1.7), and a content hash is never an id.

Lemma LC-1 (induction on the commit sequence). Under LC-R1 to LC-R3:

  1. the references of \(\mathcal B\) form a finite acyclic graph;
  2. \(\operatorname{cone}(r) \subseteq D_{\operatorname{seq}(r) + 1}\), and the cone of a row is fixed when the row is committed;
  3. every prefix \(D_n\) is closed under references;
  4. a property of rows may be proved by strong induction on \(\operatorname{seq}\), assuming it for every row of smaller number, in particular for the references.

Proof. Sequence numbers strictly decrease along references (LC-R2), so there is no cycle, and induction on \(\operatorname{seq}\) is well founded. By induction, every row of \(\operatorname{cone}(r)\) has a number at most \(\operatorname{seq}(r)\); the rows it contains and their references never change (LC-R3). (3) follows from (2). \(\square\)

Lemma LC-2 (identity is content). For rows \(r\) and \(r'\) of one deduplicated kind, \(r = r'\) exactly when they denote the same object: the same type or term, the same set, the same theory, the same binding site (parent frame, type and name), the same frame (its parent and its entry, or for a frame without an entry its parent and theory), or the same rule instance with the same stored fields.

Proof. Induction on \(\operatorname{seq}(r) + \operatorname{seq}(r')\). The encoding of a term by its head, payload, and arguments is injective on spine-normal terms (Requirement S-R3), as are the encodings of the other kinds: a set by its sorted list, a theory by its version vector (Lemma T-9). So the two rows denote the same object exactly when their references denote the same objects and their other fields agree; by the induction hypothesis the references then are the same rows, so the contents are equal, and by LC-R4 the rows are one row. \(\square\)

Lemma LC-2 is Requirement S-R2 for every deduplicated kind: comparing terms, sets, and theories is comparing row identities.

Verified facts

Typing, canonicity, and home theories are properties of a term for a signature, not of a node alone (K1.6): rule (ACU) of Definition T-4 consults \(\mathrm{ACU}(\Sigma)\), canonical form is \(N_\Sigma\) (Definition C-4), and a home includes the ACU declarations that the spines of the signature need. Inside a binder they also depend on the types of the enclosing binders (A07). A signature below is a theory row that is its own signature theory (Definitions T-1 and Y-15a).

Definition LC-4 (node facts). Let \(\Sigma\) be a signature, \(u\) a term node, and \(\Delta\) a binder environment (Definition T-3) with \(\lvert\Delta\rvert \ge \operatorname{lb}(u)\). Let \(L\) be the local typing given by the local rows, each local with its fixed type. The node fact \(\operatorname{nf}_\Sigma(u, \Delta)\) has five components:

  • \(\operatorname{ty}\): the type \(\tau\) with \(\Delta; L \vdash u: \tau\) in \(\Sigma\), or the error ILL_TYPED when there is none;
  • \(\operatorname{can}\): whether \(u\) is canonical for \(\Sigma\);
  • \(\operatorname{home}\): the join of the theory just after each declaration of a constant, type constructor, or literal kind in \(u\), of the theory just after each ACU declaration of \(\Sigma\) that a spine of \(u\) with three or more arguments needs, of the homes of the types of its locals, and of the root theory (K1.6);
  • \(\operatorname{loc}\): the locals of \(u\);
  • \(\operatorname{sv}\): the sorted type variables of \(u\) (K2.8).

Only the first \(\operatorname{lb}(u)\) entries of \(\Delta\) are read, so the key of a node fact is \((u, \Delta_{<\operatorname{lb}(u)}, \Sigma)\). For a type node the fact is its well-formedness (Definition T-2), its home, and its sorted variables, and does not depend on \(\Sigma\).

Lemma LC-3 (node facts are node-local). Let \(u\) have children \(c_1, \dots, c_k\), and let \(\Delta_i = \tau \cdot \Delta\) when \(c_i\) is the body of a λ or a let with binder type \(\tau\), and \(\Delta_i = \Delta\) otherwise. Then \(\operatorname{nf}_\Sigma(u, \Delta)\) is determined by the content of \(u\), by \(\Delta_{<\operatorname{lb}(u)}\), by the rows \(u\) references (its declaration, its local), by the canonical declarations of \(\Sigma\), and by the facts \(\operatorname{nf}_\Sigma(c_i, \Delta_i)\).

Proof. Component by component.

  • \(\operatorname{ty}\): typing is syntax-directed (Proposition T-6). Each rule of Definition T-4 reads only the children's types, \(\Delta_i\) for a bound variable (Var), the local row's type (Loc), the declaration row's type and stored type parameters (Const), the kind's carrier (Lit), and, for (ACU), whether the head's instance is in \(\mathrm{ACU}(\Sigma)\). That is decided by one-way matching against \(\Sigma\)'s ACU declarations, of which at most one matches (Definition T-6, condition 5), with membership for a class-level declaration decided in \(\Sigma\) (Definition Y-15, Lemma Y-4b). Types are unique (Theorem T-1), so the component is a value, not a choice.
  • \(\operatorname{can}\): by Theorem C-6(3) a term is canonical exactly when it is β-normal and A-canonical. Both hold for \(u\) exactly when they hold for every child and \(u\) itself satisfies the conditions of the proof of Theorem C-5(2): no spine has a λ or a spine as its head; a spine of an ACU instance has at least two arguments, none a spine of the same instance or its unit, at most one literal of the bound kind and not the unit, in the structural order (T1.6, a function of the argument rows); and no literal operation is left that would evaluate, which depends only on its arguments' values (Requirement L3).
  • \(\operatorname{home}\), \(\operatorname{loc}\), \(\operatorname{sv}\): unions and joins over the children with \(u\)'s own contribution. A join is the pointwise maximum of version vectors (Lemma T-9(3)). \(\square\)

Definition LC-5 (verified facts). For a bound-closed term node \(t\) and a signature \(\Sigma\), the fact \(\operatorname{Fact}_\Sigma(t)\) is \(\operatorname{nf}_\Sigma(t, [\,])\) together with the scope of \(t\): the deepest of the frames that fix its locals, or the error SCOPE when they do not lie on one chain (K1.6). For a type node, \(\operatorname{Fact}(\tau)\) is its node fact. A fact computation for \((t, \Sigma)\) visits the keys reachable from \((t, [\,], \Sigma)\) through the children of Lemma LC-3, children first, computes each node fact from its children's by the rules of that lemma, and keeps them in a memo keyed by the whole key (G15). For a bound-closed child it may instead read a published fact.

The A07 test is the reason for the key: a memo keyed by the node alone would give \(\#0\) under \(\lambda{:}\tau\) the type it had under \(\lambda{:}\tau'\), and admit an ill-typed application.

Theorem LC-4 (facts are functions). \(\operatorname{nf}_\Sigma(u, \Delta)\) and \(\operatorname{Fact}_\Sigma(t)\) are functions of their keys and of the contents of the rows in the cones of \(u\) (respectively \(t\)) and \(\Sigma\). Every fact computation, in any order of traversal, with a memo whose entries hold node facts under full keys, and with any set of published facts that hold the values of their keys, returns \(\operatorname{Fact}_\Sigma(t)\).

Proof. Lemma LC-3 defines \(\operatorname{nf}\) by recursion on keys, which is well founded because children have smaller sequence numbers (LC-R2), and it reads only rows of the cones, which never change (Lemma LC-1(2)). So it defines a function, fixed once \(t\) and \(\Sigma\) are committed. For a computation, induct on the order in which it finishes keys: each value is computed by the rule of Lemma LC-3 from children's values, each of which is a memo entry under its full key, a published fact, or a value finished earlier, and so equals the function's value by the induction hypothesis or by assumption. The scope is a function of the local rows of \(\operatorname{loc}(t)\) and their frames. \(\square\)

Corollary LC-5 (publication is idempotent and order-free). If every fact is published from a fact computation (LC-R5 and LC-R6), then at every moment every published fact is the value of its key. Publishing a fact twice publishes the same value, and the facts published after a set of verdicts do not depend on the order of the verdicts.

Proof. Induction on the order of publication: a computation reads only facts published before it, which hold their values by the induction hypothesis, and returns the value of its key by Theorem LC-4. \(\square\)

In particular a fact computed by any chunk, before or after any other row's verdict, is the same value, and a check may read a published fact instead of computing it. The value of a fact says nothing about whether any proof is valid: it is a property of syntax relative to the declaration rows its cone contains. Whether those declarations are themselves valid is the theory pass's question (Proposition LC-9), and every proof row whose check reads the fact has them in its cone.

Scratch

Definition LC-6 (scratch). A check of a row \(r\) runs against a view \(V_n\) whose length \(n\) is fixed for the whole check and exceeds \(\operatorname{seq}(r)\). Every lookup it makes is bounded by \(r\): it finds only rows numbered below \(\operatorname{seq}(r)\). Its scratch is a private store of scratch nodes, reset between chunks. A scratch node has the shape of a stored node: a head, a payload, and arguments, each a row below \(r\) or a scratch node. The construction engine (C1.1, C1.2) builds into scratch: mk_app with its β-, ACU-, and literal steps, instantiate, abstract, subst_types, lifting, and unfolding.

Two nodes are equal when both are rows and are one row, or when their heads and payloads agree and their arguments are pairwise equal. The engine decides equality of every pair of nodes it compares exactly so: by identity of rows, and otherwise by its heads, payloads and the equality of its arguments, recursively, with structural hashes only as a filter (G15). An engine may instead intern each scratch node it makes: return the row below \(r\) of that content when an exact, bounded lookup finds one, and otherwise the one scratch node of that content. Then equal nodes are identical, and comparison is by identity. Mapping a scratch result replaces its nodes, bottom-up, by the rows below \(r\) of the same content, found by bounded lookups; a node with a child that does not map does not map.

Lemma LC-6 (scratch equality is term equality). Within one check, two nodes, rows or scratch nodes, are equal exactly when they denote the same term. A scratch result maps to a row exactly when the term it denotes is the term of a row below \(r\), and then to that row.

Proof. Induction on the depth of the two nodes. Two rows: Lemma LC-2. Otherwise the encoding by head, payload, and arguments is injective on spine-normal terms (Requirement S-R3), so the nodes denote one term exactly when their heads and payloads agree and their arguments denote the same terms, which by the induction hypothesis is when they are equal. An interning engine returns a row exactly when one of that content exists, so the same holds of identity. For mapping: if the term is that of a row \(x\) below \(r\), every subterm of it is the term of a row below \(x\) (Lemma LC-1(3)), and by induction from the leaves each node maps to the row of its term, which is unique (LC-R4); the root maps to \(x\). If the term is not stored below \(r\), the root has no row of its content, and does not map. \(\square\)

Corollary. A check that rebuilds a term in scratch, maps it, and compares the result with a stored row by identity decides whether the two terms are equal. A miss proves that the rebuilt term is not stored below \(r\), so in particular that it is not the stored conclusion, which lies below \(r\) (LC-R2), and the check refuses. Lookups are bounded by \(r\), not by \(n\), so which rows they find is fixed by \(D_{\operatorname{seq}(r)}\), and no decision depends on \(n\) or on timing. A row found this way need not lie in \(\operatorname{cone}(r)\), but its content is the content the check built from the cone, and the check uses it only to compare it with fields of \(r\), which are in the cone.

By Theorem C-7, rebuilding with canonical inputs gives \(N_\Sigma\) of the term the rule describes; an input that its fact shows is not canonical for \(\Sigma\) is lifted first (Corollary C-9a).

Contexts, claims, and placement

Definition LC-7 (frame rows). A frame row \(f\) has a parent frame \(p\), a theory \(T(f)\), and an entry: none, a local row \(\ell\), or a proposition \(A_h\), a term node. A frame with a proposition is an assume frame; it is itself the hypothesis \(h\) it adds, so a hypothesis is its frame. The root frame has no parent, the root theory, and no entry. A frame denotes the context \(\Gamma(f)\): \(\Gamma(p)\), extended by \(\ell: \tau_\ell\) or \(h: A_h\) when \(f\) has that entry. Its entry frame \(e(f)\) is \(f\) when \(f\) has an entry, the root frame when \(f\) is the root, and \(e(p)\) otherwise. The frame of a local \(\ell\) is the frame just after it, \(\operatorname{seq}(\ell) + 1\), by (3). The local check of \(f\) (Definition LC-11) requires:

  1. \(T(f) \sqsupseteq T(p)\), decided on version vectors (Lemma T-9(2));
  2. without an entry: \(p\) has an entry or is the root, and \(T(f) \ne T(p)\), so frames without an entry never stack (K1.5);
  3. with the entry \(\ell\): \(\ell\) is the row just before \(f\), \(\operatorname{seq}(\ell) = \operatorname{seq}(f) - 1\), so that no other frame fixes it, and no ancestor in particular, and \(\ell\)'s parent is \(p\); \(T(f) = T(p)\); \(\tau_\ell\) is well formed and its home is included in \(T(f)\);
  4. with the entry \(A_h\): \(T(f) = T(p)\); \(\operatorname{Fact}_{\operatorname{sig}(T(f))}(A_h)\) has type \(\mathsf{Prop}\), is canonical, has its home included in \(T(f)\), and has its scope on the chain of \(p\) (an ancestor of \(e(p)\), or \(e(p)\)), so \(A_h\) mentions only locals fixed before \(h\);
  5. the derived fields are computed from \(p\)'s: depth plus one, the ancestor pointers of K1.5, and the sorted variables of \(\Gamma(f)\), the union of \(p\)'s and those of the entry (K2.8).

Conditions (3) and (4) carry the eigenvariable conditions of the deduction page: \((\forall\mathrm I)\) and \((\xi)\) generalize the last entry, and no hypothesis before it can mention it. A frame that skipped them would let forall_intro generalize a local that an earlier hypothesis mentions. So frames are checked rows, unlike nodes and sets (LC-R8).

A context \(\Delta\) extends \(\Gamma\), \(\Gamma \preceq \Delta\), when \(e(\Gamma)\) is \(e(\Delta)\) or one of its ancestors and \(T(\Delta) \sqsupseteq T(\Gamma)\) (K1.5, Corollary D-9).

Ancestry is decided with the ancestor pointers, which reference frames below; the check of a frame therefore reads a bounded number of rows of its cone. The adjacency in (3) is one way to make each local belong to exactly one frame; any representation in which that is checked locally serves. Two fixes of one name and type over \(p\) are one local and one frame, and two assumptions of one proposition one frame (TD1.7).

Definition LC-8 (proof rows, claims, sound claims). A proof row \(r\) has a rule tag \(\rho\), premises \(p_1, \dots, p_k\) (proof rows), arguments in the layout of \(\rho\) (K1.10), and the stored fields: a conclusion \(A_r\) (a term node), a frame \(\Gamma_r\), a signature, a hypothesis set \(H_r\) of assume frames, a dependency set \(S_r\) of locals, declarations, and sort hypotheses (K1.7, K2.8), and a home \(h_r\) (a theory row). For a natural-deduction row, \(H_r\) is stored as the hypothesis items of the dependency set, and the row's set of hypothesis propositions is empty; for a sequent row, the propositions are \(\Gamma\) and the dependency set has no hypothesis item (Definition Q-15). Write \(T_r = T(\Gamma_r)\) and \(\Sigma_r = \operatorname{sig}(T_r)\), the snapshot's answer, which the stored signature must equal. The claim of \(r\) is \(\operatorname{cl}(r) = (\Gamma_r, A_r, H_r, S_r, h_r)\). It is sound when:

  1. \(\Gamma_r\) is a context of \(T_r\) (Definition D-1), and \(A_r\) is a proposition canonical for \(\Sigma_r\), usable in \(\Gamma_r\) (K1.6);
  2. there is a derivation \(\mathcal D\) of \(\Gamma_r \vdash A_r\) in \(T_r\), by the rules of the deduction page and the class rules of Definition Y-14, with \(\operatorname{hyps}(\mathcal D) \subseteq H_r\), \(\operatorname{locs}(\mathcal D) \cup \operatorname{decls}(\mathcal D) \subseteq S_r\) (Definition D-4, with the instance declarations of Definition Y-11), and \(\operatorname{home}(\mathcal D) \sqsubseteq h_r \sqsubseteq T_r\) (Definition D-5);
  3. for every theory \(T^* \sqsupseteq h_r\) and every ground model of \(T^*\) in which each sort of \(S_r\) has a ground type, \(\Gamma_r \vdash A_r\) is valid (Definitions Y-6 and Y-12).

Condition (3) is the semantic form of the sort-hypothesis record, as (E2) is for sequents (Definition Q-5). Rule by rule it follows from the premises' (3) by the one-step argument of Theorems Y-5 and Q-23, which is what Definition Y-13's bookkeeping records; stating it semantically lets one induction cover natural-deduction rows, sequent rows, and inst, whose instantiated derivation keeps its premise's sort hypotheses rather than recomputing them (Theorem D-6).

A sound claim is all that the semantics needs: by Theorems D-2, D-8, and D-7, \(A_r\) then holds, in the subcontext of \(H_r\) and the locals of \(S_r\), in every theory that includes \(h_r\), and by (3) it is valid in every ground model of such a theory in which the sorts of \(S_r\) are inhabited. The checks below compute \(H_r\), \(S_r\), and \(h_r\) rule by rule, as K1.7 does, so the inclusions are equalities for the derivation the rows spell out; soundness uses only the inclusions.

A sequent row's claim is its judgment \(J(s)\), read as Definition LC-21 says; its soundness is that the row is established (Definition Q-5).

Definition LC-21 (readings across row kinds). A rule of one kind may cite a row of the other kind only as follows.

  1. A natural-deduction rule that cites a sequent row \(s\) reads the claim \((\Gamma_0, \operatorname{cl}(s), \emptyset, D \cup S, H)\), where \(\Gamma_0\) is the root frame rebased to the theory \(T\) of \(s\): entry frame the root frame, theory \(T\). The check builds \(\operatorname{cl}(s)\), the row closure \(\operatorname{cl}_r(s)\), in scratch by Proposition Q-3(4); it need not be stored. The theory pass reads the proof of a Proven declaration the same way, with the canonical closure \(K(s)\) (Definition Q-3d) in place of \(\operatorname{cl}(s)\); \(\vdash K(s)\) and \(J(s)\) are derivable from each other with no declaration (Theorem Q-3b).
  2. A sequent rule cites a natural-deduction row \(p\) only when \(H_p\) is empty and \(S_p\) has no local. It reads the closed sequent \(\emptyset \vdash^{\emptyset}_{T_p} A_p\), with context \(\Gamma_p\), declarations and sort hypotheses those of \(S_p\), and home \(h_p\). The theory pass reads a natural-deduction proof of a Proven declaration the same way, so its statement is \(K\) of that closed sequent: \(A_p\) with its type variables renamed (Definition Q-3d(7)).

Lemma LC-24 (the readings are sound). If \(s\) is established, the claim of (1) is sound. If \(p\)'s claim is sound and \(p\) meets (2), the sequent of (2) is established.

Proof. (1) (E1) gives a derivation of \(\vdash \operatorname{cl}(s)\) in \(T\) with \(\operatorname{decls} \subseteq D\) and home in \(H\); it is in the empty context, so it uses no hypothesis and, its conclusion being closed, no local. (E3) gives \(H \sqsubseteq T\), (E2) is (3), and \(\operatorname{cl}(s)\) is a closed canonical proposition (Proposition Q-3(1)). The claim with \(K(s)\) is sound too: Theorem Q-3b derives \(\vdash K(s)\) from \(\vdash \operatorname{cl}(s)\) with no declaration and no term beyond the parts of \(s\), \(\mathsf{imp}\) and \(\mathsf{forall}\), under a sort-preserving renaming of type variables, so its declarations, home and sort hypotheses stay within \(D\), \(H\) and \(S\). (2) \(A_p\)'s locals lie in \(S_p\), so \(A_p\) is closed. By Theorem D-2 the derivation of \(p\) strengthens to the empty context, and by Theorem D-8 it lies in \(h_p\): that is (E1). (3) for the empty context is (E2), and \(h_p \sqsupseteq \Sigma_p\) by Definition LC-10, which gives (E3). \(\square\)

A sequent with free locals or hypotheses is read in place as \(\varphi\) in \(\beta\) by no rule: its hypotheses are not entries of \(\beta\), so that reading would drop them.

Definition LC-9 (placement). The site of a proof row is the frame where its result lies (K1.8): the entry frames of its premises' frames, of the frames it is given, and of the scopes of its term arguments must lie on one chain, and their theories, with those of the premises, must be ordered by inclusion (SCOPE otherwise). The site is the deepest entry frame rebased to the largest theory: that frame itself when its theory is the largest, and otherwise the frame without an entry over it in that theory, which is a deduplicated row (LC-R4). The exceptions are those of K1.8 and K1.9: imp_intro, forall_intro, and eq_abstract place their result at the parent of the discharged entry, rebased to the premise's theory; export at the outer context rebased to the premise's theory; transport at its target. The check compares \(\Gamma_r\) with the site by identity, and reads every premise at the site: its conclusion lifted to \(\Sigma_r\) when its signature differs.

By Corollary D-9, every premise's claim holds at the site, and by Corollary C-9a its lifted conclusion is \(=_E\)-equal in \(T_r\) to its conclusion, which is how the rules of the deduction page compare terms.

Definition LC-10 (summary equations). Let a proof row have premises \(p_i\), introduced terms \(\bar t\) (the term arguments of K1.8, such as \(t\) in forall_elim and eq_refl, \(Q\) in false_elim and convert, the other disjunct in or_left, \(P\) in eq_subst), used declarations \(U\) (the cited declaration of use, the unfolding set of convert, the class of of_class, and the instance declarations and class relations that its memberships rest on), and conclusion \(A\) at site \(\Gamma\). Its summary is:

  • \(H = \bigcup_i H_{p_i}\), less the hypothesis an imp_intro or an export discharges, and \(\{h\}\) for hypothesis(Γ, h);
  • the locals of \(S\): those of the \(S_{p_i}\), with \(\operatorname{loc}(A)\), \(\operatorname{loc}(\bar t)\), and the locals of a discharged hypothesis, less a local that forall_intro, eq_abstract, or export generalizes;
  • the declarations of \(S\): those of the \(S_{p_i}\), with \(U\);
  • the home \(h = \bigsqcup_i h_{p_i} \sqcup \bigsqcup_j \operatorname{home}_{\Sigma}(t_j) \sqcup \operatorname{home}_\Sigma(A) \sqcup \bigsqcup_{d \in U} \operatorname{after}(d) \sqcup \Sigma\), where \(\operatorname{after}(d)\) is the theory just after \(d\) (K1.7);
  • the sort hypotheses of \(S\): those of the \(S_{p_i}\), with the sort of every sorted type variable of the premises (their conclusions and frames, Definition LC-7(5)) and of the introduced terms \(\bar t\) (and, for use, of the type arguments) that the conclusion's judgment lacks, unless it is redundant: entailed by the sort of a variable the conclusion keeps, or witnessed in \(h\), in which case the instance declarations of its witness join the declarations of \(S\) (Definition Y-13, K2.8). unconstrain adds none for the variable it unconstrains.

transport(p, m) (Theorem D-5) replaces \(p\)'s hypotheses and locals by what \(m\) maps them to. Its premises are \(p\) and, for each \(h \in H_p\), the judgment \(q_h\) that \(m\) gives \(h\); its introduced terms are \(m(l)\) for each local \(l\) of \(S_p\). So \(H = \bigcup_{h \in H_p} H_{q_h}\); the locals of \(S\) are those of the \(S_{q_h}\), with \(\operatorname{loc}(m(l))\) for each local \(l\) of \(S_p\) and \(\operatorname{loc}(A)\), and none of \(S_p\)'s own; the declarations and sort hypotheses of \(S\) are those of \(S_p\) and of the \(S_{q_h}\), by the items above; and \(h = h_p \sqcup \bigsqcup_{h \in H_p} h_{q_h} \sqcup \bigsqcup_{l} \operatorname{home}_\Sigma(m(l)) \sqcup \operatorname{home}_\Sigma(A) \sqcup \Sigma\). A pair of \(m\) for a local outside \(S_p\) or a hypothesis outside \(H_p\) is checked as every pair is (Definition LC-11) but adds nothing to the summary; no local or hypothesis is mapped twice, and the order of the pairs is free. A sequent premise is read as its closure (Definition LC-21(1)): it has no hypothesis or local to map.

The sorted variables of a judgment are those of its conclusion and of its frame (Definition LC-7(5)). The check computes the summary in scratch, merging sorted sets and taking maxima of version vectors, and compares \(H_r\), \(S_r\), and \(h_r\) with it by identity (Lemma LC-2). Redundancy reads witness answers for \(h\) from the snapshot (Definition LC-13); the witnesses' instance declarations are included in \(h\), since the sort is witnessed there, so adding them leaves \(h\) unchanged.

The local check of each row

Definition LC-11 (local check). The local check of a row \(r\) reads \(r\), rows of \(\operatorname{cone}(r)\), facts, and snapshot answers, builds in scratch, and returns pass with the facts it used, or a refusal with its error kind, or LIMIT. By kind:

Kind The check
type and term nodes none: termbank's commit establishes the structural invariants (LC-R8): the head is structural or a declaration's, the argument count fits its arity, the payload fits its kind, and the structural hash, loose bound, and flags are computed from the content (T1.5, Requirement S-R1). Nothing semantic: raw syntax has no meaning (G8), and a node acquires one only through a fact
pool entry, head, segment none; their invariants are termbank's (LC-R8, T1.3, T1.4)
local none on its own; its frame checks it (Definition LC-7)
set none; strict order and item kinds are termbank's (LC-R8)
frame Definition LC-7
declaration, theory the theory pass (Definition LC-12)
proof the shared steps below, then the rule's row of the next table; a sequent rule's check is on the sequents page

The shared steps of a proof row's check:

  1. Layout. termbank's commit has established that the tag is an assigned kind other than CERTIFICATE and SEALED, which a stored DAG never holds, and that the operands fit its layout (K1.10) and reference rows of the kinds it names (LC-R8). The check relies on it and does not repeat it.
  2. Premises. Each premise is read as its claim; a sequent premise as its judgment (Definition LC-21(1)). Its verdict is not read: soundness of the premise is the induction hypothesis of Theorem LC-12, not a precondition of the check.
  3. Placement. The stored signature is \(\Sigma_r\), and \(\Gamma_r\) is the site (Definition LC-9); every term argument is usable there: its fact for \(\Sigma_r\) has a type, its home is included in \(T_r\), and its scope is on the chain of \(\Gamma_r\) (K1.6).
  4. The rule. The next table.
  5. Conclusion and summary. \(A_r\) is the node the rule rebuilt, by identity; its fact for \(\Sigma_r\) has type \(\mathsf{Prop}\) and is canonical; \(H_r\), \(S_r\), and \(h_r\) are the summary of Definition LC-10, with \(H_r\) stored as hypothesis items and an empty set of hypothesis propositions (Definition LC-8).

In the table, every premise conclusion \(A_{p}\) is read lifted to \(\Sigma_r\), "rebuild" means building in scratch with the construction engine and canonical inputs, and every rebuilt conclusion is compared with \(A_r\) by identity (Lemma LC-6).

Rule Reads Compares Rebuilds
hypothesis(Γ, h) the frame; the assume frame \(h\) \(h\) is \(e(\Gamma)\) or an ancestor of it the lift of \(A_h\) to \(\Sigma_r\)
use(Γ, d, τ̄, t̄) \(d\) (an axiom, a Proven theorem, a definition's equation, or a fact) with its statement and stored type parameters \(\bar\alpha\); facts of \(\bar\tau\) and \(\bar t\); from the snapshot, the visibility of \(d\) in \(T_r\) and the membership of each \(\tau_i\) in the sort of \(\alpha_i\) \(\lvert\bar\tau\rvert = \lvert\bar\alpha\rvert\); each membership holds (Definition Y-11); each \(t_i\) has the instantiated type of its quantifier the statement lifted to \(\Sigma_r\), or, when a type argument is a function type, instantiated in the signature of \(d\)'s parent first and then lifted (K2.9); then subst_types by \(\bar\tau\) and instantiation by \(\bar t\)
truth(Γ) the frame \(\mathsf{True}\)
imp_intro(h, p) \(p\); the assume frame \(h\) \(e(\Gamma_p)\) is \(h\) \(A_h \to A_p\), with \(A_h\) lifted
imp_elim(p, q) \(p\), \(q\) \(A_p\) is \(B \to C\) with \(B = A_q\) none: \(A_r = C\)
and_intro, and_left, and_right the premises the shape \(A \land B\) \(A \land B\), or none
or_left(p, B), or_right(A, p) the premise; the fact of the other disjunct that fact has type \(\mathsf{Prop}\) \(A \lor B\)
or_elim(d, l, r) the premises \(A_d = A \lor B\), \(A_l = A \to C\), and the third premise's conclusion is \(B \to C\), by identity none
false_elim(p, Q) \(p\); the fact of \(Q\) \(A_p = \mathsf{False}\); \(Q\) has type \(\mathsf{Prop}\) none
forall_intro(x, p) \(p\); the local row \(x\) \(e(\Gamma_p)\) is \(x\)'s frame, the frame just after \(x\) (Definition LC-7(3)) \(\mathsf{forall}[\tau_x](\lambda{:}\tau_x.\, \operatorname{abs}^0_x A_p)\)
forall_elim(p, t) \(p\); the fact of \(t\) \(A_p = \mathsf{forall}[\tau](f)\) and \(t\) has type \(\tau\) \(\mathrm{app}(f, t)\), with β
eq_refl(Γ, t) the fact of \(t\) \(t = t\) at \(t\)'s type
eq_sym(p), eq_trans(p, q) the premises the shapes; the middle terms are one node \(t = s\), or \(s = u\)
eq_apply(p, q̄) the premises \(A_p = (f = g)\), \(A_{q_i} = (a_i = b_i)\); \(f(\bar a)\) well typed \(f(\bar a) = g(\bar b)\), re-sorting ACU spines and reducing β
eq_abstract(x, p) \(p\); the local row \(x\) \(e(\Gamma_p)\) is \(x\)'s frame; \(A_p\) is an equation the two abstractions over \(x\)
eq_subst(P, p, q) the premises; the fact of \(P\) \(P: \tau \to \mathsf{Prop}\); \(A_p = (a = b)\); \(A_q\) is the rebuilt \(\mathrm{app}(P, a)\) \(\mathrm{app}(P, a)\) and \(\mathrm{app}(P, b)\)
convert(p, Q, U) \(p\); the fact of \(Q\); the rows of \(U\); from the snapshot, their visibility \(U\) lists transparent definitions visible in \(T_r\); \(D_U(A_p)\) and \(D_U(Q)\) are one scratch node (Corollary C-8a) \(D_U\) of both, by the lazy procedure of C1.5
transport(p, m) \(p\); the target frame \(\Gamma^*\); the map's terms and hypothesis judgments \(q_h\) \(T^* \sqsupseteq h_p\); each pair of \(m\), used or not: a local mapped to a canonical term of its type usable in \(\Gamma^*\) (its locals on \(e(\Gamma^*)\)'s chain, its home in \(T^*\)), or an assume frame \(h\) mapped to a judgment \(q_h\) with \(\Gamma_{q_h} \preceq \Gamma^*\) and \(T_{q_h} \sqsubseteq T^*\); no local or frame twice; every local of \(S_p\) and every \(h \in H_p\) mapped, and \(A_{q_h}\) equal to the rebuilt \(A_h[m]\) for those \(h\) \(A_p[m]\) and each \(A_h[m]\), lifted to \(\operatorname{sig}(T^*)\)
export(p, Γ_o) \(p\); the frames from \(e(\Gamma_p)\) up to \(e(\Gamma_o)\) \(\Gamma_o \preceq \Gamma_p\); no local is generalized while a kept hypothesis mentions it (A08) the chain \(A_0\) of Theorem D-4
of_class(Γ, τ, c) the fact of \(\tau\); the class row; from the snapshot, the membership \(\tau: \{c\}\) in \(T_r\) with its evidence the membership holds \(\mathsf{of\_class}_c(\mathsf{TYPE}[\tau])\)
unconstrain(p, α) \(p\); the type row \(\alpha^S\) \(\alpha^S\) is not among the sorted variables of \(\Gamma_p\) the implication of Definition Y-14, its class premises in the order of \(\alpha^S\)'s class atoms, with spines of a class-level declaration at \(\alpha^S\) nested to the right (K2.8)
LIFT\((p, T')\) \(p\); the theory row \(T'\) \(T' \sqsupseteq T_p\); \(\Gamma_r\) is \(\Gamma_p\) rebased to \(T'\) \(N_{\operatorname{sig}(T')}(A_p)\)

A premise of eq_apply or eq_subst must conclude an equation. An equation between equal literals is canonically \(\mathsf{True}\) and has no sides, and these layouts store none, so such a premise is refused: an incompleteness, not a change of the rules. Use convert or eq_subst with a non-literal equation instead: from \(f = g\), eq_subst with \(P := \lambda h.\, f\,a = h\,a\) and the premise \(P\,f\) by eq_refl gives \(f\,a = g\,a\).

export reads a path of frames rather than a bounded number of rows, so its check costs the length of that path; every other check reads a number of rows bounded by its operand count, plus its facts. The terms the rules rebuild may be large, which the budget charges (Definition LC-17).

Proposition LC-8 (a passing check is a rule instance). Let \(r\) be a proof row such that the claim of every premise is sound, every frame, declaration, and theory row of \(\operatorname{cone}(r)\) denotes what Definition LC-1 says, the facts and snapshot answers the check reads hold their values, and the check of \(r\) passes. Then \(\operatorname{cl}(r)\) is sound.

Proof. Let \(\Gamma = \Gamma_r\) and \(\Sigma = \Sigma_r\). By the placement step and Corollary D-9, each premise's derivation moves to \(\Gamma\) in \(T_r\), and its lifted conclusion is \(=_E\)-equal there to its own (Corollary C-9a). Each term argument is typed as its fact says, so the typing side conditions of the rules hold (Definition T-4). Each rebuilt term is \(N_\Sigma\) of the term the rule describes (Theorem C-7), and it equals \(A_r\) as a term by Lemma LC-6. The deduction page compares and builds terms up to \(=_E\), so \(\mathcal D\) below is a derivation by its rules. By cases:

  • hypothesis: (Hyp), since \(h\)'s frame is on \(\Gamma\)'s chain.
  • use: (Use) at the admissible substitution \(\bar\tau\) (Definition Y-11), then \((\forall\mathrm E)\) for each \(t_i\); the statement read in the parent's signature at a function type is the same instance (Theorem D-6, K2.9). The two orders, lifting first or instantiating in the parent's signature first, agree by Lemma C-9(3) except where a class-level ACU declaration's carrier becomes a function type, at which it does not apply (Definition Y-15); only the parent-first order is sound there, and the check takes it at every function-type argument.
  • truth through eq_subst: the rule of the deduction page of the same name: \((\top\mathrm I)\), \((\to\mathrm I)\) with \(h\) the last entry, \((\to\mathrm E)\), the rules of \(\land\), \(\lor\), and \((\bot\mathrm E)\), \((\forall\mathrm I)\) with \(x\) the last entry, \((\forall\mathrm E)\), (Refl), (Sym), (Trans), (Cong), \((\xi)\), and (Subst). In \((\to\mathrm I)\), \((\forall\mathrm I)\), and \((\xi)\) the entry is the last of the premise's context by the comparison with \(e(\Gamma_p)\), and the result lies at its parent rebased, where Theorem D-7 places it.
  • convert: (Conv), since \(D_U(A_p) = D_U(Q)\) decides \(A_p \equiv_U Q\) (Corollary C-8a).
  • transport and export: admissible, by Theorems D-5 and D-4, whose hypotheses are the comparisons of the table.
  • of_class and unconstrain: the rules of Definition Y-14.
  • LIFT: Theorem D-7 moves the premise to \(T'\), and (Conv) with \(A_p =_E N_{\operatorname{sig}(T')}(A_p)\), since \(=_E \subseteq \equiv_\emptyset\) (Corollary C-9a).

For the summary: by soundness of the premises their recorded sets bound their derivations', and Definition LC-10 is the rule-by-rule computation of Definitions D-4, D-5, and Y-13 (K1.7, K2.8) for one more step, so the recorded sets of \(r\) bound those of \(\mathcal D\): hypotheses are removed only when \((\to\mathrm I)\) discharges them, locals only when \((\forall\mathrm I)\) or \((\xi)\) generalizes them, and the home includes every contribution Definition D-5 names. Every part of the home is included in \(T_r\), because every term argument is usable there and every declaration of \(U\) is visible there, so \(h_r \sqsubseteq T_r\). A sort hypothesis is omitted only when redundant (Definition Y-13), so (3) follows from the premises' (3) by the one-step argument of Theorem Y-5, at ground instances of every \(T^* \sqsupseteq h_r\), as in Theorem Q-23. A sequent premise's claim is sound by Lemma LC-24. \(\square\)

For the sequent rules, the admissibility theorem of each rule on the sequents page plays the role of the cases above.

The theory pass and the checked theory snapshot

A proof row's check is local because everything it needs to know about its theory has been decided once, by the theory pass, and recorded in an immutable snapshot. The rows of that pass are the declaration rows and the theory rows: extensions, merges, and joins.

Definition LC-12 (local and global conditions, the theory pass). For a declaration row \(d\) with parent theory \(P\), the local conditions are those of the validation tables of K1.3 and K2.6 to K2.8 that concern \(d\) and its operands alone, read through facts for \(\operatorname{sig}(P)\) and through visibility in \(P\): typing and closedness of bodies and statements, the type-variable conditions, the shapes of carriers and units, and the exact statements of cited laws and witnesses (Definitions T-6 and T-7, Y-1, Y-2, Y-3, Y-8, Y-10, Y-10a). The global conditions relate \(d\) to the other declarations of \(P\), or need \(P\) as a whole:

Condition Concerns Justified by
names are fresh in \(P\) every named form Definition T-1, condition 1
no two ACU declarations for one constant unify after renaming apart; literal-kind carriers and bindings ACU declarations, literal kinds, canonical instance declarations Definition T-1, conditions 2 to 4; Definitions T-6, T-7; K2.9
definitions, type definitions, specifications, and instance definitions are well formed as defining declarations: orthogonal, monotone, composable, acyclic every defining declaration (Definition Y-4) Lemma Y-3b, Theorem Y-3a, through the stored end sets (K2.7)
the class graph stays acyclic classes, class relations Definition Y-10a
arities stay hereditarily coregular; no arity is declared twice instances, class relations Definition Y-9, Lemmas Y-4c and Y-4e
the signature theory every form Definitions T-1 and Y-15a
a Proven judgment has an empty context and a home included in \(P\); its sort hypotheses not witnessed in \(P\) are refused, the others removed; its proof's signature is \(P\)'s; its statement is the canonical closure \(K(s)\) of the proof's sequent in that signature (Definition Q-3d) Proven K1.9, Definition Y-13, Theorems D-8, D-7 and Q-3b
a merge satisfies the global conditions of Definition T-1 on the union; its defining declarations are added one at a time in creation order; its coregularity is rechecked on the pairs no side covers merge rows K1.3, Lemmas Y-3b and Y-4f, Corollary Y-4d
a join is the pointwise maximum of theories included in a stated ambient theory join rows Lemma T-8, K1.3
a theory row's version vector is its parent's with \(d\)'s segment raised, or the pointwise maximum every theory row Lemma T-9

The theory pass checks the declaration and theory rows in commit order, the local conditions and the global ones, and computes the snapshot entries of each theory it passes. A block of K2.6 is checked as one declaration with its parts.

Definition LC-13 (the checked theory snapshot). The snapshot is a set of entries, each keyed by theory rows and a query, with these values:

  • the signature theory of \(T\) (Definition Y-15a);
  • the join of two theories, with the ambient theory that includes them;
  • inclusion \(T \sqsubseteq T'\) and visibility of a declaration in \(T\), from version vectors (Lemma T-9);
  • the name index of \(T\);
  • the stored dependency closure of each Proven declaration (K1.7, K1.9);
  • the end set of each defining declaration (K2.7);
  • for \(T\), the class order with its evidence and the most general domains of its arities (Definition Y-9);
  • membership answers \((T, \tau, S)\): whether \(\tau: S\) in \(T\), with the instance declarations and class relations of its descent, in first-use order;
  • witness answers \((T, S)\): whether \(S\) is witnessed in \(T\) (Definition Y-12a), with the instance declarations of its witness, chosen by the creation-order scan of the classes page.

termbank publishes the snapshot only through a verdict (LC-R5). The entries are of two sorts. Theory entries (every item above except membership and witness answers for a type or sort that no declaration names) are computed only by the theory pass, which runs as its own chunk group in commit order, and published by its verdicts. Per-type answers, membership \((T, \tau, S)\) and witnessing \((T, S)\) for a type or sort a proof row brings, are computed by the proof check from the theory entries of \(T\), charged by their weight (Definition LC-18), and returned with its facts in its chunk's ROWS verdict, which publishes them when it is applied. Both sorts are keyed values outside the induction, like facts.

Proposition LC-9 (a passing theory step is sound). Let \(x\) be a declaration or theory row whose check passes, such that every declaration and theory row of \(\operatorname{cone}(x)\) other than \(x\) denotes what Definition LC-1 says, every proof row of \(\operatorname{cone}(x)\) has a sound claim, and the snapshot answers the check reads hold their values. Then a declaration row denotes a declaration well formed in its parent, and a theory row denotes a theory: a set of declarations that contains the parent of each, satisfies the global conditions of Definition T-1, has well-formed defining declarations (Definition Y-5b), hereditarily coregular arities (Definition Y-9), an acyclic class graph, and the signature theory its row records; and its vector represents it (Lemma T-9).

Proof. For an extension \(P + d\): \(P\) is a theory by assumption, the local conditions make \(d\) well formed in \(P\), and the global conditions of the table extend each property of \(P\) to \(P + d\) by the result named in its row. Lemma Y-3b is exactly the condition for well-formed defining declarations; Lemmas Y-4c and Y-4e for coregularity. For a Proven declaration, the cited proof row's claim is sound, its context is empty, and its home is included in \(P\), so its closed judgment is derivable in \(P\) by Theorems D-8 and D-7, and with it the statement \(K(s)\) (Theorem Q-3b), with sort hypotheses that the check finds witnessed in \(P\) (Theorem Y-8). For a merge, the union of two theories satisfies the global conditions that the check verifies, and the other conditions concern only parents, which the union contains (Definition T-1); its defining declarations by Lemma Y-3b applied in creation order, and its coregularity by Lemma Y-4f. For a join, Lemma T-8 with the ambient theory. The vectors are those of Lemma T-9(4). \(\square\)

Theorem LC-10 (snapshot answers are functions). Every entry of Definition LC-13 is a function of its key and of the contents of the cones of the theory rows it names. Every computation of it, by the theory pass or on demand by a check, in any order, returns that value, and a published entry holds it.

Proof. Each entry is defined from the declarations of the theories it names, which the cones of their rows contain (a theory row references its generators, and each declaration its parent theory: Definition LC-1), and from nothing else: the signature theory as the least fixed point of Definition Y-15a, joins and inclusion on vectors (Lemma T-9), closures over the finitely many earlier Proven declarations, end sets by the reduction of Theorem Y-3a, which ends, most general domains up to the normalized representative that coregularity makes unique (Definition Y-9), membership by one descent, witnessing as a least fixed point (Lemma Y-4a), and the evidence of each by a scan in creation order, which is commit order. The rows read never change (Lemma LC-1(2)). The argument of Theorem LC-4 and Corollary LC-5 then applies unchanged. \(\square\)

Why a proof check may use the snapshot. A proof row's frame references its theory, so every theory whose answers its check reads lies in its cone. By Theorem LC-10 those answers are the values that a sequential kernel would compute, so reading them is the same as deciding them, and by Proposition LC-9 they describe a theory whenever the cone's theory rows passed. If one of them failed, the proof row is invalid whatever its own check says (Theorem LC-19). The theory pass is sequential, but it is short: declarations are few beside proof steps. A proof chunk that reads theory entries of a theory waits until the theory pass's verdict over that theory's row is published; it never computes a theory entry itself. This is the only wait between chunks, and it changes no result: by Theorem LC-10 a published entry is the value the chunk would compute, and a declaration or theory row passes in a proof chunk only when the theory pass passed it. Soundness does not rest on the wait, since an answer about a theory whose rows fail belongs to a row in \(\operatorname{dep}(F)\); determinism of charges does (Definition LC-18).

The verified watermark and soundness

The kernel's part of the trusted base is now a requirement on pure functions; it replaces Requirement B-R1.

Requirement Statement
LC-R6 (the checks implement this page, trusted) The local checks of judgment_core return pass only when the conditions of Definitions LC-7, LC-11, and LC-12 hold for the row, against the facts and snapshot answers they read. Every fact and snapshot entry they return is a computation of Definition LC-5 or LC-13. Only judgment_core constructs a verdict.

Definition LC-14 (verdicts and the verified watermark). The result of a row's check is pass, a refusal with its error kind, or LIMIT. A verdict for a range \([a, b)\) of the base lists the results of its rows in order, up to and including the first that is not pass, with the facts and snapshot entries the passing checks returned. Let \(P\) be the set of rows that pass in the verdicts applied so far. The verified watermark is the length of the longest prefix of the base contained in \(P\):

\[ \omega = \max\{\, m \le N \mid D_m \subseteq P \,\}. \]

Applying a verdict therefore advances \(\omega\) only across a contiguous prefix of passing rows (LC-R5). The facts and per-type answers of a proof chunk's (ROWS) verdict are published when \(\omega\) passes its rows. The theory pass's verdicts cover only declaration and theory rows, in commit order, and advance a separate theory mark over them; they publish theory entries when the mark passes their rows. A declaration or theory row is in \(P\) only when a theory-pass verdict passed it; a proof chunk's verdict then passes it without a second check. A row is valid when every row of its cone is in \(P\).

Lemma LC-11 (published values are exact). Under LC-R5 and LC-R6, at every moment every published fact and snapshot entry holds the value of its key.

Proof. Corollary LC-5 and Theorem LC-10, by induction on the order of publication. \(\square\)

This lemma does not depend on any proof row being valid: a fact is a property of syntax relative to its cone, and a snapshot entry a property of the declarations in its cone.

Theorem LC-12 (soundness by induction on the commit sequence). Assume LC-R1 to LC-R6 and LC-R8. Every valid row, and in particular every row below the watermark, satisfies:

  1. a type or term node has the metadata of its content (S-R1, T1.5);
  2. a frame row denotes a context of its theory (Definition D-1), and its derived fields are those of Definition LC-7(5);
  3. a declaration row denotes a declaration well formed in its parent, and a theory row a theory, with the properties of Proposition LC-9;
  4. a proof row has a sound claim (Definition LC-8).

Hence every statement below the watermark, the conclusion of a proof row or of a sequent row, a Proven declaration, or an exported judgment, is derivable in its theory in the logic extended by the admissible sequent rules, and therefore, by their admissibility theorems on the sequents page, in the logic of the deduction page.

Proof. Every row below \(\omega\) is valid: it lies in \(D_\omega \subseteq P\), and so does its cone (Lemma LC-1(3)). Let \(r\) be valid, and assume the statement for every valid row of smaller number (Lemma LC-1(4)). Every row of \(\operatorname{cone}(r)\) other than \(r\) is valid, since its cone lies in \(\operatorname{cone}(r)\), and has a smaller number, so it satisfies (1) to (4). The check of \(r\) passed, so by LC-R6 its conditions hold against the facts and snapshot answers it read, which hold their values by Lemma LC-11. By the kind of \(r\):

  • a node: (1) is LC-R8;
  • a frame: \(p\) denotes a context of \(T(p)\); the entry is no entry of \(\Gamma(p)\) (Lemma LC-25), the local's type is well formed, and its proposition is a bound-closed proposition whose locals are fixed on the chain of \(p\), so \(\Gamma(f)\) is a context of \(T(p)\), and of \(T(f) \sqsupseteq T(p)\) by Theorem D-7;
  • a declaration or theory row: Proposition LC-9, whose hypotheses are (2) to (4) for the cone;
  • a proof row: Proposition LC-8, whose hypotheses are (2) to (4) for the cone; for a sequent row, the admissibility theorem of its rule.

The induction uses the claims of earlier rows, never their verdicts, the order in which they were checked, or which check computed a fact. The last sentence holds because an admissible rule adds no derivable judgment (Definition D-3). \(\square\)

Corollary LC-13 (checking at the boundary). Theorem B-2 holds with Requirement B-R1 replaced by Theorem LC-12: a proof row below the watermark with an empty context is valid in every ground model of every theory that includes its home in which the sorts of its sort hypotheses are inhabited, and in every ground model of such a theory when they are witnessed in the home (Theorems D-8, D-7, and Y-8).

Definition LC-15 (checked rows). A row \(r\) is checked when every row of \(D_{\operatorname{seq}(r) + 1}\) has passed its check in an applied verdict.

G8 (restated). A stored node is checked iff its sequence number is below the verified watermark. Raw syntax still has no meaning of its own: a term node acquires one in a theory only through its fact for that theory's signature, and only rows below the watermark may be cited.

Theorem LC-14 (G8 holds). Under LC-R1 to LC-R6:

  1. a row is checked exactly when its sequence number is below \(\omega\);
  2. every checked row satisfies Theorem LC-12;
  3. a checked row stays checked, with the same content, forever;
  4. only a verdict, which only judgment_core constructs, makes a row checked.

Proof. (1) \(r\) is checked exactly when \(D_{\operatorname{seq}(r)+1} \subseteq P\), exactly when \(\operatorname{seq}(r) + 1 \le \omega\) by the definition of \(\omega\) as a maximum, since the prefixes are nested. (2) Theorem LC-12. (3) \(P\) only grows, so \(\omega\) never decreases, and the row never changes (LC-R3). (4) \(P\) grows only when a verdict is applied (LC-R5, LC-R6). \(\square\)

A row above the watermark may be valid: its cone passed although an earlier, unrelated row did not. It satisfies Theorem LC-12 too, but it is not checked, and views given to sessions and callers do not show it (LC-R5). Theorem LC-19 says which rows such a failure invalidates.

Parallel checking and determinism

Definition LC-16 (chunks). A chunk is a range \(C = a, b)\) of the base. check_chunk checks its rows in order against a view \(V_n\) with \(n \ge b\), fixed for the chunk, with a scratch reset at \(a\), and stops at the first row that does not pass. The fact keys of a row are the (node, signature) pairs whose facts its check reads or establishes: for a proof row, its conclusion, its term and type arguments, its premises' conclusions and, for a sequent row, the hypotheses it reads; for a frame row, its entry's type or proposition. The chunk's verdict returns the values of the fact keys and snapshot queries of its passing rows. The chunk's allowance \(a(C)\) is a function of the contents of its rows, never of a shared ledger (G3). The chunk boundaries are a function of the base's contents, such as cuts by cumulative estimated cost from row 0, not of the moments at which rows arrive.

Lemma LC-15 (a check reads only its cone). Except for whether it reaches LIMIT, the result of a row's check, and the values it returns, are functions of the contents of the rows of its cone. They do not depend on \(n\), on the facts and entries published, on the results of other rows, or on the state of the chunk's scratch.

Proof. The check reads its row, rows reached through references (the frame ancestor pointers among them), facts whose keys are rows of the cone, and snapshot answers for theories of the cone. The facts and answers are functions of the cone's contents, whether read or computed (Theorems LC-4 and LC-10), and hold their values when read (Lemma LC-11). Lookups are bounded by \(r\) and decide only term equality (Lemma LC-6). A row a lookup finds below \(r\) but outside the cone has the content the check built from the cone, its facts are computed from that content (Definition LC-18(3)), and it is only compared with fields of \(r\). The scratch memos are keyed fully (G15), so an entry left by an earlier row of the chunk holds the value of its key and changes only the work done. \(\square\)

Theorem LC-16 (checks of distinct rows commute). Except for LIMIT, the results of any set of row checks, and the values they return, are the same in every order of execution and under every interleaving of concurrent checks.

Proof. Each result is a function of its cone's contents (Lemma LC-15). No check writes anything but its private scratch: its results and facts are values that termbank publishes later. The shared state checks read is either rows of a published prefix, which never change and need no lock (LC-R3), or published facts and entries, which only grow and hold their values at every moment (Lemma LC-11), so a concurrent reader finds a value or its absence, and absence only costs work. \(\square\)

LIMIT needs more, because the work of a check depends on what it finds published: a fact read costs a lookup, a fact computed costs a traversal. K1.1 allows a memo hit to charge less than the computation; that freedom is what must be withdrawn here.

Definition LC-17 (view-independent charging). A chunk's charges are view-independent when the sequence of its charges, up to the first row that does not pass, is a function of the contents of its rows and their cones: it does not depend on \(n\), on what is published, or on timing.

Definition LC-18 (the weight discipline). The weight \(w_\Sigma(t)\) of a fact is defined recursively on the term: \(w_\Sigma(t) = 1 + \ell_\Sigma(t) + \sum_{c} w_\Sigma(c)\) over the children \(c\) of \(t\) (with their binder environments), saturating at \(2^{64}-1\), where \(\ell_\Sigma(t)\) is the fixed local cost of the node's own step (its typing, home, scope and canonical-form step). It is a function of \((t, \Sigma)\) by Theorem LC-4 and is stored with the fact. Being a tree size, it bounds from above the work of computing the fact from scratch, which visits each key of the cone once. A per-type answer (Definition LC-13) has as weight the steps of its computation from the theory entries, defined in the same way; a theory entry is always read, after the wait of Definition LC-13, and costs one unit. There is no fact floor: what is published never changes a charge. A check following the discipline:

  1. charges, for each fact key and per-type answer, exactly its weight, whichever way it obtains the value: from a published fact, from the chunk's memo, or by computing it;
  2. computes a missing fact from its children's facts, each obtained the same way (published, memo, or computed recursively), so a fact costs \(O(\text{arity})\) time once its children's facts are at hand, and the whole computation visits each key of the cone at most once per chunk;
  3. charges every other step (rebuilding, unfolding, set merges, walks over frames) by the K1.1 rules, one unit per scratch node made whether or not its interning finds a stored row, with memos private to the check; the facts of a rebuilt node are computed from its children's in scratch, also when its interning finds a stored row, never read by that row's key.

The charge of (1) can exceed the work done, never fall short of it, so G3's bound holds. Chunk allowances for conversion saturate, so heavily shared terms, whose tree weight is large, do not trigger LIMIT.

Proposition LC-17 (the weight discipline is view-independent). Under Definition LC-18, every check's charges are a function of the contents of its cone, and so are a chunk's.

Proof. Charges of kind (1) are weights, functions of keys. Kind (2) adds no charge of its own: its work is paid by the weights of kind (1). Those of kind (3) depend on the values the check computes or reads, which are functions of the cone (Lemma LC-15), and on its private memos, which start empty. Lookups into \(V_n\) are charged before they are made, so a hit and a miss cost the same. \(\square\)

The discipline charges a fact read from the view as much as a fact computed, and it gives up the reuse of published facts below the root of a computation. Reads remain cheap in time; only the abstract charge is the same.

Theorem LC-18 (chunk verdicts do not depend on scheduling). Let the chunk boundaries and allowances be as in Definition LC-16.

  1. A chunk's verdict, other than whether and where it reaches LIMIT, is a function of the contents of the cones of its rows.
  2. With view-independent charging, so is the whole verdict, LIMIT and the row that reaches it included.
  3. The set \(P\) of passing rows, the watermark, and the published facts and entries, after a set of verdicts has been applied, do not depend on the order of application, the number of workers, or the runtime profile.

Proof. (1) The chunk checks its rows in order; each result is given by Lemma LC-15, so the first row that does not pass, and the values returned, are determined. (2) The budget before each charge is \(a(C)\) less the earlier charges, a function of the contents; Budget.charge raises LIMIT exactly when the charge exceeds what remains (T1.1). (3) \(P\) is the union of the verdicts' passing rows, \(\omega\) is a function of \(P\) (Definition LC-14), and the published values are the union of the verdicts' values (Corollary LC-5). \(\square\)

The library writer emits rows below the watermark in commit order, so by (3) the library's bytes are the same at every number of workers, which is the plan's target. If each row instead receives its own allowance, a function of its content, then under view-independent charging the verdict does not depend on the chunk boundaries either.

Theorem LC-19 (a failure invalidates exactly its dependents). Let all rows of a prefix \(D_m\) have been checked, and let \(F \subseteq D_m\) be the rows whose check did not pass, by refusal or LIMIT. Then:

  1. every row of \(D_m \setminus \operatorname{dep}(F)\) is valid and satisfies Theorem LC-12;
  2. every row of \(\operatorname{dep}(F)\) has a failed row in its cone, and nothing is claimed for it;
  3. one pass in commit order computes \(\operatorname{dep}(F)\): a row belongs to it exactly when it is in \(F\) or one of its references belongs to it, the index-resolved references of Definition LC-1 included: a theory row whose generator is marked is marked;
  4. \(\omega\) is the smallest number of a row of \(F\), or \(m\) when \(F\) is empty.

Proof. (1) A row outside \(\operatorname{dep}(F)\) has no failed row in its cone, and its cone lies in \(D_m\) (Lemma LC-1(3)), where every other row passed; so it is valid, and Theorem LC-12 applies. (2) is the definition of \(\operatorname{dep}\). (3) By induction on numbers: \(\operatorname{cone}(r)\) is \(r\) with the cones of its references, all of smaller number (LC-R2), so \(r\)'s membership is decided once theirs are. (4) The definition of \(\omega\). \(\square\)

An export, a name bound to a statement and a proof row, is withdrawn exactly when its proof row is in \(\operatorname{dep}(F)\). A LIMIT result is undecided rather than refuted (K1.1): its dependents are undecided, and a check of the same row under a larger allowance may pass. A valid row above a failure is sound but not checked; it becomes checked only after its cone is committed again in a sequence without the failed rows, where by Proposition LC-20 its check passes again.

Workspaces

Authoring needs what the converter does not: rollback, nested search, and results kept from a failed attempt's siblings. Workspaces provide them ([DAG storage, TD1.12). A session builds its rows in a workspace over a verified prefix of the base: a failed operation, or a return to a snapshot, truncates it; a session fork is a child workspace; and Session.merge commits the fork into its parent.

Definition LC-19 (workspaces). A workspace \(W\) has a parent, the base or another workspace, and a mark \(\mu\): the parent's watermark when \(W\) was opened, so every row below \(\mu\) is checked. Its visible store is the parent's visible rows numbered below \(\mu\), followed by \(W\)'s own rows, numbered \(\mu, \mu + 1, \dots\) in \(W\)'s own sequence. A child workspace opened in \(W\) therefore sees \(W\)'s rows, which \(W\) has not committed. Within its visible store, \(W\) keeps LC-R1 to LC-R4: its rows reference smaller numbers, never change while they exist, and are deduplicated against the whole visible store. Each row is checked when it is appended (a rule method builds the conclusion in the workspace, the kernel checks the new row, and the method returns a handle), and a call that fails truncates the workspace to its mark at the call's start (G9). So between calls every row of the visible store is checked: the workspace's watermark is its length.

termbank must also keep:

Requirement Statement
LC-R7 (workspace discipline) (1) Frozen prefix: while \(W\) is open, its parent changes no row numbered below \(\mu\) and does not truncate below it. (2) Value rows: locals and frames are deduplicated against the whole visible store (LC-R4). (3) Order: commits happen in an order the coordinator fixes (G1).

A local carries no identity of its own: a commit or load that brings a binding site the target holds maps it. Depths, names and types, and with them structural hashes and the ACU order of terms with locals, are kept by a commit, which therefore never rebuilds a canonical form (Lemma S-6).

Definition LC-20 (truncation and commit). Truncation of \(W\) to \(m \ge \mu\) removes \(W\)'s rows numbered \(m\) or more, with the facts and entries keyed by them; while \(W\) has an open child, it is refused unless no child was made since the mark \(m\) was taken (TD1.12(4)), so it is refused whenever a child of \(W\) has a mark above \(m\) (Theorem LC-28). Commit of \(W\) into its parent \(P\) requires that \(W\) has no open child and that \(W\)'s watermark is at its end. It visits \(W\)'s rows in order and builds the id translation \(\pi\), the identity below \(\mu\):

  1. it translates the row's references by \(\pi\);
  2. for a deduplicated kind, it looks the translated content up in \(P\), exactly (LC-R4); on a hit, \(\pi(r)\) is the row found. A local is probed by its binding site; on a hit, the fix frame just after it maps with it to the frame just after the row found;
  3. otherwise, and always for the fresh kinds other than a fix frame mapped with its local in (2), it appends the translated row to \(P\), and \(\pi(r)\) is the new row;
  4. \(W\) never extends a segment it did not create: a declaration of \(W\) into a theory of \(P\) starts a segment of \(W\)'s own. So a version vector translates entry by entry, segment by \(\pi\) and count kept.

It re-keys \(W\)'s facts and entries by \(\pi\) and publishes them: they are keyed values, and hold their values whatever the status of the rows (Lemma LC-11). It returns \(\pi\) (G6). The appended rows follow \(P\)'s earlier rows, and \(P\)'s watermark passes them only by verdicts of checks run in \(P\), as for any rows (LC-R5): the recheck.

Decision: a commit rechecks. \(W\)'s verdicts are not translated into verdicts of \(P\). Reusing them would be sound only if termbank's commit met every hypothesis of Proposition LC-20, which would put that proposition and the commit's translation into the trusted base, and it would advance \(P\)'s watermark without a verdict of the checker, against LC-R5. The recheck costs one more check per appended row, linear in \(W\); the published facts make it cheap in time, though not in charges (Definition LC-18). Proposition LC-20 then states completeness only: the recheck passes, and its failure is a bug (INTERNAL), never a property of the input. A commit into a parent whose watermark is below its end is allowed; the appended rows wait for the earlier ones, as any rows do.

Proposition LC-20 (relocation). Let \(\pi\) be an injective map of rows that preserves kinds, maps each row's content to the content of its image with references translated by \(\pi\), keeps names, immediate payloads and pooled bytes, maps a local node's payload with its local row, preserves the relative order of the declaration rows it maps, maps references to rows of smaller number, keeps each local row just before its frame, and maps version vectors entry by entry, translating segments and keeping counts. Then for every row \(r\) of its domain whose cone it maps, the check of \(\pi(r)\) has the result of the check of \(r\), with the facts and answers translated by \(\pi\).

Proof. By Lemma S-6, \(\pi\) preserves structural hashes, loose bounds, flags, the structural order, identity, and canonical forms; types are computed from structure and declaration rows, which \(\pi\) maps to rows of the same content; so facts translate (Lemma LC-3). The map of vectors is injective, preserves and reflects inclusion, and commutes with pointwise maxima, since it renames segments and keeps counts, and it keeps the order of segments, which grow with sequence numbers on both sides; so inclusion, joins, and visibility translate, and with them the theory pass's conditions. Every condition of Definitions LC-7, LC-11, and LC-12 is stated through these quantities, through the order of numbers along references, and through the adjacency of Definition LC-7, which \(\pi\) keeps by hypothesis; so it holds of \(\pi(r)\) exactly when it holds of \(r\). \(\square\)

Theorem LC-21 (truncation preserves the invariants). After a truncation of \(W\) to \(m\), \(W\)'s visible store satisfies LC-R1 to LC-R4, no remaining row references a removed one, every remaining row has its check result, every open child keeps its visible store, and a handle that names a removed row is rejected (G6).

Proof. A remaining row is numbered below \(m\), and its references are numbered lower still (LC-R2), so they remain. Removing a suffix keeps the numbering contiguous, and changes no remaining row's content or its cone, so its check result stays (Lemma LC-15). A child with a mark above \(m\) refuses the truncation (Theorem LC-28). Handles carry the workspace and are validated against its length and generation (TD1.12, items 4 and 5). \(\square\)

A failed call therefore leaves the workspace as it was before the call, which is G9 for workspaces; discarding a workspace is its truncation to its mark.

Theorem LC-22 (commit preserves the invariants and checkedness). Under LC-R7, after the commit of \(W\) into \(P\):

  1. \(P\) satisfies LC-R1 to LC-R5;
  2. \(\pi\) is injective, and references still point down: for every row \(r\) of \(W\) and \(r' \in \operatorname{ref}(r)\), \(\operatorname{seq}(\pi r') < \operatorname{seq}(\pi r)\);
  3. every image \(\pi(r)\) is a row whose check passes, so the recheck of the appended rows passes;
  4. \(P\)'s rows and \(\pi\) are a function of \(P\)'s and \(W\)'s rows, so, for a fixed order of commits, every id is determined (G1).

Proof. (2) By induction in \(W\)'s order. A row appended at the end has references mapped earlier, so smaller. A row found at \(x\) has \(\operatorname{content}(x) = \pi(\operatorname{content}(r))\), so \(\pi(r') \in \operatorname{ref}(x)\) and is smaller by LC-R2 in \(P\). For injectivity: no row of \(W\) has the content of a row below \(\mu\) (LC-R4 in \(W\)); if \(\pi\) is injective on earlier rows, rows with different contents receive different translated contents, hence different rows, found or appended, while rows that are never deduplicated are appended fresh; and two rows of one deduplicated kind with one content do not exist in \(W\). (1) Appended rows take the next numbers (LC-R1); (2) gives LC-R2; no row of \(P\) changes (LC-R3); a row is appended only when \(P\) has no row of its translated content, and by injectivity no two appended rows share one (LC-R4); the watermark advances only by verdicts of the recheck (LC-R5). (3) Every row of \(W\) passed its check in \(W\). \(\pi\) satisfies the hypotheses of Proposition LC-20: contents translate by construction; names and immediate payloads are copied, local payloads are translated with their rows; declaration rows are appended in \(W\)'s order, above every row below \(\mu\); references point down by (2); a local row and its frame are either both appended, one after the other, or both mapped to an adjacent pair (Definition LC-3), so they stay adjacent; vectors map as in Definition LC-20(4). A row found by a hit has the content of \(\pi(r)\), so the same cone contents and the same result (Lemma LC-15). (4) Every step is an exact lookup or an append in order. \(\square\)

Session.merge is such a commit, of a fork's workspace into its parent's: nothing is merged back into a shared table, and the only check that runs again is the recheck, whose result Theorem LC-22(3) fixes. Theories that \(W\) made stay separate from those of its siblings: combining them is a merge row, checked by the theory pass (Definition LC-12).

Theorem LC-23 (a nested child sees exactly its parent's state). Let a child \(K\) be opened in \(W\) when \(W\)'s visible store has length \(\mu'\). Until \(K\) is committed or truncated away:

  1. \(K\)'s visible store below \(\mu'\) is \(W\)'s visible store at the opening, row for row, with the same numbers, and every fact and entry \(K\) reads holds the value \(W\) would read;
  2. nothing \(W\), a sibling, or the base does afterwards changes it;
  3. every check, construction, and query in \(K\) gives the result it gives in \(W\) at the opening, with the same new ids; with view-independent charging, the same charges.

So Proposition S-1 holds for session forks, whose workspaces are nested children: its argument rests on a fork's observable state being its parent's at the fork, which (1) to (3) supply, and on the coordinator's decision in index order, which LC-R7(3) fixes.

Proof. (1) The visible store is defined so; facts and entries hold the values of their keys wherever they are read (Lemma LC-11). (2) LC-R3 and LC-R7(1): rows below \(\mu'\) never change, and \(W\) cannot truncate below the mark of an open child. Siblings append only to their own stores, and the base only above the prefix. (3) By Lemma LC-15 every result is a function of the contents of a cone in the visible store, which (1) and (2) make equal to \(W\)'s; new rows are numbered from \(\mu'\) in both; charges by Proposition LC-17. No counter is shared with a sibling: a workspace's rows depend only on its prefix and the contents it commits (LC-R7(2)). \(\square\)

Binding sites

A local is its binding site: the frame it extends, its type and its name (TD1.7). A fresh-fix store is the store the same calls would build if every fix and assume made a new row, and the fresh-fix kernel the kernel over such stores. This section shows that the binding-site store is sound, loses no judgment the fresh-fix store derives, and keeps every row a function of the session's calls.

Lemma LC-25 (entries of a chain).

In a store that keeps LC-R1 to LC-R4 and the adjacency of Definition LC-7(3):

  1. each local has exactly one fix frame, f(ℓ), and parent(f(ℓ)) = parent(ℓ);
  2. along a chain, depths strictly increase, so its frames are distinct; it holds each local and each hypothesis at most once;
  3. two distinct locals with one binding depth lie on no common chain, so no term with a scope holds both.

Proof. (1) A fix frame's local is the row just before it, and a local's next row is its fix frame; so f(ℓ) is the row at seq(ℓ) + 1, and termbank and LC-7(3) require the two parents to agree. (2) depth(f) = depth(p) + 1 (TD1.7). A local occurs on a chain only through f(ℓ), by (1); a hypothesis is its frame. (3) Frames of one chain have distinct depths, and a term's fact requires every local's frame on its scope's chain (K1.6). ∎

Theorem LC-26 (binding sites are sound).

With locals deduplicated by (parent, type, name) and frames by their keys, Theorem LC-12 holds: every row below the watermark has a sound claim.

Proof. LC-12's proof is an induction over valid rows using LC-R1 to LC-R6, Lemma LC-11 and the local checks. LC-R1 to LC-R5 hold: locals and frames with an entry join the deduplicated kinds of LC-R4, and every other requirement is about rows in general. LC-R6 and the checks are unchanged. Only the frame case reads freshness: it needs that the entry of a frame f with parent p is no entry of Γ(p). By Lemma LC-25(1) the only frame that fixes f's local is f; an assume frame is itself the hypothesis it adds; and f is no ancestor of p. So Γ(f) names each entry once (Definition D-1); LC-7's checks give the rest. ∎

Lemma LC-27 (freshness by placement).

Let F be a frame and t a term usable at F (its scope is F's entry frame e(F) or an ancestor, K1.6). No local fixed over F occurs in t, and no hypothesis of Γ(F) mentions one.

Proof. A local ℓ of t has f(ℓ) on t's scope's chain at or above the scope (K1.6), so depth(f(ℓ)) ≤ depth(e(F)) ≤ depth(F). A local m fixed over F has depth(f(m)) = depth(F) + 1. A local has one fix frame (Lemma LC-25(1)), so m ≠ ℓ. A hypothesis of Γ(F) is an assume frame at or above F whose proposition's scope lies on its parent's chain (LC-7(4)), so the same bound applies. ∎

So every eigenvariable condition is met by placement, whatever the name: the local that (∀I), (ξ), forall_intro, eq_abstract and export generalize is the last entry of its context, and no hypothesis before it mentions it (LC-7(3), (4)); DR-3's motive λz. C[a] = C[z] is capture-free when z is fixed over a frame where C[a], a and b are usable.

Theorem LC-28 (frozen prefix, TD1.12(4)).

While a child W of P is open, P changes no row below W's prefix and does not truncate below it (LC-R7(1)).

Proof. Let c_W be P.children_made just after W's creation and s_W = P.seq then. Invariant while W is open: P.seq ≥ s_W, and every valid mark of P whose count is at least c_W has seq ≥ s_W. It holds at creation. Appends raise seq. The count never decreases, so a mark taken before W's creation has a count below c_W, and a mark taken after records seq ≥ s_W by the invariant. A truncation to m is allowed only when m.children_made equals the current count, at least c_W, so m.seq ≥ s_W, and the invariant holds after it. W's prefix ends at or below s_W, and rows never change (LC-R3). ∎

The count cannot go back, so this needs no other check of a mark. Stale verdicts and handles are refused by TD1.12(5) and CG4.

Lemma LC-29 (merged entries never meet).

Let ≡ be the equivalence on the frames and locals of a store built with fresh fixes and assumes that identifies equal binding sites: frames without an entry with ≡ parents and one theory; locals with ≡ parents, one type and one name, and their fix frames; assume frames with ≡ parents and propositions equal after renaming by ≡. Then ≡ preserves depth and ancestry, and two distinct ≡-equivalent frames or locals lie on no common chain.

Proof. Induction on depth: equivalent frames have equivalent parents, so equal depths; ancestry maps parent to parent. Two distinct frames of equal depth are not ancestors of each other, so no chain holds both. ∎

So the map from a fresh-fix store to its binding-site store is injective on every chain, on every context, on the locals of every term with a scope, and on the free locals of every row (all lie on its context's chain, (R1) of Definition Q-4). Merged locals share parent, type and name.

Proposition LC-30 (the rules that touch locals).

Each check below reads only locals of the row's chain, where the identification is injective (Lemma LC-29), and its freshness conditions hold by placement (Lemma LC-27). So each gives the same answer as with fresh fixes.

Rule or requirement What it checks Effect
Frame check LC-7(3), (4) no hypothesis before f mentions f's local holds by Lemma LC-27
forall_intro, imp_intro, eq_abstract, export (K1.9, A08) generalize the last entry; no retained hypothesis mentions it checked on the row's own chain
absThm v fixed on the row's chain (SCOPE); v ∉ locs(A) for A ∈ Γ₁ Γ₁'s locals lie on the premise's chain, which the row's extends
inst the locals of μ are distinct members of V₁ distinct rows on one chain
Placement (LC-9, K1.6) every local of a term on one chain (SCOPE) a term the fresh-fix kernel refused for mixing two locals of one binding site on different chains becomes a term over one local; nothing placed before is refused
LC-R7(1) frozen prefix Theorem LC-28
LC-R7(2) value rows locals and frames are deduplicated against the visible store; a commit maps a binding site the target holds
LC-20, LC-22 commit, translation, recheck a local and its frame map or append together, so π keeps contents, references down and adjacency (Proposition LC-20's hypotheses); LC-22's injectivity argument covers value rows
LC-3 deduplicated and fresh kinds locals and frames join the deduplicated kinds; heads, segments and declarations stay fresh
Lemma S-6 renaming ids π maps a local payload with its row and preserves depth, name and type, so hashes are kept; T1.6 is kept on every pair whose locals lie on one chain
Facts (LC-11, CG7) keyed by node and signature a fact holds whichever branch derived it: it is a function of the node's content

Theorem LC-31 (nothing derivable is lost).

  1. A judgment derivable in a context built with fresh fixes gives, after renaming its locals by ≡, a derivable judgment in the binding-site context, with the same declarations and home; and conversely.
  2. Each row the fresh-fix kernel verifies has a counterpart, built by the same rule from the counterparts of its premises and operands, that the binding-site kernel verifies; its claim is the renamed claim, up to =_E.
  3. The binding-site kernel additionally verifies only rows whose fresh-fix counterparts mix two ≡-equivalent locals or frames of different chains, which the fresh-fix kernel refuses at placement. Within one session the shell merges two variables it records only where it returns the one it holds (L1.6), so these rows come from internal helpers' locals, from transactions and forks that fixed one binding site, from the converter's cache and from loads: the sharing binding sites give.

Proof. (1) By Lemma LC-29 the renaming is injective on the context and keeps types. Lemma D-2a, applied one local at a time through fresh intermediate locals so that no image clashes, and Lemma C-9(1) carry the derivation over; the inverse renaming on that chain gives the converse. (2) A check reads its premises (contexts on the site's chain), its operands (scopes on that chain), facts about those nodes and the snapshot (LC-9, Lemma LC-15). All the locals involved lie on one chain, where the renaming is injective. Facts are functions of node content. A renaming injective on the locals involved preserves and reflects =_E (Lemma C-9(1) for it and its inverse), so two canonical terms a placed check compares are equal before exactly when their counterparts are equal after. T1.6 on locals depends on hash, depth and name, functions of depth, name and type, which ≡ preserves. (3) A counterpart check could differ only if ≡ merged two locals or frames it reads; those lie on different chains (Lemma LC-29), and the fresh-fix check refused at placement. ∎

Theorem LC-32 (uniqueness and determinism).

  1. In every visible store: one (parent, type, name) has one local, one local one fix frame, one (parent, proposition) one assume frame, one (parent, theory) one frame without an entry.
  2. Rows, ids and every deduplication outcome are functions of the session's calls and the contents committed, in the coordinator's order (CG1). No allocator or range enters a row. A name a component picks for a local over F is a function of F, τ, a base name and an avoid set that records earlier calls (CG9).
  3. No row, id or verdict depends on the order in which forks are dropped, or on the number of workers.

Proof. (1) LC-R4 for the four keys, and Lemma LC-25(1). (2) fix and assume are exact lookups or appends in commit order. A name pick reads only F, τ, the base name and the avoid set. The only counter left is a workspace's count of children made, which decides only whether a truncation is allowed, a function of the call sequence. (3) A drop changes only the parent's open-child count, which truncate and commit read after the join (TD1.12). Checking workers create no rows. ∎

Theorem LC-33 (names reach no statement identity).

Let two runs of one program differ only in the names their components pick for new locals, because their avoid sets record different earlier calls (CG9), and let each helper combine only the locals it fixes and its inputs. Then the two runs verify the same rows up to a renaming that is injective on every chain, and they give every Proven statement, every closed statement, every statement identity and every term without locals the same value. They can differ in which rows coincide, in open terms and proofs, and in library bytes.

Proof. Let the fresh-fix run make a new local at every fix. Each run is its image under the identification ≡ of Lemma LC-29 for that run's names, which is injective on every chain. Each helper's distinctness requirements hold in both runs: a pick excludes its avoid set, and Lemma LC-27 separates a new local from the helper's inputs. No helper builds a row that mixes two ≡-equivalent locals of different chains, so by Theorem LC-31(2) a row is verified in either run exactly when its fresh-fix counterpart is, with the renamed claim. A Proven's statement is K of its proof's sequent, and corresponding sequents are renamings of each other with equal k and n, so their K agree (Theorem Q-3a). A term without locals holds no name, and a statement identity (Definition I-6) is a function of a closed statement. ∎

The work is not name-free: K's charge depends on names (Theorem Q-3b, determinism). So the two runs verify the same rows only when both complete; a computation whose allowance lies below W(s) (Proposition Q-3c) can complete in one run and hit LIMIT in the other. With an allowance of at least W(s), both complete, unless a search meets the bound on its recorded automorphisms (CAPACITY, Proposition Q-3c), which depends on the visiting order.

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