File size: 8,565 Bytes
92416a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import Mathlib
import OAI.Computability.VertexCover.Analysis.BaseReductionCoherent

namespace OAI

section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace VertexCover.LabelCover
open UniqueGames.Foundations.Games
noncomputable section

def occurrenceLaw (Φ : LabelCover) : FiniteDistribution (Fin Φ.M) := by
  letI : Nonempty (Fin Φ.M) := ⟨⟨0, Φ.M_pos⟩⟩
  exact FiniteDistribution.uniform (Fin Φ.M)

def questionProjection (Φ : LabelCover) (x : Fin Φ.u) (y : Fin Φ.v) (a : Fin Φ.qU) : Fin Φ.qV :=
  if h : ∃ e, Φ.left e = x ∧ Φ.right e = y then Φ.projection h.choose a
  else ⟨0, Φ.qV_pos⟩

theorem questionProjection_at (Φ : LabelCover) (hc : Φ.ParallelCoherent)
    (e : Fin Φ.M) (a : Fin Φ.qU) :
    Φ.questionProjection (Φ.left e) (Φ.right e) a = Φ.projection e a := by
  unfold questionProjection
  split
  · rename_i h
    exact congrFun (hc h.choose e h.choose_spec.1 h.choose_spec.2) a
  · rename_i h
    exact False.elim (h ⟨e, rfl, rfl⟩)

def asGame (Φ : LabelCover) : Game (Fin Φ.u) (Fin Φ.v) (Fin Φ.qU) (Fin Φ.qV) :=
  { questions := Φ.occurrenceLaw.pushforward (fun e => (Φ.left e, Φ.right e))
    accepts := fun x y a b => decide (Φ.questionProjection x y a = b) }

theorem asGame_success (Φ : LabelCover) (hc : Φ.ParallelCoherent) (A : Φ.Labeling) :
    Φ.asGame.success A = (Φ.satisfiedCount A : ℝ) / Φ.M := by
  classical
  change (Φ.occurrenceLaw.pushforward (fun e => (Φ.left e, Φ.right e))).probability _ = _
  rw [FiniteDistribution.probability_pushforward]
  simp only [FiniteDistribution.probability, Game.wins, asGame, questionProjection_at Φ hc,
    decide_eq_true_eq]
  simp only [occurrenceLaw, FiniteDistribution.uniform, Fintype.card_fin]
  change (∑ e, if Φ.Satisfies A e then 1 / (Φ.M : ℝ) else 0) = _
  calc
    _ = (∑ e, (if Φ.Satisfies A e then 1 else 0 : ℝ)) / Φ.M := by
      rw [Finset.sum_div]
      apply Finset.sum_congr rfl
      intro e he
      split_ifs <;> simp
    _ = _ := by rw [Finset.sum_boole]; rfl

def asGameValue (Φ : LabelCover) : ℝ := by
  letI : Nonempty (Fin Φ.qU) := ⟨⟨0, Φ.qU_pos⟩⟩
  letI : Nonempty (Fin Φ.qV) := ⟨⟨0, Φ.qV_pos⟩⟩
  exact Φ.asGame.value

theorem asGameValue_eq (Φ : LabelCover) (hc : Φ.ParallelCoherent) : Φ.asGameValue = Φ.value := by
  classical
  let : Nonempty (Fin Φ.qU) := ⟨⟨0, Φ.qU_pos⟩⟩
  let : Nonempty (Fin Φ.qV) := ⟨⟨0, Φ.qV_pos⟩⟩
  change Φ.asGame.value = Φ.value
  apply le_antisymm
  · apply (Φ.asGame.value_le_iff _).mpr
    intro A
    rw [asGame_success Φ hc A]
    exact div_le_div_of_nonneg_right (Nat.cast_le.mpr (Φ.satisfiedCount_le_max A)) (by positivity)
  · apply value_le_of_counts
    intro A
    have hs := Φ.asGame.success_le_value A
    rw [asGame_success Φ hc A] at hs
    exact (div_le_iff₀ (Nat.cast_pos.mpr Φ.M_pos)).mp hs

