File size: 5,422 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 | import Mathlib
import OAI.Computability.VertexCover.Sampling.TraceLaw
import OAI.Computability.VertexCover.Sampling.Rectangle
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
namespace UniqueGames.Foundations.CorrelatedSampling
noncomputable section
variable {σ α : Type*} [Fintype σ] [DecidableEq σ] [DecidableEq α]
def localSample (accept : σ → Bool) (decode : σ → α) (fallback : α)
(proposals : List σ) : α :=
((firstAccepted accept proposals).map decode).getD fallback
def localDiagonal (left right : σ → Bool) (decode : σ → α) (fallback a : α)
(proposals : List σ) : ℝ :=
if localSample left decode fallback proposals = a ∧
localSample right decode fallback proposals = a then 1 else 0
def goodLabel (left right : σ → Bool) (decode : σ → α) (a : α) (s : σ) : Bool :=
(left s && right s) && decide (decode s = a)
omit [Fintype σ] [DecidableEq σ] in
theorem common_first_label_lower (left right : σ → Bool) (decode : σ → α)
(fallback a : α) (proposals : List σ) :
goodFirstIndicator (fun s => left s || right s) (goodLabel left right decode a) proposals ≤
localDiagonal left right decode fallback a proposals := by
cases hfirst : firstAccepted (fun s => left s || right s) proposals with
| none =>
simp only [goodFirstIndicator, hfirst]
unfold localDiagonal
split_ifs <;> norm_num
| some s =>
by_cases hc : goodLabel left right decode a s = true
· have hparts : (left s = true ∧ right s = true) ∧ decode s = a := by
simpa [goodLabel] using hc
have h := first_union_common left right proposals s hfirst hparts.1.1 hparts.1.2
simp [goodFirstIndicator, hfirst, hc, localDiagonal, localSample, h.1, h.2, hparts.2]
· have hn : 0 ≤ localDiagonal left right decode fallback a proposals := by
unfold localDiagonal
split_ifs <;> norm_num
simpa [goodFirstIndicator, hfirst, hc] using hn
omit [DecidableEq σ] in theorem union_goodLabel_mass
(w : σ → ℝ) (left right : σ → Bool) (decode : σ → α) (a : α) :
eventMass w (fun s => (left s || right s) && goodLabel left right decode a s) =
eventMass w (goodLabel left right decode a) := by
unfold eventMass
apply Finset.sum_congr rfl
intro s _
cases hl : left s <;> cases hr : right s <;> simp [goodLabel, hl, hr]
theorem finite_label_diagonal_bound (w : σ → ℝ) (left right : σ → Bool)
(decode : σ → α) (fallback a : α) (hw : ∀ s, 0 ≤ w s)
(hw_sum : ∑ s, w s = 1) (hu : 0 < eventMass w (fun s => left s || right s)) (n : Nat) :
eventMass w (goodLabel left right decode a) / eventMass w (fun s => left s || right s) *
(1 - eventMass w (fun s => !(left s || right s)) ^ n) ≤
traceAverage w n (localDiagonal left right decode fallback a) := by
have h := traceAverage_mono w hw n _ _ (common_first_label_lower left right decode fallback a)
rw [goodFirstIndicator_law w _ _ hw_sum n,
goodFirstMass_exact w _ _ hw_sum (ne_of_gt hu) n,
union_goodLabel_mass] at h
exact h
section Rectangle
variable [Fintype α] [Nonempty α]
theorem rectangle_label_diagonal_bound (thresholds : List ℝ) (p q : α → ℝ)
(fallback a : α)
(hpm : ∀ x, p x ∈ thresholds) (hqm : ∀ x, q x ∈ thresholds)
(hp0 : ∀ x, 0 ≤ p x) (hq0 : ∀ x, 0 ≤ q x)
(hp1 : ∀ x, p x ≤ 1) (hq1 : ∀ x, q x ≤ 1)
(hpsum : ∑ x, p x = 1) (hqsum : ∑ x, q x = 1) (n : Nat) :
min (p a) (q a) / (1 + totalVariation p q) *
(1 - eventMass (rectangleWeight thresholds)
(fun s => !(rectangleAccept thresholds p s || rectangleAccept thresholds q s)) ^ n) ≤
traceAverage (rectangleWeight thresholds) n
(localDiagonal (rectangleAccept thresholds p) (rectangleAccept thresholds q)
Prod.fst fallback a) := by
have hc : 0 < (Fintype.card α : ℝ) := by exact_mod_cast Fintype.card_pos
have hU : 0 < unionMass p q := by
rw [unionMass_eq p q hpsum hqsum]
linarith [totalVariation_nonneg p q]
have hmass := rectangle_union_mass thresholds p q hpm hqm hp0 hq0 hp1 hq1
have hu : 0 < eventMass (rectangleWeight thresholds)
(fun s => rectangleAccept thresholds p s || rectangleAccept thresholds q s) := by
rw [hmass]
exact div_pos hU hc
have h := finite_label_diagonal_bound (rectangleWeight thresholds)
(rectangleAccept thresholds p) (rectangleAccept thresholds q) Prod.fst fallback a
(rectangleWeight_nonnegative thresholds) (rectangleWeight_normalized thresholds) hu n
unfold goodLabel at h
rw [rectangle_common_label_mass thresholds p q a hpm hqm hp0 hq0 hp1 hq1, hmass] at h
have hratio : (min (p a) (q a) / (Fintype.card α : ℝ)) /
(unionMass p q / (Fintype.card α : ℝ)) = min (p a) (q a) / unionMass p q := by
field_simp
rw [hratio, unionMass_eq p q hpsum hqsum] at h
exact h
end Rectangle
end
end UniqueGames.Foundations.CorrelatedSampling
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
|