@@ -7,6 +7,7 @@ import VCVio.CryptoFoundations.SecExp
77import VCVio.OracleComp.QueryTracking.SeededOracle
88import VCVio.OracleComp.QueryTracking.LoggingOracle
99import VCVio.OracleComp.Coercions.Add
10+ import ToMathlib.Data.ENNReal.SumSquares
1011
1112/-!
1213# Forking Lemma
@@ -26,45 +27,6 @@ then re-samples one oracle response, bounding the probability that both runs suc
2627
2728open OracleSpec OracleComp ENNReal Function Finset
2829
29- /-! ### ENNReal Cauchy-Schwarz inequality -/
30-
31- private lemma ENNReal.two_mul_le_add_sq (a b : ℝ≥0 ∞) :
32- 2 * a * b ≤ a ^ 2 + b ^ 2 := by
33- rcases eq_or_ne a ⊤ with rfl | ha
34- · simp [top_pow, top_add, le_top]
35- rcases eq_or_ne b ⊤ with rfl | hb
36- · simp [top_pow, add_top, le_top]
37- rw [← ENNReal.coe_toNNReal ha, ← ENNReal.coe_toNNReal hb]
38- exact_mod_cast _root_.two_mul_le_add_sq a.toNNReal b.toNNReal
39-
40- private lemma ENNReal.sq_sum_le_card_mul_sum_sq {ι' : Type *}
41- (s : Finset ι') (f : ι' → ℝ≥0 ∞) :
42- (∑ i ∈ s, f i) ^ 2 ≤ s.card * ∑ i ∈ s, f i ^ 2 := by
43- rw [sq, Finset.sum_mul_sum]
44- suffices h : 2 * ∑ i ∈ s, ∑ j ∈ s, f i * f j ≤ 2 * (↑s.card * ∑ i ∈ s, f i ^ 2 ) by
45- have h2 : (2 : ℝ≥0 ∞) ≠ 0 := by norm_num
46- have h2' : (2 : ℝ≥0 ∞) ≠ ⊤ := by norm_num
47- calc ∑ i ∈ s, ∑ j ∈ s, f i * f j
48- _ = 2 ⁻¹ * (2 * ∑ i ∈ s, ∑ j ∈ s, f i * f j) := by
49- rw [← mul_assoc, ENNReal.inv_mul_cancel h2 h2', one_mul]
50- _ ≤ 2 ⁻¹ * (2 * (↑s.card * ∑ i ∈ s, f i ^ 2 )) := by gcongr
51- _ = ↑s.card * ∑ i ∈ s, f i ^ 2 := by
52- rw [← mul_assoc, ENNReal.inv_mul_cancel h2 h2', one_mul]
53- calc 2 * ∑ i ∈ s, ∑ j ∈ s, f i * f j
54- _ = ∑ i ∈ s, ∑ j ∈ s, 2 * (f i * f j) := by
55- rw [Finset.mul_sum]; congr 1 ; ext i; rw [Finset.mul_sum]
56- _ ≤ ∑ i ∈ s, ∑ j ∈ s, (f i ^ 2 + f j ^ 2 ) := by
57- gcongr with i _ j _
58- calc 2 * (f i * f j) = 2 * f i * f j := (mul_assoc ..).symm
59- _ ≤ f i ^ 2 + f j ^ 2 := ENNReal.two_mul_le_add_sq (f i) (f j)
60- _ = ∑ i ∈ s, (↑s.card * f i ^ 2 + ∑ j ∈ s, f j ^ 2 ) := by
61- congr 1 ; ext i
62- rw [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul]
63- _ = ↑s.card * ∑ i ∈ s, f i ^ 2 + ↑s.card * ∑ i ∈ s, f i ^ 2 := by
64- rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.sum_const, nsmul_eq_mul,
65- Finset.mul_sum]
66- _ = 2 * (↑s.card * ∑ i ∈ s, f i ^ 2 ) := by rw [← two_mul]
67-
6830namespace OracleComp
6931
7032variable {ι : Type } [DecidableEq ι] {spec : OracleSpec ι}
@@ -146,7 +108,7 @@ private lemma probEvent_fork_fst_eq_probEvent_pair (s : Fin (qb i + 1)) :
146108 x₁ x₂ hmem with ⟨t, h₁, h₂⟩
147109 simp [h₁, h₂]
148110
149- omit [DecidableEq ι] [ spec.DecidableEq] in
111+ omit [spec.DecidableEq] in
150112private lemma probEvent_uniform_eq_seedSlot_le_inv (s : Fin (qb i + 1 ))
151113 (seed : QuerySeed spec) :
152114 let h : ℝ≥0 ∞ := ↑(Fintype.card (spec.Range i))
@@ -156,44 +118,27 @@ private lemma probEvent_uniform_eq_seedSlot_le_inv (s : Fin (qb i + 1))
156118 · simp [hnone]
157119 · rcases Option.ne_none_iff_exists'.mp hnone with ⟨u₀, hu₀⟩
158120 rw [hu₀]
159- calc
160- Pr[fun u : spec.Range i => (some u₀ : Option (spec.Range i)) = some u |
161- liftComp ($ᵗ spec.Range i) spec]
162- = Pr[fun u : spec.Range i => u₀ = u | liftComp ($ᵗ spec.Range i) spec] := by simp
163- _ = (↑(Fintype.card (spec.Range i)) : ℝ≥0 ∞)⁻¹ := by
164- rw [probEvent_eq_eq_probOutput']
165- have hLift :
166- Pr[= u₀ | liftComp (($ᵗ spec.Range i : ProbComp (spec.Range i))) spec] =
167- Pr[= u₀ | ($ᵗ spec.Range i : ProbComp (spec.Range i))] := by
168- simpa using
169- (probOutput_liftComp (spec := unifSpec) (superSpec := spec)
170- (mx := ($ᵗ spec.Range i : ProbComp (spec.Range i))) (x := u₀))
171- rw [hLift]
172- simp [probOutput_uniformSample]
173- _ ≤ (↑(Fintype.card (spec.Range i)) : ℝ≥0 ∞)⁻¹ := le_rfl
174-
175- omit [DecidableEq ι] [spec.DecidableEq] in
121+ have : Pr[fun u : spec.Range i => (some u₀ : Option (spec.Range i)) = some u |
122+ liftComp ($ᵗ spec.Range i) spec] =
123+ Pr[fun u : spec.Range i => u₀ = u | liftComp ($ᵗ spec.Range i) spec] := by
124+ congr 1 ; ext; simp
125+ rw [this]
126+ exact le_of_eq (seededOracle.probEvent_liftComp_uniformSample_eq_of_eq u₀)
127+
128+ omit [spec.DecidableEq] in
176129private lemma probEvent_uniform_eq_seedSlot_eq_inv_of_get (s : Fin (qb i + 1 ))
177130 (seed : QuerySeed spec) {u₀ : spec.Range i}
178131 (hu₀ : (seed i)[↑s]? = some u₀) :
179132 let h : ℝ≥0 ∞ := ↑(Fintype.card (spec.Range i))
180133 Pr[fun u : spec.Range i => (seed i)[↑s]? = some u | liftComp ($ᵗ spec.Range i) spec] = h⁻¹ := by
181134 simp only
182135 rw [hu₀]
183- calc
184- Pr[fun u : spec.Range i => (some u₀ : Option (spec.Range i)) = some u |
185- liftComp ($ᵗ spec.Range i) spec]
186- = Pr[fun u : spec.Range i => u₀ = u | liftComp ($ᵗ spec.Range i) spec] := by simp
187- _ = (↑(Fintype.card (spec.Range i)) : ℝ≥0 ∞)⁻¹ := by
188- rw [probEvent_eq_eq_probOutput']
189- have hLift :
190- Pr[= u₀ | liftComp (($ᵗ spec.Range i : ProbComp (spec.Range i))) spec] =
191- Pr[= u₀ | ($ᵗ spec.Range i : ProbComp (spec.Range i))] := by
192- simpa using
193- (probOutput_liftComp (spec := unifSpec) (superSpec := spec)
194- (mx := ($ᵗ spec.Range i : ProbComp (spec.Range i))) (x := u₀))
195- rw [hLift]
196- simp [probOutput_uniformSample]
136+ have : Pr[fun u : spec.Range i => (some u₀ : Option (spec.Range i)) = some u |
137+ liftComp ($ᵗ spec.Range i) spec] =
138+ Pr[fun u : spec.Range i => u₀ = u | liftComp ($ᵗ spec.Range i) spec] := by
139+ congr 1 ; ext; simp
140+ rw [this]
141+ exact seededOracle.probEvent_liftComp_uniformSample_eq_of_eq u₀
197142
198143private lemma probOutput_collision_given_seed_le (s : Fin (qb i + 1 ))
199144 (seed : QuerySeed spec) :
0 commit comments