def tupleEquiv (a n : ℕ) : (Fin n → Fin a) ≃ Fin (a ^ n) :=
  Fintype.equivFinOfCardEq (by simp)

def parallelPower (Φ : LabelCover) (n : ℕ) : LabelCover where
  u := Φ.u ^ n
  v := Φ.v ^ n
  qU := Φ.qU ^ n
  qV := Φ.qV ^ n
  M := Φ.M ^ n
  qU_pos := pow_pos Φ.qU_pos _
  qV_pos := pow_pos Φ.qV_pos _
  M_pos := pow_pos Φ.M_pos _
  left e := tupleEquiv Φ.u n (fun i => Φ.left ((tupleEquiv Φ.M n).symm e i))
  right e := tupleEquiv Φ.v n (fun i => Φ.right ((tupleEquiv Φ.M n).symm e i))
  projection e a := tupleEquiv Φ.qV n (fun i => Φ.projection ((tupleEquiv Φ.M n).symm e i)
    ((tupleEquiv Φ.qU n).symm a i))

def repeatLabeling (Φ : LabelCover) (n : ℕ) (A : Φ.Labeling) : (Φ.parallelPower n).Labeling :=
  (fun x => tupleEquiv Φ.qU n (fun i => A.1 ((tupleEquiv Φ.u n).symm x i)),
   fun y => tupleEquiv Φ.qV n (fun i => A.2 ((tupleEquiv Φ.v n).symm y i)))

theorem repeat_perfect (Φ : LabelCover) (n : ℕ) (A : Φ.Labeling) (hA : ∀ e, Φ.Satisfies A e) :
    ∀ e, (Φ.parallelPower n).Satisfies (Φ.repeatLabeling n A) e := by
  intro e
  change tupleEquiv Φ.qV n _ = tupleEquiv Φ.qV n _
  apply congrArg (tupleEquiv Φ.qV n)
  funext i
  simpa only [Satisfies, repeatLabeling, parallelPower, Equiv.symm_apply_apply] using hA ((tupleEquiv Φ.M n).symm e i)

def repeatedStrategy (Φ : LabelCover) (n : ℕ) (A : (Φ.parallelPower n).Labeling) :
    Strategy (Fin n → Fin Φ.u) (Fin n → Fin Φ.v) (Fin n → Fin Φ.qU) (Fin n → Fin Φ.qV) :=
  (fun x => (tupleEquiv Φ.qU n).symm (A.1 (tupleEquiv Φ.u n x)),
   fun y => (tupleEquiv Φ.qV n).symm (A.2 (tupleEquiv Φ.v n y)))

theorem repetition_success_probability (Φ : LabelCover) (hc : Φ.ParallelCoherent) (n : ℕ)
    (B : Strategy (Fin n → Fin Φ.u) (Fin n → Fin Φ.v)
      (Fin n → Fin Φ.qU) (Fin n → Fin Φ.qV)) :
    (Φ.asGame.repetition n).success B = (Φ.occurrenceLaw.iid n).probability
      (fun es => decide (∀ i, Φ.projection (es i)
        (B.1 (fun j => Φ.left (es j)) i) = B.2 (fun j => Φ.right (es j)) i)) := by
  classical
  unfold Game.success
  change (((Φ.occurrenceLaw.pushforward (fun e => (Φ.left e, Φ.right e))).iid n).transport
    (Game.tupleQuestionEquiv n)).probability _ = _
  rw [FiniteDistribution.probability_transport, FiniteDistribution.iid_pushforward,
    FiniteDistribution.probability_pushforward]
  congr 1
  funext es
  simp only [Game.wins, Game.repetition, Game.tupleQuestionEquiv, asGame,
    Equiv.coe_fn_mk, questionProjection_at Φ hc, decide_eq_true_eq]

