Documentation

Core.GuardedPlusCal.Syntax

The output of Computable2Guarded: every guard (await/receive/with) sits at the very start of its atomic branch. Reuses ElaboratedPlusCal.Ref/.Multicast rather than redefining them — Computable2Guarded's Ref field-access fix (Core/TypedPlusCal/Syntax.lean) flows through automatically. Unlike ElaboratedPlusCal, Statement here is genuinely flat: by this stage every if/while/either has already been rewritten away into AtomicBranch's precondition/action split (𝒞_cflow/𝒞_flat/𝒞_reord), so no constructor embeds a nested Block/Branches the way CorePlusCal.Statement.if/.while/.either do — no mutual, partial, or position tracking is needed anywhere in this file (ElaboratedPlusCal carries none either, see Typed2Computable/PlusCal.lean's module doc).

Block, unlike every other type here, is generic over an arbitrary index family α : Bool → Type, not (Typ Expr : Type), since it's purely structural and doesn't reference Typ/Expr at all. Block (Statement Typ Expr true) false/Block (Statement Typ Expr false) true both instantiate it.

Pinned at ComputableTLAPlus.Typ/ComputablePlusCal.Expression for this pass's actual use (ComputableGuardedPlusCal below), the same way Core/ComputablePlusCal/Syntax.lean pins the shared ElaboratedPlusCal layer rather than forking a monomorphic copy.

structure GuardedPlusCal.Block (α : BoolType) (b : Bool) :

A (possibly empty) sequence of non-terminal α false objects followed by a potentially terminal α b. Generic over the index family α itself, not Typ/Expr — see the module doc above.

Instances For
    @[implicit_reducible]
    instance GuardedPlusCal.instReprBlock {α : BoolType} [(b : Bool) → Repr (α b)] {b : Bool} :
    Repr (Block α b)

    deriving Repr can't discharge this — α's Repr instance is only known per-index (∀ b, Repr (α b)), not as one instance for the whole family.

    Equations
    def GuardedPlusCal.Block.map {α β : BoolType} (f : b : Bool⦄ → α bβ b) {b : Bool} (B : Block α b) :
    Block β b
    Equations
    Instances For
      def GuardedPlusCal.Block.traverse {α β : BoolType} {m : TypeType} [Applicative m] (f : b : Bool⦄ → α bm (β b)) {b : Bool} (B : Block α b) :
      m (Block β b)
      Equations
      Instances For

        Block's list-like interface. end/cons are the constructors the semantics recurses on; toList/ofList are the two halves of the isomorphism with non-empty lists; concat/prepend extend a block on the right and on the left. All abbrevs or @[reducible] so that rw sees through them in Semantics/Lemmas.lean.

        @[reducible, inline]
        abbrev GuardedPlusCal.Block.end {α : BoolType} {b : Bool} (S : α b) :
        Block α b

        The one-statement block: nothing before the (possibly terminal) S.

        Equations
        Instances For
          @[reducible, inline]
          abbrev GuardedPlusCal.Block.cons {α : BoolType} {b : Bool} (S : α false) (B : Block α b) :
          Block α b

          S prefixed onto B. S is necessarily non-terminal.

          Equations
          Instances For
            @[reducible, inline]
            abbrev GuardedPlusCal.Block.toList {α : BoolType} (B : Block α false) :
            List (α false)

            Every statement of a non-terminal block, in program order.

            Equations
            Instances For
              def GuardedPlusCal.Block.ofList {α : BoolType} (xs : List (α false)) (xs_nonempty : xs []) :

              Inverse of Block.toList: a non-empty list read as a block.

              Equations
              Instances For
                @[reducible]
                def GuardedPlusCal.Block.concat {α : BoolType} {b : Bool} (B : Block α false) (S : α b) :
                Block α b

                B extended on the right by a (possibly terminal) S, which becomes the new last.

                Equations
                Instances For
                  def GuardedPlusCal.Block.prepend {α : BoolType} {b : Bool} (xs : List (α false)) (B : Block α b) :
                  Block α b

                  B extended on the left by xs.

                  Equations
                  Instances For
                    @[reducible, inline]
                    abbrev GuardedPlusCal.Ref (Typ Expr : Type) :
                    Equations
                    Instances For
                      @[reducible, inline]
                      abbrev GuardedPlusCal.Multicast (Typ Expr : Type) :
                      Equations
                      Instances For
                        def GuardedPlusCal.Ref.bimap {Typ Typ' Expr Expr' : Type} (f : TypTyp') (g : ExprExpr') (r : Ref Typ Expr) :
                        Ref Typ' Expr'

                        ElaboratedPlusCal.Ref carries no Bifunctor/Bitraversable instance (it has an extra baseType : τ field, same reason Typed2Computable/PlusCal.lean's Ref.toComputable is hand-written rather than a generic bitraverse call) — small local helpers instead, used only by Statement's instances below, not registered as global instances.

                        Equations
                        Instances For
                          def GuardedPlusCal.Ref.bitraverse {Typ Typ' Expr Expr' : Type} {m : TypeType} [Applicative m] (f : Typm Typ') (g : Exprm Expr') (r : Ref Typ Expr) :
                          m (Ref Typ' Expr')
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            inductive GuardedPlusCal.Statement (Typ Expr : Type) :
                            BoolBoolType

                            A statement in the Guarded PlusCal language. The first Bool (guardClass) is true for a statement allowed in a branch's precondition (with/await/receive); the second (terminal) is true only for goto, which always ends a branch's action block.

                            Instances For
                              def GuardedPlusCal.instReprStatement.repr {Typ✝ Expr✝ : Type} {a✝ a✝¹ : Bool} [Repr Typ✝] [Repr Expr✝] :
                              Statement Typ✝ Expr✝ a✝ a✝¹Std.Format
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[implicit_reducible]
                                instance GuardedPlusCal.instReprStatement {Typ✝ Expr✝ : Type} {a✝ a✝¹ : Bool} [Repr Typ✝] [Repr Expr✝] :
                                Repr (Statement Typ✝ Expr✝ a✝ a✝¹)
                                Equations
                                def GuardedPlusCal.Statement.boundName? {Typ Expr : Type} {b b' : Bool} :
                                Statement Typ Expr b b'Option String

                                The one name a statement binds, if any — with's binder, and nothing else. Lives here rather than beside either of its users because both WellFormedness.WellScoped.GuardedPlusCal (where a binder must be fresh against the enclosing scope) and Guarded2Network's Fresh (where a binder must not shadow the pass's generated inbox) need exactly this, and stating it twice is how the two drift. Stated for every guard class, since only Guarded2Network needs the action one and the answer there is always none.

                                Equations
                                Instances For
                                  @[implicit_reducible]
                                  instance GuardedPlusCal.instBifunctorStatement {b b' : Bool} :
                                  Bifunctor fun (x1 x2 : Type) => Statement x1 x2 b b'
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  @[implicit_reducible]
                                  instance GuardedPlusCal.instBitraversableStatement {b b' : Bool} :
                                  Bitraversable fun (x1 x2 : Type) => Statement x1 x2 b b'
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  structure GuardedPlusCal.AtomicBranch (Typ Expr : Type) :
                                  Instances For
                                    @[implicit_reducible]
                                    instance GuardedPlusCal.instReprAtomicBranch {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                    Repr (AtomicBranch Typ✝ Expr✝)
                                    Equations
                                    def GuardedPlusCal.instReprAtomicBranch.repr {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                    AtomicBranch Typ✝ Expr✝Std.Format
                                    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.
                                      @[implicit_reducible]
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      structure GuardedPlusCal.AtomicBlock (Typ Expr : Type) :
                                      Instances For
                                        def GuardedPlusCal.instReprAtomicBlock.repr {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                        AtomicBlock Typ✝ Expr✝Std.Format
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          @[implicit_reducible]
                                          instance GuardedPlusCal.instReprAtomicBlock {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                          Repr (AtomicBlock Typ✝ Expr✝)
                                          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]
                                          abbrev GuardedPlusCal.Thread (Typ Expr : Type) :

                                          One parallel {...} thread — a sequence of labelled atomic blocks, in program order. AtomicBlock already carries a label, unlike ElaboratedPlusCal.Process.threads's List (String × Block τ ε true) pairing, so no separate label pairing is needed here.

                                          Equations
                                          Instances For
                                            structure GuardedPlusCal.Declarations (Typ Expr : Type) :

                                            What a scope declares: its variables with their initializers, its channels, and its FIFOs.

                                            Instances For
                                              def GuardedPlusCal.instReprDeclarations.repr {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                              Declarations Typ✝ Expr✝Std.Format
                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                @[implicit_reducible]
                                                instance GuardedPlusCal.instReprDeclarations {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                                Repr (Declarations Typ✝ Expr✝)
                                                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.
                                                structure GuardedPlusCal.Process (Typ Expr : Type) :

                                                A declared process: its optional mailbox, its fairness, its identity, its own declarations, and its parallel threads, each a Thread Typ Expr of self-labelled atomic blocks.

                                                Instances For
                                                  def GuardedPlusCal.instReprProcess.repr {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                                  Process Typ✝ Expr✝Std.Format
                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    @[implicit_reducible]
                                                    instance GuardedPlusCal.instReprProcess {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                                    Repr (Process Typ✝ Expr✝)
                                                    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.
                                                    structure GuardedPlusCal.Algorithm (Typ Expr : Type) :
                                                    Instances For
                                                      def GuardedPlusCal.instReprAlgorithm.repr {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                                      Algorithm Typ✝ Expr✝Std.Format
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        @[implicit_reducible]
                                                        instance GuardedPlusCal.instReprAlgorithm {Typ✝ Expr✝ : Type} [Repr Typ✝] [Repr Expr✝] :
                                                        Repr (Algorithm Typ✝ Expr✝)
                                                        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.