Documentation

CslibFrontier.Computability.CellProbe.Randomized

Randomized Cell-Probe Trees, Schemes, and Zero-Error Yao Averaging #

This file extends Cslib.CellProbe ([Mil99]) with internal-coin randomized cell-probe trees (RandProbeTree S w α := ProbOracleComp (@ProbeOp.Result S w) α), randomized cell-probe schemes (Randomized.Scheme), and the averaging (coin-fixing) argument, the easy direction of Yao's principle [Yao77], for zero-error (Las Vegas) randomized schemes.

Private coin draws (unifSpec) incur 0 cell probes, while each cell read or write incurs 1 probe; in Randomized.Scheme, init : PMF (Mem cells w) is an uncharged initial-memory distribution (which operations can inspect only by probing cells). Because every ProbeOp.Result q is finite (Fin (2 ^ w) or PUnit), ProbOracleComp.coinLaw and ProbOracleComp.fixCoins represent any RandProbeTree as a finite mixture of deterministic ProbeTrees (RandProbeTree.run_eq_coinLaw_bind_fixCoins).

Averaging over coin-fixed deterministic schemes via Cslib.RandomizedCost.exists_mem_support_of_coinFixing and Cslib.RandomizedCost.exists_mem_support_tsum_mul_le_of_coinFixing (the easy direction of Yao's principle [Yao77]) converts any zero-error (Las Vegas) randomized scheme P (hcorr requires every supported transcript on correctSeqs to satisfy Good, so bounded-error Monte Carlo schemes and adaptive sequence adversaries are out of scope) into a deterministic scheme preserving correctness across correctSeqs while incurring at most P's expected probes under a fixed oblivious sequence distribution hardDist:

Main definitions #

Main results #

References #

Internal-coin randomized cell-probe trees #

@[reducible, inline]

Adaptive cell-probe tree on S cells of w-bit words with private finite-uniform coin draws (unifSpec), defined as ProbOracleComp (@ProbeOp.Result S w) α.

def Cslib.CellProbe.RandProbeTree.read {S w : ℕ} (i : Fin S) :
RandProbeTree S w (Fin (2 ^ w))

Read cell i : Fin S (1 probe).

Write v : Fin (2 ^ w) to cell i : Fin S (1 probe).

Embed a closed ProbComp sampler (0 probes).

Embed a deterministic ProbeTree into RandProbeTree with zero coin draws.

noncomputable def Cslib.CellProbe.RandProbeTree.run {S w : ℕ} {α : Type} :
RandProbeTree S w α → Mem S w → PMF ((α × Mem S w) × ℕ)

Joint distribution of ((result, postMem), probeCount) executed from pre-memory m, charging 0 probes for private coin samples (.inl n) and 1 probe per cell read/write (.inr q).

noncomputable def Cslib.CellProbe.RandProbeTree.expectedProbes {S w : ℕ} {α : Type} (t : RandProbeTree S w α) (m : Mem S w) :

Expected number of cell probes executed from pre-memory m, valued in ℝ≥0∞.

@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
(pure a).run m = PMF.pure ((a, m), 0)
@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_read {S w : ℕ} (i : Fin S) (m : Mem S w) :
(read i).run m = PMF.pure ((m i, m), 1)
@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_bind {S w : ℕ} {α β : Type} (t : RandProbeTree S w α) (k : α → RandProbeTree S w β) (m : Mem S w) :
(t >>= k).run m = (t.run m).bind fun (x : (α × Mem S w) × ℕ) => match x with | ((a, m'), p₁) => PMF.map (fun (x : (β × Mem S w) × ℕ) => match x with | (out, p₂) => (out, p₁ + p₂)) ((k a).run m')
@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_map {S w : ℕ} {α β : Type} (f : α → β) (t : RandProbeTree S w α) (m : Mem S w) :
(f <$> t).run m = PMF.map (fun (x : (α × Mem S w) × ℕ) => match x with | ((a, m'), p) => ((f a, m'), p)) (t.run m)
@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_sample {S w : ℕ} {α : Type} (p : ProbComp α) (m : Mem S w) :
(sample p).run m = PMF.map (fun (a : α) => ((a, m), 0)) p.eval
@[simp]
theorem Cslib.CellProbe.RandProbeTree.run_ofProbeTree {S w : ℕ} {α : Type} (t : ProbeTree S w α) (m : Mem S w) :
@[simp]
theorem Cslib.CellProbe.RandProbeTree.expectedProbes_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
@[simp]
@[simp]
theorem Cslib.CellProbe.RandProbeTree.expectedProbes_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
@[simp]
@[simp]
@[simp]
theorem Cslib.CellProbe.RandProbeTree.expectedProbes_map {S w : ℕ} {α β : Type} (f : α → β) (t : RandProbeTree S w α) (m : Mem S w) :
theorem Cslib.CellProbe.RandProbeTree.expectedProbes_bind {S w : ℕ} {α β : Type} (t : RandProbeTree S w α) (k : α → RandProbeTree S w β) (m : Mem S w) :
(t >>= k).expectedProbes m = t.expectedProbes m + ∑' (am : α × Mem S w), (PMF.map Prod.fst (t.run m)) am * (k am.1).expectedProbes am.2

Coin-fixing, coin-free projection, and cell padding for RandProbeTree #

Fixing private coins ω ← ProbOracleComp.coinLaw t reproduces the exact joint ((result, postMem), probes) distribution of t.run m.

Expected probe count of t from m equals the coinLaw t-average of ProbeTree.probes (fixCoins t ω) m.

Predicate that a RandProbeTree makes no private coin draws (Sum.inl).

Project a coin-free RandProbeTree to a deterministic ProbeTree.

@[simp]
@[simp]
theorem Cslib.CellProbe.RandProbeTree.isCoinFree_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) :
def Cslib.CellProbe.RandProbeTree.padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') :
RandProbeTree S w α → RandProbeTree S' w α

Lift a RandProbeTree S w α to S' cells (S ≤ S') via Fin.castLE.

