The output of Guarded2Network: a receive is no longer an abstract guard statement — it's
compiled into a genuine second kind of thread, Thread.rx, that loops reading a process-local
inbox sequence variable, and every later await/with guard that referenced the received
value now reads that inbox instead. Reuses GuardedPlusCal.Block/Ref/Multicast/
Declarations unchanged — none of those shapes are affected by this pass, only Statement
(drops receive) and Thread (gains a second, non-code constructor) are.
- No separate
ChanReftype:GuardedPlusCal.Statementalready reuses one uniformReffor both a channel argument and an ordinary reference (Core/GuardedPlusCal/Syntax.lean'ssend/assign), soNetworkPlusCal.Statementcarries that same uniformity forward. - Real
Bifunctor/Bitraversableinstances throughout, matchingCore/GuardedPlusCal/Syntax.lean's instances (Ref.bimap/Ref.bitraversereused directly, sinceRefitself has no generic instance). Threadis a genuine sum (.code (blocks : List AtomicBlock)|.rx (chan : Ref Typ Expr) (label : String) (τ : Typ) (inbox : String)) — a receiving thread is a real second kind of thread, not folded into.code.deriving Reprthroughout — noPretty.leanneeded yet:-d dump-networkrenders viareprStr, the same way-d dump-guardeddoes today (Fugue.lean's existing debug-dump wiring). A real pretty-printer is only worth adding once a backend needs one.- Lives under the existing
Fugue.Corelean_libtarget (itsroots := #[Core]glob picks this file up automatically) — no newlakefile.leantarget needed, unlikeFugue.G2N, already declared for the pass itself.
A statement in the Network PlusCal language — identical to GuardedPlusCal.Statement minus
receive (compiled away into Thread.rx by this pass), including with's ann : Typ field
(GuardedPlusCal.Statement.with's doc comment explains why it's kept). The first Bool
(guardClass) is true for a statement allowed in a branch's precondition (with/await); the
second (terminal) is true only for goto.
- with {Typ Expr : Type} (name : String) (ann : Typ) (bound : Bool) (e : Expr) : Statement Typ Expr true false
- await {Typ Expr : Type} (e : Expr) : Statement Typ Expr true false
- skip {Typ Expr : Type} : Statement Typ Expr false false
- print {Typ Expr : Type} (e : Expr) : Statement Typ Expr false false
- assert {Typ Expr : Type} (e : Expr) : Statement Typ Expr false false
- send {Typ Expr : Type} (c : GuardedPlusCal.Ref Typ Expr) (e : Expr) : Statement Typ Expr false false
- multicast {Typ Expr : Type} (c : String) (filter : GuardedPlusCal.Multicast Typ Expr) : Statement Typ Expr false false
- assign {Typ Expr : Type} (r : GuardedPlusCal.Ref Typ Expr) (e : Expr) : Statement Typ Expr false false
- goto {Typ Expr : Type} (label : String) : Statement Typ Expr false true
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- precondition : Option (GuardedPlusCal.Block (Statement Typ Expr true) false)
- action : GuardedPlusCal.Block (Statement Typ Expr false) true
Instances For
Equations
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.
Equations
- One or more equations did not get rendered due to their size.
- label : String
- branches : List (AtomicBranch Typ Expr)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
One parallel {...} thread — either ordinary code (a sequence of labelled atomic blocks, in
program order, same shape as GuardedPlusCal.Thread) or a dedicated receiving loop: drains chan
of type τ into a process-local inbox sequence variable (fresh per process, via
Guarded2Network.freshName). A real second kind of thread, not folded into .code, since its body
isn't a List AtomicBlock — see the module doc.
label is the receiving loop's own block label. .rx's meaning is the single atomic block
label : receive(chan, tmp) ; inbox := Append(inbox, tmp) ; goto label, without the temporary
variable tmp ever being assigned to — so the loop needs a label of its own
to be scheduled by, and to be the target of its own terminal goto, whereas tmp is never written
and needs no name at all. Both are freshly generated, so this one field carries the one that
matters.
- code {Typ Expr : Type} (blocks : List (AtomicBlock Typ Expr)) : Thread Typ Expr
- rx {Typ Expr : Type} (chan : GuardedPlusCal.Ref Typ Expr) (label : String) (τ : Typ) (inbox : String) : Thread Typ Expr
Instances For
Equations
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.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
- isFair : Bool
- name : String
- globalState : GuardedPlusCal.Declarations Typ Expr
Instances For
Equations
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.
Equations
- One or more equations did not get rendered due to their size.