File size: 8,017 Bytes
9dbc64e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import OAI.Computability.DepthThree.Core
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Option
import Mathlib.Tactic.Ring

namespace OAI

universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 uDepth13 uDepth14 uDepth15 uDepth16 uDepth17 uDepth18 uDepth19 uDepth20 uDepth21

noncomputable section

open scoped BigOperators Classical

namespace DepthThreeLowerBound

abbrev Restriction (V : Type uDepth1) := V → Option Bool
abbrev Live {V : Type uDepth2} (σ : Restriction V) := {v : V // σ v = none}

def fill {V : Type uDepth3} (σ : Restriction V) (z : Cube (Live σ)) : Cube V :=
  fun v => if h : σ v = none then z ⟨v, h⟩ else (σ v).getD false

@[simp] theorem fill_live {V : Type uDepth4} (σ : Restriction V) (z : Cube (Live σ))
    (v : Live σ) : fill σ z v.val = z v := by
  simp [fill, v.property]

@[simp] theorem fill_fixed {V : Type uDepth5} (σ : Restriction V) (z : Cube (Live σ))
    (v : V) (b : Bool) (h : σ v = some b) : fill σ z v = b := by
  simp [fill, h]

def finiteAvg {Ω : Type uDepth6} [Fintype Ω] (f : Ω → ℝ) : ℝ :=
  (Fintype.card Ω : ℝ)⁻¹ * ∑ ω, f ω

section Averages

variable {Ω : Type uDepth7} {Λ : Type uDepth8} [Fintype Ω] [Fintype Λ]

theorem finiteAvg_congr {f g : Ω → ℝ} (h : ∀ ω, f ω = g ω) :
    finiteAvg f = finiteAvg g := by
  unfold finiteAvg
  congr 1
  exact Finset.sum_congr rfl (fun ω _ => h ω)

@[simp] theorem finiteAvg_zero : finiteAvg (fun _ : Ω => (0 : ℝ)) = 0 := by
  simp [finiteAvg]

theorem finiteAvg_add (f g : Ω → ℝ) :
    finiteAvg (fun ω => f ω + g ω) = finiteAvg f + finiteAvg g := by
  simp [finiteAvg, Finset.sum_add_distrib, mul_add]

theorem finiteAvg_sub (f g : Ω → ℝ) :
    finiteAvg (fun ω => f ω - g ω) = finiteAvg f - finiteAvg g := by
  simp [finiteAvg, Finset.sum_sub_distrib, mul_sub]

theorem finiteAvg_const_mul (c : ℝ) (f : Ω → ℝ) :
    finiteAvg (fun ω => c * f ω) = c * finiteAvg f := by
  unfold finiteAvg
  rw [← Finset.mul_sum]
  ring

theorem finiteAvg_mul_const (f : Ω → ℝ) (c : ℝ) :
    finiteAvg (fun ω => f ω * c) = finiteAvg f * c := by
  unfold finiteAvg
  rw [← Finset.sum_mul]
  ring

theorem finiteAvg_sum {ι : Type uDepth9} (s : Finset ι) (f : ι → Ω → ℝ) :
    finiteAvg (fun ω => ∑ i ∈ s, f i ω) = ∑ i ∈ s, finiteAvg (f i) := by
  classical
  simp only [finiteAvg, Finset.mul_sum]
  exact Finset.sum_comm

theorem finiteAvg_nonneg {f : Ω → ℝ} (h : ∀ ω, 0 ≤ f ω) :
    0 ≤ finiteAvg f := by
  exact mul_nonneg (inv_nonneg.mpr (Nat.cast_nonneg _))
    (Finset.sum_nonneg (fun ω _ => h ω))

theorem finiteAvg_mono {f g : Ω → ℝ} (h : ∀ ω, f ω ≤ g ω) :
    finiteAvg f ≤ finiteAvg g := by
  exact mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun ω _ => h ω))
    (inv_nonneg.mpr (Nat.cast_nonneg _))

theorem finiteAvg_abs_le (f : Ω → ℝ) :
    |finiteAvg f| ≤ finiteAvg (fun ω => |f ω|) := by
  unfold finiteAvg
  rw [abs_mul, abs_of_nonneg (inv_nonneg.mpr (Nat.cast_nonneg _))]
  exact mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs f Finset.univ)
    (inv_nonneg.mpr (Nat.cast_nonneg _))

@[simp] theorem finiteAvg_const [Nonempty Ω] (c : ℝ) :
    finiteAvg (fun _ : Ω => c) = c := by
  have hc : (Fintype.card Ω : ℝ) ≠ 0 := by
    exact_mod_cast Fintype.card_ne_zero
  simp [finiteAvg, nsmul_eq_mul, hc]

theorem finiteAvg_equiv (e : Ω ≃ Λ) (f : Λ → ℝ) :
    finiteAvg (fun ω => f (e ω)) = finiteAvg f := by
  unfold finiteAvg
  rw [Fintype.card_congr e, e.sum_comp f]

theorem finiteAvg_comm (f : Ω → Λ → ℝ) :
    finiteAvg (fun ω => finiteAvg (f ω)) =
      finiteAvg (fun l => finiteAvg (fun ω => f ω l)) := by
  simp only [finiteAvg, Finset.mul_sum]
  rw [Finset.sum_comm]
  apply Finset.sum_congr rfl
  intro l hl
  apply Finset.sum_congr rfl
  intro ω hω
  ring

