Documentation

CslibFrontier.Computability.Distributed.SharedMemory.Basic

Wait-free shared-memory consensus and the critical-configuration engine #

This module models deterministic asynchronous shared-memory protocols interacting with an indexed family of typed deterministic sequential shared objects (ObjSpec), following [Her91] (§§2.2–3.1, pp. 128–133; see also prior register-impossibility work [LAA87] cited in [Her91], §3.1, p. 132). It serves as the shared-memory counterpart to Cslib.FLP (asynchronous crash-fault message passing) and reuses Cslib.LTS for multistep reachability.

In each global configuration (Config), every shared object i : I holds a sequential state in ObjState i, and every process p : P holds an internal local state in S together with a write-once decision slot decided : Option V (ProcState). In an atomic step (Protocol.step), an undecided (Config.Active) process p invokes a single shared object i = π.target p s with operation π.op p s, updates object i to the resulting sequential state, updates p's local state from the returned response, and optionally writes its decision to decided. Once p has decided, its decision is immutable and p takes no further active transitions in Protocol.lts.

Protocol.SolvesWaitFreeConsensus specifies wait-free consensus ([Her91], §3, p. 130):

For binary consensus (V = Bool), we develop the constructive bivalence and critical-configuration engine ([Her91], §3.1, pp. 131–133):

Main definitions #

Main results #

References #

structure Cslib.Distributed.SharedMemory.ObjSpec (Op : Type u_1) (Resp : Type u_2) (ObjState : Type u_3) :
Type (max (max u_1 u_2) u_3)

Specification of a single deterministic sequential shared object with operation type Op, response type Resp, initial state init, and atomic transition step returning (nextState, response).

  • init : ObjState

    Initial state of the shared object.

  • step : Op → ObjState → ObjState × Resp

    Atomic transition taking an operation and current state to (nextState, response).

structure Cslib.Distributed.SharedMemory.ProcState (S : Type u_1) (V : Type u_2) :
Type (max u_1 u_2)

Local state of a single process: internal protocol state state paired with a write-once decision register decided.

  • state : S

    Internal local state of the process.

  • decided : Option V

    Write-once consensus decision (none while undecided).

