The logic¶
The kernel implements polymorphic higher-order logic in the HOL tradition (HOL Light, Isabelle/HOL), presented by natural deduction with explicit contexts. This page explains the logic. The theory pages define it rigorously and prove it sound; the kernel reference gives its data structures.
For a first introduction, read Concepts and theory. For the comparison with dependent types and the limits of compatibility, see Why Isabelle/HOL.
Types¶
τ::= α type variable
| κ(τ₁, …, τₙ) a declared type constructor: Prop, Scalar, List(τ), Set(τ), …
| τ → τ functions
Every type is inhabited, as in HOL. Prop is the type of propositions,
declared by the logic core.
A constant, axiom, or theorem whose type mentions type variables is a
scheme: ∀x:α. x = x holds at every type. Using a scheme instantiates its
type variables; this type instantiation is what lets one theorem about
sets, measures, or groups serve every admissible carrier. Types do not
depend on term values, and there is no hierarchy of universes. Type
variables can carry class constraints, or sorts, as implemented by the
Theory mechanisms. A structure can also be an
ordinary argument, with a theorem assuming a predicate such as
is_group(G); this is useful for multiple structures on the same carrier.
Terms¶
t::= x bound variable (de Bruijn index)
| ℓ local (a fixed parameter of a context)
| c[τ̄] constant at type arguments τ̄
| t(t₁, …, tₙ) application spine, n ≥ 1
| λx:τ. t abstraction
| let x:τ = t in t local definition
| lit_k(v) literal of kind k with value v
Applications are n-ary spines: the function of a spine is never
itself an application. A constant declared ACU, such as + on Scalar,
may be applied to any number of arguments from two up, meaning the nested
binary application.
Propositions and rules¶
The logic core declares True, False, ∧, ∨, →, ∀, and the kernel
equality = at every type. ¬, ↔, and ∃ are defined:
¬P:= P → False
P ↔ Q:= (P → Q) ∧ (Q → P)
∃x. P:= ∀Q. (∀x. P → Q) → Q
The rules are natural deduction: introduction and elimination for each
connective, hypotheses, axioms and theorems with type and term
instantiation, reflexivity, symmetry, transitivity, congruence of
application (EqApply), the ξ-rule under abstraction (EqAbstract),
substitution into a predicate (EqSubstitute), conversion, and transport
between contexts. The larger system's certificate-checking workflows are
described in checking and evidence; the current public API
does not register arbitrary trusted certificate checkers. An axiom is an
explicit theory assumption, distinct from a proved theorem.
Classical reasoning is a profile choice. Excluded middle, choice, function extensionality, and infinity are admitted axioms of a profile, recorded in every result that uses them. The intended CAS profiles admit them; a constructive profile can leave them out. Propositional extensionality is the logic core's one axiom: it holds in every topos, so it is not classical, and the elimination of conversion steps needs it.
Conservative definitions. A new constant may be defined by a closed
body that does not mention it, whose type variables all occur in the
constant's type. Such definitions preserve consistency. The kernel also
implements type definitions from nonempty subsets and specifications backed
by witness facts. Their side conditions, along with those for overloading
and classes, are given in the class theory.
Recursive definitions and induction principles are theory-level
constructions and proofs, not kernel rules: the optional judgment_nat
package builds the natural numbers, induction, and primitive recursion from
these mechanisms and the classical principles
(natural numbers).
Definitional equality¶
The kernel identifies terms that are equal by computation:
| Rule | Example |
|---|---|
| α | λx. x and λy. y |
| β | (λx. x + 1)(2) and 2 + 1 |
| ζ | let y = 2 in y·y and 2·2 |
| δ | a transparent definition and its body |
| ACU | a + (b + c), (c + a) + b, and 0 + a + b + c |
| literals | 2 + 3 and 5; (1/2)·2·x and x; 2 < 3 and True |
Annihilation (0·x = 0) and distributivity are not definitional: they
fail on the extended carrier of the scalar profile
(0·∞ is Indeterminate), so they are guarded theorems. Everything the
kernel identifies follows from declared laws, so this speeds proofs up
without changing what is provable.
The kernel builds every checked term in canonical form: ACU spines
flattened, literals folded, units removed, arguments sorted by a structural
order. This lets the kernel share expressions and compare their canonical
forms by identity. Transparent definitions remain folded during construction;
defeq compares terms with the permitted definitions unfolded, so it can
recognize equalities that handle identity alone does not. convert changes
a judgment's proposition using that broader relation. The
conversion page specifies the algorithm, and the
definition tutorial demonstrates the distinction.
Contexts¶
A context is a chain of entries: fixing a local of a type, or assuming a proposition. The kernel tracks which locals, hypotheses, axioms, and literal kinds each judgment uses. Export discharges the hypotheses a judgment used and generalizes the locals it used, turning a result found under assumptions into a guarded theorem that any other context can apply.
CAS user symbols are constants of a session theory, not locals. A
context then mentions no locals, so the requests of one session can reuse
the same context, and the facts proved in it, instead of rebuilding it.
Two contexts built separately are different contexts even when their
assumptions read the same; identifying them needs a checked renaming
(architecture note, section 19.2). As the session declares new symbols, its
theory grows, and its contexts follow it: each frame of a context records
its theory, and a frame without an entry moves the context to a theory
that includes its own (rebase). Contexts are
compared by their entries: one extends another when its entries continue
the other's and its theory includes the other's.