Documentation

CslibFrontier.Computability.Interactive.Debate

Debate with a stochastic oracle: the cross-examination protocol #

Two provers debate the output of a randomized computation in front of a verifier who samples only one step of it. The computation is a step law law : List Bool → PMF Bool: given the bits written so far, most recent first, the law of the next bit. Its transcript and output are the oracle programs Debate.transcript and Debate.output, which query each prefix in turn.

Debate.run interprets the protocol of [BrownCohenIrvingPiliouras2024, Figure 1]. In each round the proposer claims a probability for the next bit; the interpreter asks an independent copy of each player for a coin, adds the two coins and sets the bit from the claim and the sum; the challenger may then abort. On an abort the verifier samples the disputed step itself and accepts exactly when the claim is close to its sample mean. Without an abort the verifier outputs the last bit. Each player is a program with private state, private coins and sample access to the step law; a player sees the public history and its own state, never the other player's.

The correctness theorems, at the constants of the Lean development accompanying the source (Debate.Params.default) and at Debate.Params.figure1, are steps toward [BrownCohenIrvingPiliouras2024, Theorem 6.2], not that theorem. Completeness needs no Lipschitz hypothesis. Soundness assumes that the output is Lipschitz in the whole step law (ProbOracleComp.LipschitzAt K law (Debate.output n)), which is stronger than Definition 6.1 of the source; the reason for the stronger hypothesis is recorded in cslib-frontier issue #7579. None of these theorems makes a claim about running time, about the number of oracle queries of any party, or about machines given by an encoding.

Deviations from the source #

Main definitions #

Main results #

References #

The computation under debate #

@[reducible, inline]

The oracle interface of a step law: a query is the list of bits written so far, most recent first, and the reply is the next bit.

The transcript of the first n steps, most recent bit first: each step queries the bits written before it.

The output of an n-step computation: the last bit of its transcript (false when n = 0).

The number of true replies among n independent samples of the step after bits.

Rounds and players #

def Cslib.Interactive.Debate.coinBit {N : ℕ} (claim : Fin (N + 1)) (coinA coinB : ZMod N) :

The bit of a round: true exactly when the sum of the two coins, as a number below N, is below the claim k. If either coin is uniform on ZMod N and N ≠ 0, the bit is true with probability k / N.

The public record of one round on the grid N.

  • claim : Fin (N + 1)

    The proposer's claim k, read as the probability k / N that the next bit is true.

  • coinA : ZMod N

    The coin obtained from the independent copy of the challenger.

  • coinB : ZMod N

    The coin obtained from the independent copy of the proposer.

The bit written in a round.

@[reducible, inline]

The public history of a debate: its completed rounds, most recent first.

The bits written so far, most recent first.

A proposer on the grid N: the player claiming that the output is true. It keeps a private state, draws private coins and samples steps of the computation at will.

A challenger on the grid N: the player disputing that the output is true. It keeps a private state, draws private coins and samples steps of the computation at will.

  • State : Type

    The private state carried between rounds.

  • init : self.State

    The initial private state.

  • abort : History N → Round N → StateT self.State (ProbOracleComp StepSpec) Bool

    Whether to abort after a round, from the public history before the round, the round and the private state.

  • coin : History N → Fin (N + 1) → ProbOracleComp StepSpec (ZMod N)

    The independent copy asked for a coin. It sees the public history and the current claim, and shares no state with the challenger.

The protocol #

The parameters of the protocol and of its prescribed strategies.

  • rounds : ℕ

    The number of rounds, which is the number of steps of the computation.

  • grid : ℕ

    The grid size N: claims are multiples of 1 / N, and the honest proposer draws N samples for each claim.

  • challengerSamples : ℕ

    The number of samples the honest challenger draws in each round.

  • challengerTolerance : ℝ

    The honest challenger aborts when the claim and its sample mean differ by at least this much.

  • verifierSamples : ℕ

    The number of samples the verifier draws after an abort.

  • verifierTolerance : ℝ

    The verifier accepts after an abort when the claim and its sample mean differ by less than this much.

noncomputable def Cslib.Interactive.Debate.verdict (P : Params) (bits : List Bool) (claim : Fin (P.grid + 1)) :

The verifier's decision after an abort in the round after bits with claim claim: draw P.verifierSamples samples of the disputed step and accept exactly when the claim is within P.verifierTolerance of their mean.

noncomputable def Cslib.Interactive.Debate.runFrom (P : Params) (A : Proposer P.grid) (B : Challenger P.grid) :

The remaining rounds rounds of a debate from the public history history and the two private states.

