Documentation

Elaborator.Monad

The effects the type checker needs: a local typing context Γ, a metavariable context, error reporting, and fresh-name generation.

structure Binding :

One Γ entry in the named half of Context (below): a Memory-keyed name (Origin.free — PlusCal variables/channels/fifos, self) or a top-level declaration (Origin.module/Origin.intrinsicCONSTANT/VARIABLE/operator/function/builtin). type is the Γ-lookup result; isScheme marks a declaration whose Typ.vars are freshened into fresh metavariables at every reference (specializeType, Elaborator/Expressions.lean's inferExpr) — only operator/function definitions and builtinContext entries; and origin is the Origin baked onto every Expression.var node that resolves here. Expression-level lexical binders (\A/\E/CHOOSE/set-builders/map'/fn, operator/function parameters) are not Bindings — they live on Context.lexical as de Bruijn positions. No default for origin — every construction site says which.

Instances For
    structure Context :

    The local typing context Γ, split by how a name resolves under locally-nameless binding:

    • lexical — expression-level binders, innermost first. A .var reference matching entry i here elaborates to Origin.bound i.
    • named — everything Memory-keyed or top-level (Origin.free/.module/.intrinsic), each carrying its own Binding. A .var match here takes the stored origin verbatim.

    lexical is consulted first, so an expression binder shadows a same-named PlusCal variable for the scope of its body.

    Instances For
      class MonadMetavarContext (α : outParam Type) (m : TypeType) :

      The metavariable context: tracks only whether each metavariable is resolved, and to what. MVarId is fixed at this project's own TypedTLAPlus.MVarId (:= Nat).

      The pending-upper-bounds bookkeeping the direction-aware solving algorithm needs on top of this is Elaborator/Subtyping.lean's job to layer over this class, not this file's concern.

      Instances
        structure MetavarContext (α : Type) :

        Backing store for the generic MonadMetavarContext instance below: index n holds ?n's resolved value, or none while still unresolved.

        Instances For
          @[implicit_reducible]
          Equations
          @[implicit_reducible]
          Equations
          • One or more equations did not get rendered due to their size.

          The effect bundle the checker's expression/declaration/PlusCal-level rules check against.

          Instances