Proof authoring theory

The theorem store

Definition T-1 (guarded theorem). A guarded theorem is a fact of the session (an axiom, a Proven declaration, or a definition equation) whose proposition has the shape

\[ \forall x_1{:}\tau_1.\; \cdots\; \forall x_n{:}\tau_n.\; G(\bar x) \to C(\bar x) \qquad\text{or}\qquad \forall x_1{:}\tau_1.\; \cdots\; \forall x_n{:}\tau_n.\; C(\bar x), \]

with its type parameters \(\bar\alpha\). Its record lists the parameters and their types, the guard (as a normalized guard formula, \(\top\) for the second shape), and the conclusion. The parameters are opened as pattern variables for matching.

Theorem T-1 (records are read, not trusted). The store's record of a theorem is a function of the fact's checked proposition alone: the store reads the quantifier prefix, the implication, and the conclusion from the proposition the session reports.

Proof. By construction (LG4): registration takes a fact handle and parses its proposition with the session's own term structure. \(\square\)

Theorem T-2 (instantiation and application). For a guarded theorem \(d\), type arguments \(\bar\sigma\), terms \(\bar t\) of the instantiated parameter types usable in a context \(\Gamma\):

  1. instantiate returns \(\Gamma \vdash G(\bar t) \to C(\bar t)\) (or \(\Gamma \vdash C(\bar t)\)), a kernel judgment;
  2. apply, given a kernel judgment \(\Gamma \vdash G(\bar t)\), returns \(\Gamma \vdash C(\bar t)\).

Proof. (1) is the session's use of the fact with \(\bar\sigma\) and \(\bar t\) in \(\Gamma\). (2) is imp_elim (DR-5). Every record is a fact, so type instantiation is always the declaration's (closed-judgment type instantiation). Replacing an instantiated guard by its normal form uses the backward implication from G-1. \(\square\)

Lookup

Definition T-3 (index keys). The index maps each theorem to a key sequence computed from its conclusion (for an equation, its left side; for another proposition, the proposition) by a preorder walk that records each node's head and arity, except that a pattern variable becomes the wildcard * and its subterm is skipped. An ACU spine is coarsened to a subtree wildcard as well: after instantiation its units can remove its head entirely, so requiring that head would miss valid matches. Type variables are subtree wildcards, and rigid keys conservatively omit literal payloads and bound-variable indices. A query term's keys are computed the same way, without wildcards. This is a discrimination tree [McCune 1992; Graf 1996], coarsened at ACU spines.

Proposition T-4 (no missed candidates). If a theorem's pattern matches a term (Definition M-1), the index returns the theorem as a candidate for that term.

Proof. A match makes every rigid node of the pattern outside ACU spines identical in head and arity to the corresponding node of the term, and leaves the pattern's wildcards, type variables, and ACU spines unconstrained in the keys; the term's key sequence therefore follows a path of the tree that leads to the theorem. \(\square\)

The index may return candidates that do not match; the matcher (and its verification, Theorem M-2) filters them. A missed candidate would lose an opportunity; a false candidate costs a failed match. Neither affects soundness.

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