Command Groups
All commands of the language, grouped by what they do with scopes and statements
Overview
Every Formall command does one of a few things with the scope tree: it opens a scope (a context the statements inside depend on), passes through without creating a context, adds statements to the current scope, moves a result above an enclosing scope, generates ordinary commands for you, or works with labels. Commands of one group share their boundary and label behaviour, so learning one of them explains the others.
Reading signatures. Each command page starts with its signatures and, under them, what to pass as
each parameter of that command. The names in signatures are placeholders, not names to declare: a name ending in
Label is a label (a command that returns statements can usually stand there too), …Atom /
…AtomName — an atom or its name, …Expression — an expression, …Type — a
type. Arguments come in two sides: first the expressions — terms and statements left -> right,
written as they are, without quotation marks — then, after a bar |, the proofs: labels, proofs <…>,
calls and commands that give statements (axiom(P | L)). Quotation marks are left only for texts that are not
terms: file paths and the kinds of rule("…") and notation("…").
Two forms of the language are not commands at all, though they derive statements as commands do: a
proof <…> and a call T[…].
They are described with the basics and listed below among the inference steps.
| Group | Commands | What they share |
|---|---|---|
| Context | type, for,
if, lock,
axiom, rule |
Open a scope; what is proved inside depends on it. Boundaries for closing commands. |
| Transparent headers | import, notation |
Stand in a header chain or end with ;, but are not a context: commands pass through them. |
| Inference steps | <…>, T[…],
define |
Add new statements to the current scope. |
| Calls that leave their blocks | contradict[| S], generalize[| S], deduce[| S], obtain[| S] |
A call whose lock axiom asks for a proof under for or if takes those blocks and delivers the result above them, removing the assumption or the variable. |
| Generators | decide |
Writes ordinary if / call / <…> text for you; the checker sees only that text. |
| Tools | show |
Print what is visible at the place (scope, facts, labels) or search for text; produce nothing. |
| Labels | + - * ^, expect( ) |
Combine and compare collections of statements; no logical content. |
A second way to look at the same commands is the trusted base: the axioms, the locks, the
enumerations and the two rules — define (from ∃!)
and bijective. The steps of a proof rest on theorems the file writes and names: a call on a quantified
fact removes its quantifier through notation("apply" | A∀Apply), rewriting by equality in proofs through
notation("hint" | …), and the introduction of a quantifier or an implication, the elimination of an
existential, the closing of an assumption are calls of theorems (generalize, deduce,
obtain, contradict of the library). tools/trust.py lists what each theorem relies on.
Context
Context commands are block commands: they open a scope that lasts until } (or until the end of the
enclosing block). A statement proved inside the scope depends on the scope's header, and outside of it the statement
becomes a theorem with that header turned into parameters and conditions, which a call T[…] fills in again:
type(T)andfor(x: T)introduce parameters — types and atoms (⋀ in Isabelle/Pure).type(T = a | b)also declares an enumeration.if(A -> B)introduces assumptions (⟹).lock()is an assumption block whose assumptions are added later, from inside, byaxiom(… | L); a theorem proved with them receives them as parameters that a call realizes.rule("…", …)introduces rules of the logic; a theorem proved under a rule needs that rule wherever it is applied.
All of them are boundaries: closing commands stop at them, and a label on type,
lock or rule names the scope instead of capturing statements.
Transparent headers
import("file.fl") and notation("kind", …) may stand in a header chain
(for(∘, e) notation("infixl", ∘, 70) if(…) { … }) or end with ;, but they are not a
context: closing commands pass through them, and theorems get no parameters or conditions from them.
They are not one command, because they do different things. notation changes only how text is read and
printed: if all operators were written in prefix form and abbreviations expanded by hand, the proof would stay the
same. import brings atoms, axioms, rules and theorems of another file into scope; without it the proof
does not check. It also has its own permissions (--import-root, formall.project).
Inference steps
These forms and commands add statements to the scope they are written in; a label on them captures those statements there.
<…>— rewriting: angle brackets, hints<e | L>, chains<t0 -> t1 | H -> t2>.T[…]— applying a theorem: parameters are instantiated, conditions are discharged by facts, lock axioms are realized; on a quantified fact,L[a], — removing its quantifier (∀-elimination).witness[t | L]— a call of the library's theorem: replacing a term in a fact by a quantified variable (∃-introduction).define(f := …)— a new atom with its defining theorem.
Calls that leave their blocks
A step that takes statements proved inside a scope and delivers the result above it, removing what the scope assumed, is a call of a theorem whose lock axiom asks for a proof of that shape; the library proves the theorems once:
| Call | Takes | Result above the blocks |
|---|---|---|
contradict[| S] | if(A -> B) | The assumption is false: the contradiction flips it (A -> ❌ for A -> ✔) |
deduce[| S] | if(P) | P ⇒ Q for the Q proved inside |
generalize[| S] | for(x) | ∀{x | …} |
obtain[| S] | for(x) if(p(x)) | The statement itself, when it does not mention x (∃-elimination) |
They share all of their mechanics:
- the proof after the bar is a label, a proof or a nested call; a nested call delivers above its own blocks
first, and the outer call stands where that result stands, so the calls compose from the inside out:
generalize[| deduce[| contradict[| …]]]; - a label on such a call captures the result at the delivery scope, not where the call is written;
- context commands a call does not take (
type,lock,rule) are boundaries: the result cannot be carried across them.
contradict and deduce close the same if; which one to use is the author's
decision, so each step names what it does.
Generators
decide(X) computes the value of X from facts by the tables of the functions over
finite types. It produces ordinary if / call / <…> text that is parsed and checked
like hand-written code; it adds nothing to the trusted base. The hints <e | decide()>
and <e |* A, B> inside proofs work the same way. A case split by hand is a
branch if (P -> ❌) S and the same step S after it (decide).
Tools
show() prints the context of its place into the log: the enclosing
for / if (which one a closing command will close), the nearby facts and the labels of the file;
show("text") searches visible facts and labels, imported ones included. It produces no statements — the
proof is the same with or without it.
Labels
Label commands treat a label as a collection of statements: + union, - difference,
* intersection, ^ symmetric difference. expect( ) checks that collections are equal and
reports the difference otherwise; the commonly used check “these statements were proved” is
expect(a -> b; … | L). Declaring, defining and extending labels (+L;, L:,
L::, L+:) is described in Labels.