All proofs
Project-declaredLean 4.32.0 · mathlib@81a5d257

Eval Dist uniform Sample bind update

evalDist_uniformSample_bind_update

Plain-language statement

Overwriting one coordinate of a uniform function table is measure-preserving. Drawing a value u uniformly from R, then a full function table g : D → R uniformly, and returning Function.update g t u yields the same distribution as drawing the table directly. This is the t-marginal independence of the uniform (product) distribution on D → R:...

Exact Lean statement

lemma evalDist_uniformSample_bind_update
    {D R : Type} [Finite D] [DecidableEq D] [Finite R] [Nonempty R]
    [SampleableType R] [SampleableType (D → R)] (t : D) :
    𝒟[do let u ← $ᵗ R; let g ← $ᵗ (D → R); pure (Function.update g t u)] =
      𝒟[$ᵗ (D → R)]

Formal artifact

Lean source

Canonical source
Full Lean sourceLean 4
lemma evalDist_uniformSample_bind_update    {D R : Type} [Finite D] [DecidableEq D] [Finite R] [Nonempty R]    [SampleableType R] [SampleableType (D  R)] (t : D) :    𝒟[do let u  $ᵗ R; let g  $ᵗ (D  R); pure (Function.update g t u)] =      𝒟[$ᵗ (D  R)] := by  classical  letI := Fintype.ofFinite D  letI := Fintype.ofFinite R  haveI : Nonempty (D  R) := fun _ => Classical.arbitrary R  refine evalDist_ext fun h => ?_  rw [probOutput_uniformSample (D  R) h, probOutput_bind_eq_sum_fintype]  -- For each fixed `u`, count the tables `g` whose `t`-update equals `h`.  have hinner :  u : R,      Pr[= h | (do let g  $ᵗ (D  R); pure (Function.update g t u))]        = (if u = h t then            (Fintype.card R : 0∞) * (Fintype.card (D  R) : 0∞)⁻¹ else 0) := by    intro u    rw [bind_pure_comp, probOutput_map_eq_sum_fintype_ite]    simp only [probOutput_uniformSample (D  R)]    rw [ Finset.sum_filter, Finset.sum_const, nsmul_eq_mul]    -- The matching tables are exactly `Function.update h t r` for `r : R`.    have hcard :        ((Finset.univ.filter fun g : D  R => h = Function.update g t u).card : 0∞)          = if u = h t then (Fintype.card R : 0∞) else 0 := by      by_cases hu : u = h t      · have hset : (Finset.univ.filter fun g : D  R => h = Function.update g t u)            = Finset.univ.image (fun r : R => Function.update h t r) := by          ext g          simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image]          constructor          · intro hg            exact g t, by subst hg; simp          · rintro r, rfl            subst hu; simp        rw [hset, Finset.card_image_of_injective _          (fun r₁ r₂ hr => by simpa using congrFun hr t), Finset.card_univ, if_pos hu]      · rw [if_neg hu, Nat.cast_eq_zero, Finset.card_eq_zero, Finset.filter_eq_empty_iff]        rintro g - rfl        simp at hu    rw [hcard, ite_mul, zero_mul]  simp_rw [hinner, mul_ite, mul_zero]  rw [Finset.sum_ite_eq' Finset.univ (h t), if_pos (Finset.mem_univ _), probOutput_uniformSample R,       mul_assoc, ENNReal.inv_mul_cancel (by simp [Fintype.card_ne_zero])        (ENNReal.natCast_ne_top _), one_mul]
Project
VCVio
License
Apache-2.0
Commit
2ceb2d825ee3
Source
VCVio/OracleComp/Constructions/SampleableType.lean:447-490

Reuse this declaration

Bring the exact result into your workflow

The import identifies the source module. Your project still needs the pinned package dependency shown on this page.

What this badge means

This completion status comes from the project or community source. It has not yet been represented here as an independent rebuild and axiom audit.

Continue in this project

Related declarations

Project-declaredLean 4.32.0

Expected Cost Nat eq sum tail probs of pathwise Cost At Most

AddWriterT.expectedCostNat_eq_sum_tail_probs_of_pathwiseCostAtMost

Plain-language statement

Finite tail-sum formula for natural-valued writer cost under a pathwise upper bound. If every execution path of oa incurs cost at most n, then the tail probabilities vanish above n, so the infinite tail sum truncates to Finset.range n.

program verificationseparation logiccryptography

Source project: VCVio

Person-level attribution pending.

View proof record
Project-declaredLean 4.32.0

IND CPA advantage to Real le sum step signed Advantage Real abs

AsymmEncAlg.IND_CPA_advantage_toReal_le_sum_step_signedAdvantageReal_abs

Plain-language statement

Planned generic one-time-to-many-time lift: bounded multi-query IND-CPA advantage is at most the sum of the extracted one-time signed advantages over the first q fresh LR queries.

program verificationseparation logiccryptography

Source project: VCVio

Person-level attribution pending.

View proof record