Documentation

CslibFrontier.Computability.WordRAM.Resizable.LoopDist

Geometric while-loop exit distributions on the Resizable Word RAM #

Iteration and limiting exit distributions (loopStepRPMF, loopIterRPMF, loopExitRPMF) and state invariants (RLoopStateInv) on RData r for randomized Las Vegas while loops over the word-granular Resizable Word RAM (Cslib.WordRAM.Resizable), mirroring the fixed-memory absorbing while-loop exit calculus in Cslib.WordRAM.Randomized.Expected on RData r (including the dynamic word frontier frontier).

Main definitions #

Main results #

References #

noncomputable def Cslib.WordRAM.Resizable.loopStepRPMF {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) (x : RData r) :

One step of a while loop distribution on RData r.

theorem Cslib.WordRAM.Resizable.loopStepRPMF_of_holds {r : ℕ} {cond : Cond r} {μ_body : RData r → PMF (RData r)} {x : RData r} (hc : cond.Holds x.toData) :
loopStepRPMF cond μ_body x = μ_body x
theorem Cslib.WordRAM.Resizable.loopStepRPMF_of_not_holds {r : ℕ} {cond : Cond r} {μ_body : RData r → PMF (RData r)} {x : RData r} (hc : ¬cond.Holds x.toData) :
loopStepRPMF cond μ_body x = PMF.pure x
noncomputable def Cslib.WordRAM.Resizable.loopIterRPMF {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) :
ℕ → RData r → PMF (RData r)

K-step iterate of loopStepRPMF.

@[simp]
theorem Cslib.WordRAM.Resizable.loopIterRPMF_zero {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) (x : RData r) :
loopIterRPMF cond μ_body 0 x = PMF.pure x
theorem Cslib.WordRAM.Resizable.loopIterRPMF_succ {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) (K : ℕ) (x : RData r) :
loopIterRPMF cond μ_body (K + 1) x = (loopStepRPMF cond μ_body x).bind (loopIterRPMF cond μ_body K)
theorem Cslib.WordRAM.Resizable.loopIterRPMF_of_not_holds {r : ℕ} {cond : Cond r} {μ_body : RData r → PMF (RData r)} {x : RData r} (hc : ¬cond.Holds x.toData) (K : ℕ) :
loopIterRPMF cond μ_body K x = PMF.pure x
theorem Cslib.WordRAM.Resizable.loopIterRPMF_succ_right {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) (K : ℕ) (x : RData r) :
loopIterRPMF cond μ_body (K + 1) x = (loopIterRPMF cond μ_body K x).bind (loopStepRPMF cond μ_body)
theorem Cslib.WordRAM.Resizable.loopIterRPMF_indicator_mono {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) (x y : RData r) :
Monotone fun (K : ℕ) => {z : RData r | ¬cond.Holds z.toData}.indicator (⇑(loopIterRPMF cond μ_body K x)) y
def Cslib.WordRAM.Resizable.RLoopStateInv {r : ℕ} (cond : Cond r) (I Q : RData r → Prop) (x : RData r) :

Combined active/exit state invariant for while loops on RData r.

