Concepts and theory¶
The central result in judgment is a proposition proved in a particular theory and context. Understanding those three parts makes the API easier to use and tells you what a checked result actually guarantees.
Read a judgment¶
We write a checked judgment as
𝒯 is the theory: the declared types, symbols, definitions, and facts.
Γ is the context: fixed local variables and temporary assumptions.
P is the proposition established by a derivation. In a session, a
Step represents this result: statement() is P, hypotheses() lists the
assumptions of Γ it uses, and axioms() and dependencies() list the
declarations of 𝒯 it rests on. A Fact is a declared, closed result, such
as a named theorem or an axiom.
For example, from an assumption P ∧ Q the conjunction rules derive
Q ∧ P. That result holds in the context containing the assumption.
Implication introduction then gives (P ∧ Q) → (Q ∧ P) in the outer
context. The first tutorial executes exactly
this derivation.
An Expr has a different role. It says that the expression has been
checked for typing and scope. The constant False is a valid expression
of type Prop; constructing it does not prove False.
Separate types from values¶
The logic uses polymorphic simple types. A type is a type variable, an application of a declared type constructor, or a function type:
α a type variable
List(α) a constructor applied to a type argument
α → Prop a predicate on values of type α
Prop is built into the logical vocabulary. Names such as List or
Scalar above illustrate declarations supplied by a theory; they are not
all built into the root theory. Type variables can carry class constraints
called sorts, such as a requirement that a carrier support an admitted
algebraic structure.
Types can depend on other types, but they do not contain arbitrary term expressions. A polynomial's degree or a matrix's dimensions can therefore be represented as values and expressed in propositions. Changing those values does not itself change the type of the surrounding expression. The HOL rationale explains the benefits and costs of this choice.
Polymorphism lets a theorem be reused at different types. The equality
constant, for example, has a type scheme α → α → Prop. Instantiating it
at A gives equality between two terms of type A. This is distinct from
quantifying over values: ∀x:A. x = x quantifies over x, while the
theorem's type parameter lets the whole statement be used at another type.
Every type is inhabited in the HOL semantics. Defining a type from a subset therefore needs evidence that the subset is nonempty. Sorted theorems additionally track the required sort inhabitation conditions; the type and class theory states these conditions precisely.
Keep declarations and assumptions distinct¶
Declaring x: A as a constant (symbol) gives a theory a symbol. Fixing
x: A in a frame (fix, or a proof's var or intro_var) introduces a
local parameter that can later be abstracted or universally quantified.
Assuming P (assume, or a proof's given or intro) introduces a
hypothesis that proofs may use. These operations have different identities and scope rules even
when a printer gives their objects the same name.
A local parameter is identified by its binding site: the frame it
extends, its type, and its name. Fixing x: A twice over the same frame
gives one parameter, while x: A fixed over two different frames gives two
parameters, though both print as x. Assumptions are shared the same way:
assuming P twice over one frame gives one hypothesis. A parameter fixed
over a frame occurs in no term usable at that frame, so it is fresh there
whatever its name, and the side condition of universal generalization
holds by where it was fixed. A session keeps the names of its own
variables distinct and reserves names that begin with · for its internal
helpers. judgment_shell's debug printer show prints parameters as
v0, v1, … in order of first occurrence, and a theorem's statement does
not depend on how its parameters were named or where they were bound.
Definitions and axioms also differ. A definition gives a new symbol a body and must satisfy the conservative-definition checks. An axiom admits a proposition without deriving it. The kernel checks proofs relative to the admitted axioms; it does not decide whether a collection of arbitrary axioms has a model.
Dependency tracking preserves these distinctions. A theorem proved under
an assumption cannot become unconditional by moving it into a new
container. imp_intro, forall_intro, and discharge turn the used
assumptions into implications and the used locals into universal
quantifiers, and finishing a theorem does the same for its header. The
receiving caller can then see and discharge the conditions.
Three ways to compare expressions¶
| Comparison | What it establishes | How to ask |
|---|---|---|
| Identity | The handles name the same canonical expression. | same_as |
| Definitional equality | The terms agree under the kernel's computation rules and the unfolding you allow. | change, convert, or rfl |
| Proved equality | A derivation establishes the proposition s = t in a context. |
A Step built with equality rules or a theorem |
For live handles in the same session, shared canonical construction makes identity useful. It avoids storing or repeatedly comparing copies of the same canonical expression. It is not a cross-session identifier or a test for every mathematical equality.
Conversion includes beta reduction (applying a lambda), zeta reduction
(substituting a let-bound value), permitted transparent-definition
unfolding, and the declared ACU and literal rules. ACU means associativity,
commutativity, and a unit: once the relevant laws have been registered,
a + (b + c) and c + a + b + 0 have the same canonical reading.
Bound-variable names are immaterial because binders use de Bruijn indices.
Construction performs the canonical reductions but leaves transparent
definitions folded. change and convert unfold only the transparent
definitions listed in their unfold argument, none by default. Opaque
definitions remain opaque. The definition tutorial
shows why different expressions can still be definitionally equal.
Conversion does not use arbitrary assumptions or rewrite theorems. If a
theory proves s = t using a guard, you must supply evidence for that guard
and use equality inference. A refused conversion neither refutes the
theorem nor establishes s ≠ t. convert changes a proved proposition to
a definitionally equal one; it does not prove an unrelated target.
Make arithmetic laws explicit¶
The kernel has trusted implementations for integer, rational, and formal-polynomial literals. Registering a literal kind connects its operations to law declarations in a theory. This is why exact computation can replace a sequence of arithmetic proof steps without silently choosing a number system for the application.
Symbolic identities still depend on that number system. In an ordinary
field, 0 · x = 0. In the extended scalar carrier, x can
include infinity or indeterminate values, so an analogous simplification
needs the appropriate domain conditions. Likewise, distributing or
canceling symbolic factors is theorem-level reasoning, not an automatic
consequence of canonical term construction.
The conversion theory explains how accepted conversion steps are justified by laws in an ordinary logical reading. This justification does not remove the implementation from the trusted base: the code must still compute and check those steps correctly.
Understand the trust boundary¶
A search engine chooses candidates and proposes evidence. Only the kernel
produces checked judgments after validating their rules, types, scopes,
and side conditions. A bad candidate can be rejected without making its
search algorithm trusted. An axiom declaration deliberately enlarges the
assumptions, so admitting arbitrary solver output as axioms would defeat
that separation. An external decider's answer enters as an assumption
instead: register_claim records the decider, its query, and its version
on the assumption's frame, one claim per frame and decider, and a result
that uses the assumption keeps it as a hypothesis or a premise.
Checked results rely on the implementation of the kernel, the
termbank.dag storage whose rows it checks, exact arithmetic, and the
admitted theory axioms. The trusted-base inventory
gives the full boundary, including the in-process memory-safety assumptions.
The mathematical soundness arguments are written proofs; this Mojo
implementation has not been formally verified.
Every step of a session keeps its proof rows in the proof DAG. If another
system will need to replay the proof, keep the derivation and its
dependencies, through Session.seal, Session.export, or judgment_store,
rather than relying on a handle alone.
Continue into the formal theory¶
| Question | Formal treatment |
|---|---|
| What are the exact term forms and binder rules? | Syntax |
| What makes a term well typed and usable in a context? | Typing |
| Which inference rules establish a proposition? | Deduction |
| In what models are those rules sound? | Semantics |
| Why do canonicalization and conversion preserve meaning? | Conversion |
| What justifies type definitions and sorted overloading? | Types and classes |
| How does checking fit into a larger search system? | Checking at the boundary |
The theory index distinguishes established results, implementation requirements, and proposals. Some chapters describe the larger CAS design; the capabilities page identifies what the packages implement.