Documentation

Elaborator.Declarations

Declaration/module-level checking: checkDeclaration/checkDeclarations, threading Γ 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/RECURSIVE are out of scope: neither has a CoreTLAPlus.Declaration constructor. Operator definitions thus get no self- or mutual recursion (their own name is never in scope for their own body); function definitions get self-recursion unconditionally (f is in scope checking its own body), matching ordinary TLA⁺ recursive functions.

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 [τ₁,...,τₙ].

@[reducible, inline]
abbrev SrcDecl :

The checker's actual input for one declaration: CoreTLAPlus.Declaration at α := Option Typ.

Equations
Instances For
    @[reducible, inline]
    abbrev Decl :

    The checker's output for one declaration.

    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
        def checkDeclaration {m : TypeType} [Monad m] [MonadElaborator m] [MonadPendingBounds m] (moduleName : String) (d : SrcDecl) :

        Γ ⊢ D ⊣ Γ' — checks one declaration, returning its elaborated form alongside the bindings Γ' adds over Γ ([] for ASSUME, which adds none). 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
        Instances For

          Γ ⊢ D₁, …, Dₙ ⊣ Γ' — checks a whole declaration list, threading Γ through each one. Returns the accumulated Γ' \ Γ bindings alongside the checked declarations.

          Equations
          Instances For