define
Naming a term, or an operation whose result is unique
Overview
define introduces a new atom together with what defines it. There are two forms, and both are conservative: nothing new can be proven about the old atoms, so a definition can never make a theory inconsistent.
+definitionLabel: define(atomName := expression)+definitionLabel: define(atomName | theoremLabel)atomName- The name of the new constant.
expression- Its definition: a term (
S(S(0))) or a function written as a constructor ({a, b: ℕ | e}). The defining statements say the constant equals it — in both directions. theoremLabel- A proved unique existence
∃!{c: R | φ(c)} -> ✔(withrule("define", ∃!, ✔)); the constant is that unique element, and the definition isφof it. Underforatoms the theorem gives a function of them. definitionLabel- Receives the defining statements, to use as hints and facts.
Command Properties
- Group
- Inference steps
- Produces
- The defining statements (a theorem over the atoms of the definition)
- Delivery & Label
- The new atom is declared in the current scope (until the end of the block or file). The label receives the defining statements.
- Creates scope
- No.
- Mechanism
- Explicit form: the atom gets the type of the expression; for a function
{a, b: T | e}the label holds the theoremname(a, b) -> eande -> name(a, b)overa, b— call it or use it as a hint of a proof to unfold or fold. Unique-existence form: see below.
Basic examples
Explicit definition
An atom equal to a term can always be eliminated by substituting the term, which is why this is conservative.
Unfold and fold a definition
Definition by unique existence
An operation like the union of two sets is defined after it is proven that for any arguments the result exists and is unique. The language does not know which atom means «there exists a unique» — the theory declares it, as it declares the rules of its quantifiers:
Union of two sets
In the repository the set theory is built this way: define(∪ | T∪), define(∩ | T∩), define({} | T{}) for unordered pairs, and the Kuratowski pair as an explicit definition define(⟨⟩ := {a, b: 𝕊 | {}({}(a, a), {}(a, b))}).
The theorem must have the form Q{c: R | φ} -> v for a quantifier Q and value v declared by rule("define", …). Its for atoms become the arguments of the new operation, and its conditions stay: the defining statement can be used only where unique existence was proven. This is the theorem on functional extensions (J. Shoenfield, Mathematical Logic, § 4.6), the same principle as func … means … existence uniqueness in Mizar.
What the kernel sees
For the steps of a proof, define(f := …) is a for(f) block with a lock under
it whose axioms are the definition: f(a) -> e and
e -> f(a) for an explicit definition, φ(a, f(a)) -> ✔ (under the conditions
of the theorem) for unique existence. Both blocks are declarations: the code after the command continues inside the
lock until the end of the enclosing block. Inside the lock, a call finds the lock already assumed. Outside it,
or when a call substitutes an atom that the definition mentions, an explicit definition is replaced by its body
and its axioms become e -> e, given as statements proved there; an interpretation realizes them by the
definition in its own copy. So a constant can never be detached from its definition: a definition made under
for(x) does not survive a call with another value of x, and a call taking the blocks
around a proof that mentions the constant cannot cross the lock.
The certificate kernel knows an explicit definition as a definition level: the constant with its value,
and the defining statements as facts it checks to be true by unfolding the value. A result leaves the definition by the
level's own rule, stated of the value. This is how Lean, Coq, Isabelle and HOL Light treat definitions; why it is
conservative and how it compares is on Definitions in the Kernel. A definition by
unique existence has no value: for the kernel it stays a for block with a lock, and how to leave it — with a
function that satisfies it — is shown on Leaving a Block. The
research behind the design is in docs/design/constants.md of the repository; subtypes work the same way
(type).
Definitions and their requirements
A mathematical definition and a theorem can have different requirements.
Include the requirements of a public notion in its defining predicate. For example,
library/analysis/domains.fl defines functionLimitOnDomain(f,D,a,L)
as both an accumulation-point condition on a and the epsilon-delta
condition. The weaker helper satisfiesEpsilonDeltaConditionOnDomain
names only the latter condition, which can hold vacuously. A fact about the public
limit already supplies the accumulation-point requirement; its uniqueness theorem
does not ask the caller to supply it again.
Extra assumptions needed by a particular theorem belong in that theorem's conditions. Requirements for an operation defined from unique existence remain on its defining equation: being able to write a well-typed expression does not establish those requirements. Check the exported contract with show, and document these distinctions beside the mathematical definition.