import Mathlib import OAI.Computability.VertexCover.Games.Value import OAI.Computability.VertexCover.Games.Conditioning import OAI.Computability.VertexCover.Repetition.Scalar 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.Repetition.SelectionSequence private theorem exists_unused {n : Nat} (S : Finset (Fin n)) (hcard : S.card < n) : ∃ j : Fin n, j ∉ S := by classical apply Classical.byContradiction intro h have hall : ∀ j : Fin n, j ∈ S := by intro j apply Classical.byContradiction intro hj exact h ⟨j, hj⟩ have hfull : S = Finset.univ := Finset.ext (fun j => iff_of_true (hall j) (Finset.mem_univ j)) have hbad : n < n := by simpa only [hfull, Finset.card_univ, Fintype.card_fin] using hcard exact Nat.lt_irrefl n hbad noncomputable def nextSet {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) (S : Finset (Fin n)) : Finset (Fin n) := if hs : S.card < n then insert (Classical.choose (witness S hs)) S else S noncomputable def selectedSet {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) : Nat → Finset (Fin n) | 0 => ∅ | m + 1 => nextSet Step witness (selectedSet Step witness m) theorem selectedSet_card {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) (m : Nat) : (selectedSet Step witness m).card = min m n := by induction m with | zero => simp [selectedSet] | succ m ih => by_cases hm : m < n · have hc : (selectedSet Step witness m).card = m := by simpa only [Nat.min_eq_left (Nat.le_of_lt hm)] using ih have hs : (selectedSet Step witness m).card < n := by simpa only [hc] using hm rw [selectedSet, nextSet, dite_eq_left hs, Finset.card_insert_of_notMem ((Classical.choose_spec (witness _ hs)).1), hc, Nat.min_eq_left (Nat.succ_le_of_lt hm)] · have hc : (selectedSet Step witness m).card = n := by simpa only [Nat.min_eq_right (Nat.le_of_not_gt hm)] using ih have hs : ¬(selectedSet Step witness m).card < n := by rw [hc] exact Nat.not_lt.mpr (Nat.le_refl n) rw [selectedSet, nextSet, dite_eq_right hs, hc, Nat.min_eq_right (Nat.le_trans (Nat.le_of_not_gt hm) (Nat.le_succ m))] theorem selectedSet_subset_succ {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) (m : Nat) : selectedSet Step witness m ⊆ selectedSet Step witness (m + 1) := by change selectedSet Step witness m ⊆ nextSet Step witness (selectedSet Step witness m) unfold nextSet split · exact Finset.subset_insert _ _ · exact le_rfl theorem selectedSet_monotone {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) : Monotone (selectedSet Step witness) := monotone_nat_of_le_succ (selectedSet_subset_succ Step witness) theorem selectedSet_univ {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) : selectedSet Step witness n = Finset.univ := by apply Finset.eq_of_subset_of_card_le (Finset.subset_univ _) simp [selectedSet_card] theorem selectedSet_step {n : Nat} (Step : Finset (Fin n) → Fin n → Prop) (witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) (m : Nat) (hm : m < n) : ∃ j, j ∉ selectedSet Step witness m ∧ selectedSet Step witness (m + 1) = insert j (selectedSet Step witness m) ∧ Step (selectedSet Step witness m) j := by have hc : (selectedSet Step witness m).card = m := by rw [selectedSet_card, Nat.min_eq_left (Nat.le_of_lt hm)] have hs : (selectedSet Step witness m).card < n := by simpa only [hc] using hm let j := Classical.choose (witness (selectedSet Step witness m) hs) have hj := Classical.choose_spec (witness (selectedSet Step witness m) hs) refine ⟨j, hj.1, ?_, hj.2⟩ simp only [selectedSet, nextSet, dite_eq_left hs, j] def SetStep {n : Nat} (P : Finset (Fin n) → ℝ) (v ell : ℝ) (S : Finset (Fin n)) (j : Fin n) : Prop := P (insert j S) ≤ P S * (v + 15 * Real.sqrt (((S.card : ℝ) * ell + logTwo (1 / P S)) / ((n : ℝ) - S.card))) theorem totalSetStep {n : Nat} (P : Finset (Fin n) → ℝ) (v ell : ℝ) (hnonneg : ∀ S, 0 ≤ P S) (hanti : Antitone P) (hpositive : ∀ S, S.card < n → 0 < P S → ∃ j, j ∉ S ∧ SetStep P v ell S j) : ∀ S, S.card < n → ∃ j, j ∉ S ∧ SetStep P v ell S j := by intro S hcard by_cases hp : 0 < P S · exact hpositive S hcard hp · obtain ⟨j, hj⟩ := exists_unused S hcard have hz : P S = 0 := le_antisymm (le_of_not_gt hp) (hnonneg S) have hnext : P (insert j S) = 0 := le_antisymm ((hanti (Finset.subset_insert j S)).trans (le_of_eq hz)) (hnonneg (insert j S)) refine ⟨j, hj, ?_⟩ simpa only [SetStep, hnext, hz, zero_mul] using (le_refl (0 : ℝ)) theorem exists_scalar_sequence {n : Nat} (P : Finset (Fin n) → ℝ) (v ell : ℝ) (hempty : P ∅ = 1) (hnonneg : ∀ S, 0 ≤ P S) (hanti : Antitone P) (hpositive : ∀ S, S.card < n → 0 < P S → ∃ j, j ∉ S ∧ SetStep P v ell S j) : ∃ p : Nat → ℝ, p 0 = 1 ∧ (∀ m, 0 ≤ p m) ∧ Antitone p ∧ ScalarRecurrence p n v ell ∧ p n = P Finset.univ := by let witness := totalSetStep P v ell hnonneg hanti hpositive let sets := selectedSet (SetStep P v ell) witness let p := fun m => P (sets m) refine ⟨p, ?_, ?_, ?_, ?_, ?_⟩ · change P (selectedSet (SetStep P v ell) witness 0) = 1 simpa only [selectedSet] using hempty · intro m exact hnonneg (sets m) · intro i j hij exact hanti (selectedSet_monotone (SetStep P v ell) witness hij) · intro m hm obtain ⟨j, _, hnext, hbound⟩ := selectedSet_step (SetStep P v ell) witness m hm have hc : (selectedSet (SetStep P v ell) witness m).card = m := by rw [selectedSet_card, Nat.min_eq_left (Nat.le_of_lt hm)] change P (selectedSet (SetStep P v ell) witness (m + 1)) ≤ _ rw [hnext] simpa only [SetStep, hc] using hbound · change P (selectedSet (SetStep P v ell) witness n) = P Finset.univ rw [selectedSet_univ] open UniqueGames.Foundations.Games section ActualGame variable {Q₁ Q₂ A₁ A₂ : Type*} variable [Fintype Q₁] [Fintype Q₂] [Fintype A₁] [Fintype A₂] variable [Nonempty A₁] [Nonempty A₂] def ConditionalCoordinateBound (G : Game Q₁ Q₂ A₁ A₂) (n : Nat) (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) (ell : ℝ) : Prop := ∀ (S : Finset (Fin n)) (_hcard : S.card < n) (hp : 0 < G.selectedSuccess strategy S), ∃ j, j ∉ S ∧ (((G.repetition n).questions.condition (G.selectedWins strategy S) hp).probability (G.coordinateWin strategy j)) ≤ G.value + 15 * Real.sqrt (((S.card : ℝ) * ell + logTwo (1 / G.selectedSuccess strategy S)) / ((n : ℝ) - S.card)) theorem repetition_success_le_of_conditionalCoordinateBound (G : Game Q₁ Q₂ A₁ A₂) (n : Nat) (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) {v ell : ℝ} (hvalue : G.value ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell) (hcoordinate : ConditionalCoordinateBound G n strategy ell) : (G.repetition n).success strategy ≤ (1 - (1 - v)^3 / 6000)^((n : ℝ) / ell) := by have hpositive : ∀ S : Finset (Fin n), S.card < n → 0 < G.selectedSuccess strategy S → ∃ j, j ∉ S ∧ SetStep (G.selectedSuccess strategy) v ell S j := by intro S hcard hp obtain ⟨j, hj, hbound⟩ := hcoordinate S hcard hp refine ⟨j, hj, ?_⟩ change G.selectedSuccess strategy (insert j S) ≤ _ rw [G.selectedSuccess_insert strategy S j hp] exact mul_le_mul_of_nonneg_left (hbound.trans (add_le_add hvalue (le_refl _))) (le_of_lt hp) obtain ⟨p, hp0, hpnonneg, hpmono, hrec, hpn⟩ := exists_scalar_sequence (G.selectedSuccess strategy) v ell (G.selectedSuccess_empty strategy) (G.selectedSuccess_nonnegative strategy) (G.selectedSuccess_antitone strategy) hpositive have hbound := scalar_bound_6000 p n (G.value_nonnegative.trans hvalue) hv1 hell hp0 hpnonneg hpmono hrec rw [hpn, G.selectedSuccess_univ strategy] at hbound exact hbound end ActualGame end UniqueGames.Foundations.Repetition.SelectionSequence 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