theorem Cslib.CellProbe.RandProbeTree.run_padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') (t : RandProbeTree S w α) (m : Mem S w) :
(padCells h t).run (padMem h m) = PMF.map (fun (x : (α × Mem S w) × ℕ) => match x with | ((a, m₁), p) => ((a, padMem h m₁), p)) (t.run m)
@[simp]
theorem Cslib.CellProbe.RandProbeTree.expectedProbes_padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') (t : RandProbeTree S w α) (m : Mem S w) :

Randomized cell-probe schemes and Yao averaging for zero-error schemes #

structure Cslib.CellProbe.Randomized.Scheme (Op : Type u) (Result : Op → Type) (cells w : ℕ) :

Randomized cell-probe scheme with cells cells of w-bit words, consisting of an initial memory distribution init : PMF (Mem cells w) (0 probes) and per-operation internal-coin probe trees step : (o : Op) → RandProbeTree cells w (Result o).

  • init : PMF (Mem cells w)

    Initial cell memory distribution (0 probes; persistent state lives in cells words).

  • step (o : Op) : RandProbeTree cells w (Result o)

    Adaptive randomized cell-probe decision tree executed for each operation o : Op.

noncomputable def Cslib.CellProbe.Randomized.Scheme.ofDeterministic {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : CellProbe.Scheme Op Result cells w) :
Scheme Op Result cells w

Embed a deterministic CellProbe.Scheme as a Randomized.Scheme.

noncomputable def Cslib.CellProbe.Randomized.Scheme.runFrom {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) :
Mem cells w → List Op → PMF ((List (Sigma Result) × Mem cells w) × ℕ)

Joint distribution of ((transcript, postMem), probeCount) executed across ops starting from pre-memory m.

noncomputable def Cslib.CellProbe.Randomized.Scheme.runSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) :
PMF (List (Sigma Result) × ℕ)

Joint distribution of (transcript, totalProbes) across ops starting from P.init.

noncomputable def Cslib.CellProbe.Randomized.Scheme.expectedProbesFrom {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) (ops : List Op) :

Expected total cell probes across ops starting from pre-memory m, valued in ℝ≥0∞.

noncomputable def Cslib.CellProbe.Randomized.Scheme.expectedSeqProbes {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) :

Expected total cell probes across ops starting from P.init, valued in ℝ≥0∞.