theorem Cslib.Distributed.SharedMemory.ProcState.ext {S : Type u_1} {V : Type u_2} {x y : ProcState S V} (state : x.state = y.state) (decided : x.decided = y.decided) :
x = y
def Cslib.Distributed.SharedMemory.instDecidableEqProcState.decEq {S✝ : Type u_1} {V✝ : Type u_2} [DecidableEq S✝] [DecidableEq V✝] (x✝ x✝¹ : ProcState S✝ V✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
structure Cslib.Distributed.SharedMemory.Config (P : Type u_1) {I : Type u_2} (ObjState : I → Type u_3) (S : Type u_4) (V : Type u_5) :
Type (max (max (max (max u_1 u_2) u_3) u_4) u_5)

Global configuration of a shared-memory system over process type P and object family I: the state mem i of every shared object i together with the local state proc p of every process p.

  • mem (i : I) : ObjState i

    Current sequential state of each shared object.

  • proc : P → ProcState S V

    Current local state and optional decision of each process.

theorem Cslib.Distributed.SharedMemory.Config.ext_iff {P : Type u_1} {I : Type u_2} {ObjState : I → Type u_3} {S : Type u_4} {V : Type u_5} {x y : Config P ObjState S V} :
x = y ↔ x.mem = y.mem ∧ x.proc = y.proc
theorem Cslib.Distributed.SharedMemory.Config.ext {P : Type u_1} {I : Type u_2} {ObjState : I → Type u_3} {S : Type u_4} {V : Type u_5} {x y : Config P ObjState S V} (mem : x.mem = y.mem) (proc : x.proc = y.proc) :
x = y
def Cslib.Distributed.SharedMemory.Config.Active {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {ObjState : I → Type u_5} (c : Config P ObjState S V) (p : P) :

Process p is active in configuration c when it has not yet decided a value.

Instances For
    @[instance_reducible]
    instance Cslib.Distributed.SharedMemory.Config.instDecidableActive {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {ObjState : I → Type u_5} (c : Config P ObjState S V) (p : P) :
    def Cslib.Distributed.SharedMemory.Config.Decided {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {ObjState : I → Type u_5} (c : Config P ObjState S V) (v : V) :

    Configuration c has decided v if at least one process has decided = some v.

    def Cslib.Distributed.SharedMemory.Config.Agreed {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {ObjState : I → Type u_5} (c : Config P ObjState S V) :

    All decided values in configuration c agree with one another.

    structure Cslib.Distributed.SharedMemory.Protocol (P : Type u_1) {I : Type u_2} {Op : I → Type u_3} {Resp : I → Type u_4} {ObjState : I → Type u_5} (objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)) (S : Type u_6) (V : Type u_7) :
    Type (max (max (max (max (max u_1 u_2) u_3) u_4) u_6) u_7)

    Deterministic asynchronous shared-memory protocol for processes P with input/decision values V, local state S, and shared objects objs : ∀ i, ObjSpec (Op i) (Resp i) (ObjState i). Each step of an active process p in local state s invokes object target p s with operation op p s, then updates p's local state via next and optional decision via decideVal from the returned response.

    • init : P → V → S

      Initial local state of process p given its input value.

    • target : P → S → I

      Shared object targeted by process p in local state s.

    • op (p : P) (s : S) : Op (self.target p s)

      Operation invoked on target p s by process p in local state s.

    • next (p : P) (s : S) : Resp (self.target p s) → S

      Next internal local state of p after receiving the object's response.

    • decideVal (p : P) (s : S) : Resp (self.target p s) → Option V

      Optional decision written by p after receiving the object's response.

    def Cslib.Distributed.SharedMemory.Protocol.initConfig {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} (π : Protocol P objs S V) (inp : P → V) :
    Config P ObjState S V

    Initial global configuration for input assignment inp : P → V: every shared object starts at (objs i).init and every process p starts undecided at π.init p (inp p).

    def Cslib.Distributed.SharedMemory.Protocol.step {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) (c : Config P ObjState S V) :
    Config P ObjState S V

    Single atomic step of process p from configuration c. If p has already decided, step is a no-op; otherwise p invokes π.target p s and updates that object and p's local state.

    def Cslib.Distributed.SharedMemory.Protocol.run {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (sched : List P) (c : Config P ObjState S V) :
    Config P ObjState S V

    Execute a finite schedule sched : List P of process steps from configuration c.

    @[simp]
    theorem Cslib.Distributed.SharedMemory.Protocol.run_nil {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (c : Config P ObjState S V) :
    π.run [] c = c
    @[simp]
    theorem Cslib.Distributed.SharedMemory.Protocol.run_cons {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) (sched : List P) (c : Config P ObjState S V) :
    π.run (p :: sched) c = π.run sched (π.step p c)
    def Cslib.Distributed.SharedMemory.Protocol.lts {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) :
    LTS (Config P ObjState S V) P

    Active-step labelled transition system of π: transitions are labelled by p : P and fire precisely when p is still undecided (c.Active p).

    Instances For
      instance Cslib.Distributed.SharedMemory.Protocol.instDeterministicLTS {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) :
      def Cslib.Distributed.SharedMemory.Protocol.Reachable {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (inp : P → V) (c : Config P ObjState S V) :

      Configuration c is reachable under input assignment inp via active protocol steps.

      @[reducible, inline]
      abbrev Cslib.Distributed.SharedMemory.Protocol.StepRel {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (c' c : Config P ObjState S V) :

      Active-step relation c' ≺ c of π: c' is reached from c by one atomic step of an active (undecided) process p.

      @[reducible, inline]
      abbrev Cslib.Distributed.SharedMemory.Protocol.WaitFree {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) :

      Wait-free termination ([Her91], §2.3 & §3, pp. 129–130): from every initial configuration π.initConfig inp, the active-step relation π.StepRel is accessible, so no infinite sequence of active steps exists from any reachable configuration.

      theorem Cslib.Distributed.SharedMemory.Protocol.WaitFree.of_wellFounded {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S V} (hwf : WellFounded π.StepRel) :

      Any protocol whose active-step relation is globally well-founded is wait-free.

      structure Cslib.Distributed.SharedMemory.Protocol.SolvesWaitFreeConsensus {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) :

      π.SolvesWaitFreeConsensus states that π solves wait-free consensus over P and V ([Her91], §3, p. 130): active steps from every initConfig are accessible (WaitFree), reachable configurations satisfy agreement, and every decided value in a reachable configuration equals some process's initial input.

      • waitFree : π.WaitFree

        No infinite sequence of active steps exists.

      • agreement (inp : P → V) (c : Config P ObjState S V) : π.Reachable inp c → c.Agreed

        Reachable configurations never decide two distinct values.

      • validity (inp : P → V) (c : Config P ObjState S V) (v : V) : π.Reachable inp c → c.Decided v → ∃ (q : P), inp q = v

        Every decided value in a reachable configuration is some process's initial input.

      theorem Cslib.Distributed.SharedMemory.Protocol.step_of_not_active {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p : P} {c : Config P ObjState S V} (h : ¬c.Active p) :
      π.step p c = c
      theorem Cslib.Distributed.SharedMemory.Protocol.step_of_active {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p : P} {c : Config P ObjState S V} (h : c.Active p) :
      π.step p c = { mem := Function.update c.mem (π.target p (c.proc p).state) ((objs (π.target p (c.proc p).state)).step (π.op p (c.proc p).state) (c.mem (π.target p (c.proc p).state))).1, proc := Function.update c.proc p { state := π.next p (c.proc p).state ((objs (π.target p (c.proc p).state)).step (π.op p (c.proc p).state) (c.mem (π.target p (c.proc p).state))).2, decided := π.decideVal p (c.proc p).state ((objs (π.target p (c.proc p).state)).step (π.op p (c.proc p).state) (c.mem (π.target p (c.proc p).state))).2 } }
      @[simp]
      theorem Cslib.Distributed.SharedMemory.Protocol.step_proc_of_ne {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p q : P} (c : Config P ObjState S V) (hne : q ≠ p) :
      (π.step p c).proc q = c.proc q
      theorem Cslib.Distributed.SharedMemory.Protocol.active_step_of_ne {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p q : P} {c : Config P ObjState S V} (hne : q ≠ p) :
      (π.step p c).Active q ↔ c.Active q
      theorem Cslib.Distributed.SharedMemory.Protocol.step_mem_of_ne_target {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p : P} {c : Config P ObjState S V} (h : c.Active p) {j : I} (hne : j ≠ π.target p (c.proc p).state) :
      (π.step p c).mem j = c.mem j
      theorem Cslib.Distributed.SharedMemory.Protocol.step_comm_of_ne_target {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p q : P} {c : Config P ObjState S V} (hp : c.Active p) (hq : c.Active q) (hpq : p ≠ q) (htarget : π.target p (c.proc p).state ≠ π.target q (c.proc q).state) :
      π.step q (π.step p c) = π.step p (π.step q c)

      Steps by distinct active processes targeting distinct shared objects commute exactly.

      theorem Cslib.Distributed.SharedMemory.Protocol.procDecided_step {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p : P} (q : P) {c : Config P ObjState S V} {v : V} (hd : (c.proc p).decided = some v) :
      ((π.step q c).proc p).decided = some v

      Decisions are write-once across single steps: once p decides v, every step preserves it.

      theorem Cslib.Distributed.SharedMemory.Protocol.procDecided_stable {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {p : P} {c c' : Config P ObjState S V} {v : V} (hd : (c.proc p).decided = some v) (hreach : π.lts.CanReach c c') :
      (c'.proc p).decided = some v

      Decisions are write-once across arbitrary reachable paths.

      theorem Cslib.Distributed.SharedMemory.Protocol.reachable_initConfig {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (inp : P → V) :
      π.Reachable inp (π.initConfig inp)
      theorem Cslib.Distributed.SharedMemory.Protocol.Reachable.trans {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S V} {inp : P → V} {c c' : Config P ObjState S V} (hr : π.Reachable inp c) (hc : π.lts.CanReach c c') :
      π.Reachable inp c'
      theorem Cslib.Distributed.SharedMemory.Protocol.acc_of_canReach {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) {c c' : Config P ObjState S V} (ha : Acc π.StepRel c) (hreach : π.lts.CanReach c c') :
      Acc π.StepRel c'

      Accessibility under StepRel propagates forward along any active multi-step path.

      theorem Cslib.Distributed.SharedMemory.Protocol.Reachable.acc {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S V} {inp : P → V} {c : Config P ObjState S V} (hr : π.Reachable inp c) (hwf : π.WaitFree) :

      Every configuration reachable from π.initConfig inp in a wait-free protocol is accessible under StepRel.

      theorem Cslib.Distributed.SharedMemory.Protocol.Reachable.induction {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S V} {inp : P → V} {motive : Config P ObjState S V → Prop} (hinit : motive (π.initConfig inp)) (hstep : ∀ {c : Config P ObjState S V} {p : P}, motive c → c.Active p → motive (π.step p c)) {c : Config P ObjState S V} (hr : π.Reachable inp c) :
      motive c

      Invariant principle for configurations reachable under inp, derived from Cslib.LTS.mtrInv_of_trInv.

      theorem Cslib.Distributed.SharedMemory.Protocol.canReach_step {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) (c : Config P ObjState S V) :
      π.lts.CanReach c (π.step p c)
      theorem Cslib.Distributed.SharedMemory.Protocol.canReach_run {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (sched : List P) (c : Config P ObjState S V) :
      π.lts.CanReach c (π.run sched c)
      theorem Cslib.Distributed.SharedMemory.Protocol.reachable_run {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (inp : P → V) (sched : List P) :
      π.Reachable inp (π.run sched (π.initConfig inp))

      Solo executions #

      def Cslib.Distributed.SharedMemory.Protocol.soloRun {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) (c : Config P ObjState S V) (ha : Acc π.StepRel c) :
      Config P ObjState S V

      Run process p alone from an accessible configuration c until p is no longer active (has decided).

      theorem Cslib.Distributed.SharedMemory.Protocol.soloRun_of_not_active {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c : Config P ObjState S V} (ha : Acc π.StepRel c) (h : ¬c.Active p) :
      π.soloRun p c ha = c
      theorem Cslib.Distributed.SharedMemory.Protocol.soloRun_of_active {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c : Config P ObjState S V} (ha : Acc π.StepRel c) (h : c.Active p) :
      π.soloRun p c ha = π.soloRun p (π.step p c) ⋯
      theorem Cslib.Distributed.SharedMemory.Protocol.soloRun_not_active {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c : Config P ObjState S V} (ha : Acc π.StepRel c) :
      ¬(π.soloRun p c ha).Active p
      theorem Cslib.Distributed.SharedMemory.Protocol.exists_decided_soloRun {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c : Config P ObjState S V} (ha : Acc π.StepRel c) :
      ∃ (v : V), ((π.soloRun p c ha).proc p).decided = some v
      theorem Cslib.Distributed.SharedMemory.Protocol.canReach_soloRun {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c : Config P ObjState S V} (ha : Acc π.StepRel c) :
      π.lts.CanReach c (π.soloRun p c ha)
      theorem Cslib.Distributed.SharedMemory.Protocol.soloRun_mem_proc_eq {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c₁ : Config P ObjState S V} (ha₁ : Acc π.StepRel c₁) {c₂ : Config P ObjState S V} (ha₂ : Acc π.StepRel c₂) :
      c₁.mem = c₂.mem → c₁.proc p = c₂.proc p → (π.soloRun p c₁ ha₁).mem = (π.soloRun p c₂ ha₂).mem ∧ (π.soloRun p c₁ ha₁).proc p = (π.soloRun p c₂ ha₂).proc p

      Solo-run indistinguishability: a solo execution of process p depends only on the shared memory c.mem and p's own local state c.proc p; the local states of other processes q ≠ p are neither read nor modified during p's solo run.

      def Cslib.Distributed.SharedMemory.Protocol.CanDecide {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (c : Config P ObjState S V) (v : V) :

      Decision value v is reachable from configuration c.

      theorem Cslib.Distributed.SharedMemory.Protocol.CanDecide.of_canReach {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S V} {c₁ c₂ : Config P ObjState S V} {v : V} (hreach : π.lts.CanReach c₁ c₂) (hdec : π.CanDecide c₂ v) :
      π.CanDecide c₁ v
      theorem Cslib.Distributed.SharedMemory.Protocol.exists_canDecide {P : Type u_1} {I : Type u_2} {S : Type u_3} {V : Type u_4} {Op : I → Type u_5} {Resp : I → Type u_6} {ObjState : I → Type u_7} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S V) (p : P) {c : Config P ObjState S V} (ha : Acc π.StepRel c) :
      ∃ (v : V), π.CanDecide c v

      From every accessible configuration c and any process p, p's solo execution reaches a decision.

      Binary bivalence and critical configurations #

      def Cslib.Distributed.SharedMemory.Protocol.IsUnivalent {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S Bool) (c : Config P ObjState S Bool) (b : Bool) :

      Configuration c is b-univalent (b-valent) if b is reachable from c and !b is not ([Her91], §3.1, p. 131).

      def Cslib.Distributed.SharedMemory.Protocol.IsBivalent {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S Bool) (c : Config P ObjState S Bool) :

      Configuration c is bivalent if both false and true are reachable decisions from c ([Her91], §3.1, p. 131).

      def Cslib.Distributed.SharedMemory.Protocol.IsCritical {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S Bool) (c : Config P ObjState S Bool) :

      Configuration c is critical if c is bivalent yet every active step from c is a decision step leaving the set of bivalent configurations ([Her91], §3.1, pp. 131–132).

      theorem Cslib.Distributed.SharedMemory.Protocol.IsUnivalent.of_canReach {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S Bool} (p : P) {c c' : Config P ObjState S Bool} {b : Bool} (ha : Acc π.StepRel c) (hu : π.IsUnivalent c b) (hreach : π.lts.CanReach c c') :
      π.IsUnivalent c' b
      theorem Cslib.Distributed.SharedMemory.Protocol.IsUnivalent.soloRun_decided {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S Bool} (w : P) {c c' : Config P ObjState S Bool} {b : Bool} (hu : π.IsUnivalent c b) (hreach : π.lts.CanReach c c') (ha' : Acc π.StepRel c') :
      ((π.soloRun w c' ha').proc w).decided = some b

      In any accessible configuration c' reachable from a b-univalent configuration c, running any process w solo decides b.

      theorem Cslib.Distributed.SharedMemory.Protocol.not_univalent_of_indistinguishable {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S Bool} (w : P) {u₀ u₁ c₀ c₁ : Config P ObjState S Bool} (ha₀ : Acc π.StepRel u₀) (ha₁ : Acc π.StepRel u₁) (hu₀ : π.IsUnivalent u₀ false) (hu₁ : π.IsUnivalent u₁ true) (hr₀ : π.lts.CanReach u₀ c₀) (hr₁ : π.lts.CanReach u₁ c₁) (hmem : c₀.mem = c₁.mem) (hproc : c₀.proc w = c₁.proc w) :

      Solo-indistinguishability contradiction ([Her91], §3.1, pp. 131–133): if c₀ is reachable from an accessible false-univalent configuration u₀, c₁ is reachable from an accessible true-univalent configuration u₁, and c₀ and c₁ have identical shared memory and identical local state at some witness process w, then w's solo execution yields a contradiction.

      theorem Cslib.Distributed.SharedMemory.Protocol.IsBivalent.active_all {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] {π : Protocol P objs S Bool} (hcons : π.SolvesWaitFreeConsensus) {inp : P → Bool} {c : Config P ObjState S Bool} (hr : π.Reachable inp c) (hbiv : π.IsBivalent c) (p : P) :
      c.Active p

      Under consensus agreement, every process in a reachable bivalent configuration is still active (undecided): a decided process's write-once decision would persist into a reachable configuration deciding the opposite bit.

      theorem Cslib.Distributed.SharedMemory.Protocol.exists_bivalent_init {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] [Fintype P] (π : Protocol P objs S Bool) (hcons : π.SolvesWaitFreeConsensus) (hcard : 2 ≤ Fintype.card P) :
      ∃ (inp : P → Bool), π.IsBivalent (π.initConfig inp)

      Initial bivalence (extending [Her91], §3.1, p. 131 from |P| = 2 to 2 ≤ Fintype.card P via single-input flips): every wait-free binary consensus protocol over 2 ≤ Fintype.card P processes has at least one bivalent initial configuration.

      theorem Cslib.Distributed.SharedMemory.Protocol.exists_critical_config {P : Type u_1} {I : Type u_2} {S : Type u_3} {Op : I → Type u_4} {Resp : I → Type u_5} {ObjState : I → Type u_6} {objs : (i : I) → ObjSpec (Op i) (Resp i) (ObjState i)} [DecidableEq P] [DecidableEq I] (π : Protocol P objs S Bool) (hcons : π.SolvesWaitFreeConsensus) {inp : P → Bool} {c : Config P ObjState S Bool} (hr : π.Reachable inp c) (hbiv : π.IsBivalent c) :
      ∃ (cstar : Config P ObjState S Bool) (p : P) (q : P), π.lts.CanReach c cstar ∧ π.IsCritical cstar ∧ (∀ (r : P), cstar.Active r) ∧ p ≠ q ∧ π.IsUnivalent (π.step p cstar) false ∧ π.IsUnivalent (π.step q cstar) true

      Constructive critical configuration ([Her91], §3.1, pp. 131–132): from any reachable bivalent configuration c of a wait-free binary consensus protocol, structural induction on Reachable.acc reaches a critical configuration c* in which every process is active and two distinct processes p ≠ q step to false-univalent and true-univalent configurations respectively.