theorem power_satisfies_iff (Φ : LabelCover) (n : ℕ) (A : (Φ.parallelPower n).Labeling)
    (es : Fin n → Fin Φ.M) :
    (Φ.parallelPower n).Satisfies A (tupleEquiv Φ.M n es) ↔
      ∀ i, Φ.projection (es i)
        ((Φ.repeatedStrategy n A).1 (fun j => Φ.left (es j)) i) =
        (Φ.repeatedStrategy n A).2 (fun j => Φ.right (es j)) i := by
  simp only [Satisfies, parallelPower, repeatedStrategy, Equiv.symm_apply_apply]
  rw [← Equiv.eq_symm_apply]
  exact funext_iff

theorem repetition_success (Φ : LabelCover) (hc : Φ.ParallelCoherent) (n : ℕ)
    (A : (Φ.parallelPower n).Labeling) :
    (Φ.asGame.repetition n).success (Φ.repeatedStrategy n A) =
      ((Φ.parallelPower n).satisfiedCount A : ℝ) / (Φ.M ^ n : ℕ) := by
  classical
  let : Nonempty (Fin Φ.M) := ⟨⟨0, Φ.M_pos⟩⟩
  rw [repetition_success_probability Φ hc]
  have hlaw : Φ.occurrenceLaw.iid n = FiniteDistribution.uniform (Fin n → Fin Φ.M) :=
    FiniteDistribution.iid_uniform n
  rw [hlaw]
  simp only [← power_satisfies_iff Φ n A, FiniteDistribution.probability,
    FiniteDistribution.uniform, Fintype.card_fun, Fintype.card_fin, decide_eq_true_eq]
  calc
    _ = ∑ e : Fin (Φ.M ^ n), if (Φ.parallelPower n).Satisfies A e then
        1 / ((Φ.M ^ n : ℕ) : ℝ) else 0 :=
      Fintype.sum_equiv (tupleEquiv Φ.M n) _ _ (fun _ => rfl)
    _ = (∑ e : Fin (Φ.M ^ n), (if (Φ.parallelPower n).Satisfies A e then 1 else 0 : ℝ)) /
        (Φ.M ^ n : ℕ) := by
      rw [Finset.sum_div]
      apply Finset.sum_congr rfl
      intro e he
      split_ifs <;> simp
    _ = _ := by
      have hsum : (∑ e : Fin (Φ.parallelPower n).M,
          (@ite ℝ ((Φ.parallelPower n).Satisfies A e) (Classical.propDecidable _) 1 0)) =
          ((Φ.parallelPower n).satisfiedCount A : ℝ) := by
        rw [satisfiedCount, Finset.card_filter, Nat.cast_sum]
        apply Finset.sum_congr rfl
        intro e he
        by_cases h : (Φ.parallelPower n).Satisfies A e <;> simp only [h, ite_true, ite_false, Nat.cast_zero, Nat.cast_one]
      exact congrArg (fun x : ℝ => x / ((Φ.M ^ n : ℕ) : ℝ)) hsum

theorem power_value_le_repetition (Φ : LabelCover) (hc : Φ.ParallelCoherent) (n : ℕ) :
    (Φ.parallelPower n).value ≤
      (letI : Nonempty (Fin Φ.qU) := ⟨⟨0, Φ.qU_pos⟩⟩;
       letI : Nonempty (Fin Φ.qV) := ⟨⟨0, Φ.qV_pos⟩⟩;
       (Φ.asGame.repetition n).value) := by
  classical
  let : Nonempty (Fin Φ.qU) := ⟨⟨0, Φ.qU_pos⟩⟩
  let : Nonempty (Fin Φ.qV) := ⟨⟨0, Φ.qV_pos⟩⟩
  apply value_le_of_counts
  intro A
  have hs := (Φ.asGame.repetition n).success_le_value (Φ.repeatedStrategy n A)
  rw [repetition_success Φ hc] at hs
  exact (div_le_iff₀ (Nat.cast_pos.mpr (pow_pos Φ.M_pos n))).mp hs

end
end VertexCover.LabelCover


end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end

end OAI