@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.runFrom_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) :
@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.runFrom_cons {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) (o : Op) (ops : List Op) :
P.runFrom m (o :: ops) = ((P.step o).run m).bind fun (x : (Result o × Mem cells w) × ℕ) => match x with | ((a, m'), p₁) => PMF.map (fun (x : (List (Sigma Result) × Mem cells w) × ℕ) => match x with | ((tr, m''), p₂) => ((⟨o, a⟩ :: tr, m''), p₁ + p₂)) (P.runFrom m' ops)
@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.runSeq_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) :
@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.expectedSeqProbes_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) :
theorem Cslib.CellProbe.Randomized.Scheme.expectedSeqProbes_eq_init_tsum {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) :
P.expectedSeqProbes ops = ∑' (m₀ : Mem cells w), P.init m₀ * P.expectedProbesFrom m₀ ops
noncomputable def Cslib.CellProbe.Randomized.Scheme.padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (P : Scheme Op Result cells w) :
Scheme Op Result cells' w

Pad a Randomized.Scheme from cells cells to cells' cells (cells ≤ cells').

@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.padCells_step {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (P : Scheme Op Result cells w) (o : Op) :
theorem Cslib.CellProbe.Randomized.Scheme.runFrom_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (P : Scheme Op Result cells w) (m : Mem cells w) (ops : List Op) :
(padCells h P).runFrom (padMem h m) ops = PMF.map (fun (x : (List (Sigma Result) × Mem cells w) × ℕ) => match x with | ((tr, m₁), p) => ((tr, padMem h m₁), p)) (P.runFrom m ops)
@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.runSeq_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (P : Scheme Op Result cells w) (ops : List Op) :
(padCells h P).runSeq ops = P.runSeq ops
@[simp]
theorem Cslib.CellProbe.Randomized.Scheme.expectedSeqProbes_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (P : Scheme Op Result cells w) (ops : List Op) :

Multi-step private-coin fixing over Fin horizon × ↥opsAlphabet #

def Cslib.CellProbe.Randomized.Scheme.fixIndexedScheme {Op : Type u} {Result : Op → Type} {cells w : ℕ} [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) (horizon : ℕ) (opsAlphabet : Finset Op) (m₀ : Mem cells w) (Ω : (idx : Fin horizon × ↥opsAlphabet) → ProbOracleComp.Coins (P.step ↑idx.2)) :
IndexedScheme Op Result cells w

Fix an initial memory m₀ and an array Ω of step-and-operation-indexed private coin trees over Fin horizon × ↥opsAlphabet into a deterministic IndexedScheme (returning pure default outside horizon or outside opsAlphabet).

noncomputable def Cslib.CellProbe.Randomized.Scheme.indexedSchemeLaw {Op : Type u} {Result : Op → Type} {cells w : ℕ} [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) (horizon : ℕ) (opsAlphabet : Finset Op) :
PMF (IndexedScheme Op Result cells w)

Product distribution over deterministic IndexedSchemes obtained by sampling m₀ ← P.init and independent private coins ProbOracleComp.coinLaw (P.step o) for each (t, o) in Fin horizon × ↥opsAlphabet.

theorem Cslib.CellProbe.Randomized.Scheme.runSeq_eq_indexedSchemeLaw_bind {Op : Type u} {Result : Op → Type} {cells w : ℕ} [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) {horizon : ℕ} {opsAlphabet : Finset Op} {ops : List Op} (hlen : ops.length ≤ horizon) (halph : ∀ o ∈ ops, o ∈ opsAlphabet) :
P.runSeq ops = (P.indexedSchemeLaw horizon opsAlphabet).bind fun (D : IndexedScheme Op Result cells w) => PMF.pure ((D.runSeq ops).1, D.seqProbes ops)

Sampling D ← P.indexedSchemeLaw horizon opsAlphabet and running D deterministically on any sequence ops of length ≤ horizon over opsAlphabet reproduces the exact (transcript, probes) distribution P.runSeq ops.

theorem Cslib.CellProbe.Randomized.Scheme.expectedSeqProbes_eq_indexedSchemeLaw_tsum {Op : Type u} {Result : Op → Type} {cells w : ℕ} [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) {horizon : ℕ} {opsAlphabet : Finset Op} {ops : List Op} (hlen : ops.length ≤ horizon) (halph : ∀ o ∈ ops, o ∈ opsAlphabet) :
P.expectedSeqProbes ops = ∑' (D : IndexedScheme Op Result cells w), (P.indexedSchemeLaw horizon opsAlphabet) D * ↑(D.seqProbes ops)

Expected sequence probes of P on ops equals the indexedSchemeLaw-average of D.seqProbes ops whenever ops.length ≤ horizon and ∀ o ∈ ops, o ∈ opsAlphabet.

theorem Cslib.CellProbe.Randomized.Scheme.exists_det_indexedScheme_le_expectedSeqProbes {Op : Type u} {Result : Op → Type} {cells w : ℕ} [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) (opsAlphabet : Finset Op) (horizon : ℕ) (correctSeqs : Set (List Op)) (hcorrectSeqs : ∀ ops ∈ correctSeqs, ops.length ≤ horizon ∧ ∀ o ∈ ops, o ∈ opsAlphabet) (Good : List Op → List (Sigma Result) → Prop) (hcorr : ∀ ops ∈ correctSeqs, ∀ tr ∈ (PMF.map Prod.fst (P.runSeq ops)).support, Good ops tr) (hardDist : PMF (List Op)) (hhardDist : ∀ ops ∈ hardDist.support, ops.length ≤ horizon ∧ ∀ o ∈ ops, o ∈ opsAlphabet) :
∃ D_det ∈ (P.indexedSchemeLaw horizon opsAlphabet).support, (∀ ops ∈ correctSeqs, Good ops (D_det.runSeq ops).1) ∧ ∑' (ops : List Op), hardDist ops * ↑(D_det.seqProbes ops) ≤ ∑' (ops : List Op), hardDist ops * P.expectedSeqProbes ops

Averaging (coin-fixing) argument, the easy direction of Yao's principle [Yao77], for zero-error schemes (IndexedScheme over explicit finite opsAlphabet): Suppose opsAlphabet : Finset Op is a finite set of admissible operations, correctSeqs is any set of oblivious operation sequences of length ≤ horizon over opsAlphabet on which every supported transcript of P.runSeq ops satisfies Good ops (zero-error / Las Vegas correctness; bounded-error Monte Carlo schemes are out of scope), and hardDist : PMF (List Op) is any fixed sequence distribution supported on sequences of length ≤ horizon over opsAlphabet.

Then there exists a single deterministic D_det : IndexedScheme Op Result cells w (in the time-aware step-indexed relaxation) in the support of P.indexedSchemeLaw horizon opsAlphabet that satisfies Good ops (D_det.runSeq ops).1 for every ops ∈ correctSeqs and incurs expected probes over hardDist at most that of P.

theorem Cslib.CellProbe.Randomized.Scheme.exists_det_indexedScheme_tsum_mul_le {Op : Type u} {Result : Op → Type} {cells w : ℕ} [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) (opsAlphabet : Finset Op) (horizon : ℕ) (correctSeqs : Set (List Op)) (hcorrectSeqs : ∀ ops ∈ correctSeqs, ops.length ≤ horizon ∧ ∀ o ∈ ops, o ∈ opsAlphabet) (Good : List Op → List (Sigma Result) → Prop) (hcorr : ∀ ops ∈ correctSeqs, ∀ tr ∈ (PMF.map Prod.fst (P.runSeq ops)).support, Good ops tr) (hardDist : PMF (List Op)) (hhardDist : ∀ ops ∈ hardDist.support, ops.length ≤ horizon ∧ ∀ o ∈ ops, o ∈ opsAlphabet) {ε : ENNReal} (hε : ∀ ops ∈ hardDist.support, P.expectedSeqProbes ops ≤ ε) :
∃ D_det ∈ (P.indexedSchemeLaw horizon opsAlphabet).support, (∀ ops ∈ correctSeqs, Good ops (D_det.runSeq ops).1) ∧ ∑' (ops : List Op), hardDist ops * ↑(D_det.seqProbes ops) ≤ ε

Uniform-budget Yao averaging (easy direction) for zero-error schemes against oblivious operation sequences (Cslib.RandomizedCost.exists_mem_support_tsum_mul_le_of_coinFixing): if P.expectedSeqProbes ops ≤ ε for every ops ∈ hardDist.support, then some D_det ∈ (P.indexedSchemeLaw horizon opsAlphabet).support satisfies Good on correctSeqs and has average probe count ≤ ε under hardDist.

theorem Cslib.CellProbe.Randomized.Scheme.exists_det_indexedScheme_le_expectedSeqProbes_of_fintype {Op : Type u} {Result : Op → Type} {cells w : ℕ} [Fintype Op] [DecidableEq Op] [(o : Op) → Inhabited (Result o)] (P : Scheme Op Result cells w) (horizon : ℕ) (correctSeqs : Set (List Op)) (hcorrectSeqs : ∀ ops ∈ correctSeqs, ops.length ≤ horizon) (Good : List Op → List (Sigma Result) → Prop) (hcorr : ∀ ops ∈ correctSeqs, ∀ tr ∈ (PMF.map Prod.fst (P.runSeq ops)).support, Good ops tr) (hardDist : PMF (List Op)) (hhardDist : ∀ ops ∈ hardDist.support, ops.length ≤ horizon) :
∃ D_det ∈ (P.indexedSchemeLaw horizon Finset.univ).support, (∀ ops ∈ correctSeqs, Good ops (D_det.runSeq ops).1) ∧ ∑' (ops : List Op), hardDist ops * ↑(D_det.seqProbes ops) ≤ ∑' (ops : List Op), hardDist ops * P.expectedSeqProbes ops

[Fintype Op] convenience wrapper for exists_det_indexedScheme_le_expectedSeqProbes, instantiating opsAlphabet := Finset.univ.

Random-initial-memory / coin-free-step specialization (CellProbe.Scheme) #

noncomputable def Cslib.CellProbe.Randomized.Scheme.schemeLaw {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (hstep : ∀ (o : Op), (P.step o).IsCoinFree) :
PMF (CellProbe.Scheme Op Result cells w)

Distribution over time-invariant deterministic CellProbe.Schemes induced by P.init when every per-operation probe tree P.step o makes no private coin draws (IsCoinFree).

theorem Cslib.CellProbe.Randomized.Scheme.runSeq_eq_schemeLaw_bind {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (hstep : ∀ (o : Op), (P.step o).IsCoinFree) (ops : List Op) :
P.runSeq ops = (P.schemeLaw hstep).bind fun (D : CellProbe.Scheme Op Result cells w) => PMF.pure ((D.runSeq ops).1, D.seqProbes ops)
theorem Cslib.CellProbe.Randomized.Scheme.expectedSeqProbes_eq_schemeLaw_tsum {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (hstep : ∀ (o : Op), (P.step o).IsCoinFree) (ops : List Op) :
P.expectedSeqProbes ops = ∑' (D : CellProbe.Scheme Op Result cells w), (P.schemeLaw hstep) D * ↑(D.seqProbes ops)
theorem Cslib.CellProbe.Randomized.Scheme.exists_det_scheme_le_expectedSeqProbes {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (hstep : ∀ (o : Op), (P.step o).IsCoinFree) (correctSeqs : Set (List Op)) (Good : List Op → List (Sigma Result) → Prop) (hcorr : ∀ ops ∈ correctSeqs, ∀ tr ∈ (PMF.map Prod.fst (P.runSeq ops)).support, Good ops tr) (hardDist : PMF (List Op)) :
∃ D_det ∈ (P.schemeLaw hstep).support, (∀ ops ∈ correctSeqs, Good ops (D_det.runSeq ops).1) ∧ ∑' (ops : List Op), hardDist ops * ↑(D_det.seqProbes ops) ≤ ∑' (ops : List Op), hardDist ops * P.expectedSeqProbes ops

Random-initial-memory / coin-free-step averaging argument [Yao77] (CellProbe.Scheme): when randomness lives only in initial memory P.init and per-operation trees draw no private coins (∀ o, (P.step o).IsCoinFree, so operations observe P.init only by probing cells), zero-error averaging against oblivious operation sequences yields a time-invariant deterministic D_det : CellProbe.Scheme Op Result cells w in (P.schemeLaw hstep).support preserving Good on all ops ∈ correctSeqs and incurring at most P's expected probes over hardDist — without requiring [DecidableEq Op], opsAlphabet, or horizon (bounded-error Monte Carlo schemes are out of scope).