Documentation

CslibFrontier.Computability.CellProbe.Defs

Adaptive Cell-Probe Decision Trees and Deterministic Cell-Probe Schemes #

The cell-probe model originates in Minsky and Papert [MP69] and was developed for dynamic data structures by Fredman and for static data structures by Yao [Yao81] (see [Mil99], §1.2, pp. 1–2; §1.5, p. 4; §2.1, pp. 4–5). In a time-invariant deterministic Scheme, persistent state between operations consists solely of S cells of w-bit words (Mem S w := Fin S → Fin (2 ^ w), total space S * w bits, with no persistent registers across operations). IndexedScheme is a time-aware relaxation whose step additionally receives the global operation index t : ℕ (a free clock outside cell memory); because per-operation coin fixing (Randomized.Scheme.exists_det_indexedScheme_le_expectedSeqProbes) returns an IndexedScheme (only the coin-free-step variant returns a time-invariant Scheme), deterministic lower bounds used with it must hold against step-indexed schemes.

Each operation is answered by an adaptive read/write decision tree (ProbeTree S w α := OracleComp (@ProbeOp.Result S w) α) whose internal nodes either read a cell i : Fin S (branching 2 ^ w ways on its w-bit content) or overwrite a cell i : Fin S with a w-bit value, while all local computation between probes is uncharged. Three conventions differ slightly from Miltersen's presentation ([Mil99], §1.2, pp. 1–2):

For the read-only embedding of static Boolean DecisionTrees into ProbeTree S 1 α, see CslibFrontier.Computability.CellProbe.DecisionTree.

Main definitions #

Main results #

References #

Cell memory and subset snapshots #

@[reducible, inline]
abbrev Cslib.CellProbe.Mem (S w : ℕ) :

Memory state of a cell-probe data structure with S cells of w-bit words (S * w bits total, with no persistent registers between operations).

All-zero initial memory of S cells of w-bit words.

theorem Cslib.CellProbe.card_mem (S w : ℕ) :
Fintype.card (Mem S w) = (2 ^ w) ^ S

Cardinality of the S-cell w-bit memory state space Mem S w.

def Cslib.CellProbe.restrictMem {S w : ℕ} (m : Mem S w) (I : Finset (Fin S)) (i : ↥I) :
Fin (2 ^ w)

Subset snapshot of memory m restricted to a cell set I : Finset (Fin S), defined via Finset.restrict.

@[simp]
theorem Cslib.CellProbe.restrictMem_apply {S w : ℕ} (m : Mem S w) (I : Finset (Fin S)) (i : ↥I) :
restrictMem m I i = m ↑i
theorem Cslib.CellProbe.restrictMem_eq_iff {S w : ℕ} {m₁ m₂ : Mem S w} {I : Finset (Fin S)} :
restrictMem m₁ I = restrictMem m₂ I ↔ ∀ i ∈ I, m₁ i = m₂ i

Two memories have equal snapshots on I iff they agree at every cell in I.

def Cslib.CellProbe.padMem {S S' w : ℕ} (_h : S ≤ S') (m : Mem S w) :
Mem S' w

