Documentation

Core.CorePlusCal.Syntax

SurfacePlusCal, but with every goto explicit and at the end of a block — the output of statement desugaring.

Statement/Block/Branches are indexed by a Bool tracking whether a statement/block is "terminal" (ends in goto) at the type level: "every block ends in exactly one terminal statement" is a structural invariant rather than a side condition to maintain by hand.

Process.threads : List (List (String × Block α β true)) pairs each atomic block with its label (the outer list is SurfacePlusCal's parallel {...} {...} threads, the inner list the sequence of labelled atomic blocks within one thread).

Process/Declarations/Algorithm share the same α/β as Statement/Block/Branches/ Multicast: α is the declared-type annotation at whatever stage of checking it's currently at. Content that can't be expressed via this shared α (@mailbox's channel name/index expressions, @parameter's presence-as-a-Bool) instead gets a concrete field (Process.mailbox, Declarations.variables' isParameter).

structure CorePlusCal.Multicast (α β : Type) :

A multicast's recipients and payload, after the desugarer has collapsed SurfacePlusCal.MulticastFilter's bind list to a single binder.

The surface form [x₁ ⋈₁ e₁, …, xₙ ⋈ₙ eₙ ↦ v] names the components of a recipient tuple, not a chain of lets: it reaches every c[y] for y in the Cartesian product of the components, where an -bind contributes its set and an =-bind the singleton containing its value. The desugarer turns that product into one set (set) over one binder (recipient), rewriting each original name in val to a projection of it — the same collapse a multi-binder function literal [x ∈ A, y ∈ B ↦ e] already gets. So nothing downstream reconstructs which bind was which, and n = 1 — the overwhelmingly common case — passes through untouched.

  • recipient : String
  • ann : α

    The recipient's declared-type annotation slot, at whatever stage of checking this is: the channel's own domain type once checked, since the recipient is what indexes the channel.

  • set : β

    The set of recipients, always of the channel's domain type.

  • val : β
Instances For
    @[implicit_reducible]
    instance CorePlusCal.instReprMulticast {α✝ β✝ : Type} [Repr α✝] [Repr β✝] :
    Repr (Multicast α✝ β✝)
    Equations
    def CorePlusCal.instReprMulticast.repr {α✝ β✝ : Type} [Repr α✝] [Repr β✝] :
    Multicast α✝ β✝Std.Format
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[implicit_reducible]
      instance CorePlusCal.instInhabitedMulticast {a✝ : Type} [Inhabited a✝] {a✝¹ : Type} [Inhabited a✝¹] :
      Inhabited (Multicast a✝ a✝¹)
      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 CorePlusCal.Ref (β : Type) :

      SurfacePlusCal.Ref, but each bracket group's own index is unary: x[e₁, …, eₙ] (n > 1) desugars to x[<<e₁, …, eₙ>>]. x[e₁][e₂] (two separate bracket groups) is unaffected — args' outer list (one entry per path segment) doesn't change shape. .inl for a .field segment, .inr for a (now-unary) bracket-index segment.

      Instances For
        def CorePlusCal.instReprRef.repr {β✝ : Type} [Repr β✝] :
        Ref β✝Std.Format
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[implicit_reducible]
          instance CorePlusCal.instReprRef {β✝ : Type} [Repr β✝] :
          Repr (Ref β✝)
          Equations
          @[implicit_reducible]
          Equations
          @[implicit_reducible]
          Equations
          • One or more equations did not get rendered due to their size.
          inductive CorePlusCal.Statement (α β : Type) :
          Instances For
            partial def CorePlusCal.instReprStatement.repr_1 {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Statement α✝ β✝ a✝Std.Format
            partial def CorePlusCal.instReprBlock.repr_3 {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Branches α✝ β✝ a✝Std.Format
            @[implicit_reducible]
            instance CorePlusCal.instReprStatement {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Repr (Statement α✝ β✝ a✝)
            Equations
            partial def CorePlusCal.instReprBlock.repr_2 {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Block α✝ β✝ a✝Std.Format
            @[implicit_reducible]
            instance CorePlusCal.instReprBlock {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Repr (Block α✝ β✝ a✝)
            Equations
            partial def CorePlusCal.instReprBlock.repr_1 {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Statement α✝ β✝ a✝Std.Format
            partial def CorePlusCal.instReprStatement.repr_3 {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Branches α✝ β✝ a✝Std.Format
            partial def CorePlusCal.instReprStatement.repr_2 {α✝ β✝ : Type} {a✝ : Bool} [Repr α✝] [Repr β✝] :
            Block α✝ β✝ a✝Std.Format
            inductive CorePlusCal.Block (α β : Type) :

            A block is a (possibly empty) sequence of non-terminal statements followed by a potentially-terminal one.

            Instances For
              inductive CorePlusCal.Branches (α β : Type) :
              Instances For
                @[reducible, inline]
                abbrev CorePlusCal.Block.begin {α β : Type} {b : Bool} :
                Block α β bList (Statement α β false)
                Equations
                Instances For
                  @[reducible, inline]
                  abbrev CorePlusCal.Block.end {α β : Type} {b : Bool} :
                  Block α β bStatement α β b
                  Equations
                  Instances For
                    partial def CorePlusCal.Statement.bimap {b : Bool} {α β γ δ : Type} (f : αβ) (g : γδ) (S : Statement α γ b) :
                    Statement β δ b
                    partial def CorePlusCal.Block.bimap {α β γ δ : Type} {b : Bool} (f : αβ) (g : γδ) (B : Block α γ b) :
                    Block β δ b
                    partial def CorePlusCal.Branches.bimap {α β γ δ : Type} {b : Bool} (f : αβ) (g : γδ) :
                    Branches α γ bBranches β δ b
                    @[implicit_reducible]
                    instance CorePlusCal.instBifunctorStatement {b : Bool} :
                    Bifunctor fun (x1 x2 : Type) => Statement x1 x2 b
                    Equations
                    @[implicit_reducible]
                    instance CorePlusCal.instBifunctorBlock {b : Bool} :
                    Bifunctor fun (x1 x2 : Type) => Block x1 x2 b
                    Equations
                    @[implicit_reducible]
                    instance CorePlusCal.instBifunctorBranches {b : Bool} :
                    Bifunctor fun (x1 x2 : Type) => Branches x1 x2 b
                    Equations
                    @[implicit_reducible]
                    def CorePlusCal.instInhabitedOfApplicative_core {F : Type u_1 → Type u_2} [Applicative F] {α : Type u_1} [Inhabited α] :
                    Inhabited (F α)
                    Equations
                    Instances For
                      partial def CorePlusCal.Statement.bitraverse {F : TypeType} [Applicative F] {α β γ δ : Type} {b : Bool} (f : αF β) (g : γF δ) (S : Statement α γ b) :
                      F (Statement β δ b)
                      partial def CorePlusCal.Block.bitraverse {F : TypeType} [Applicative F] {α β γ δ : Type} {b : Bool} (f : αF β) (g : γF δ) (B : Block α γ b) :
                      F (Block β δ b)
                      partial def CorePlusCal.Branches.bitraverse {F : TypeType} [Applicative F] {α β γ δ : Type} {b : Bool} (f : αF β) (g : γF δ) :
                      Branches α γ bF (Branches β δ b)
                      @[implicit_reducible]
                      Equations
                      • One or more equations did not get rendered due to their size.
                      @[implicit_reducible]
                      instance CorePlusCal.instBitraversableBlock {b : Bool} :
                      Bitraversable fun (x1 x2 : Type) => Block x1 x2 b
                      Equations
                      @[implicit_reducible]
                      instance CorePlusCal.instBitraversableBranches {b : Bool} :
                      Bitraversable fun (x1 x2 : Type) => Branches x1 x2 b
                      Equations
                      • One or more equations did not get rendered due to their size.
                      structure CorePlusCal.Declarations (α β : Type) :

                      The declarations at the top of an algorithm or process block — the annotation-carrying counterpart is SurfacePlusCal.Declarations. Shares the same α as Statement/Block/ Branches/Multicast.

                      Instances For
                        def CorePlusCal.instReprDeclarations.repr {α✝ β✝ : Type} [Repr α✝] [Repr β✝] :
                        Declarations α✝ β✝Std.Format
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          @[implicit_reducible]
                          instance CorePlusCal.instReprDeclarations {α✝ β✝ : Type} [Repr α✝] [Repr β✝] :
                          Repr (Declarations α✝ β✝)
                          Equations
                          def CorePlusCal.Declarations.bimap {α β γ δ : Type} (f : αβ) (g : γδ) (decls : Declarations α γ) :
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def CorePlusCal.Declarations.bitraverse {F : TypeType} [Applicative F] {α β γ δ : Type} (f : αF β) (g : γF δ) (decls : Declarations α γ) :
                            F (Declarations β δ)
                            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.
                              structure CorePlusCal.Process (α β : Type) :
                              • mailbox : Option (String × List β)

                                (channel name, filter/index args), from at most one @mailbox annotation; none if the process has no mailbox.

                              • isFair : Bool
                              • name : String
                              • =|∈ : Bool

                                true for =, false for .

                              • id : β
                              • localState : Declarations α β
                              • threads : List (List (String × Block α β true))

                                One entry per parallel {...} thread; each thread is a sequence of labelled atomic blocks, in program order.

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