Labels
Naming and managing collections of statements
Overview
Labels in Formall serve as named references to collections of statements. They are used to store proof results and pass them on: to calls T[a | L], as hints of proofs <e | L>, to commands like generalize and contradict.
Declaration and Definition
Combined Declaration and Definition
Use +Name: before a command to both declare and define in one step:
Declaration + definition
Module-level declaration: T::
The most common case — a theorem proved deep inside for and if blocks, whose label must live at the top of the file — has its own form. T:: declares the label at the top level of the current file (exactly where +T; would stand before the statement that contains the definition) and defines it here, like theorem in Lean. All for and if between the top level and the definition become the theorem's parameters and conditions. T:: on a label that is already declared is an error (define it with T:), and an undeclared T: is still an error, so a typo never creates a new theorem silently. +T; stays for other levels — for example, a label declared inside a hypothesis block.
Module-level declaration
Forward Declaration
Declare a label with +Name; before defining it later. Use Name: (without +) to add statements to an already declared label. This is useful when the definition happens inside a nested scope but the label must be accessible outside it:
Forward declaration
Delivery Scope
A label placed on a command captures the result at the delivery scope of that command. For most non-scope commands, delivery is the current scope. A call that takes the blocks its proof stands in is special: contradict[| S] delivers above the if it closes, generalize[| S] above the for it takes. Scope commands (if, rule) deliver into themselves.
| Command | Delivery scope | Boundaries |
|---|---|---|
for | N/A (no label allowed) | — |
if | Into itself | — |
type, lock, rule | Into itself (scope marker) | — |
proofs <…>, calls T[…], axiom, +-*^ | Current scope | — |
contradict[| S], a call taking an if | Parent of the if taken | for, type, lock, rule |
generalize[| S], a call taking a for | Parent of the for taken | if, type, lock, rule |
+Label: syntax physically appears. For example, +L: contradict[| …] places the label in the parent of the if the call closes.Since such calls deliver to a different scope, labels on them capture results at those delivery scopes:
Labels at different delivery levels
Since generalize[| …] delivers to the parent of the for it takes, you can pass a proof directly to avoid needing a separate label inside the loop:
generalize delivers above for
Scope Visibility
Labels follow scoping: a label is accessible in the scope where it was declared (and in all nested scopes). When that scope closes, the label is no longer accessible.
Whenever a label's statements are read — by a call, a proof hint, label commands, or any other operation — statements are filtered by scope visibility. Only statements whose definition scope lies on the path from the current scope up to the label's declaration scope are included. Statements from sibling branches of the scope tree are foreign and are excluded (with a warning).
Scope filtering
Collected holds statements from two sibling if branches. Inside the second if, only its own branch's statements are visible.
Using Labels with prove
Inside a proof, you can specify which label to use for a particular substitution using the <expr | Label> syntax:
Labels in prove
Lock Labels
When a label is placed on lock(), it can be used as the first argument of axiom. See lock() and axiom for details. Here is a complete example:
Lock label with axiom
Undeclaration and Undefinition
Two operations for removing label data:
-Name;(undeclaration) — removes the label entirely; any subsequent use causes an error. The label is searched upward through all parent scopes, so you can undeclare a label from inside a nested block.Name-;(undefinition) — clears the label's statements but keeps it declared for later reuse
Undefinition and undeclaration
Since undeclaration searches upward, it can be used to remove visibility of labels declared in outer scopes. A common use case is sealing a lock() after all axioms have been defined:
Sealing a lock via undeclaration
After -𝒜;, no new axioms can be added to this lock, but existing axioms and theorems still work.
Augmentation
By default, redefining a label (L: cmd) clears all its statements in the current scope and replaces them. With an augmentation postfix, you control how new statements combine with existing ones:
L+: cmd— union: adds new, skipping duplicatesL-: cmd— subtract: removes matching statementsL*: cmd— intersect: keeps only statements present in bothL^: cmd— symmetric difference: XOR of the two sets
+L+: cmd is an error). Declare and define first, then augment.All four augmentation operations
Accumulating across scope branches
The L+: postfix is especially useful for collecting results from different scope branches. Plain L: cmd would fail because it tries to clear statements from foreign scopes:
Accumulating with Label+: across scope branches
Duplicate Statements
Statement equality in labels considers both content and scope. Two statements with identical expressions are equal only if they were defined in the same scope. This affects all set operations and augmentation.
Defining a Label with Another Label
A label name is a proof — after | of a call, of a proof hint or of a command — and so it is where a
statement stands: C: H; defines C with the statements of H visible here, as
C: +(H); does. As every reading of a label, it keeps only the statements on the path to here (see
Scope Visibility).
A copy stands where C is declared. That decides which atoms are parameters of its statements — the
atoms of the blocks between a statement and the declaration of its label. A theorem declared at the top of a file
takes the for atoms of its blocks as parameters; its copy declared inside those blocks takes none of
them: it is the statement as a fact of this place.
A copy of a label is a fact of its place
A proof gives its statements to whoever takes it: written as a statement, to the block; as an argument, to the
command that takes it; in a hint, to the hint. A label name alone (H;) is +(H); written as a
statement: it gives the block the statements of H visible here — they are its facts already, so nothing is
added, and the interpreter warns. See Label Commands for +,
-, *, ^.