The trusted base¶
A bug in the trusted base can make the system accept a false judgment. A bug anywhere else can only cost an answer or its quality. This page is the inventory (architecture note, section 30.6). Changes to the trusted base require an explicit contract and soundness review.
Inventory¶
| Component | Where | Why it is trusted |
|---|---|---|
| Proof-DAG storage | termbank.dag (src/termbank/dag/), with termbank's hashes, node metadata, budget, and errors (src/termbank/) |
Exact deduplication, references only to smaller sequence numbers, rows that never change, the watermark and the verdicts that move it, workspaces, and verified spill blocks are the hypotheses of the soundness theorem (below) |
| SHA-256 | src/termbank/sha256.mojo |
A spilled block's digest, held in RAM, is the only check that a block read back is the block the checker passed (integrity) |
| The stateless checker | src/judgment_core/checker_*.mojo; in src/judgment_core/checker/, the view adapter (dag_view.mojo), the theory pass (theory.mojo, sorts.mojo, overloading.mojo, literal_kinds.mojo), the literal reader (literal_read.mojo), and verdict construction (verdict.mojo) |
The local check of every row and declaration form, the construction engine those checks run, verified facts, the theory pass, and the construction of verdicts (below) |
| Literal-kind implementations | codec.mojo, literal_values.mojo, literal_numeric.mojo, literals.mojo, poly.mojo, with errors.mojo and limits.mojo (the Call budget), in src/judgment_core/ |
Exact integer, rational, and formal-polynomial arithmetic and their encodings (C1.4, K2.1). They must compute exactly what the literal laws determine (requirements L1–L4), and evaluate only where the laws determine the value, declining everywhere else (L5) |
| Exact integers and rationals | apn_mojo Integer, Rational |
They implement the exact literal kinds |
| fp_mojo | fp.data (Result), fp.adt and fp.matching (Choice, match), fp.effects (ThreadTransferable) |
check_proof returns an fp Result. A literal value stores exactly one of its forms, integer, rational, or polynomial, in a Choice, and is matched exhaustively or read after its form is tested (literal_values.mojo, literals.mojo): the compiler's admission of each match, Choice storage, and its form tests must be correct. ThreadTransferable marks views, verdicts, and scratch as movable between threads, a claim that rests on termbank.dag's reclamation protocols |
| Profile axioms | scalar and other profiles |
They give the symbols their meaning |
| Imported statements | the import theories of judgment_store |
Theorems of a pinned Isabelle release used without a proof our kernel checked: trusted as proved by Isabelle's kernel and as translated faithfully by isabelle_bridge; each carries its provenance in every label. That provenance, and the class a bundle gives its own axioms, is recorded as the file states it: the system does not authenticate where an article or a bundle came from, so a label shows what a file claims, and a result's dependency list names the declarations it actually rests on. Replayed theorems are not in this row |
| Literal laws | the theorems or axioms each LiteralKind cites |
The literal scheme (lit(a) + lit(b) = lit(a + b) and the like) is not an axiom: it follows from the cited ordered-ring or ordered-field laws (Theorem C-11), and for a polynomial kind from the laws Q1 to Q8 and its base's (Theorem C-11P). Only cited axioms are trusted, as profile axioms |
| Propositional extensionality | the logic core | The core's one axiom; it holds in every topos, so it is not classical |
| Classical principles | the profiles that admit them | Excluded middle, choice, function extensionality, infinity |
| Admitted rule bundles | n1, Rubi's rules as theorems, MetiTarski's bounds once guarded, … |
Rules not derived from the profile's axioms |
| Admitted checkers | none | A certificate checker would be implemented in Mojo rather than reduced to kernel steps, and admitted with a proof that it preserves the admissible rules; termbank.dag refuses certificate rows at commit (TD1.8) |
Everything else is untrusted¶
Within judgment_core, the following hold no trusted logic:
- the construction engine as a producer drives it
(
checker/construct.mojo,checker/derived.mojo) and the bootstrap of the core prefix (checker/core_prefix.mojo): they write rows, and the checker checks those rows like any others; - the value types and the operand layouts (
inspect.mojo,layout.mojo,law_codes.mojo), which no check reads; - the independent reference checks in
src/judgment_core/testing/(reference_checker.mojo,reference_closure.mojo,br_format.mojo,br_expand.mojo,br_reference.mojo), which only tests and bench programs import (K1.13).
judgment_shell (except Session's handle validation, which the
storage section names), judgment_search,
judgment_store (except the imported statements above), the
prebuilt core's generated shims and its Mojo
and Python clients, every engine, the coordinator,
the pattern matcher, the polynomial algorithms, Rubi's search, the
normalizer, MetiTarski, every external decider (an RCF decider or SMT
solver, whose answers enter as certificates or as hypotheses), and the CAS
are untrusted.
How the base is kept small and correct¶
- No extension points. The literal kinds are a closed set compiled into the kernel; there is no public trait for adding one. Checkers are admitted one by one, by an explicit, recorded application action.
- Handles hold no content. A public handle of a checked object names a stored row, by (session, workspace id) or by a sequence number below the watermark (CG4). A raw row id or a content hash is never a handle, and a row asserts nothing until a verdict has moved the watermark past it (CG5).
- Constants are declarations, not names. Same-named constants of sibling theories have different heads, so they are different terms, and nothing proved in one theory reaches a sibling by its name.
- One construction engine. The checks and the producer run the same
engine for canonical construction, substitution, β, abstraction,
conversion's rebuild, and LIFT
(KC1.8), and only the
checker's run decides a verdict.
tests/judgment_core/checker/test_checker_engine.mojotests its β, abstraction, ACU spines, and literal evaluation in scratch. - An independent literal reference.
tests/reference/literal_reference.pyimplements every literal encoding and operation with Python integers and fractions, including every declining case (L5) and the size ceiling. - The in-process assumption. The kernel shares a process with
untrusted code. Handles are checked, but nothing can protect
termbank.dag's tables or the checker's scratch from code that writes to their memory through unsafe pointers. Soundness assumes that no client does; Candle states the same assumption about its programs (safe_dec). Mojo 1.2 has no private fields, so the assumption also covers names beginning with_: no client uses those oftermbankorjudgment_corevalues. Code reviews of every package check for both. The layering check (scripts/check_layering.py) restricts cross-package imports to root exports and thetermbank.dagsubpackage, rejecting private module paths and relative escapes, and rejects a construction of aVerdictoutsidejudgment_core.checker(CG8). The thinjudgmentpublic facade additionally rejects private-member access except through an unshadowed instance-methodself. The implementation packages have their own private objects; this lexical check does not infer receiver types or establish ownership there, and their prohibition on private kernel storage is an audited in-process assumption. Tests and measurement programs may inspect storage. - Defence in depth. The
weak_hashtest build makes every structural hash and every index probe collide, so that no path relies on distinct hashes. The reference-row and bridge-rule gates (KC1.14) check every sequent and declaration row of every article the classical profile accepts with a reference checker that shares no code withjudgment_core.checker, and judge each row's expansion into the deduction page's rules (Definition Q-13, Theorem Q-25). - Adversarial tests feed the checker rows that differ from valid ones
in one element (KC1.14's corruption fixtures), inject failures into
interning, declarations, workspace commits, and spills
(
tests/termbank/dag/test_dag_stress.mojo), and corrupt spilled blocks (test_dag_spill.mojo). - External auditing contracts.
judgment_storewrites session theorems as OpenTheory articles (Article.write), for rechecking by an independent HOL kernel and for replay in Isabelle through the external bridge. This repository does not provide a foreign proof auditor. - Dependencies are visible. Every result lists the classes of its dependencies, so a result that relies on an admitted bundle says so.
The stateless checker and DAG storage¶
Scope. This section details the first and third rows of the
inventory: termbank.dag and judgment_core.checker
(checker, DAG storage), the
sole trusted storage and checking implementation. The checks of type
definitions, overloading, classes, and sorts run in the theory pass.
The soundness theorem on the local checking
page holds by induction on the commit sequence. Suppose termbank.dag
keeps its invariants, and every row below the watermark passed its local
check against the stored contents of earlier rows. Then every statement
below the watermark is derivable in the logic extended by the admissible
sequent rules (sequents). The trusted base is
exactly what those two hypotheses rest on.
termbank.dag: trusted storage¶
- Interning is exact. Within a table, each distinct content has exactly
one row, so equal ids mean equal contents and the reverse. A hash match is
confirmed by an exact comparison of rows. Hashes only find ids; they never
are ids. The
weak_hashbuild, in which every hash collides, must pass. - The commit sequence. Every row of every table has one number in a single commit sequence. Every reference in a row points to a smaller sequence number, so the DAG is acyclic and closed under subterms by construction. The writer checks this on every append, whatever the producer supplied.
- The watermark and the theory mark. Each advances only when
termbank.dagapplies aVerdictof its kind fromjudgment_core.checker: one of this bank and of its current generation, whose range starts at the mark. A verdict that arrives early waits as pending; one that overlaps, comes from another bank or a truncated generation, or follows a stored refusal is refused. A mark never moves back. Facts and snapshot entries are published only with a verdict. Views given to sessions and callers stop at the watermark (CG4, CG5). - Immutability. A row never changes after commit. Columns are stored in chunks that never move. A snapshot is published by an atomic store of a sequence number, with release and acquire ordering, so a reader that sees a sequence number sees every row below it completely written. Readers take no lock.
- Lock-free reclamation. A replaced index run set, a merged run and a
former open index are freed only when no reader's epoch can still hold
them, and a reader keeps data from a cache frame only when the frame's
versioned state word is unchanged across the read (TD1.10, TD1.11).
DagView'sThreadTransferableconformance is an unchecked claim that rests on these protocols, so they are trusted: a reader that read freed or reused memory could see a row that was never committed. - Local and frame invariants. A local is its binding site, has a name and is followed by its fix frame; locals and frames are deduplicated (CG9), and set items are strictly increasing. termbank checks these at commit, and the checks of locals, contexts and canonical forms rest on them.
- Workspaces. A workspace is an overlay on a frozen parent prefix. Truncating it to a mark removes exactly the rows, annotations, marks and pending verdicts above the mark, and advances its generation, so no verdict computed before the truncation applies. A commit deduplicates its rows into the parent, returns an id translation, and either completes or leaves the target as it was. The appended rows are checked again in the target (Definition LC-20), so the translation is trusted for completeness only, never for soundness. A nested child sees its parent's uncommitted rows, and no workspace sees a sibling's rows.
- Annotation lookups. A lookup answers the one published fact or answer stored under its exact key. Annotations are keyed values outside the induction (TD1.6): which ones are published affects neither results nor charges, but each published one must hold the value of its key, which termbank keeps by refusing a second, different value for a key.
- Spilled data. Every byte read back from a spill file is checked against a digest held in RAM before it is used (below).
- Handles. The code that issues and validates handles is trusted for
what a handle means (CG4). A (session, workspace id) handle must name a
workspace row whose local check passed. A sequence number is a handle
only below the watermark. The
judgment_shellSessionfacade owns this handle validation.
judgment_core.checker¶
- Local checks.
check_proofandcheck_declarationimplement the local check of every rule and declaration form exactly as the local checking page states it. This includes the authoring ruleshypothesis,use,convert,transport,export,of_class,unconstrainand LIFT. A rule's side conditions, and the agreement of its stored conclusion, sets, home, sort hypotheses, context and signature with what the rule computes, must be checked without exception. A missed condition is a soundness bug. - The sequent rules (
refl,trans,sym,appThm,absThm,betaConv,assume,eqMp,deductAntisym,proveHyp,instas the kindsubst,use,ofClass, and the sequent LIFT) extend the kernel's trusted rule set. The codes and layouts are those of TD1.8. Its declaration kinds (axiom,thm,defineConst,defineConstList,defineTypeOp,defineSortedTypeOp,defineInstance,ofClass,instanceandclassRelation) are rows ofuseorofClass(Definition Q-17); the declarations themselves are declaration rows, which the theory pass checks.- Each one rests on an admissibility theorem on the sequents page. Type instantiation is admissible (Theorem D-6 and Corollary D-6a), and the sort-hypothesis rule has its own theorem.
- Each sequent rule is a derived rule over the unified judgment (Definition Q-18): a bounded combination of the deduction page's rules, among them (Weak) by entries, (Transport) and (InstType). Those three are primitive there and proved admissible (Theorems D-3 and D-5, Corollary D-6a). The checker's check of a row is the rule's fast path. It never runs the expansion, so checking costs nothing more.
- The bridge-rule gate expands every accepted sequent-rule row into
those rules (Definition Q-13), and an independent judge in
src/judgment_core/testing/checks each instance, with native (Weak) by entries, (Transport), and (InstType) (KC1.14).
- The construction engine computes every term a rule determines: canonical construction, substitution and instantiation, β, abstraction, conversion's rebuild, and LIFT. The checker runs it into scratch and maps the result to ids by read-only lookups. The producer runs the same engine, but that does not make the producer trusted, because only the checker's run decides a verdict.
-
The theory pass decides each declaration's global conditions:
- definitions, type definitions and specifications;
- overloading orthogonality;
- classes, instances and class relations;
- sorts and coregularity;
- merge and inclusion;
- ACU and literal-kind laws.
It builds the checked theory snapshot that proof checks read. - Contexts. The frame check (
check_frame_row) decides the conditions of every frame row (Definition LC-7). - Verified facts. The type, home, canonicity, scope, locals, sorted type variables and weight of a (term, signature) pair are computed by the checker alone. - Verdict construction. Onlyjudgment_core.checkerconstructs aVerdict(CG8), and only for rows that passed.
What is not trusted¶
None of the following components can make the system accept a false judgment. A bug in one of them can only refuse, stall, or report wrongly:
- the producer and its look-ahead window;
- the parallel driver, chunk planning, allowances and the report;
- fp_mojo's parallel runtime, in its role of running jobs;
- the library writer and reader;
- the facade's builder.
A verdict names its own bank, generation and range. Rows never change
within a generation, and facts and the snapshot only grow, so a verdict is
correct against any view of its bank and generation. termbank.dag
applies only verdicts that are contiguous with the mark of their kind. Results delivered late, out of order, twice, or not at all
therefore cannot place an unchecked row below the watermark. The driver and
the runtime are trusted for nothing. Tests check their determinism and
their progress (KC1.12).
fp_mojo's algebraic data and exhaustive matching stay in the base, as in the
inventory above.
Integrity: the threat model¶
- Process memory is trusted. The in-process assumption above holds:
no client writes the memory of
termbank.dagor of the checker, nor its members whose names start with_. Faults in RAM hardware are out of scope. - Every file is untrusted: spill files, published libraries, manifests and articles. The adversary considered can read and write any of them between the moment the process writes a file and the moment it reads the file back. The adversary cannot write process memory and cannot find second preimages or collisions of SHA-256.
- What must not happen. A row below the watermark is checked by CG5 and is never checked again. If a spilled row read back could differ from the row the checker passed, an attacker could forge checked rows.
- Spilled blocks. Sealed segments spill as compressed blocks of at least
1 MiB.
- Each block has a SHA-256 digest of its raw, uncompressed bytes, computed when the block is written and held in RAM, in the block directory, which is charged to the session's memory budget.
- On read-back, the stored bytes are inflated into a buffer of exactly the raw length held in RAM, and the digest of the raw bytes is recomputed and compared with the copy in RAM before any row of the block is used. A copy on disk, if there is one, is never used for the comparison.
- Because the digest covers the raw bytes, a codec bug can only cost an answer. The inflater runs on bytes the adversary may have written, so its memory safety on every input is trusted: it writes only inside its buffer (TD1.11).
- A mismatch or a read failure gives
STORAGE: no row is returned, and a check reports the undecided refusalSTORAGE, never a verdict. - Index runs that spill are covered in the same way.
- Published libraries. A library has one SHA-256 digest per compressed
block, and the Merkle root of those digests is in its manifest
(library DAG format).
- The digests detect corruption and identify content (SG2).
- They do not authenticate where a library came from, since anyone can recompute them.
- Soundness does not rest on them. A loaded DAG enters above the watermark, and the checker advances the watermark over it, as SG1 requires.
- No checks on resident data at each access. Resident rows are process memory, so no row read is hashed or authenticated. There is no SHA-256 per 4 KiB page and no radix walk per access.
- Why checksums are not used. Under this trust boundary, a block read back from a spill file becomes checked rows without a recheck. A non-cryptographic checksum (CRC-32, xxHash and the like) would let anyone who can write the spill file forge checked rows. This holds even when the checksum is kept in RAM: CRC-32 is affine over GF(2), so an attacker can make any change and adjust four bytes to keep the checksum. Only a second-preimage-resistant hash whose reference copy lives in RAM prevents this.
- Tests.
- Flipping one byte of a spilled block, or replacing the block, gives
STORAGEon read-back and never a different row. - A spill file carries no digest that the comparison uses (review).
- A library block changed without updating the manifest fails its digest.
- A library with a changed block and recomputed digests loads, and the checker refuses the forged rows when it checks them.
- Flipping one byte of a spilled block, or replacing the block, gives