File size: 3,134 Bytes
8769036
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicSampling
import OAI.NumberTheory.TwoPoint.Circuits.CircuitProbabilisticMethod
import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling

namespace OAI

/-! Independent repetition amplifies the single-hit experiment. These finite
identities are the random-subset step of the circuit polynomial construction. -/

namespace TwoPointCorrelations

open Finset
open scoped Classical

def isolatesOne {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : Prop :=
  ∃ i ∈ S, ∀ j ∈ S, x j = singleBitPattern i j

lemma singleHitScore_eq_indicator {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) :
    singleHitScore S x = if isolatesOne S x then 1 else 0 := by
  by_cases hx : isolatesOne S x
  · rw [ite_eq_left hx]
    obtain ⟨i, hi, hxi⟩ := hx
    unfold singleHitScore
    rw [sum_eq_single i]
    · exact ite_eq_left hxi
    · intro j hj hji
      unfold cubePattern
      apply ite_eq_right
      intro hxj
      have hh := (hxi i hi).symm.trans (hxj i hi)
      simp [singleBitPattern, Ne.symm hji] at hh
    · exact fun h => (h hi).elim
  · rw [ite_eq_right hx]
    unfold singleHitScore
    apply sum_eq_zero
    intro i hi
    unfold cubePattern
    exact ite_eq_right (fun h => hx ⟨i, hi, h⟩)

theorem bernoulliCubeLaw_isolatesOne (n : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1)
    (S : Finset (Fin n)) :
    (bernoulliCubeLaw n p hp hp1).probability (isolatesOne S) =
      (S.card : ℝ) * p * (1 - p) ^ (S.card - 1) := by
  unfold FiniteLaw.probability
  have heq : (fun x => if isolatesOne S x then (1 : ℝ) else 0) = singleHitScore S :=
    funext (fun x => (singleHitScore_eq_indicator S x).symm)
  rw [heq]
  exact bernoulliCubeLaw_singleHitScore n p hp hp1 S

lemma FiniteLaw.probability_complement {α : Type*} [Fintype α]
    (μ : FiniteLaw α) (E : α → Prop) :
    μ.probability (fun x => ¬E x) = 1 - μ.probability E := by
  unfold FiniteLaw.probability FiniteLaw.average
  calc
    _ = ∑ x, (μ.weight x - μ.weight x * (if E x then (1 : ℝ) else 0)) := by
      apply sum_congr rfl
      intro x _
      by_cases hx : E x <;> simp [hx]
    _ = _ := by rw [sum_sub_distrib, μ.total]

theorem FiniteLaw.independent_failure {α : Type*} [Fintype α]
    (μ : FiniteLaw α) (E : α → Prop) (s : ℕ) :
    (FiniteLaw.independent (fun _ : Fin s => μ)).probability
      (fun x => ∀ i, ¬E (x i)) = (1 - μ.probability E) ^ s := by
  calc
    _ = ∏ _i : Fin s, μ.probability (fun x => ¬E x) :=
      FiniteLaw.independent_probability_all (fun _ : Fin s => μ) (fun _ x => ¬E x)
    _ = _ := by
      simp only [μ.probability_complement, prod_const, card_univ, Fintype.card_fin]

theorem FiniteLaw.independent_failure_le {α : Type*} [Fintype α]
    (μ : FiniteLaw α) (E : α → Prop) (s : ℕ)
    (hE : (1 / 8 : ℝ) ≤ μ.probability E) :
    (FiniteLaw.independent (fun _ : Fin s => μ)).probability
      (fun x => ∀ i, ¬E (x i)) ≤ (7 / 8 : ℝ) ^ s := by
  rw [μ.independent_failure]
  apply pow_le_pow_left₀
  · linarith [μ.probability_le_one E]
  · linarith

end TwoPointCorrelations

end OAI