Documentation

CslibFrontier.DataStructure.CellProbe.Randomized.StateTransition

Randomized Cell-Probe State-Transition Implementations #

This file extends Cslib.DataStructure.CellProbe.StateTransitionImpl to randomized cell-probe schemes (Cslib.CellProbe.Randomized.Scheme; deterministic cell-probe model from [Mil99], §1.2, internal-coin randomized trees) implementing relational state-transition specifications (Cslib.DataStructure.StateTransitionSpec, [CLRS09], Section 17.3; [MU17], Sections 2.1 and 2.3).

A Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl D P s₀ couples cell-probe execution with a latent seed type Seed : Type, a reference distribution seedLaw : PMF Seed up to density factor seedSlack : ℝ≥0∞, a seed-coupled invariant rep, and an addition-only ℝ≥0∞ amortized-in-expectation probe inequality:

Main definitions #

Main results #

References #

Coupled state, step-outcome, and transcript bundles #

structure Cslib.DataStructure.CellProbe.Randomized.CoupledState (Seed : Type) (State : Type u) (cells w : ℕ) :

Coupled latent seed, abstract specification state, and concrete cell-probe memory Mem cells w for relational randomized cell-probe analysis.

  • seed : Seed

    Latent random seed.

  • state : State

    Abstract specification state.

  • mem : CellProbe.Mem cells w

    Concrete cell-probe memory (cells words of w bits).

structure Cslib.DataStructure.CellProbe.Randomized.CoupledOutcome (Seed : Type) (State : Type u) (Result : Type) (cells w : ℕ) :

Coupled post-step outcome pairing the updated latent seed, abstract post-state, post-memory, and returned observation. Carrying result explicitly makes the marginal equation ((P.step o).run t.mem).map Prod.fst = (μ_step t).map CoupledOutcome.resultMem syntactic without Classical.choice.

  • seed : Seed

    Updated latent random seed.

  • state : State

    Updated abstract specification state.

  • mem : CellProbe.Mem cells w

    Updated concrete cell-probe memory.

  • result : Result

    Observation returned by the operation.

def Cslib.DataStructure.CellProbe.Randomized.CoupledOutcome.toCoupledState {Seed : Type} {State : Type u} {Result : Type} {cells w : ℕ} (q : CoupledOutcome Seed State Result cells w) :
CoupledState Seed State cells w

Forget result to obtain the post-step CoupledState.

def Cslib.DataStructure.CellProbe.Randomized.CoupledOutcome.resultMem {Seed : Type} {State : Type u} {Result : Type} {cells w : ℕ} (q : CoupledOutcome Seed State Result cells w) :
Result × CellProbe.Mem cells w

Extract (q.result, q.mem) for comparison against ((P.step o).run m).map Prod.fst.

Coupled state augmented with an accumulated relational transcript D.Transcript.

  • seed : Seed

    Current latent random seed.

  • state : D.State

    Current abstract specification state.

  • mem : CellProbe.Mem cells w

    Current concrete cell-probe memory.

  • trace : D.Transcript

    Accumulated relational execution transcript from s₀.

Randomized cell-probe StateTransitionImpl #

Certified randomized cell-probe implementation of a relational D : StateTransitionSpec from initial state s₀ over P : Cslib.CellProbe.Randomized.Scheme D.Op D.Result cells w.

Deterministic-to-randomized lifting #

Canonical embedding of any deterministic CellProbe.StateTransitionImpl into CellProbe.Randomized.StateTransitionImpl over Randomized.Scheme.ofDeterministic P (Seed := Unit, seedLaw := PMF.pure (), seedSlack := 1).

@[simp]
theorem Cslib.DataStructure.CellProbe.StateTransitionImpl.toRandomized_rep {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Scheme D.Op D.Result cells w} {s₀ : D.State} (C : StateTransitionImpl D P s₀) (θ : Unit) (s : D.State) (m : CellProbe.Mem cells w) :
C.toRandomized.rep θ s m ↔ C.rep s m
@[reducible, inline]
noncomputable abbrev Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal := 1) (seedSlack_ne_top : seedSlack ≠ ⊤ := by simp) (initPotential : ℕ := 0) (potential : Seed → CellProbe.Mem cells w → ℕ := fun (x : Seed) (x_1 : CellProbe.Mem cells w) => 0) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :

Construct a Randomized.StateTransitionImpl on a functional specification ([D.HasStepFn f]), setting singleState := True and reasoning over PMF (Seed × Mem cells w).