The debate protocol of [BrownCohenIrvingPiliouras2024, Figure 1] between the proposer A and the challenger B; the result is true when the verifier accepts.

In each round the proposer claims a probability for the next bit, the interpreter obtains one coin from an independent copy of each player and sets the bit by coinBit, and the challenger may abort. After an abort the verifier draws P.verifierSamples samples of the disputed step and accepts exactly when the claim is within P.verifierTolerance of their mean; after P.rounds rounds without an abort it outputs the last bit. Every private sample of either player, of either copy and of the verifier is a fresh draw.

The prescribed strategies #

A uniform coin on ZMod N (the coin 0 in the degenerate case N = 0).

The honest proposer: in each round it draws P.grid fresh samples of the next step and claims the fraction that are true; its copy returns a uniform coin.

The honest challenger: in each round it draws P.challengerSamples fresh samples of the step just taken and aborts when the claim differs from the fraction that are true by at least P.challengerTolerance; its copy returns a uniform coin.

noncomputable def Cslib.Interactive.Debate.sampleCount (error failure : ℝ) :

The number of samples after which a sample mean of a Bool-valued step is within error of its probability except with probability at most failure (Hoeffding's inequality).

The parameters for a (T + 1)-step computation with Lipschitz constant K, following Params.defaults of the Lean development accompanying the source. An estimate with error e and failure probability f uses ⌈-log (f / 2) / (2 e ^ 2)⌉ samples. With c = 1 / (100 K), s = 2 / (100 K) and b = 5 / (100 K): the honest proposer's claim is within c of the truth except with probability 1 / (100 (T + 1)); the honest challenger, with the same failure probability, does not abort a claim within s and aborts a claim off by b; the verifier accepts a claim within c and rejects a claim off by s, each except with probability 1 / 100.

The parameters of [BrownCohenIrvingPiliouras2024, Figure 1] and of the proof of Theorem 6.2 for a T-step computation with Lipschitz constant K, with d = ⌈150 K⌉ (dedebate.tex, line 252):

  • T rounds (line 253);
  • the verifier draws r = ⌈192 d ^ 2 log 100⌉ samples (line 263) and accepts when the claim is within 1 / (4 d) of their mean (line 264);
  • the honest provers draw R = ⌈192 d ^ 2 log (100 T)⌉ samples (lines 461 and 546), which is also the grid, so that the honest proposer's sample mean is a grid point;
  • the honest challenger aborts unless the claim is within 1 / (2 d) of its sample mean (line 546).

The source writes log without a base and does not round the sample counts. The logarithm is natural here: the proof equates 2 exp (-R / (192 d ^ 2)) with 1 / (50 T) (line 487), which holds for the natural logarithm only. The counts are rounded up.

Evaluation against a step law #

Sample counts #

The coin step #

theorem Cslib.Interactive.Debate.map_coinBit_uniformOfFintype_left {N : ℕ} [NeZero N] (k : Fin (N + 1)) (z : ZMod N) :
(PMF.map (fun (w : ZMod N) => coinBit k w z) (Probability.PMF.uniformOfFintype (ZMod N))) true = ↑↑k / ↑N

A uniform coin from the challenger's copy makes the bit of a round true with probability k / N, whatever the coin from the proposer's copy.

theorem Cslib.Interactive.Debate.map_coinBit_uniformOfFintype_right {N : ℕ} [NeZero N] (k : Fin (N + 1)) (z : ZMod N) :
(PMF.map (fun (w : ZMod N) => coinBit k z w) (Probability.PMF.uniformOfFintype (ZMod N))) true = ↑↑k / ↑N

A uniform coin from the proposer's copy makes the bit of a round true with probability k / N, whatever the coin from the challenger's copy.

theorem Cslib.Interactive.Debate.map_coinBit_uniformOfFintype_right_false {N : ℕ} [NeZero N] (k : Fin (N + 1)) (z : ZMod N) :
(PMF.map (fun (w : ZMod N) => coinBit k z w) (Probability.PMF.uniformOfFintype (ZMod N))) false = 1 - ↑↑k / ↑N

A uniform coin from the proposer's copy makes the bit of a round false with probability 1 - k / N, whatever the coin from the challenger's copy.

The computation from a prefix #

The honest players and the verifier #

The best nearby step law #

Rounds #

Soundness #

Completeness #

The default parameters #

theorem Cslib.Interactive.Debate.evalWith_verdict_false_le (law : List Bool → PMF Bool) (P : Params) (hsamples : 0 < P.verifierSamples) (bits : List Bool) (claim : Fin (P.grid + 1)) {e : ℝ} (he : 0 ≤ e) (h : |↑↑claim / ↑P.grid - ((law bits) true).toReal| + e ≤ P.verifierTolerance) :

The verifier's check after an abort. If the claim is closer to the true probability of the step than the verifier's tolerance, by a margin e, then the verifier rejects it only when its sample mean is off by e, which by Hoeffding's inequality has probability at most 2 exp (-2 r e ^ 2) for r samples.

theorem Cslib.Interactive.Debate.evalWith_verdict_of_pure {law : List Bool → PMF Bool} (P : Params) (hsamples : 0 < P.verifierSamples) {bits : List Bool} {bit : Bool} (hlaw : law bits = PMF.pure bit) (claim : Fin (P.grid + 1)) (h : |↑↑claim / ↑P.grid - if bit = true then 1 else 0| < P.verifierTolerance) :

At a deterministic step the verifier accepts every claim within its tolerance of the bit prescribed by the step law.

The default parameters are positive: the grid, both sample counts and both tolerances.

The constants of Figure 1 #

Correctness #

Completeness, as a step. A step toward [BrownCohenIrvingPiliouras2024, Theorem 6.2], not that theorem: if the output of a (T + 1)-step computation is true with probability at least 2 / 3, then the honest proposer of the protocol of Figure 1 makes the verifier accept with probability at least 3 / 5 against every challenger. No Lipschitz hypothesis is needed.

The challenger is an arbitrary program with private state, private coins and unbounded sample access to the step law. Nothing is claimed about running time or query counts, the grid replaces the real numbers of the source, and the constants are Params.default, which depend on K.

Soundness, as a step. A step toward [BrownCohenIrvingPiliouras2024, Theorem 6.2], not that theorem: if the output of a (T + 1)-step computation is K-Lipschitz in its whole step law (every step and every transcript prefix, which is stronger than Definition 6.1 of the source; the reason is recorded in cslib-frontier issue #7579) and is true with probability at most 1 / 3, then against the honest challenger of the protocol of Figure 1 every proposer makes the verifier accept with probability at most 2 / 5.

The proposer is an arbitrary program with private state, private coins and unbounded sample access to the step law. Nothing is claimed about running time or query counts, the grid replaces the real numbers of the source, and the constants are Params.default.

Completeness at Params.figure1, as a step. A step toward [BrownCohenIrvingPiliouras2024, Theorem 6.2], not that theorem: if the output of a T-step computation is true with probability at least 2 / 3, then the honest proposer of the protocol of Figure 1 at Params.figure1 makes the verifier accept with probability at least 3 / 5 against every challenger. No Lipschitz hypothesis is needed.

The challenger is an arbitrary program with private state, private coins and unbounded sample access to the step law. Nothing is claimed about running time or query counts, and the grid replaces the real numbers of the source. Params.figure1 takes the number of rounds and the verifier's sample count and threshold from Figure 1, and the honest provers' sample count and the honest challenger's threshold from the proof of Theorem 6.2 in Appendix D. The margins in the proof are not the source's. Here, with d = ⌈150 K⌉, the honest estimate may be off by 1 / (10 d) and the verifier's sample mean by 3 / (20 d), the first failing with probability at most 1 / (50 T) per round and the second with probability at most 1 / 50, by Hoeffding's inequality 2 exp (-2 n e ^ 2). The source allows 1 / (8 d) for both (dedebate.tex, lines 487, 494 and 495), with the same failure probabilities, from its bound 2 exp (-e ^ 2 n / 3) (lines 449 to 453), and concludes with (2 / 3 - 1 / 150) (49 / 50) ^ 2 > 3 / 5 (lines 539 to 541).

Soundness at Params.figure1, as a step. A step toward [BrownCohenIrvingPiliouras2024, Theorem 6.2], not that theorem: if the output of a T-step computation is K-Lipschitz in its whole step law and is true with probability at most 1 / 3, then against the honest challenger of the protocol of Figure 1 at Params.figure1, every proposer makes the verifier accept with probability at most 2 / 5. The Lipschitz hypothesis is in the whole step law (every step and every transcript prefix), which is stronger than Definition 6.1 of the source; the reason is recorded in cslib-frontier issue #7579.

The proposer is an arbitrary program with private state, private coins and unbounded sample access to the step law. Nothing is claimed about running time or query counts, and the grid replaces the real numbers of the source. Params.figure1 takes the number of rounds and the verifier's sample count and threshold from Figure 1, and the honest provers' sample count and the honest challenger's threshold from the proof of Theorem 6.2 in Appendix D. The margins in the proof are not the source's. Here, with d = ⌈150 K⌉, claims are split at 3 / (8 d) and 5 / (8 d) from the truth, and each sample mean may be off by 1 / (8 d), failing with probability at most 1 / (50 T) per round for the challenger and 1 / 50 for the verifier; the Lipschitz term is at most K · 5 / (8 d) ≤ 1 / 240. The source splits at 3 / (8 d) and 3 / (4 d) (dedebate.tex, line 550), with the same failure probabilities (lines 584 and 591).

Query counts #

A step toward milestone 3 of cslib-frontier issue #7579: the oracle-query component q of [BrownCohenIrvingPiliouras2024, Theorem 6.2], as a worst-case bound on external queries, that is queries to the step law; private samples are free (ProbOracleComp.IsQueryBounded). Nothing is claimed about running time. The interpreter has one query channel for all parties, so the verifier's share is identified as the additive term of isQueryBounded_run_of_isQueryBounded and by isQueryBounded_run_of_isQueryBounded_zero. The Lean development accompanying the source counts expected queries per party; the bounds here are worst-case, on every path.

countTrue bits n makes at most n external queries, that is queries to the step law.

The verifier's check. The check after an abort makes at most P.verifierSamples external queries, that is queries to the step law.

theorem Cslib.Interactive.Debate.isQueryBounded_run_of_isQueryBounded (P : Params) (A : Proposer P.grid) (B : Challenger P.grid) {a₁ a₂ b₁ b₂ : ℕ} (hclaim : ∀ (history : History P.grid) (stateA : A.State), ((A.claim history).run stateA).IsQueryBounded a₁) (hcoinA : ∀ (history : History P.grid) (claim : Fin (P.grid + 1)), (A.coin history claim).IsQueryBounded a₂) (habort : ∀ (history : History P.grid) (round : Round P.grid) (stateB : B.State), ((B.abort history round).run stateB).IsQueryBounded b₁) (hcoinB : ∀ (history : History P.grid) (claim : Fin (P.grid + 1)), (B.coin history claim).IsQueryBounded b₂) :
(run P A B).IsQueryBounded (P.rounds * (a₁ + a₂ + b₁ + b₂) + P.verifierSamples)

The run. If every call of the players' four programs makes at most a₁ (the proposer's claim), a₂ (the proposer's copy's coin), b₁ (the challenger's decision to abort) and b₂ (the challenger's copy's coin) external queries, that is queries to the step law, then the run makes at most P.rounds * (a₁ + a₂ + b₁ + b₂) + P.verifierSamples. The additive term is the verifier's check, which runs at most once: it ends the run.

theorem Cslib.Interactive.Debate.isQueryBounded_run_of_isQueryBounded_zero (P : Params) (A : Proposer P.grid) (B : Challenger P.grid) (hclaim : ∀ (history : History P.grid) (stateA : A.State), ((A.claim history).run stateA).IsQueryBounded 0) (hcoinA : ∀ (history : History P.grid) (claim : Fin (P.grid + 1)), (A.coin history claim).IsQueryBounded 0) (habort : ∀ (history : History P.grid) (round : Round P.grid) (stateB : B.State), ((B.abort history round).run stateB).IsQueryBounded 0) (hcoinB : ∀ (history : History P.grid) (claim : Fin (P.grid + 1)), (B.coin history claim).IsQueryBounded 0) :

The verifier's share. If the players make no external query, the whole run makes at most P.verifierSamples external queries, that is queries to the step law.

The honest proposer's claim makes at most P.grid external queries, that is queries to the step law. A query count, not a running time.

The honest proposer's copy draws its coin as a private sample, which is free, and makes no query to the step law.

The honest challenger's decision to abort makes at most P.challengerSamples external queries, that is queries to the step law. A query count, not a running time.

The honest challenger's copy draws its coin as a private sample, which is free, and makes no query to the step law.

The verifier's sample count at Params.figure1, which is the count printed in Figure 1, is at most 192 (150 K + 1) ^ 2 log 100 + 1, since ⌈150 K⌉ < 150 K + 1. It does not depend on T.

The verifier's sample count at Params.figure1 is O(K ^ 2): at most 42000000 K ^ 2 + 1868. It does not depend on T.

The verifier's sample count at the default constants is at most 20000 log 200 K ^ 2 + 1; this exact form is the one to use when the constant matters. It does not depend on T.

The verifier's sample count at the default constants is O(K ^ 2): at most 111000 K ^ 2 + 1, from log 200 < 8 log 2. The Lean development accompanying the source proves 106000 k ^ 2 + 1 for its expected count (vera_fast) with a sharper bound on log 200; the exact form Params.default_verifierSamples_le is the statement to use when the constant matters. It does not depend on T.