theorem Cslib.WordRAM.Resizable.loopIterRPMF_support_inv {r : ℕ} {cond : Cond r} {I Q : RData r → Prop} {μ_body : RData r → PMF (RData r)} (hinv : ∀ (x : RData r), I x → cond.Holds x.toData → ∀ y ∈ (μ_body x).support, RLoopStateInv cond I Q y) (K : ℕ) {x : RData r} (hx : RLoopStateInv cond I Q x) (y : RData r) :
y ∈ (loopIterRPMF cond μ_body K x).support → RLoopStateInv cond I Q y
theorem Cslib.WordRAM.Resizable.pmf_rdata_step_drift_bound {r : ℕ} (μ : PMF (RData r)) (cond : Cond r) {C p_exit : ENNReal} (hp_pos : 0 < p_exit) (hp_top : p_exit ≠ ⊤) (hp_exit : p_exit ≤ μ.toOuterMeasure {y : RData r | ¬cond.Holds y.toData}) :
(C + ∑' (y : RData r), μ y * if cond.Holds y.toData then C / p_exit else 0) ≤ C / p_exit
theorem Cslib.WordRAM.Resizable.hasSum_loopExitRDensity {r : ℕ} {cond : Cond r} {I Q : RData r → Prop} {μ_body : RData r → PMF (RData r)} {p_exit : ENNReal} (hp_pos : 0 < p_exit) (hp_top : p_exit ≠ ⊤) (hinv : ∀ (x : RData r), I x → cond.Holds x.toData → ∀ y ∈ (μ_body x).support, RLoopStateInv cond I Q y) (hp_exit : ∀ (x : RData r), I x → cond.Holds x.toData → p_exit ≤ (μ_body x).toOuterMeasure {y : RData r | ¬cond.Holds y.toData}) {x : RData r} (hx : RLoopStateInv cond I Q x) :
HasSum (fun (y : RData r) => ⨆ (K : ℕ), {z : RData r | ¬cond.Holds z.toData}.indicator (⇑(loopIterRPMF cond μ_body K x)) y) 1
noncomputable def Cslib.WordRAM.Resizable.loopExitRPMF {r : ℕ} (cond : Cond r) (μ_body : RData r → PMF (RData r)) (x : RData r) :

Limiting exit distribution of RCode.loop cond body from x under μ_body.

theorem Cslib.WordRAM.Resizable.loopExitRPMF_apply_of_hasSum {r : ℕ} {cond : Cond r} {μ_body : RData r → PMF (RData r)} {x : RData r} (h : HasSum (fun (y : RData r) => ⨆ (K : ℕ), {z : RData r | ¬cond.Holds z.toData}.indicator (⇑(loopIterRPMF cond μ_body K x)) y) 1) (y : RData r) :
(loopExitRPMF cond μ_body x) y = ⨆ (K : ℕ), {z : RData r | ¬cond.Holds z.toData}.indicator (⇑(loopIterRPMF cond μ_body K x)) y
theorem Cslib.WordRAM.Resizable.loopExitRPMF_of_not_holds {r : ℕ} {cond : Cond r} {μ_body : RData r → PMF (RData r)} {x : RData r} (hc : ¬cond.Holds x.toData) :
loopExitRPMF cond μ_body x = PMF.pure x
theorem Cslib.WordRAM.Resizable.loopExitRPMF_of_holds {r : ℕ} {cond : Cond r} {I Q : RData r → Prop} {μ_body : RData r → PMF (RData r)} {p_exit : ENNReal} (hp_pos : 0 < p_exit) (hp_top : p_exit ≠ ⊤) (hinv : ∀ (x : RData r), I x → cond.Holds x.toData → ∀ y ∈ (μ_body x).support, RLoopStateInv cond I Q y) (hp_exit : ∀ (x : RData r), I x → cond.Holds x.toData → p_exit ≤ (μ_body x).toOuterMeasure {y : RData r | ¬cond.Holds y.toData}) {x : RData r} (hIx : I x) (hcx : cond.Holds x.toData) :
loopExitRPMF cond μ_body x = (μ_body x).bind (loopExitRPMF cond μ_body)
theorem Cslib.WordRAM.Resizable.mem_support_loopExitRPMF {r : ℕ} {cond : Cond r} {I Q : RData r → Prop} {μ_body : RData r → PMF (RData r)} {p_exit : ENNReal} (hp_pos : 0 < p_exit) (hp_top : p_exit ≠ ⊤) (hinv : ∀ (x : RData r), I x → cond.Holds x.toData → ∀ y ∈ (μ_body x).support, RLoopStateInv cond I Q y) (hp_exit : ∀ (x : RData r), I x → cond.Holds x.toData → p_exit ≤ (μ_body x).toOuterMeasure {y : RData r | ¬cond.Holds y.toData}) {x : RData r} (hx : RLoopStateInv cond I Q x) {y : RData r} (hy : y ∈ (loopExitRPMF cond μ_body x).support) :
(¬cond.Holds y.toData ∧ Q y) ∧ ∃ (K : ℕ), y ∈ (loopIterRPMF cond μ_body K x).support