Declaration/module-level checking: checkDeclaration/checkDeclarations, threading Γ (and,
alongside it, Δ — see Δ's own doc comment below) across CONSTANTS/VARIABLES/ASSUME/
operator-definition/function-definition, plus builtinContext, a minimal Γ₀ prelude of core
TLA⁺ operators (equality, boolean connectives, core set theory) needed before any user
declaration is checked.
Every declaration's expressions are closed out via resolveMVars before checkDeclaration
returns, so a metavariable freshened during one declaration doesn't leak unresolved into the
next declaration's Γ.
THEOREM is out of scope: it has no CoreTLAPlus.Declaration constructor. RECURSIVE is in
scope (.recursive, Δ): an operator definition is in scope for its own body, and every
sibling operator's Δ-pending name, exactly while both remain undischarged — self- and
mutual-recursion, following reference/thesis.txt:2109-2187 (Fig 3.1.9/3.1.10). An operator
not named by any RECURSIVE still gets none of this (Δ empty ⟹ no-op), matching the
pre-RECURSIVE behavior below unchanged. Function definitions get self-recursion
unconditionally (f is in scope checking its own body), matching ordinary TLA⁺ recursive
functions — Δ plays no role there, per the thesis's own Function-definition rule.
A multi-argument function definition f[x₁ ∈ e₁,...,xₙ ∈ eₙ] isn't pre-tupled the way a
multi-index call is: n = 1 gives a domain type of τ₁ itself; n > 1 requires the
annotation's domain to be Typ.tuple [τ₁,...,τₙ].
The checker's actual input for one declaration: CoreTLAPlus.Declaration at α := Option Typ.
Equations
Instances For
The checker's output for one declaration.
Equations
Instances For
Δ — "operators that have been marked recursive" (reference/thesis.txt:2114), threaded
alongside Γ through a module's declarations. A RECURSIVE predeclaration (.recursive) adds
its entries here, never to Γ; an .operator definition that discharges one removes it. Kept
separate from Γ itself (not merged permanently) so that a later .operator naming the same f
sees f ∉ Γ exactly as if RECURSIVE had never run — requireFresh below needs no Δ-aware
carve-out as a result.
Equations
Instances For
Γ₀ — the minimal builtin prelude. Every entry is a scheme (Binding.isScheme := true):
each is a genuine operator definition, so Typ.vars used for whatever's meant to be generic get
freshened into their own metavariable at every reference (specializeType,
Elaborator/Expressions.lean's inferExpr).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Γ ⊢ D ⊣ Γ' — checks one declaration, returning its elaborated form (none for .recursive,
which emits no TypedTLAPlus.Declaration — B.1) alongside the bindings Γ' adds over Γ ([]
for ASSUME/.recursive) and Δ's own updated state. A CONSTANT/VARIABLE binding is never a
scheme (Binding.isScheme := false, even if its annotation mentions a Typ.var): a CONSTANT is
one fixed, if abstract, value, not a family to instantiate fresh per reference. An
operator/function definition's own binding is a scheme, any arity — see each case below.
Equations
- One or more equations did not get rendered due to their size.
- checkDeclaration moduleName δ (CoreTLAPlus.Declaration.assume e) = do let e' ← checkExpr e SurfaceTLAPlus.Typ.bool let e' ← resolveMVars e' pure (some (Declaration.assume e'), [], δ)
- checkDeclaration moduleName δ (CoreTLAPlus.Declaration.function (some τ) f args body) = do requireFresh✝ (posOf body) f throw (TCError.notAFunctionType (posOf body) τ)
Instances For
Γ ∣ Δ ⊢ D₁, …, Dₙ ⊣ Γ' ∣ Δ' — checks a whole declaration list, threading Γ and Δ through
each one. Returns the accumulated Γ' \ Γ bindings alongside the checked declarations (.recursive
contributing no Decl at all — Option.toList's [] case) and Δ's final state, so a caller
spanning more than one such list (declarations₁/declarations₂ either side of the embedded
PlusCal algorithm, Elaborator.lean) can thread Δ across both and, only once both are checked,
report any name still pending.