@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_seed {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).Seed = Seed
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_seedLaw {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).seedLaw = seedLaw
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_seedSlack {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).seedSlack = seedSlack
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_initPotential {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).initPotential = initPotential
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_charge {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).charge = charge
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_rep {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).rep = rep
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_potential {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).potential = potential
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.ofFn_singleState {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (Seed : Type) (seedLaw : PMF Seed) (charge : D.State → D.Op → ℕ) (rep : Seed → D.State → CellProbe.Mem cells w → Prop) (seedSlack : ENNReal) (seedSlack_ne_top : seedSlack ≠ ⊤) (initPotential : ℕ) (potential : Seed → CellProbe.Mem cells w → ℕ) (init_exec : ∃ (ν₀ : PMF (Seed × CellProbe.Mem cells w)), PMF.map Prod.snd ν₀ = P.init ∧ (∀ (θ : Seed), (PMF.map Prod.fst ν₀) θ ≤ seedSlack * seedLaw θ) ∧ ∀ p ∈ ν₀.support, rep p.1 s₀ p.2 ∧ potential p.1 p.2 ≤ initPotential) (step_exec : ∀ (s : D.State) (o : D.Op) (ν : PMF (Seed × CellProbe.Mem cells w)), D.valid s o → (∀ (θ : Seed), (PMF.map Prod.fst ν) θ ≤ seedSlack * seedLaw θ) → (∀ p ∈ ν.support, rep p.1 s p.2) → ∃ (μ_step : Seed × CellProbe.Mem cells w → PMF (Seed × CellProbe.Mem cells w)), (∀ p ∈ ν.support, PMF.map Prod.fst ((P.step o).run p.2) = PMF.map (fun (q : Seed × CellProbe.Mem cells w) => ((D.stepFn s o).2, q.2)) (μ_step p) ∧ ∀ q ∈ (μ_step p).support, rep q.1 (D.stepFn s o).1 q.2) ∧ (∀ (θ' : Seed), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ seedSlack * seedLaw θ') ∧ ∑' (p : Seed × CellProbe.Mem cells w), ν p * ((P.step o).expectedProbes p.2 + ∑' (q : Seed × CellProbe.Mem cells w), (μ_step p) q * ↑(potential q.1 q.2)) ≤ ↑(charge s o) + ∑' (p : Seed × CellProbe.Mem cells w), ν p * ↑(potential p.1 p.2)) :
(ofFn Seed seedLaw charge rep seedSlack seedSlack_ne_top initPotential potential init_exec step_exec).singleState ↔ True

Cell padding (cells ≤ cells') #

Lift a Randomized.StateTransitionImpl from cells cells to cells' cells (cells ≤ cells') via Cslib.CellProbe.Randomized.Scheme.padCells, preserving initPotential and charge.

@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.padCells_seed {cells cells' w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (h : cells ≤ cells') (C : StateTransitionImpl D P s₀) :
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.padCells_rep {cells cells' w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (h : cells ≤ cells') (C : StateTransitionImpl D P s₀) (θ : C.Seed) (s : D.State) (m' : CellProbe.Mem cells' w) :
(padCells h C).rep θ s m' ↔ ∃ (m : CellProbe.Mem cells w), m' = CellProbe.padMem h m ∧ C.rep θ s m
@[simp]
theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.padCells_potential {cells cells' w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (h : cells ≤ cells') (C : StateTransitionImpl D P s₀) (θ : C.Seed) (m' : CellProbe.Mem cells' w) :
(padCells h C).potential θ m' = C.potential θ fun (i : Fin cells) => m' (Fin.castLE h i)

Sequence-level expected-amortized probe bounds and transcript contracts #

theorem Cslib.CellProbe.Randomized.Scheme.runFrom_cons_fst {Op : Type v} {Result : Op → Type} {cells w : ℕ} (Q : Scheme Op Result cells w) (m : Mem cells w) (o : Op) (ops : List Op) :
PMF.map Prod.fst (Q.runFrom m (o :: ops)) = (PMF.map Prod.fst ((Q.step o).run m)).bind fun (x : Result o × Mem cells w) => match x with | (a, m') => PMF.map (fun (x : List (Sigma Result) × Mem cells w) => match x with | (tr, m'') => (⟨o, a⟩ :: tr, m'')) (PMF.map Prod.fst (Q.runFrom m' ops))

First-component (transcript, postMem) decomposition of Randomized.Scheme.runFrom on o :: ops.

theorem Cslib.CellProbe.Randomized.Scheme.runFrom_append_fst {Op : Type v} {Result : Op → Type} {cells w : ℕ} (Q : Scheme Op Result cells w) (m : Mem cells w) (ops₁ ops₂ : List Op) :
PMF.map Prod.fst (Q.runFrom m (ops₁ ++ ops₂)) = (PMF.map Prod.fst (Q.runFrom m ops₁)).bind fun (x : List (Sigma Result) × Mem cells w) => match x with | (tr₁, m₁) => PMF.map (fun (x : List (Sigma Result) × Mem cells w) => match x with | (tr₂, m₂) => (tr₁ ++ tr₂, m₂)) (PMF.map Prod.fst (Q.runFrom m₁ ops₂))

First-component (transcript, postMem) decomposition of Randomized.Scheme.runFrom across ops₁ ++ ops₂.

theorem Cslib.CellProbe.Randomized.Scheme.expectedProbesFrom_cons {Op : Type v} {Result : Op → Type} {cells w : ℕ} (Q : Scheme Op Result cells w) (m : Mem cells w) (o : Op) (ops : List Op) :
Q.expectedProbesFrom m (o :: ops) = (Q.step o).expectedProbes m + ∑' (am : Result o × Mem cells w), (PMF.map Prod.fst ((Q.step o).run m)) am * Q.expectedProbesFrom am.2 ops

Stepwise expected-probe recurrence for Randomized.Scheme.expectedProbesFrom on o :: ops.

theorem Cslib.CellProbe.Randomized.Scheme.expectedProbesFrom_append {Op : Type v} {Result : Op → Type} {cells w : ℕ} (Q : Scheme Op Result cells w) (m : Mem cells w) (ops₁ ops₂ : List Op) :
Q.expectedProbesFrom m (ops₁ ++ ops₂) = Q.expectedProbesFrom m ops₁ + ∑' (tm : List (Sigma Result) × Mem cells w), (PMF.map Prod.fst (Q.runFrom m ops₁)) tm * Q.expectedProbesFrom tm.2 ops₂

Append decomposition for Randomized.Scheme.expectedProbesFrom across ops₁ ++ ops₂.

theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.seq_expected_amortized {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (C : StateTransitionImpl D P s₀) (ops : List D.Op) (hv : D.ValidOpSeq s₀ ops) :
∃ (ν_final : PMF (TraceState C.Seed D cells w)), PMF.map Prod.fst (P.runSeq ops) = PMF.map (fun (u : TraceState C.Seed D cells w) => u.trace.labels) ν_final ∧ (∀ (θ : C.Seed), (PMF.map TraceState.seed ν_final) θ ≤ C.seedSlack * C.seedLaw θ) ∧ (C.singleState → ∃ (s' : D.State), ∀ u ∈ ν_final.support, u.state = s') ∧ (∀ u ∈ ν_final.support, u.trace.ops = ops ∧ D.ValidTranscript s₀ u.trace u.state ∧ C.rep u.seed u.state u.mem) ∧ P.expectedSeqProbes ops + ∑' (u : TraceState C.Seed D cells w), ν_final u * ↑(C.potential u.seed u.mem) ≤ ↑C.initPotential + ∑' (u : TraceState C.Seed D cells w), ν_final u * ↑(D.totalCostTranscript C.charge s₀ u.trace)

Multi-operation expected-amortized sequence theorem (seq_expected_amortized). For any demonically admissible operation sequence D.ValidOpSeq s₀ ops, executing P from P.init admits a coupled transcript-and-state distribution ν_final whose label marginal equals (P.runSeq ops).map Prod.fst, whose support elements are valid relational transcripts of ops ending in represented states, and whose expected total transcript charge plus C.initPotential bounds P.expectedSeqProbes ops plus expected final potential.

Zero-error transcript correctness of P.runSeq ops in D.toObliviousSequenceSpec s₀ across any demonically admissible sequence D.ValidOpSeq s₀ ops.

theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.expectedSeqProbes_le_of_opCharge {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (C : StateTransitionImpl D P s₀) {opCharge : D.Op → ℕ} (hcharge : ∀ (s : D.State) (o : D.Op), D.valid s o → C.charge s o ≤ opCharge o) {ops : List D.Op} (hv : D.ValidOpSeq s₀ ops) :
P.expectedSeqProbes ops ≤ ↑C.initPotential + ↑(List.map opCharge ops).sum

When C.charge s o ≤ opCharge o on admissible inputs, P.expectedSeqProbes ops is bounded by C.initPotential + (ops.map opCharge).sum for every ops satisfying D.ValidOpSeq s₀ ops.

theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.seq_expected_amortized_ofFn {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (C : StateTransitionImpl D P s₀) {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (ops : List D.Op) (hv : D.ValidHistory s₀ ops) :
(D.toObliviousSequenceSpec s₀).Contract ops (PMF.map Prod.fst (P.runSeq ops)) ∧ (∀ out ∈ (PMF.map Prod.fst (P.runSeq ops)).support, out = (D.run s₀ ops).2) ∧ P.expectedSeqProbes ops ≤ ↑C.initPotential + ↑(D.totalCost C.charge s₀ ops)

Sequence-level expected-amortized theorem on deterministic specifications (D.HasStepFn f). Across any admissible history D.ValidHistory s₀ ops, P.runSeq ops satisfies the zero-error contract (D.toObliviousSequenceSpec s₀).Contract ops (concentrating every supported output trace on (D.run s₀ ops).2) and satisfies P.expectedSeqProbes ops ≤ C.initPotential + D.totalCost C.charge s₀ ops.

theorem Cslib.DataStructure.CellProbe.Randomized.StateTransitionImpl.expectedSeqProbes_le_ofFn {cells w : ℕ} {D : StateTransitionSpec} {P : CellProbe.Randomized.Scheme D.Op D.Result cells w} {s₀ : D.State} (C : StateTransitionImpl D P s₀) {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (ops : List D.Op) (hv : D.ValidHistory s₀ ops) :
P.expectedSeqProbes ops ≤ ↑C.initPotential + ↑(D.totalCost C.charge s₀ ops)

Expected sequence probes of P across any admissible history D.ValidHistory s₀ ops on a deterministic specification ([D.HasStepFn f]) is at most C.initPotential + D.totalCost C.charge s₀ ops.