theorem finiteAvg_product (f : Ω × Λ → ℝ) :
    finiteAvg f = finiteAvg (fun ω => finiteAvg (fun l => f (ω, l))) := by
  simp only [finiteAvg, Fintype.card_prod, Nat.cast_mul, mul_inv,
    Fintype.sum_prod_type, Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro ω hω
  apply Finset.sum_congr rfl
  intro l hl
  ring

theorem finiteAvg_pi_prod {ι : Type uDepth10} [Fintype ι]
    {κ : ι → Type uDepth21} [∀ i, Fintype (κ i)] (f : ∀ i, κ i → ℝ) :
    finiteAvg (fun x : ∀ i, κ i => ∏ i, f i (x i)) =
      ∏ i, finiteAvg (f i) := by
  classical
  unfold finiteAvg
  rw [Fintype.card_pi, Nat.cast_prod, ← Fintype.prod_sum]
  rw [Finset.prod_mul_distrib, Finset.prod_inv_distrib]

end Averages

def restrictionCoordinateWeight (p : ℝ) : Option Bool → ℝ
  | none => p
  | some _ => (1 - p) / 2

def restrictionWeight {V : Type uDepth11} [Fintype V] (p : ℝ) (σ : Restriction V) : ℝ :=
  ∏ v, restrictionCoordinateWeight p (σ v)

def restrictionAvg {V : Type uDepth12} [Fintype V] (p : ℝ)
    (F : Restriction V → ℝ) : ℝ :=
  ∑ σ, restrictionWeight p σ * F σ

@[simp] theorem restrictionCoordinateWeight_sum (p : ℝ) :
    (∑ a : Option Bool, restrictionCoordinateWeight p a) = 1 := by
  simp [Fintype.sum_option, restrictionCoordinateWeight]
  ring

theorem restrictionCoordinateWeight_nonneg {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1)
    (a : Option Bool) : 0 ≤ restrictionCoordinateWeight p a := by
  cases a with
  | none => exact hp
  | some b => exact div_nonneg (sub_nonneg.mpr hp1) (by norm_num)

theorem restrictionWeight_nonneg {V : Type uDepth13} [Fintype V] {p : ℝ}
    (hp : 0 ≤ p) (hp1 : p ≤ 1) (σ : Restriction V) :
    0 ≤ restrictionWeight p σ := by
  exact Finset.prod_nonneg (fun v _ => restrictionCoordinateWeight_nonneg hp hp1 (σ v))

@[simp] theorem restrictionWeight_sum {V : Type uDepth14} [Fintype V] (p : ℝ) :
    (∑ σ : Restriction V, restrictionWeight p σ) = 1 := by
  classical
  unfold restrictionWeight
  rw [← Fintype.prod_sum]
  simp only [restrictionCoordinateWeight_sum, Finset.prod_const_one]

@[simp] theorem restrictionAvg_const {V : Type uDepth15} [Fintype V] (p c : ℝ) :
    restrictionAvg p (fun _ : Restriction V => c) = c := by
  simp [restrictionAvg, ← Finset.sum_mul]

theorem restrictionAvg_nonneg {V : Type uDepth16} [Fintype V] {p : ℝ}
    (hp : 0 ≤ p) (hp1 : p ≤ 1) {F : Restriction V → ℝ}
    (hF : ∀ σ, 0 ≤ F σ) : 0 ≤ restrictionAvg p F := by
  exact Finset.sum_nonneg (fun σ _ =>
    mul_nonneg (restrictionWeight_nonneg hp hp1 σ) (hF σ))

theorem restrictionAvg_mono {V : Type uDepth17} [Fintype V] {p : ℝ}
    (hp : 0 ≤ p) (hp1 : p ≤ 1) {F G : Restriction V → ℝ}
    (h : ∀ σ, F σ ≤ G σ) : restrictionAvg p F ≤ restrictionAvg p G := by
  exact Finset.sum_le_sum (fun σ _ =>
    mul_le_mul_of_nonneg_left (h σ) (restrictionWeight_nonneg hp hp1 σ))

theorem restrictionAvg_add {V : Type uDepth18} [Fintype V] (p : ℝ)
    (F G : Restriction V → ℝ) :
    restrictionAvg p (fun σ => F σ + G σ) = restrictionAvg p F + restrictionAvg p G := by
  simp [restrictionAvg, mul_add, Finset.sum_add_distrib]

theorem restrictionAvg_const_mul {V : Type uDepth19} [Fintype V] (p c : ℝ)
    (F : Restriction V → ℝ) :
    restrictionAvg p (fun σ => c * F σ) = c * restrictionAvg p F := by
  simp [restrictionAvg, Finset.mul_sum, mul_left_comm]

theorem restrictionAvg_abs_le {V : Type uDepth20} [Fintype V] {p : ℝ}
    (hp : 0 ≤ p) (hp1 : p ≤ 1) (F : Restriction V → ℝ) :
    |restrictionAvg p F| ≤ restrictionAvg p (fun σ => |F σ|) := by
  unfold restrictionAvg
  calc
    _ ≤ ∑ σ, |restrictionWeight p σ * F σ| :=
      Finset.abs_sum_le_sum_abs _ _
    _ = _ := by
      apply Finset.sum_congr rfl
      intro σ hσ
      rw [abs_mul, abs_of_nonneg (restrictionWeight_nonneg hp hp1 σ)]

end DepthThreeLowerBound

end

end OAI