The output of PlusCal statement checking. ElaboratedPlusCal.Statement/Block/Branches/
Declarations/Process/Algorithm mirror CorePlusCal's shape node-for-node, but parameterized
over (τ ε : Type) rather than CorePlusCal's (α β : Type): Ref carries an extra resolved
type : τ, and Statement.receive an extra coe : TypedTLAPlus.Coercion, so a later pass
(WellFormedness/Restrictions.lean check 1) can tell whether a bare Ref position (assign's
LHS, receive's destination) is Channel-shaped without Γ, which is gone by then. Coercion
isn't a third parameter — its shape is TLA⁺-expression-specific regardless of instantiation.
TypedPlusCal pins this layer at τ := TypedTLAPlus.Typ, ε := TypedTLAPlus.Expression TypedTLAPlus.Typ. Core/ComputablePlusCal/Syntax.lean pins the same layer at
ComputableTLAPlus's types, reusing these definitions rather than re-copying them: neither
Ref.type nor receive's Coercion field change shape across the two, so no second
monomorphic copy is needed. Multicast is reused generically from CorePlusCal (its
target is a bare String, not a Ref, so no type to carry either way).
Carries its own resolved baseType (unlike CorePlusCal.Ref). args follows
CorePlusCal.Ref's shape: one entry per path segment, .inl for a .field segment, .inr for a
(unary) bracket-index segment.
baseType is the base variable's type (name's Γ-lookup result), before any .args segment
is applied — kept this way rather than the result type because the result type is always cheap to
recompute from baseType (Ref.stepType/.resultType below), but recovering baseType from the
result type isn't possible in general (a record access or tuple projection isn't invertible).
- name : String
- baseType : τ
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
A fresh copy of CorePlusCal.Statement's shape, not an abbrev over it: parameterized over
(τ ε : Type) instead of (α β : Type), since receive needs an extra field
CorePlusCal.Statement.receive has no room for.
- goto {τ ε : Type} (label : String) : Statement τ ε true
- skip {τ ε : Type} : Statement τ ε false
- print {τ ε : Type} (e : ε) : Statement τ ε false
- assign {τ ε : Type} : List (Ref τ ε × ε) → Statement τ ε false
- if {τ ε : Type} {b : Bool} (cond : ε) (B₁ B₂ : Block τ ε b) : Statement τ ε b
- await {τ ε : Type} (e : ε) : Statement τ ε false
- with {τ ε : Type} (var : String) (ann : τ) («=|∈» : Bool) (val : ε) (B : Block τ ε false) : Statement τ ε false
- assert {τ ε : Type} (e : ε) : Statement τ ε false
- either {τ ε : Type} {b : Bool} (branches : Branches τ ε b) : Statement τ ε b
- while {τ ε : Type} {b : Bool} (cond : ε) (B : Block τ ε b) : Statement τ ε false
- receive
{τ ε : Type}
(c r : Ref τ ε)
(coe : TypedTLAPlus.Coercion)
: Statement τ ε false
Differs from
CorePlusCal.Statement.receivebycoe: the checked element→reference-type upcast for the value read off the channel at runtime. - send {τ ε : Type} (c : Ref τ ε) (e : ε) : Statement τ ε false
- multicast {τ ε : Type} (c : String) (filter : Multicast τ ε) : Statement τ ε false
Instances For
Equations
Equations
Equations
Runs act over every non-terminal statement in B (B.begin, in order), then its terminal
one (B.end). Shared shape for WellFormedness's per-check walkers
(Restrictions.checkRestrictions, WellScoped.checkWellScoped, Labelling.checkGotoTargets),
each supplying its own act.
Equations
- ElaboratedPlusCal.Block.forStatements act B = do B.begin.forM act act B.end
Instances For
Block.forStatements, distributed over either/or branches.
Equations
- One or more equations did not get rendered due to their size.
- ElaboratedPlusCal.Branches.forStatements act (ElaboratedPlusCal.Branches.either B) = ElaboratedPlusCal.Block.forStatements (fun {b' : Bool} => act) B
Instances For
Pre-order recursion over s and every statement nested inside it: act s first, then the
same over whatever if/either/while/with nest below — the four constructors that embed a
Block/Branches; every other statement is a leaf. The structural half of what a per-node check
needs, so a check that has no context to thread supplies only the check itself
(WellFormedness/Labelling.lean) rather than restating this recursion.
A check whose per-node work depends on where it is in the tree can't use this — WellFormedness/ WellScoped/TypedPlusCal.lean extends its in-scope set at every with binder, which needs the
recursion and the check interleaved, so it keeps its own copy.
partial: the recursion isn't visibly decreasing to Lean through the Block/Branches
nesting, same as every other walker over this type.
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
A fresh copy of CorePlusCal.Algorithm's shape.
- isFair : Bool
- name : String
- globalState : Declarations τ ε
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Runs act over the top-level statements of every labelled block of every thread of p — the
threads/(label, Block) nesting flattened away. Only the top-level statements: act is
whatever the caller wants per block, Statement.forEachNode if it wants the whole subtree.
Per process, not per algorithm, because all three callers need it that way: labels
(WellFormedness/Labelling.lean) and in-scope names (WellFormedness/WellScoped/TypedPlusCal. lean) are both process-scoped, and WellFormedness/Reachability.lean visits a process's own
id/mailbox/localState expressions in the same loop.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checked PlusCal expressions — always TypedTLAPlus.Expression at the checker's own Typ.
Instances For
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Equations
Instances For
The type after one Ref path segment, given the type before it. A pure structural pattern
match — every segment is already elaborated, so this replays the same step-rule
Elaborator/Expressions.lean's stepInto/indexInto use at check time, without re-checking.
Total: the fallback (τ unchanged) only triggers on a Ref no well-typed input can produce.
Equations
- TypedPlusCal.Ref.stepType (SurfaceTLAPlus.Typ.record fs) (Sum.inl field) = (List.lookup field fs).getD (SurfaceTLAPlus.Typ.record fs)
- TypedPlusCal.Ref.stepType τ (Sum.inl field) = τ
- TypedPlusCal.Ref.stepType (x_1.function rng) (Sum.inr idx) = rng
- TypedPlusCal.Ref.stepType elem.seq (Sum.inr idx) = elem
- TypedPlusCal.Ref.stepType (SurfaceTLAPlus.Typ.tuple τs) (Sum.inr (TypedTLAPlus.Expression.nat n)) = (n.toNat?.bind fun (x : ℕ) => τs[x - 1]?).getD (SurfaceTLAPlus.Typ.tuple τs)
- TypedPlusCal.Ref.stepType (SurfaceTLAPlus.Typ.tuple τs) (Sum.inr idx) = SurfaceTLAPlus.Typ.tuple τs
- TypedPlusCal.Ref.stepType τ (Sum.inr idx) = τ