Pad an S-cell memory to S' cells (S ≤ S') by filling cells [S, S') with 0.

@[simp]
theorem Cslib.CellProbe.padMem_castLE {S S' w : ℕ} (h : S ≤ S') (m : Mem S w) (i : Fin S) :
padMem h m (Fin.castLE h i) = m i
theorem Cslib.CellProbe.padMem_of_ge {S S' w : ℕ} (h : S ≤ S') (m : Mem S w) {i : Fin S'} (hi : S ≤ ↑i) :
padMem h m i = ⟨0, ⋯⟩
@[simp]
theorem Cslib.CellProbe.padMem_update {S S' w : ℕ} (h : S ≤ S') (m : Mem S w) (i : Fin S) (v : Fin (2 ^ w)) :

Elementary cell-probe operations #

inductive Cslib.CellProbe.ProbeOp (S w : ℕ) :

Elementary cell-probe actions on S cells of w-bit words.

  • read {S w : ℕ} (cell : Fin S) : ProbeOp S w

    Read the w-bit word currently stored in cell.

  • write {S w : ℕ} (cell : Fin S) (val : Fin (2 ^ w)) : ProbeOp S w

    Overwrite cell with val (w-bit word).

Instances For
    @[instance_reducible]
    def Cslib.CellProbe.instDecidableEqProbeOp.decEq {S✝ w✝ : ℕ} (x✝ x✝¹ : ProbeOp S✝ w✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    instance Cslib.CellProbe.instReprProbeOp {S✝ w✝ : ℕ} :
    Repr (ProbeOp S✝ w✝)
    @[instance_reducible]
    @[reducible, inline]

    Response type of a single cell probe: Fin (2 ^ w) for a read, PUnit for a write.

    Instances For
      @[instance_reducible]
      @[instance_reducible]
      @[instance_reducible]

      Every cell-probe reply type has at most 2 ^ w values.

      Cell index accessed by a ProbeOp.

      @[simp]
      theorem Cslib.CellProbe.ProbeOp.cell_read {S w : ℕ} (i : Fin S) :
      (read i).cell = i
      @[simp]
      theorem Cslib.CellProbe.ProbeOp.cell_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) :
      (write i v).cell = i

      Deterministic adaptive cell-probe trees #

      @[reducible, inline]
      abbrev Cslib.CellProbe.ProbeTree (S w : ℕ) (α : Type) :

      Deterministic adaptive cell-probe decision tree returning α : Type on S cells of w bits. Defined as OracleComp (@ProbeOp.Result S w) α (= (PFunctor.mk (ProbeOp S w) ProbeOp.Result).FreeM α), inheriting LawfulMonad, do-notation, and arbitrary uncharged computation in continuations.

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

      Read cell i : Fin S (1 probe).

      def Cslib.CellProbe.ProbeTree.write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) :

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

      def Cslib.CellProbe.ProbeTree.run {S w : ℕ} {α : Type} :
      ProbeTree S w α → Mem S w → α × Mem S w

      Execute a deterministic ProbeTree from memory m, returning (result, nextMem).

      def Cslib.CellProbe.ProbeTree.eval {S w : ℕ} {α : Type} (t : ProbeTree S w α) (m : Mem S w) :
      α

      Return value produced by executing t from memory m.

      def Cslib.CellProbe.ProbeTree.nextMem {S w : ℕ} {α : Type} (t : ProbeTree S w α) (m : Mem S w) :
      Mem S w

      Updated memory state after executing t from memory m.

      def Cslib.CellProbe.ProbeTree.probes {S w : ℕ} {α : Type} :
      ProbeTree S w α → Mem S w → ℕ

      Pathwise number of cell probes (reads plus writes, each charged 1) executed from m.

      def Cslib.CellProbe.ProbeTree.probedCells {S w : ℕ} {α : Type} :
      ProbeTree S w α → Mem S w → Finset (Fin S)

      Set of distinct cell indices probed (read or written) along the path executed from m.

      def Cslib.CellProbe.ProbeTree.depth {S w : ℕ} {α : Type} :
      ProbeTree S w α → ℕ

      Worst-case structural depth of a ProbeTree across all cell replies.

      Compositional and structural lemmas for ProbeTree #

      @[simp]
      theorem Cslib.CellProbe.ProbeTree.run_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
      (pure a).run m = (a, m)
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.run_read {S w : ℕ} (i : Fin S) (m : Mem S w) :
      (read i).run m = (m i, m)
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.run_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.run_bind {S w : ℕ} {α β : Type} (t : ProbeTree S w α) (k : α → ProbeTree S w β) (m : Mem S w) :
      (t >>= k).run m = (k (t.run m).1).run (t.run m).2
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.run_map {S w : ℕ} {α β : Type} (f : α → β) (t : ProbeTree S w α) (m : Mem S w) :
      (f <$> t).run m = (f (t.run m).1, (t.run m).2)
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.eval_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
      (pure a).eval m = a
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.eval_read {S w : ℕ} (i : Fin S) (m : Mem S w) :
      (read i).eval m = m i
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.eval_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.eval_bind {S w : ℕ} {α β : Type} (t : ProbeTree S w α) (k : α → ProbeTree S w β) (m : Mem S w) :
      (t >>= k).eval m = (k (t.eval m)).eval (t.nextMem m)
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.nextMem_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
      (pure a).nextMem m = m
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.nextMem_read {S w : ℕ} (i : Fin S) (m : Mem S w) :
      (read i).nextMem m = m
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.nextMem_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.nextMem_bind {S w : ℕ} {α β : Type} (t : ProbeTree S w α) (k : α → ProbeTree S w β) (m : Mem S w) :
      (t >>= k).nextMem m = (k (t.eval m)).nextMem (t.nextMem m)
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probes_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
      (pure a).probes m = 0
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probes_read {S w : ℕ} (i : Fin S) (m : Mem S w) :
      (read i).probes m = 1
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probes_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
      (write i v).probes m = 1
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probes_bind {S w : ℕ} {α β : Type} (t : ProbeTree S w α) (k : α → ProbeTree S w β) (m : Mem S w) :
      (t >>= k).probes m = t.probes m + (k (t.run m).1).probes (t.run m).2
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probes_map {S w : ℕ} {α β : Type} (f : α → β) (t : ProbeTree S w α) (m : Mem S w) :
      (f <$> t).probes m = t.probes m
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probedCells_pure {S w : ℕ} {α : Type} (a : α) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probedCells_read {S w : ℕ} (i : Fin S) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probedCells_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probedCells_bind {S w : ℕ} {α β : Type} (t : ProbeTree S w α) (k : α → ProbeTree S w β) (m : Mem S w) :
      (t >>= k).probedCells m = t.probedCells m ∪ (k (t.run m).1).probedCells (t.run m).2
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probedCells_map {S w : ℕ} {α β : Type} (f : α → β) (t : ProbeTree S w α) (m : Mem S w) :
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.depth_pure {S w : ℕ} {α : Type} (a : α) :
      (pure a).depth = 0
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.depth_read {S w : ℕ} (i : Fin S) :
      (read i).depth = 1
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.depth_write {S w : ℕ} (i : Fin S) (v : Fin (2 ^ w)) :
      (write i v).depth = 1
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.depth_map {S w : ℕ} {α β : Type} (f : α → β) (t : ProbeTree S w α) :
      (f <$> t).depth = t.depth
      theorem Cslib.CellProbe.ProbeTree.depth_bind_le {S w : ℕ} {α β : Type} (t : ProbeTree S w α) (k : α → ProbeTree S w β) {d : ℕ} (hk : ∀ (a : α), (k a).depth ≤ d) :
      (t >>= k).depth ≤ t.depth + d
      theorem Cslib.CellProbe.ProbeTree.card_probedCells_le_probes {S w : ℕ} {α : Type} (t : ProbeTree S w α) (m : Mem S w) :

      The number of distinct probed cells along a path is at most the number of probes.

      theorem Cslib.CellProbe.ProbeTree.probes_le_depth {S w : ℕ} {α : Type} (t : ProbeTree S w α) (m : Mem S w) :

      Pathwise probe count from any memory is bounded by structural depth.

      Structural depth characterizes OracleComp.IsQueryBounded on ProbeTree.

      Frame and locality / replay #

      theorem Cslib.CellProbe.ProbeTree.nextMem_eq_of_notMem_probedCells {S w : ℕ} {α : Type} (t : ProbeTree S w α) (m : Mem S w) {i : Fin S} (hi : i ∉ t.probedCells m) :
      (t.run m).2 i = m i

      Any cell outside t.probedCells m retains its initial value in (t.run m).2.

      theorem Cslib.CellProbe.ProbeTree.run_eq_of_eq_on_probedCells {S w : ℕ} {α : Type} (t : ProbeTree S w α) {m₁ m₂ : Mem S w} (h : ∀ i ∈ t.probedCells m₁, m₂ i = m₁ i) :
      (t.run m₂).1 = (t.run m₁).1 ∧ t.probes m₂ = t.probes m₁ ∧ t.probedCells m₂ = t.probedCells m₁ ∧ ∀ i ∈ t.probedCells m₁, (t.run m₂).2 i = (t.run m₁).2 i

      Locality and replay for deterministic ProbeTrees: if m₂ agrees with m₁ on t.probedCells m₁, then executing t from m₂ produces the exact same return value, probe count, probed-cell set, and post-memory contents on t.probedCells m₁ (for cells outside t.probedCells m₁, see nextMem_eq_of_notMem_probedCells).

      Information-theoretic counting lower bound #

      theorem Cslib.CellProbe.ProbeTree.card_le_pow_depth {S w : ℕ} {α : Type} {ι : Type u_1} (t : ProbeTree S w α) (I : Finset ι) (enc : ι → Mem S w) (hinj : Set.InjOn (fun (x : ι) => (t.run (enc x)).1) ↑I) :
      I.card ≤ (2 ^ w) ^ t.depth

      Standard 2 ^ w-ary branching bound: if t : ProbeTree S w α produces distinct return values across (enc x) for all x ∈ I, then I.card ≤ (2 ^ w) ^ t.depth.

      theorem Cslib.CellProbe.ProbeTree.card_le_pow_depth_of_injective {S w : ℕ} {α : Type} {ι : Type u_1} [Fintype ι] (t : ProbeTree S w α) (enc : ι → Mem S w) (hinj : Function.Injective fun (x : ι) => (t.run (enc x)).1) :
      Fintype.card ι ≤ (2 ^ w) ^ t.depth

      Standard 2 ^ w-ary branching bound: if t : ProbeTree S w α distinguishes every input of a finite type ι via enc : ι → Mem S w, then Fintype.card ι ≤ (2 ^ w) ^ t.depth.

      theorem Cslib.CellProbe.ProbeTree.clog_le_depth_of_injective {S w : ℕ} {α : Type} {ι : Type u_1} [Fintype ι] (t : ProbeTree S w α) (enc : ι → Mem S w) (hinj : Function.Injective fun (x : ι) => (t.run (enc x)).1) :

      Information-theoretic worst-case cell-probe lower bound ⌈log_{2^w} |ι|⌉ ≤ t.depth whenever t distinguishes all inputs of ι (for w = 0, Nat.clog 1 _ = 0).

      Cell padding on ProbeTree #

      def Cslib.CellProbe.ProbeTree.padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') :
      ProbeTree S w α → ProbeTree S' w α

      Lift a ProbeTree S w α to S' cells (S ≤ S') by embedding cell indices via Fin.castLE.

      @[simp]
      theorem Cslib.CellProbe.ProbeTree.run_padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') (t : ProbeTree S w α) (m : Mem S w) :
      (padCells h t).run (padMem h m) = ((t.run m).1, padMem h (t.run m).2)
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.probes_padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') (t : ProbeTree S w α) (m : Mem S w) :
      (padCells h t).probes (padMem h m) = t.probes m
      @[simp]
      theorem Cslib.CellProbe.ProbeTree.depth_padCells {S S' w : ℕ} {α : Type} (h : S ≤ S') (t : ProbeTree S w α) :

      Deterministic cell-probe schemes and multi-step interval locality #

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

      Time-invariant deterministic cell-probe scheme with cells cells of w-bit words. Persistent state between operations consists solely of Mem cells w.

      • init : Mem cells w

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

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

        Adaptive read/write cell-probe decision tree executed for each operation o : Op.

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

      Time-aware relaxation of a deterministic cell-probe scheme: step receives the global operation index t : ℕ (a free clock outside cell memory) in addition to o : Op. Fixing per-operation private coins via the averaging (coin-fixing) argument, the easy direction of Yao's principle [Yao77], produces an IndexedScheme, so deterministic lower bounds paired with it must hold against step-indexed schemes.

      • init : Mem cells w

        Initial cell memory (0 probes).

      • step : ℕ → (o : Op) → ProbeTree cells w (Result o)

        Adaptive read/write cell-probe decision tree executed at step t on operation o.

      def Cslib.CellProbe.Scheme.toIndexed {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) :
      IndexedScheme Op Result cells w

      Embed any time-invariant Scheme as a step-indexed IndexedScheme.

      def Cslib.CellProbe.IndexedScheme.runInterval {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) :
      ℕ → Mem cells w → List Op → List (Sigma Result) × Mem cells w

      Execute an operation slice ops : List Op starting at step index t₀ and memory m, returning (transcript, postMem).

      def Cslib.CellProbe.IndexedScheme.probesInterval {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) :
      ℕ → Mem cells w → List Op → ℕ

      Total number of cell probes incurred while executing ops from step index t₀ and m.

      def Cslib.CellProbe.IndexedScheme.probedCellsInterval {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) :
      ℕ → Mem cells w → List Op → Finset (Fin cells)

      Set of distinct cell indices probed during ops starting at step index t₀ and memory m.

      def Cslib.CellProbe.IndexedScheme.runSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (ops : List Op) :
      List (Sigma Result) × Mem cells w

      Execute ops from step 0 and initial memory D.init, returning (transcript, postMem).

      def Cslib.CellProbe.IndexedScheme.seqProbes {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (ops : List Op) :

      Total number of cell probes executed across ops starting from D.init.

      def Cslib.CellProbe.IndexedScheme.probedCellsSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (ops : List Op) :
      Finset (Fin cells)

      Set of distinct cells probed across ops starting from D.init.

      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.runInterval_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) :
      D.runInterval t₀ m [] = ([], m)
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.runInterval_cons {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (o : Op) (ops : List Op) :
      D.runInterval t₀ m (o :: ops) = (⟨o, ((D.step t₀ o).run m).1⟩ :: (D.runInterval (t₀ + 1) ((D.step t₀ o).run m).2 ops).1, (D.runInterval (t₀ + 1) ((D.step t₀ o).run m).2 ops).2)
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.length_runInterval_fst {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      (D.runInterval t₀ m ops).1.length = ops.length
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.probesInterval_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) :
      D.probesInterval t₀ m [] = 0
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.probesInterval_cons {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (o : Op) (ops : List Op) :
      D.probesInterval t₀ m (o :: ops) = (D.step t₀ o).probes m + D.probesInterval (t₀ + 1) ((D.step t₀ o).run m).2 ops
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.probedCellsInterval_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) :
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.probedCellsInterval_cons {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (o : Op) (ops : List Op) :
      D.probedCellsInterval t₀ m (o :: ops) = (D.step t₀ o).probedCells m ∪ D.probedCellsInterval (t₀ + 1) ((D.step t₀ o).run m).2 ops
      theorem Cslib.CellProbe.IndexedScheme.runInterval_append {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops₁ ops₂ : List Op) :
      D.runInterval t₀ m (ops₁ ++ ops₂) = ((D.runInterval t₀ m ops₁).1 ++ (D.runInterval (t₀ + ops₁.length) (D.runInterval t₀ m ops₁).2 ops₂).1, (D.runInterval (t₀ + ops₁.length) (D.runInterval t₀ m ops₁).2 ops₂).2)
      theorem Cslib.CellProbe.IndexedScheme.probesInterval_append {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops₁ ops₂ : List Op) :
      D.probesInterval t₀ m (ops₁ ++ ops₂) = D.probesInterval t₀ m ops₁ + D.probesInterval (t₀ + ops₁.length) (D.runInterval t₀ m ops₁).2 ops₂
      theorem Cslib.CellProbe.IndexedScheme.probedCellsInterval_append {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops₁ ops₂ : List Op) :
      D.probedCellsInterval t₀ m (ops₁ ++ ops₂) = D.probedCellsInterval t₀ m ops₁ ∪ D.probedCellsInterval (t₀ + ops₁.length) (D.runInterval t₀ m ops₁).2 ops₂
      theorem Cslib.CellProbe.IndexedScheme.card_probedCellsInterval_le_probesInterval {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      (D.probedCellsInterval t₀ m ops).card ≤ D.probesInterval t₀ m ops
      theorem Cslib.CellProbe.IndexedScheme.nextMem_runInterval_eq_of_notMem_probedCellsInterval {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) {i : Fin cells} (hi : i ∉ D.probedCellsInterval t₀ m ops) :
      (D.runInterval t₀ m ops).2 i = m i

      Cells outside D.probedCellsInterval t₀ m ops are unchanged in (D.runInterval t₀ m ops).2.

      theorem Cslib.CellProbe.IndexedScheme.nextMem_runSeq_eq_of_notMem_probedCellsSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (ops : List Op) {i : Fin cells} (hi : i ∉ D.probedCellsSeq ops) :
      (D.runSeq ops).2 i = D.init i

      Cells outside D.probedCellsSeq ops retain D.init in (D.runSeq ops).2.

      theorem Cslib.CellProbe.IndexedScheme.runInterval_eq_of_eq_on_probedCellsInterval {Op : Type u} {Result : Op → Type} {cells w : ℕ} (D : IndexedScheme Op Result cells w) (t₀ : ℕ) {m₁ m₂ : Mem cells w} (ops : List Op) (h : ∀ i ∈ D.probedCellsInterval t₀ m₁ ops, m₂ i = m₁ i) :
      (D.runInterval t₀ m₂ ops).1 = (D.runInterval t₀ m₁ ops).1 ∧ D.probesInterval t₀ m₂ ops = D.probesInterval t₀ m₁ ops ∧ D.probedCellsInterval t₀ m₂ ops = D.probedCellsInterval t₀ m₁ ops ∧ ∀ i ∈ D.probedCellsInterval t₀ m₁ ops, (D.runInterval t₀ m₂ ops).2 i = (D.runInterval t₀ m₁ ops).2 i

      Multi-step interval locality and replay: if m₂ agrees with m₁ on D.probedCellsInterval t₀ m₁ ops, then simulating ops from (t₀, m₂) produces the exact same transcript, probe count, probed-cell set, and post-memory contents on D.probedCellsInterval t₀ m₁ ops (for cells outside D.probedCellsInterval t₀ m₁ ops, see nextMem_runInterval_eq_of_notMem_probedCellsInterval).

      def Cslib.CellProbe.IndexedScheme.padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) :
      IndexedScheme Op Result cells' w

      Pad an IndexedScheme from cells cells to cells' cells (cells ≤ cells').

      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.padCells_init {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) :
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.padCells_step {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) (t : ℕ) (o : Op) :
      (padCells h D).step t o = ProbeTree.padCells h (D.step t o)
      theorem Cslib.CellProbe.IndexedScheme.runInterval_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      (padCells h D).runInterval t₀ (padMem h m) ops = ((D.runInterval t₀ m ops).1, padMem h (D.runInterval t₀ m ops).2)
      theorem Cslib.CellProbe.IndexedScheme.probesInterval_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      (padCells h D).probesInterval t₀ (padMem h m) ops = D.probesInterval t₀ m ops
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.runSeq_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) (ops : List Op) :
      (padCells h D).runSeq ops = ((D.runSeq ops).1, padMem h (D.runSeq ops).2)
      @[simp]
      theorem Cslib.CellProbe.IndexedScheme.seqProbes_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (D : IndexedScheme Op Result cells w) (ops : List Op) :
      (padCells h D).seqProbes ops = D.seqProbes ops
      def Cslib.CellProbe.Scheme.runFrom {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) (ops : List Op) :
      List (Sigma Result) × Mem cells w

      Execute ops from memory m under a time-invariant Scheme.

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

      Total probes incurred while executing ops from memory m under P.

      def Cslib.CellProbe.Scheme.probedCellsFrom {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) (ops : List Op) :
      Finset (Fin cells)

      Distinct cells probed while executing ops from memory m under P.

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

      Execute ops from initial memory P.init, returning (transcript, postMem).

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

      Total number of cell probes executed across ops starting from P.init.

      def Cslib.CellProbe.Scheme.probedCellsSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) :
      Finset (Fin cells)

      Set of distinct cells probed across ops starting from P.init.

      def Cslib.CellProbe.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 time-invariant Scheme from cells cells to cells' cells (cells ≤ cells').

      @[simp]
      theorem Cslib.CellProbe.Scheme.toIndexed_padCells {Op : Type u} {Result : Op → Type} {cells cells' w : ℕ} (h : cells ≤ cells') (P : Scheme Op Result cells w) :
      @[simp]
      theorem Cslib.CellProbe.Scheme.toIndexed_runSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) :
      P.toIndexed.runSeq ops = P.runSeq ops
      @[simp]
      theorem Cslib.CellProbe.Scheme.toIndexed_seqProbes {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) :
      @[simp]
      theorem Cslib.CellProbe.Scheme.toIndexed_step {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (t : ℕ) (o : Op) :
      P.toIndexed.step t o = P.step o
      theorem Cslib.CellProbe.Scheme.toIndexed_runInterval_eq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      P.toIndexed.runInterval t₀ m ops = P.runFrom m ops
      theorem Cslib.CellProbe.Scheme.toIndexed_probesInterval_eq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      P.toIndexed.probesInterval t₀ m ops = P.probesFrom m ops
      theorem Cslib.CellProbe.Scheme.toIndexed_probedCellsInterval_eq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (t₀ : ℕ) (m : Mem cells w) (ops : List Op) :
      @[simp]
      theorem Cslib.CellProbe.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.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) = (⟨o, ((P.step o).run m).1⟩ :: (P.runFrom ((P.step o).run m).2 ops).1, (P.runFrom ((P.step o).run m).2 ops).2)
      @[simp]
      theorem Cslib.CellProbe.Scheme.probesFrom_nil {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) :
      @[simp]
      theorem Cslib.CellProbe.Scheme.probesFrom_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.probesFrom m (o :: ops) = (P.step o).probes m + P.probesFrom ((P.step o).run m).2 ops
      theorem Cslib.CellProbe.Scheme.nextMem_runFrom_eq_of_notMem_probedCellsFrom {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (m : Mem cells w) (ops : List Op) {i : Fin cells} (hi : i ∉ P.probedCellsFrom m ops) :
      (P.runFrom m ops).2 i = m i

      Cells outside P.probedCellsFrom m ops are unchanged in (P.runFrom m ops).2.

      theorem Cslib.CellProbe.Scheme.nextMem_runSeq_eq_of_notMem_probedCellsSeq {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) (ops : List Op) {i : Fin cells} (hi : i ∉ P.probedCellsSeq ops) :
      (P.runSeq ops).2 i = P.init i

      Cells outside P.probedCellsSeq ops retain P.init in (P.runSeq ops).2.

      theorem Cslib.CellProbe.Scheme.runFrom_eq_of_eq_on_probedCellsFrom {Op : Type u} {Result : Op → Type} {cells w : ℕ} (P : Scheme Op Result cells w) {m₁ m₂ : Mem cells w} (ops : List Op) (h : ∀ i ∈ P.probedCellsFrom m₁ ops, m₂ i = m₁ i) :
      (P.runFrom m₂ ops).1 = (P.runFrom m₁ ops).1 ∧ P.probesFrom m₂ ops = P.probesFrom m₁ ops ∧ P.probedCellsFrom m₂ ops = P.probedCellsFrom m₁ ops ∧ ∀ i ∈ P.probedCellsFrom m₁ ops, (P.runFrom m₂ ops).2 i = (P.runFrom m₁ ops).2 i
      @[simp]
      theorem Cslib.CellProbe.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).1, padMem h (P.runSeq ops).2)
      @[simp]
      theorem Cslib.CellProbe.Scheme.seqProbes_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).seqProbes ops = P.seqProbes ops