Documentation

CslibFrontier.Computability.Distributed.Byzantine.PhaseKing

Two-round rotating-king protocol and multivalued-to-binary reduction steps #

The recursive oral messages protocol (CslibFrontier.Computability.Distributed.Byzantine.RecursiveOralMessages) solves synchronous Byzantine agreement for n > 3t in t + 1 rounds by relaying full trees of depth t + 1, so its message size grows exponentially in t. This module lands two polynomial-communication synchronous protocol steps toward #7210 (#3261) in Cslib.Distributed.Byzantine:

  1. Two-round rotating-king protocol step (phaseKing, after Berman and Garay): a 2 * (t + 1)-round deterministic protocol over any [DecidableEq V] for 4 * t < Fintype.card P in which every point-to-point message is a single value of V (Msg = V) and each process stores three fields (PhaseKingState V). Primary-source locator verification against the paywalled [BermanGaray1989] proceedings text, inventory registration, and the 3-round-per-phase 3 * t < n extension of Berman, Garay and Perry remain open under #7210. Given an injective schedule kings : Fin (t + 1) ↪ P of t + 1 phase kings:

    • In round 2 * k (universal broadcast), every process broadcasts its current estimate est. Because 4 * t < n implies n < 2 * (n - 2 * t), at most one value x : V appears at least n - 2 * t times (and a fortiori at most one appears at least n - t times). Each process records kingProposal (x if some x has multiplicity ≥ n - 2 * t, else est) and overwhelming (some x if some x has multiplicity ≥ n - t, else none).
    • In round 2 * k + 1 (king tie-break), kings k broadcasts its kingProposal, and every process updates est to x when overwhelming = some x and to the value received from kings k otherwise.

    Unanimity among correct processes persists across every phase whenever 2 * t < n (phaseKing_persists), even if kings k is faulty and equivocates. By the pigeonhole principle at least one of the t + 1 distinct kings is correct, and in its phase all correct processes converge to that king's proposal whenever 4 * t < n (phaseKing_converges_of_notMem): if any correct process had overwhelming = some x (multiplicity ≥ n - t), at least n - 2 * t correct processes broadcast x, so the correct king also saw multiplicity ≥ n - 2 * t and proposed x. The threshold 4 * t < n is sharp for this 2-round phase structure: on Fin 4 with t = 1, phaseKing fails for every king schedule and round bound (phaseKing_fails_four_one), because a single traitor can create a 2-versus-2 tie at n - 2 * t = 2 for an honest king while giving another honest process multiplicity n - t = 3.

  2. Multivalued-to-binary reduction step (turpinCoan, after Turpin and Coan, §§2–3, pp. 74–75): given any R₀-round binary protocol πBool : Protocol P SBool MBool solving SolvesByzantineAgreement t R₀, turpinCoan t default πBool solves multivalued Byzantine agreement over any [DecidableEq V] in R₀ + 2 rounds for all 3 * t < Fintype.card P (turpinCoan_solvesByzantineAgreement), sending V-values in round 1 only (turpinCoan_valueMessagesSent_eq). Verified against the published IPL text (§§1–4, pp. 73–75 in manual/sources.md); inventory registration remains open under #7210 pending an outside-fleet source check:

    • In round 1 (r = 0), every process broadcasts its initial value input : V and marks itself perplexed if 2 * #{j | heard j = input} ≤ n + t (the exact integer-multiplied form of #{j | heard j ≠ input} ≥ (n - t) / 2 in [TurpinCoan1984], §2, p. 74).
    • In round 2 (r = 1), every process broadcasts its 1-bit perplexed : Bool flag, sets alert := decide (n - 2 * t ≤ #{j | perp j = true}), records as candidate the unique value vouched for by more than t non-perplexed senders (uniqueAboveOn ... (t + 1)), and initializes πBool on alert.
    • Rounds 3 through R₀ + 2 run πBool; processes decide default when πBool outputs true and candidate when πBool outputs false.

Model and threshold notes #

Main definitions #

Main results #

References #

Multivalued synchronous protocols #

structure Cslib.Distributed.Byzantine.MultivaluedProtocol (P : Type u_1) (State : Type u_2) (Msg : Type u_3) (Val : Type u_4) :
Type (max (max (max u_1 u_2) u_3) u_4)

A deterministic synchronous message-passing protocol on the complete graph of processes P with input and decision values in Val.

This is the value-parameterized counterpart of Cslib.Distributed.Byzantine.Protocol (which fixes Val = Bool), sharing the same synchronous round execution against static Byzantine faults.

  • init : P → Val → State

    The initial state of a process with a given input value.

  • send : ℕ → P → State → P → Msg

    send r i s j: the message process i in state s sends to j in round r + 1.

  • update : ℕ → P → State → (P → Msg) → State

    update r i s m: the state of i after round r + 1, where m j came from j.

  • output : P → State → Val

    The decision of a process in a given state.

def Cslib.Distributed.Byzantine.MultivaluedProtocol.state {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] (π : MultivaluedProtocol P S M V) (F : Finset P) (adv : ℕ → P → P → M) (x : P → V) :
ℕ → P → S

The state of process i after r rounds on inputs x when the processes in F are faulty and a faulty j sends adv r j i to i in round r + 1.

def Cslib.Distributed.Byzantine.MultivaluedProtocol.decision {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] (π : MultivaluedProtocol P S M V) (F : Finset P) (adv : ℕ → P → P → M) (x : P → V) (R : ℕ) (i : P) :
V

The decision of process i after R rounds.

structure Cslib.Distributed.Byzantine.MultivaluedProtocol.SolvesByzantineAgreement {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] (π : MultivaluedProtocol P S M V) (t R : ℕ) :

π solves multivalued Byzantine agreement over V against at most t faults in R rounds: whenever at most t processes are faulty, all correct processes decide the same value after R rounds, and they decide v whenever all correct processes have input v.

  • agreement (F : Finset P) : F.card ≤ t → ∀ (adv : ℕ → P → P → M) (x : P → V), ∀ i ∉ F, ∀ j ∉ F, π.decision F adv x R i = π.decision F adv x R j

    Agreement: all correct processes decide the same value.

  • validity (F : Finset P) : F.card ≤ t → ∀ (adv : ℕ → P → P → M) (x : P → V) (v : V), (∀ i ∉ F, x i = v) → ∀ i ∉ F, π.decision F adv x R i = v

    Validity: if all correct processes have input v, they decide v.

theorem Cslib.Distributed.Byzantine.MultivaluedProtocol.SolvesByzantineAgreement.mono {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] {π : MultivaluedProtocol P S M V} {t t' R : ℕ} (h : π.SolvesByzantineAgreement t R) (ht : t' ≤ t) :

Tolerating t faults implies tolerating at most t' ≤ t faults.

@[simp]
theorem Cslib.Distributed.Byzantine.MultivaluedProtocol.toProtocol_state {P : Type u_1} {S : Type u_2} {M : Type u_3} [DecidableEq P] (π : MultivaluedProtocol P S M Bool) (F : Finset P) (adv : ℕ → P → P → M) (x : P → Bool) (r : ℕ) :
π.toProtocol.state F adv x r = π.state F adv x r

Execution states of π.toProtocol coincide with those of π.

@[simp]
theorem Cslib.Distributed.Byzantine.MultivaluedProtocol.toProtocol_decision {P : Type u_1} {S : Type u_2} {M : Type u_3} [DecidableEq P] (π : MultivaluedProtocol P S M Bool) (F : Finset P) (adv : ℕ → P → P → M) (x : P → Bool) (R : ℕ) (i : P) :
π.toProtocol.decision F adv x R i = π.decision F adv x R i

Decisions of π.toProtocol coincide with those of π.

Over any nontrivial value domain V, no deterministic synchronous protocol on 2 ≤ Fintype.card P ≤ 3 * t processes solves multivalued Byzantine agreement against t faults: embedding two distinct values of V as Bool reduces to Protocol.not_solvesByzantineAgreement (after Fischer, Lynch and Merritt, Theorem 1 and §3.1).

Unique threshold extraction #

def Cslib.Distributed.Byzantine.uniqueAboveOn {P : Type u_1} {V : Type u_2} [DecidableEq V] (dom : Finset P) (k : ℕ) (f : P → V) :

Return some v when v is the unique value in dom.image f whose multiplicity on dom is at least k, and none otherwise.

theorem Cslib.Distributed.Byzantine.uniqueAboveOn_eq_some_iff {P : Type u_1} {V : Type u_2} [DecidableEq V] {dom : Finset P} {k : ℕ} (hk : 1 ≤ k) {f : P → V} {v : V} :
uniqueAboveOn dom k f = some v ↔ k ≤ {p ∈ dom | f p = v}.card ∧ ∀ (w : V), k ≤ {p ∈ dom | f p = w}.card → w = v

For 1 ≤ k, uniqueAboveOn dom k f = some v if and only if v appears at least k times on dom and every value appearing at least k times on dom equals v.

theorem Cslib.Distributed.Byzantine.uniqueAboveOn_eq_some_iff_of_lt_two_mul {P : Type u_1} {V : Type u_2} [DecidableEq V] {dom : Finset P} {k : ℕ} (hdom : dom.card < 2 * k) {f : P → V} {v : V} :
uniqueAboveOn dom k f = some v ↔ k ≤ {p ∈ dom | f p = v}.card

When dom.card < 2 * k, at most one value can appear k times on dom, so uniqueAboveOn dom k f = some v holds precisely when v has multiplicity at least k.

Two-round rotating-king protocol step (4 * t < n) #

Local state of a process in the 2-round-per-phase phaseKing protocol: its current estimate est, the tie-break value kingProposal it would broadcast as phase king in the second round of the current phase, and the overwhelming value (if any) seen with multiplicity at least n - t in the first round of the current phase.

  • est : V

    Current decision estimate.

  • kingProposal : V

    Value proposed as phase king in round 2 * k + 1 (multiplicity ≥ n - 2 * t, else est).

  • overwhelming : Option V

    Unique value received at least n - t times in round 2 * k, if any.

def Cslib.Distributed.Byzantine.phaseKing {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [DecidableEq V] (t : ℕ) (kings : Fin (t + 1) ↪ P) :

Two-round-per-phase rotating-king protocol step toward #7210 (after Berman and Garay; primary-source locator verification and the 3-round-per-phase 3 * t < n extension of Berman, Garay and Perry remain open under #7210).

Runs t + 1 two-round phases indexed by kings : Fin (t + 1) ↪ P, with every point-to-point message a single element of V:

  • Round 2 * k (r % 2 = 0, r / 2 = k < t + 1): every process broadcasts s.est, sets kingProposal to the unique value of multiplicity ≥ n - 2 * t (defaulting to s.est), and sets overwhelming to the unique value of multiplicity ≥ n - t (if any).
  • Round 2 * k + 1 (r % 2 = 1, r / 2 = k < t + 1): kings ⟨k, hk⟩ broadcasts s.kingProposal (other processes send s.est), and every process sets est to s.overwhelming.getD (m (kings ⟨k, hk⟩)).
  • Rounds ≥ 2 * (t + 1): local states freeze.
theorem Cslib.Distributed.Byzantine.phaseKing_persists {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [DecidableEq V] {t : ℕ} (kings : Fin (t + 1) ↪ P) {F : Finset P} (hF : F.card ≤ t) (hn : 2 * t < Fintype.card P) (adv : ℕ → P → P → V) (x : P → V) {k : ℕ} (hk : k < t + 1) {v : V} (huniv : ∀ p ∉ F, ((phaseKing t kings).state F adv x (2 * k) p).est = v) (i : P) :
i ∉ F → ((phaseKing t kings).state F adv x (2 * (k + 1)) i).est = v

Unanimity persistence for phaseKing: across any phase k < t + 1 (even when kings ⟨k, hk⟩ ∈ F equivocates arbitrarily), if F.card ≤ t, 2 * t < Fintype.card P, and all correct processes enter phase k with est = v, then all correct processes finish phase k with est = v.

theorem Cslib.Distributed.Byzantine.phaseKing_converges_of_notMem {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [DecidableEq V] {t : ℕ} (kings : Fin (t + 1) ↪ P) {F : Finset P} (hF : F.card ≤ t) (hn : 4 * t < Fintype.card P) (adv : ℕ → P → P → V) (x : P → V) (k : Fin (t + 1)) (hking : kings k ∉ F) (i : P) :
i ∉ F → ((phaseKing t kings).state F adv x (2 * (↑k + 1)) i).est = ((phaseKing t kings).state F adv x (2 * ↑k + 1) (kings k)).kingProposal

Honest-king convergence for phaseKing: if F.card ≤ t, 4 * t < Fintype.card P, and the king kings k of phase k is correct (kings k ∉ F), then all correct processes end phase k with the same estimate (namely kings k's kingProposal from round 2 * k).

theorem Cslib.Distributed.Byzantine.phaseKing_state_eq_of_le {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [DecidableEq V] {t : ℕ} (kings : Fin (t + 1) ↪ P) (F : Finset P) (adv : ℕ → P → P → V) (x : P → V) {R : ℕ} (hR : 2 * (t + 1) ≤ R) :
(phaseKing t kings).state F adv x R = (phaseKing t kings).state F adv x (2 * (t + 1))

phaseKing freezes local states once all t + 1 two-round phases have completed (2 * (t + 1) ≤ R).

theorem Cslib.Distributed.Byzantine.phaseKing_solvesByzantineAgreement {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [DecidableEq V] {t : ℕ} (kings : Fin (t + 1) ↪ P) (hn : 4 * t < Fintype.card P) {R : ℕ} (hR : 2 * (t + 1) ≤ R) :

Protocol-correctness step toward #7210 (after Berman and Garay; primary-source check, inventory registration, and the 3-round-per-phase 3 * t < n extension of Berman, Garay and Perry remain open under #7210): whenever 4 * t < Fintype.card P and 2 * (t + 1) ≤ R, phaseKing t kings solves multivalued Byzantine agreement against at most t faults in R rounds with single-value messages (Msg = V).

theorem Cslib.Distributed.Byzantine.exists_polyMsg_solvesByzantineAgreement {P : Type u_1} [Fintype P] [DecidableEq P] (V : Type u_2) {t R : ℕ} (hn : 4 * t < Fintype.card P) (hR : 2 * (t + 1) ≤ R) :

Single-value-message existence step toward #7210 (after Berman and Garay; primary-source check and the 3-round-per-phase 3 * t < n extension of Berman, Garay and Perry remain open under #7210): whenever 4 * t < Fintype.card P and 2 * (t + 1) ≤ R, there exists a synchronous protocol over V with constant-field local state PhaseKingState V and message alphabet V itself (2 * (t + 1) * (|P| - |F|) * |P| honest point-to-point transmissions across the 2 * (t + 1) active rounds) solving t-resilient Byzantine agreement in R rounds.

Sharpness of 4 * t < n for 2-round Phase-King (Fin 4, t = 1) #

Sharpness of 4 * t < n for two-round phaseKing: on Fin 4 with t = 1 (4 * t = n, contrasting with om1 and om, which succeed on Fin 4 using 2-round relay vectors/trees), phaseKing 1 kings fails to solve 1-fault Byzantine agreement for every king schedule kings : Fin 2 ↪ Fin 4 and every round bound R.

In phase 0, faulty kings 1 creates a 2-versus-2 tie (multiplicity = n - 2 * t = 2) at the honest king kings 0 while giving another honest process p multiplicity n - t = 3 for the opposite bit; in phase 1, kings 1 is the phase king and equivocates to split kings 0 and p.

Multivalued-to-binary reduction step (3 * t < n) #

inductive Cslib.Distributed.Byzantine.TurpinCoanMsg (V : Type u_1) (MBool : Type u_2) :
Type (max u_1 u_2)

Messages sent by turpinCoan: an initial domain value val in round 1, a 1-bit perplexed flag in round 2, and messages bin of the underlying binary protocol in rounds 3 onward.

  • val {V : Type u_1} {MBool : Type u_2} (v : V) : TurpinCoanMsg V MBool

    Round 1: broadcast of the process's initial value in V.

  • perplexed {V : Type u_1} {MBool : Type u_2} (b : Bool) : TurpinCoanMsg V MBool

    Round 2: 1-bit flag indicating whether the sender was perplexed after round 1.

  • bin {V : Type u_1} {MBool : Type u_2} (m : MBool) : TurpinCoanMsg V MBool

    Rounds ≥ 3: message of the underlying binary Byzantine agreement protocol.

@[instance_reducible]
instance Cslib.Distributed.Byzantine.instDecidableEqTurpinCoanMsg {V✝ : Type u_1} {MBool✝ : Type u_2} [DecidableEq V✝] [DecidableEq MBool✝] :
DecidableEq (TurpinCoanMsg V✝ MBool✝)
def Cslib.Distributed.Byzantine.instDecidableEqTurpinCoanMsg.decEq {V✝ : Type u_1} {MBool✝ : Type u_2} [DecidableEq V✝] [DecidableEq MBool✝] (x✝ x✝¹ : TurpinCoanMsg V✝ MBool✝) :
Decidable (x✝ = x✝¹)

Whether a TurpinCoanMsg carries an element of the value domain V.

structure Cslib.Distributed.Byzantine.TurpinCoanState (P : Type u_1) (V : Type u_2) (SBool : Type u_3) :
Type (max (max u_1 u_2) u_3)

Local state of a process in turpinCoan.

  • input : V

    The process's initial input value.

  • heard : P → V

    heard j: the value received from j in round 1.

  • perplexed : Bool

    Whether this process was perplexed after round 1 (2 * count(input) ≤ n + t).

  • candidate : V

    Candidate value endorsed by more than t non-perplexed senders after round 2.

  • binState : SBool

    Local state of the underlying binary protocol from round 3 onward.

def Cslib.Distributed.Byzantine.turpinCoan {P : Type u_1} {V : Type u_2} {SBool : Type u_3} {MBool : Type u_4} [Fintype P] [DecidableEq V] (t : ℕ) (default : V) (πBool : Protocol P SBool MBool) :

Two-round multivalued-to-binary preprocessing step toward #7210 (after Turpin and Coan, §2, p. 74; inventory registration remains open under #7210 pending an outside-fleet source check).

Transforms any binary Byzantine agreement protocol πBool : Protocol P SBool MBool into a multivalued protocol over V with fallback default : V in two preprocessing rounds:

  • Round 1 (r = 0): broadcast s.input; become perplexed iff 2 * #{j | heard j = s.input} ≤ Fintype.card P + t.
  • Round 2 (r = 1): broadcast s.perplexed; set alert := decide (n - 2 * t ≤ #{j | perp j}), compute candidate as the unique value seen in round 1 from at least t + 1 senders reporting perp j = false (defaulting to default), and initialize πBool with alert.
  • Rounds r + 2 (r ≥ 0): run round r + 1 of πBool; decide default if πBool decides true (alert) and s.candidate otherwise.
def Cslib.Distributed.Byzantine.turpinCoanValueMessagesSent {P : Type u_1} {V : Type u_2} {SBool : Type u_3} {MBool : Type u_4} [Fintype P] [DecidableEq P] [DecidableEq V] (t : ℕ) (default : V) (πBool : Protocol P SBool MBool) (F : Finset P) (adv : ℕ → P → P → TurpinCoanMsg V MBool) (x : P → V) (R : ℕ) :

Total number of V-carrying (TurpinCoanMsg.isVal) point-to-point messages sent by correct processes (univ \ F) across the first R rounds of turpinCoan.

theorem Cslib.Distributed.Byzantine.turpinCoan_valueMessagesSent_eq {P : Type u_1} {V : Type u_2} {SBool : Type u_3} {MBool : Type u_4} [Fintype P] [DecidableEq P] [DecidableEq V] (t : ℕ) (default : V) (πBool : Protocol P SBool MBool) (F : Finset P) (adv : ℕ → P → P → TurpinCoanMsg V MBool) (x : P → V) (R : ℕ) :
turpinCoanValueMessagesSent t default πBool F adv x (R + 1) = (Fintype.card P - F.card) * Fintype.card P

Across R + 1 rounds of turpinCoan, correct processes transmit V-values in round 1 only, for an exact total of (Fintype.card P - F.card) * Fintype.card P value-bearing messages (independent of R, t, and the adversary adv).

theorem Cslib.Distributed.Byzantine.turpinCoan_solvesByzantineAgreement {P : Type u_1} {V : Type u_2} {SBool : Type u_3} {MBool : Type u_4} [Fintype P] [DecidableEq P] [DecidableEq V] {t R₀ : ℕ} (default : V) {πBool : Protocol P SBool MBool} (hn : 3 * t < Fintype.card P) (hBool : πBool.SolvesByzantineAgreement t R₀) :
(turpinCoan t default πBool).SolvesByzantineAgreement t (R₀ + 2)

Multivalued-to-binary reduction step toward #7210 (after Turpin and Coan, §§2–3, pp. 74–75; inventory registration remains open under #7210 pending an outside-fleet source check): if 3 * t < Fintype.card P and πBool : Protocol P SBool MBool solves binary Byzantine agreement against t faults in R₀ rounds, then turpinCoan t default πBool solves multivalued Byzantine agreement over V against t faults in R₀ + 2 rounds.