File size: 7,237 Bytes
ea76aac | 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 | import Mathlib
import OAI.Computability.MaxCut.Encoding.ActualGoodRows
import OAI.Computability.MaxCut.Games.RowErasureSelection
namespace OAI
/-! The two full-table events used in the projected-witness transfer. Their
sample space contains actual occurrence tuples and complete affine tables,
but no projection choice. The selected witness depends on row advice only.
-/
namespace MaxCutGames.Decoder.ActualEvents
open Integration.BinaryLinear Reduction ActualSource Foundations.Games
open Inverse Inverse.RowErasure
open Inverse.Shortcode (Mat)
open scoped BigOperators Classical
noncomputable section
local instance homFintype {D F : Type*}
[AddCommGroup D] [Module F2 D] [AddCommGroup F] [Module F2 F]
[Fintype D] [Fintype F] : Fintype (D →ₗ[F2] F) :=
Fintype.ofInjective (fun M : D →ₗ[F2] F => (M : D → F)) DFunLike.coe_injective
abbrev Context (S : Source) (k d : ℕ) :=
ActualGame.Question S k × (ActualHomogeneous.E k →ₗ[F2] Vector d)
abbrev Sample (S : Source) (k s d r : ℕ) :=
Context S k d × (RowErasureDescriptions.RowMap s r × Mat s (1 + 2 * k))
abbrev FullTableSample (S : Source) (k s d r : ℕ) :=
(ActualGame.Question S k × (Alphabet s →ₗ[F2] Vector r)) × ActualGame.Map k s d
/-- A bijection merely rearranges the full sampled table and changes its
matrix coordinates. It never appends the hidden projection to this law. -/
def fullTableEquiv (S : Source) (k s d r : ℕ) :
FullTableSample S k s d r ≃ Sample S k s d r where
toFun p := ((p.1.1, (LinearMap.snd F2 (Alphabet s) (Vector d)).comp p.2),
(LinearMap.toMatrix' p.1.2,
MatrixCoordinates.mapEquiv k s ((LinearMap.fst F2 (Alphabet s) (Vector d)).comp p.2)))
invFun q := ((q.1.1, Matrix.toLin' q.2.1),
((MatrixCoordinates.mapEquiv k s).symm q.2.2).prod q.1.2)
left_inv p := by
rcases p with ⟨⟨U, A⟩, P⟩
apply Prod.ext
· simp
· apply LinearMap.ext
intro x
simp only [LinearEquiv.symm_apply_apply, LinearMap.prod_apply]
rfl
right_inv q := by
rcases q with ⟨⟨U, T⟩, A, M⟩
apply Prod.ext
· apply Prod.ext rfl
apply LinearMap.ext
intro x
rfl
· apply Prod.ext
· exact LinearMap.toMatrix'_toLin' A
· change MatrixCoordinates.mapEquiv k s
((LinearMap.fst F2 (Alphabet s) (Vector d)).comp
(((MatrixCoordinates.mapEquiv k s).symm M).prod T)) = M
have hf : (LinearMap.fst F2 (Alphabet s) (Vector d)).comp
(((MatrixCoordinates.mapEquiv k s).symm M).prod T) =
(MatrixCoordinates.mapEquiv k s).symm M := by
apply LinearMap.ext
intro x
rfl
rw [hf, LinearEquiv.apply_symm_apply]
def unrestricted (S : Source) (k s d r : ℕ) : FiniteDistribution (Sample S k s d r) :=
FiniteDistribution.uniform _
def sliceEvent (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s))
(α : ℝ) (p : Sample S k s d r) : Bool :=
decide ((RowErasureMatrix.family s (1 + 2 * k) r).selectedEvent
(ActualGoodRows.table S k s d labeling p.1.1 p.1.2) α p.2.1 p.2.2)
def targetHit (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s))
(α : ℝ) (p : Sample S k s d r) : Bool :=
decide ((RowErasureMatrix.family s (1 + 2 * k) r).selectedMatch
(ActualGoodRows.table S k s d labeling p.1.1 p.1.2) α p.2.1 p.2.2)
theorem targetHit_implies_slice (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s))
(α : ℝ) (p : Sample S k s d r)
(h : targetHit S k s d r labeling α p = true) :
sliceEvent S k s d r labeling α p = true := by
exact of_decide_eq_true h |> fun hm => decide_eq_true
((RowErasureMatrix.family s (1 + 2 * k) r).selectedMatch_event _ α _ _ hm)
theorem uniform_probability_expect {Ω : Type*} [Fintype Ω] [Nonempty Ω]
(p : Ω → Bool) :
(FiniteDistribution.uniform Ω).probability p =
𝔼 x : Ω, if p x then (1 : ℝ) else 0 := by
simp only [FiniteDistribution.probability, FiniteDistribution.uniform,
Fintype.expect_eq_sum_div_card, Finset.sum_div, ite_div, one_div, zero_div]
theorem unrestricted_slice_mass (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s)) (α : ℝ) :
(unrestricted S k s d r).probability (sliceEvent S k s d r labeling α) =
𝔼 q : Context S k d,
RowErasureMatrix.selectedEventMass r
(ActualGoodRows.table S k s d labeling q.1 q.2) α := by
unfold unrestricted
rw [uniform_probability_expect, ActualSpectral.expect_prod]
apply Finset.expect_congr rfl
intro q _
rw [ActualSpectral.expect_prod]
simp only [sliceEvent, RowErasureMatrix.selectedEventMass, uniformMass, indicator,
decide_eq_true_eq]
theorem unrestricted_match_mass (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s)) (α : ℝ) :
(unrestricted S k s d r).probability
(fun p => sliceEvent S k s d r labeling α p && targetHit S k s d r labeling α p) =
𝔼 q : Context S k d,
RowErasureMatrix.selectedMatchMass r
(ActualGoodRows.table S k s d labeling q.1 q.2) α := by
have he : (fun p => sliceEvent S k s d r labeling α p && targetHit S k s d r labeling α p) =
targetHit S k s d r labeling α := by
funext p
by_cases h : targetHit S k s d r labeling α p = true
· simp [h, targetHit_implies_slice S k s d r labeling α p h]
· simp [Bool.eq_false_iff.mpr h]
rw [he]
unfold unrestricted
rw [uniform_probability_expect, ActualSpectral.expect_prod]
apply Finset.expect_congr rfl
intro q _
rw [ActualSpectral.expect_prod]
simp only [targetHit, RowErasureMatrix.selectedMatchMass, uniformMass, indicator,
decide_eq_true_eq]
/-- The full-table slice event pays exactly one bounded column-fiber factor. -/
theorem slice_probability_lower (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s)) (α g₀ : ℝ)
(hgood : g₀ ≤ ActualGoodRows.adviceMass S k s d r labeling α) :
g₀ * (1 / (2 : ℝ) ^ (s * r)) ≤
(unrestricted S k s d r).probability (sliceEvent S k s d r labeling α) := by
rw [unrestricted_slice_mass]
have h := RowErasureMatrix.selectedEventMass_contextual_ge (r := r)
(fun q : Context S k d => ActualGoodRows.table S k s d labeling q.1 q.2) α g₀
(by simpa only [ActualGoodRows.adviceMass, ActualSpectral.expect_prod] using hgood)
simpa only [mul_comm] using h
theorem target_probability_lower (S : Source) (k s d r : ℕ)
(labeling : Fin (TableKeysGame.vertexCount S k s d) → Fin (2 ^ s)) (α : ℝ) :
(α / 2) * (unrestricted S k s d r).probability (sliceEvent S k s d r labeling α) ≤
(unrestricted S k s d r).probability
(fun p => sliceEvent S k s d r labeling α p && targetHit S k s d r labeling α p) := by
rw [unrestricted_slice_mass, unrestricted_match_mass]
exact RowErasureMatrix.selectedMatchMass_contextual_ge (r := r)
(fun q : Context S k d => ActualGoodRows.table S k s d labeling q.1 q.2) α
end
end MaxCutGames.Decoder.ActualEvents
end OAI
|