Documentation

Core.SurfaceTLAPlus.Syntax

The surface syntax of TLA⁺ modules, as accepted by the parser — a CST close to the concrete grammar (https://lamport.azurewebsites.net/tla/TLAPlus2Grammar.tla), prior to desugaring.

Positions are not stored structurally in these types: every constructor produced by the parser is tagged out-of-band via the @@/posOf/match_source mechanism in Common/Position.lean.

The entire set of prefix operators reserved in TLA⁺. Fin _ parameters distinguish alternative spellings of the same operator (given in doc-comment order).

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

        The entire set of postfix operators reserved in TLA⁺.

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

            The entire set of infix operators reserved in TLA⁺.

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

                    TLA⁺ types, in the same format as Apalache.

                    • bool : Typ
                    • int : Typ
                    • str : Typ
                    • function : TypTypTyp

                      τ -> τ

                    • set : TypTyp

                      Set(τ)

                    • seq : TypTyp

                      Seq(τ)

                    • bag : TypTyp

                      Bag(τ)

                    • tuple : List TypTyp

                      <<τ₁, …, τₙ>>

                    • operator : List TypTypTyp

                      (τ₁, …, τₙ) => τₙ₊₁

                    • var : StringTyp

                      A rigid, universally-quantified type variable a.

                    • const : StringTyp

                      CONSTANT — an abstract type.

                    • record : List (String × Typ)Typ
                    • channel : TypTyp

                      Channel(τ). Covariant: τ <: τ' → Channel(τ) <: Channel(τ').

                    • address : Typ

                      Address.

                    • mvar : Typ

                      A metavariable ?n, resolved during type checking; never appears in a fully-elaborated TypedTLAPlus term.

                    Instances For

                      Whether τ is Channel-shaped: a bare Channel(τ'), or an indexed channel family dom -> Channel(τ') (as Elaborator/PlusCal.lean's checkChannelDecl encodes it). Shared by WellFormedness/Declarations.lean (checks 2(a)/(d)) and WellFormedness/Restrictions.lean (check

                      1. as one source of truth for "legal channel type."
                      Equations
                      Instances For

                        Groups of variables bound in quantifiers (\A/\E/…).

                        Instances For
                          def SurfaceTLAPlus.instReprQuantifierBound.repr {α✝ β✝ : Type} [Repr α✝] [Repr β✝] :
                          QuantifierBound α✝ β✝Std.Format
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            @[implicit_reducible]
                            instance SurfaceTLAPlus.instReprQuantifierBound {α✝ β✝ : Type} [Repr α✝] [Repr β✝] :
                            Repr (QuantifierBound α✝ β✝)
                            Equations
                            @[implicit_reducible]
                            instance SurfaceTLAPlus.instBEqQuantifierBound {α✝ β✝ : Type} [BEq α✝] [BEq β✝] :
                            BEq (QuantifierBound α✝ β✝)
                            Equations
                            @[implicit_reducible]
                            Equations
                            • One or more equations did not get rendered due to their size.

                            Either a single bound variable x, or a tuple of them ⟨x, y, …, z⟩.

                            An inductive rather than an alias for 𝒱 ⊕ List 𝒱, for the same reason QuantifierBound is one. Expression.choose/.collect instantiate this at α × String, and α is itself a datatype being declared wherever Expression is nested inside one — Parser_/Annotations.lean's Annotation holds Expression (List Annotation). Lean's nested-inductive compiler inspects constructor argument types syntactically, and a recursive occurrence may sit under List/Prod/Sum or another inductive, but not under a definition, whose head stays opaque; reducibility does not help, an abbrev fails exactly as a def does ("contains a non valid occurrence of the datatypes being declared"). This was invisible while the element type was plain String: no α, hence no occurrence to check.

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

                                Independent of α — the empty tuple needs no annotation.

                                Equations
                                @[implicit_reducible]
                                Equations
                                • One or more equations did not get rendered due to their size.
                                @[implicit_reducible]
                                Equations
                                • One or more equations did not get rendered due to their size.
                                @[reducible, inline]

                                General annotations, as supported in Apalache.

                                Equations
                                Instances For

                                  TLA⁺ expressions as accepted syntactically, before desugaring. The α parameter carries whatever comment-annotation payload the caller wants attached at binder sites (e.g. @type annotations).

                                  Instances For
                                    partial def SurfaceTLAPlus.instReprExpression.repr {α✝ : Type} [Repr α✝] :
                                    Expression α✝Std.Format
                                    partial def SurfaceTLAPlus.instBEqExpression.beq {α✝ : Type} [BEq α✝] :
                                    Expression α✝Expression α✝Bool
                                    partial def SurfaceTLAPlus.Expression.map {α β : Type} (f : αβ) (e : Expression α) :
                                    partial def SurfaceTLAPlus.Expression.traverse {F : TypeType} [Applicative F] {α β : Type} (f : αF β) (e : Expression α) :
                                    F (Expression β)
                                    @[implicit_reducible]
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    @[implicit_reducible]
                                    Equations
                                    • One or more equations did not get rendered due to their size.

                                    A top-level TLA⁺ declaration, prior to desugaring. Own type rather than the Core/Declaration.lean shared one CoreTLAPlus/TypedTLAPlus reuse verbatim: a function definition's binder list here may still be shared-domain (x, y \in S) or tuple-pattern (<<x,y>> \in S) sugar — the same QuantifierBound shape \A/\E/set-builders already accept — which Desugarer/TLAPlus.lean flattens down to CoreTLAPlus.Declaration.function's plain per-binder form before anything past desugaring ever sees it. RECURSIVE and module INSTANCE are not represented.

                                    Instances For
                                      @[implicit_reducible]

                                      Hand-written since deriving Repr can't discharge the higher-kinded Repr (Expression α) obligation.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      @[implicit_reducible]
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      @[implicit_reducible]
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      structure SurfaceTLAPlus.Module (α β : Type) :

                                      A parsed TLA⁺ module, EXTENDS-list and all, wrapping the embedded (Distributed) PlusCal algorithm at whatever α the caller instantiates it at — kept abstract to avoid a cyclic import between the two Core ASTs. Own type for the same reason Declaration above is: its declarations₁/declarations₂ are lists of this Declaration, not Core/Declaration.lean's shared one.

                                      Instances For
                                        @[implicit_reducible]
                                        instance SurfaceTLAPlus.instReprModule {α β : Type} [Repr α] [Repr β] :
                                        Repr (Module α β)

                                        Hand-written, same reason as Declaration's Repr instance above.

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

                                        @@ posOf m, for the same reason SurfacePlusCal.Process/.Algorithm's instances carry it: mapping a module rebuilds the structure, and a rebuilt node that isn't re-registered has no position of its own — posOf then answers for it with whatever unrelated value last occupied that address (Common/Position.lean).

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