Download data/lean/OAI/Computability/MeanPayoff/FiniteBox.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 41.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MeanPayoff/FiniteBox.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MeanPayoff/FiniteBox.lean
-
curl -L -o FiniteBox.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MeanPayoff/FiniteBox.lean
41.6 kB
| import OAI.Computability.MeanPayoff.Probability | |
| namespace OAI | |
| section | |
| namespace MeanPayoff | |
| abbrev Vec (V : Type) := V β β€ | |
| def shift {V : Type} (p : Vec V) (c : β€) : Vec V := fun i => p i + c | |
| def clip {V : Type} (a b p : Vec V) : Vec V := | |
| fun i => min (b i) (max (a i) (p i)) | |
| def InBox {V : Type} (a b p : Vec V) : Prop := a β€ p β§ p β€ b | |
| def Subsolution {V : Type} (F : Vec V β Vec V) (a b y : Vec V) : Prop := | |
| InBox a b y β§ β i, a i < y i β y i β€ F y i | |
| def Supersolution {V : Type} (F : Vec V β Vec V) (a b z : Vec V) : Prop := | |
| InBox a b z β§ β i, z i < b i β F z i β€ z i | |
| def subSupport {V : Type} (a y : Vec V) : Set V := {i | a i < y i} | |
| def superSupport {V : Type} (b z : Vec V) : Set V := {i | z i < b i} | |
| structure OperatorLaws {V : Type} (F : Vec V β Vec V) : Prop where | |
| mono : Monotone F | |
| translation : β p c, F (shift p c) = shift (F p) c | |
| def transformed (G : Game) (e : Fin G.m) : β€ := (G.n + 1 : β€) * G.weight e + 1 | |
| def outgoing (G : Game) (v : Fin G.n) : Finset (Fin G.m) := | |
| Finset.univ.filter (fun e => G.tail e = v) | |
| theorem outgoing_nonempty (G : Game) (v : Fin G.n) : (outgoing G v).Nonempty := by | |
| obtain β¨e, heβ© := G.total v | |
| exact β¨e, by simp [outgoing, he]β© | |
| def operator (G : Game) (p : Vec (Fin G.n)) : Vec (Fin G.n) := fun i => | |
| if G.maxOwner i then | |
| (outgoing G i).sup' (outgoing_nonempty G i) (fun e => transformed G e + p (G.head e)) | |
| else | |
| (outgoing G i).inf' (outgoing_nonempty G i) (fun e => transformed G e + p (G.head e)) | |
| theorem operator_laws (G : Game) : OperatorLaws (operator G) := by | |
| constructor | |
| Β· intro p q hpq i | |
| simp only [operator] | |
| split | |
| Β· apply (Finset.sup'_le_iff _ _).2 | |
| intro e he | |
| exact le_trans (add_le_add_right (hpq (G.head e)) _) | |
| (Finset.le_sup' (fun e => transformed G e + q (G.head e)) he) | |
| Β· apply (Finset.le_inf'_iff _ _).2 | |
| intro e he | |
| exact le_trans (Finset.inf'_le (fun e => transformed G e + p (G.head e)) he) | |
| (add_le_add_right (hpq (G.head e)) _) | |
| Β· intro p c | |
| funext i | |
| simp only [operator, shift] | |
| split | |
| Β· simpa only [add_assoc] using | |
| (Finset.sup'_add (outgoing G i) | |
| (fun e => transformed G e + p (G.head e)) c (outgoing_nonempty G i)).symm | |
| Β· obtain β¨e, he, heqβ© := Finset.exists_mem_eq_inf' (outgoing_nonempty G i) | |
| (fun e => transformed G e + p (G.head e)) | |
| obtain β¨f, hf, hfqβ© := Finset.exists_mem_eq_inf' (outgoing_nonempty G i) | |
| (fun e => transformed G e + (p (G.head e) + c)) | |
| have hlo := Finset.inf'_le (fun e => transformed G e + p (G.head e)) hf | |
| have hup := Finset.inf'_le (fun e => transformed G e + (p (G.head e) + c)) he | |
| rw [heq] at hlo β’ | |
| rw [hfq] at hup β’ | |
| omega | |
| section Projections | |
| variable {V : Type} {F : Vec V β Vec V} | |
| theorem subsolution_raise_floor (laws : OperatorLaws F) {a b a' y : Vec V} | |
| (hy : Subsolution F a b y) (haa' : a β€ a') (ha'b : a' β€ b) : | |
| Subsolution F a' b (fun i => max (y i) (a' i)) β§ | |
| subSupport a' (fun i => max (y i) (a' i)) β subSupport a y := by | |
| refine β¨β¨β¨?_, ?_β©, ?_β©, ?_β© | |
| Β· intro i; exact le_max_right _ _ | |
| Β· intro i; exact max_le (hy.1.2 i) (ha'b i) | |
| Β· intro i hi | |
| have hiy : a' i < y i := by simpa using hi | |
| have heq : max (y i) (a' i) = y i := max_eq_left (le_of_lt hiy) | |
| dsimp only | |
| rw [heq] | |
| exact le_trans (hy.2 i (lt_of_le_of_lt (haa' i) hiy)) | |
| (laws.mono (fun j => le_max_left (y j) (a' j)) i) | |
| Β· intro i hi | |
| have hiy : a' i < y i := by simpa [subSupport] using hi | |
| exact lt_of_le_of_lt (haa' i) hiy | |
| theorem supersolution_lower_ceiling (laws : OperatorLaws F) {a b b' z : Vec V} | |
| (hz : Supersolution F a b z) (hab' : a β€ b') (hb'b : b' β€ b) : | |
| Supersolution F a b' (fun i => min (z i) (b' i)) β§ | |
| superSupport b' (fun i => min (z i) (b' i)) β superSupport b z := by | |
| refine β¨β¨β¨?_, ?_β©, ?_β©, ?_β© | |
| Β· intro i; exact le_min (hz.1.1 i) (hab' i) | |
| Β· intro i; exact min_le_right _ _ | |
| Β· intro i hi | |
| have hiz : z i < b' i := by simpa using hi | |
| have heq : min (z i) (b' i) = z i := min_eq_left (le_of_lt hiz) | |
| dsimp only | |
| rw [heq] | |
| exact le_trans (laws.mono (fun j => min_le_left (z j) (b' j)) i) | |
| (hz.2 i (lt_of_lt_of_le hiz (hb'b i))) | |
| Β· intro i hi | |
| have hiz : z i < b' i := by simpa [superSupport] using hi | |
| exact lt_of_lt_of_le hiz (hb'b i) | |
| def centerSub (y q : Vec V) (d A : β€) : Vec V := | |
| fun i => max (y i - d + A) (q i - A) | |
| def centerSuper (z q : Vec V) (e A : β€) : Vec V := | |
| fun i => min (z i + e - A) (q i + A) | |
| theorem centerSub_support (y q : Vec V) (d A : β€) : | |
| subSupport (fun i => q i - A) (centerSub y q d A) = | |
| {i | d - 2 * A < y i - q i} := by | |
| ext i | |
| simp only [subSupport, centerSub, Set.mem_ofPred_eq, lt_max_iff, lt_self_iff_false, | |
| or_false] | |
| omega | |
| theorem centerSuper_support (z q : Vec V) (e A : β€) : | |
| superSupport (fun i => q i + A) (centerSuper z q e A) = | |
| {i | e - 2 * A < q i - z i} := by | |
| ext i | |
| simp only [superSupport, centerSuper, Set.mem_ofPred_eq, min_lt_iff, | |
| lt_self_iff_false, or_false] | |
| omega | |
| theorem centered_subsolution (laws : OperatorLaws F) {a b y q : Vec V} {d A : β€} | |
| (hy : Subsolution F a b y) (hq : InBox a b q) | |
| (hA : 0 < A) (hdev : β i, y i - q i β€ d) (hd : 2 * A β€ d) : | |
| Subsolution F (fun i => q i - A) (fun i => q i + A) (centerSub y q d A) β§ | |
| subSupport (fun i => q i - A) (centerSub y q d A) β subSupport a y := by | |
| have hs : subSupport (fun i => q i - A) (centerSub y q d A) β | |
| subSupport a y := by | |
| rw [centerSub_support] | |
| intro i hi | |
| have hqi : a i β€ q i := hq.1 i | |
| change a i < y i | |
| change d - 2 * A < y i - q i at hi | |
| omega | |
| refine β¨β¨β¨?_, ?_β©, ?_β©, hsβ© | |
| Β· intro i; exact le_max_right _ _ | |
| Β· intro i | |
| change max (y i - d + A) (q i - A) β€ q i + A | |
| apply max_le | |
| Β· have := hdev i; omega | |
| Β· omega | |
| Β· intro i hi | |
| have hiy : y i β€ F y i := hy.2 i (hs hi) | |
| have hlarge : q i - A < y i - d + A := by | |
| simpa only [centerSub, lt_max_iff, lt_self_iff_false, or_false] using hi | |
| have heq : centerSub y q d A i = y i - d + A := | |
| max_eq_left (le_of_lt hlarge) | |
| rw [heq] | |
| have hmono : F (shift y (-d + A)) i β€ F (centerSub y q d A) i := by | |
| apply laws.mono | |
| intro j | |
| have := le_max_left (y j - d + A) (q j - A) | |
| simp [shift, centerSub, sub_eq_add_neg, add_assoc] | |
| rw [laws.translation] at hmono | |
| simp only [shift] at hmono | |
| omega | |
| theorem centered_supersolution (laws : OperatorLaws F) {a b z q : Vec V} {e A : β€} | |
| (hz : Supersolution F a b z) (hq : InBox a b q) | |
| (hA : 0 < A) (hdev : β i, q i - z i β€ e) (he : 2 * A β€ e) : | |
| Supersolution F (fun i => q i - A) (fun i => q i + A) (centerSuper z q e A) β§ | |
| superSupport (fun i => q i + A) (centerSuper z q e A) β superSupport b z := by | |
| have hs : superSupport (fun i => q i + A) (centerSuper z q e A) β | |
| superSupport b z := by | |
| rw [centerSuper_support] | |
| intro i hi | |
| have hqi : q i β€ b i := hq.2 i | |
| change z i < b i | |
| change e - 2 * A < q i - z i at hi | |
| omega | |
| refine β¨β¨β¨?_, ?_β©, ?_β©, hsβ© | |
| Β· intro i | |
| change q i - A β€ min (z i + e - A) (q i + A) | |
| apply le_min | |
| Β· have := hdev i; omega | |
| Β· omega | |
| Β· intro i; exact min_le_right _ _ | |
| Β· intro i hi | |
| have hiz : F z i β€ z i := hz.2 i (hs hi) | |
| have hsmall : z i + e - A < q i + A := by | |
| simpa only [centerSuper, min_lt_iff, lt_self_iff_false, or_false] using hi | |
| have heq : centerSuper z q e A i = z i + e - A := | |
| min_eq_left (le_of_lt hsmall) | |
| rw [heq] | |
| have hmono : F (centerSuper z q e A) i β€ F (shift z (e - A)) i := by | |
| apply laws.mono | |
| intro j | |
| have := min_le_left (z j + e - A) (q j + A) | |
| simp [shift, centerSuper, sub_eq_add_neg, add_assoc] | |
| rw [laws.translation] at hmono | |
| simp only [shift] at hmono | |
| omega | |
| end Projections | |
| def averageStep {V : Type} (a b rβ rβ : Vec V) : Vec V := | |
| clip a b (fun i => (rβ i + rβ i) / 2) | |
| theorem high_deviation_step {V : Type} {a b y q rβ rβ : Vec V} {d D : β€} | |
| (hyb : y β€ b) (hD : 0 < D) (hd : 2 * D β€ d) | |
| (hdev : β i, y i - q i β€ d) | |
| (hrβ : β i, q i - D β€ rβ i) | |
| (hrβ : centerSub y q d D β€ rβ) : | |
| β i, y i - averageStep a b rβ rβ i β€ d := by | |
| intro i | |
| have hq := hdev i | |
| have h1 := hrβ i | |
| have h2 := le_trans (le_max_left (y i - d + D) (q i - D)) (hrβ i) | |
| have hb : y i β€ b i := hyb i | |
| have havg : y i - d β€ (rβ i + rβ i) / 2 := by omega | |
| have hclip : y i - d β€ min (b i) (max (a i) ((rβ i + rβ i) / 2)) := | |
| le_min (by omega) (le_trans havg (le_max_right _ _)) | |
| change y i - min (b i) (max (a i) ((rβ i + rβ i) / 2)) β€ d | |
| omega | |
| theorem high_bad_step {V : Type} {a b y q rβ rβ : Vec V} {d D : β€} | |
| (hyb : y β€ b) (hD : 0 < D) (hd : 2 * D β€ d) | |
| (hrβ : centerSub y q d D β€ rβ) (hrβ : centerSub y q d D β€ rβ) : | |
| β i, y i - averageStep a b rβ rβ i β€ d - D := by | |
| intro i | |
| have h1 := le_trans (le_max_left (y i - d + D) (q i - D)) (hrβ i) | |
| have h2 := le_trans (le_max_left (y i - d + D) (q i - D)) (hrβ i) | |
| have hb : y i β€ b i := hyb i | |
| have havg : y i - d + D β€ (rβ i + rβ i) / 2 := by omega | |
| have hclip : y i - d + D β€ min (b i) (max (a i) ((rβ i + rβ i) / 2)) := | |
| le_min (by omega) (le_trans havg (le_max_right _ _)) | |
| change y i - min (b i) (max (a i) ((rβ i + rβ i) / 2)) β€ d - D | |
| omega | |
| theorem low_deviation_step {V : Type} {a b z q rβ rβ : Vec V} {e D : β€} | |
| (haz : a β€ z) (hD : 0 < D) (he : 2 * D β€ e) | |
| (hdev : β i, q i - z i β€ e) | |
| (hrβ : rβ β€ centerSuper z q e D) | |
| (hrβ : β i, rβ i β€ q i + D) : | |
| β i, averageStep a b rβ rβ i - z i β€ e := by | |
| intro i | |
| have hq := hdev i | |
| have h1 : rβ i β€ z i + e - D := le_trans (hrβ i) (min_le_left (z i + e - D) (q i + D)) | |
| have h2 := hrβ i | |
| have ha : a i β€ z i := haz i | |
| have havg : (rβ i + rβ i) / 2 β€ z i + e := by omega | |
| have hclip : min (b i) (max (a i) ((rβ i + rβ i) / 2)) β€ z i + e := | |
| le_trans (min_le_right _ _) (max_le (by omega) havg) | |
| change min (b i) (max (a i) ((rβ i + rβ i) / 2)) - z i β€ e | |
| omega | |
| theorem low_bad_step {V : Type} {a b z q rβ rβ : Vec V} {e D : β€} | |
| (haz : a β€ z) (hD : 0 < D) (he : 2 * D β€ e) | |
| (hrβ : rβ β€ centerSuper z q e D) (hrβ : rβ β€ centerSuper z q e D) : | |
| β i, averageStep a b rβ rβ i - z i β€ e - D := by | |
| intro i | |
| have h1 : rβ i β€ z i + e - D := le_trans (hrβ i) (min_le_left (z i + e - D) (q i + D)) | |
| have h2 : rβ i β€ z i + e - D := le_trans (hrβ i) (min_le_left (z i + e - D) (q i + D)) | |
| have ha : a i β€ z i := haz i | |
| have havg : (rβ i + rβ i) / 2 β€ z i + e - D := by omega | |
| have hclip : min (b i) (max (a i) ((rβ i + rβ i) / 2)) β€ z i + e - D := | |
| le_trans (min_le_right _ _) (max_le (by omega) havg) | |
| change min (b i) (max (a i) ((rβ i + rβ i) / 2)) - z i β€ e - D | |
| omega | |
| theorem no_tight_sequence (G : Game) (p : Vec (Fin G.n)) | |
| (v : β β Fin G.n) (w : β β β€) | |
| (h : β k, p (v k) = (G.n + 1 : β€) * w k + 1 + p (v (k + 1))) : False := by | |
| have hmod : β k : β, | |
| p (v k) + (k : β€) β‘ p (v 0) [ZMOD (G.n + 1 : β€)] := by | |
| intro k | |
| induction k with | |
| | zero => simp | |
| | succ k ih => | |
| apply Int.ModEq.trans _ ih | |
| apply Int.modEq_iff_dvd.mpr | |
| use w k | |
| have hk := h k | |
| push_cast | |
| linarith | |
| have hinj : Function.Injective (fun k : Fin (G.n + 1) => v k.val) := by | |
| intro i j hij | |
| change v i.val = v j.val at hij | |
| apply Fin.ext | |
| have hm := (hmod i.val).trans (hmod j.val).symm | |
| rw [hij] at hm | |
| have hc := Int.ModEq.add_left_cancel' (p (v j.val)) hm | |
| have hn : i.val β‘ j.val [MOD (G.n + 1)] := | |
| Int.natCast_modEq_iff.mp (by simpa only [Nat.cast_add, Nat.cast_one] using hc) | |
| exact hn.eq_of_lt_of_lt i.isLt j.isLt | |
| have hc := Fintype.card_le_of_injective _ hinj | |
| simp only [Fintype.card_fin] at hc | |
| omega | |
| theorem comparison_step (G : Game) {a b y z : Vec (Fin G.n)} | |
| (hy : Subsolution (operator G) a b y) | |
| (hz : Supersolution (operator G) a b z) | |
| {d : β€} (hd : 0 < d) (hdev : β j, y j - z j β€ d) | |
| (i : Fin G.n) (hi : y i - z i = d) : | |
| β e : Fin G.m, G.tail e = i β§ | |
| y (G.head e) - z (G.head e) = d β§ | |
| y i = transformed G e + y (G.head e) := by | |
| have hay : a i < y i := by have hzi : a i β€ z i := hz.1.1 i; omega | |
| have hzb : z i < b i := by have hyi : y i β€ b i := hy.1.2 i; omega | |
| have hys := hy.2 i hay | |
| have hzs := hz.2 i hzb | |
| have hmono : operator G y i β€ operator G z i + d := by | |
| have hm := (operator_laws G).mono (a := y) (b := shift z d) | |
| (fun j => by have := hdev j; dsimp [shift]; omega) i | |
| rw [(operator_laws G).translation] at hm | |
| exact hm | |
| have hyeq : y i = operator G y i := by omega | |
| have hzeq : z i = operator G z i := by omega | |
| by_cases ho : G.maxOwner i = true | |
| Β· obtain β¨e, he, heqβ© := Finset.exists_mem_eq_sup' (outgoing_nonempty G i) | |
| (fun e => transformed G e + y (G.head e)) | |
| have htail : G.tail e = i := (Finset.mem_filter.mp he).2 | |
| have hye : y i = transformed G e + y (G.head e) := by | |
| rw [hyeq, operator, ite_eq_left ho]; exact heq | |
| have hzle : transformed G e + z (G.head e) β€ z i := by | |
| rw [hzeq, operator, ite_eq_left ho] | |
| exact Finset.le_sup' (fun e => transformed G e + z (G.head e)) he | |
| exact β¨e, htail, by have := hdev (G.head e); omega, hyeβ© | |
| Β· obtain β¨e, he, heqβ© := Finset.exists_mem_eq_inf' (outgoing_nonempty G i) | |
| (fun e => transformed G e + z (G.head e)) | |
| have htail : G.tail e = i := (Finset.mem_filter.mp he).2 | |
| have hze : z i = transformed G e + z (G.head e) := by | |
| rw [hzeq, operator, ite_eq_right ho]; exact heq | |
| have hyle : y i β€ transformed G e + y (G.head e) := by | |
| rw [hyeq, operator, ite_eq_right ho] | |
| exact Finset.inf'_le (fun e => transformed G e + y (G.head e)) he | |
| have hj := hdev (G.head e) | |
| exact β¨e, htail, by omega, by omegaβ© | |
| theorem box_comparison (G : Game) {a b y z : Vec (Fin G.n)} | |
| (hy : Subsolution (operator G) a b y) | |
| (hz : Supersolution (operator G) a b z) : y β€ z := by | |
| classical | |
| let : Nonempty (Fin G.n) := β¨β¨0, G.positiveβ©β© | |
| let d : β€ := Finset.univ.sup' Finset.univ_nonempty (fun i => y i - z i) | |
| have hdev : β i, y i - z i β€ d := fun i => | |
| Finset.le_sup' (fun j => y j - z j) (Finset.mem_univ i) | |
| by_contra h | |
| change Β¬ (β i, y i β€ z i) at h | |
| obtain β¨k, hkβ© := not_forall.mp h | |
| have hd : 0 < d := by have := hdev k; omega | |
| obtain β¨v, _, hvβ© := Finset.exists_mem_eq_sup' (Finset.univ_nonempty (Ξ± := Fin G.n)) | |
| (fun i => y i - z i) | |
| let S := {i : Fin G.n // y i - z i = d} | |
| let sβ : S := β¨v, hv.symmβ© | |
| have hs : β s : S, β e : Fin G.m, G.tail e = s.val β§ | |
| y (G.head e) - z (G.head e) = d β§ | |
| y s.val = transformed G e + y (G.head e) := | |
| fun s => comparison_step G hy hz hd hdev s.val s.property | |
| choose edge hedge using hs | |
| let next : S β S := fun s => β¨G.head (edge s), (hedge s).2.1β© | |
| let path : β β S := fun k => next^[k] sβ | |
| apply no_tight_sequence G y (fun k => (path k).val) | |
| (fun k => G.weight (edge (path k))) | |
| intro k | |
| have heq := (hedge (path k)).2.2 | |
| simpa only [path, Function.iterate_succ_apply', next, transformed] using heq | |
| def boxStep {V : Type} (F : Vec V β Vec V) (a b p : Vec V) : Vec V := | |
| clip a b (F p) | |
| theorem boxStep_in_box {V : Type} (F : Vec V β Vec V) | |
| {a b : Vec V} (hab : a β€ b) (p : Vec V) : InBox a b (boxStep F a b p) := by | |
| constructor | |
| Β· intro i | |
| exact le_min (hab i) (le_max_left _ _) | |
| Β· intro i; exact min_le_left _ _ | |
| theorem boxStep_mono {V : Type} {F : Vec V β Vec V} (hF : Monotone F) | |
| (a b : Vec V) : Monotone (boxStep F a b) := by | |
| intro p q hpq i | |
| exact min_le_min_left _ (max_le_max_left _ (hF hpq i)) | |
| theorem fixed_iff_comparisons {V : Type} (F : Vec V β Vec V) | |
| {a b p : Vec V} (hab : a β€ b) : | |
| boxStep F a b p = p β Subsolution F a b p β§ Supersolution F a b p := by | |
| constructor | |
| Β· intro heq | |
| have hp := boxStep_in_box F hab p | |
| rw [heq] at hp | |
| have hc : β i, min (b i) (max (a i) (F p i)) = p i := congrFun heq | |
| constructor | |
| Β· refine β¨hp, ?_β© | |
| intro i hi | |
| have := hc i | |
| omega | |
| Β· refine β¨hp, ?_β© | |
| intro i hi | |
| have := hc i | |
| omega | |
| Β· rintro β¨hy, hzβ© | |
| funext i | |
| have ha : a i β€ p i := hy.1.1 i | |
| have hb : p i β€ b i := hy.1.2 i | |
| have hs := hy.2 i | |
| have ht := hz.2 i | |
| change min (b i) (max (a i) (F p i)) = p i | |
| omega | |
| def volume {n : β} (b p : Vec (Fin n)) : β := β i, (b i - p i).toNat | |
| theorem volume_decreases {n : β} {b p q : Vec (Fin n)} | |
| (hpq : p β€ q) (hqb : q β€ b) (hne : p β q) : volume b q < volume b p := by | |
| apply Finset.sum_lt_sum | |
| Β· intro i _ | |
| exact Int.toNat_le_toNat (sub_le_sub_left (hpq i) _) | |
| Β· have hx : β i, p i β q i := Function.ne_iff.mp hne | |
| obtain β¨i, hiβ© := hx | |
| have hpi : p i β€ q i := hpq i | |
| have hqi : q i β€ b i := hqb i | |
| refine β¨i, Finset.mem_univ i, ?_β© | |
| apply (Int.toNat_lt_toNat (by omega)).mpr | |
| omega | |
| def basicFrom {n : β} (F : Vec (Fin n) β Vec (Fin n)) (hF : Monotone F) | |
| (a b : Vec (Fin n)) (hab : a β€ b) (p : Vec (Fin n)) | |
| (hp : InBox a b p) (hinc : p β€ boxStep F a b p) : | |
| {r : Vec (Fin n) Γ β // InBox a b r.1 β§ boxStep F a b r.1 = r.1 β§ | |
| r.2 β€ volume b p + 1} := by | |
| by_cases heq : boxStep F a b p = p | |
| Β· exact β¨(p, 1), hp, heq, by omegaβ© | |
| Β· have hq := boxStep_in_box F hab p | |
| have hnext : boxStep F a b p β€ boxStep F a b (boxStep F a b p) := | |
| boxStep_mono hF a b hinc | |
| have hvol : volume b (boxStep F a b p) < volume b p := | |
| volume_decreases hinc hq.2 (Ne.symm heq) | |
| let r := basicFrom F hF a b hab (boxStep F a b p) hq hnext | |
| exact β¨(r.val.1, r.val.2 + 1), r.property.1, r.property.2.1, by | |
| have := r.property.2.2; dsimp only; omegaβ© | |
| termination_by volume b p | |
| def basic (G : Game) (a b : Vec (Fin G.n)) (hab : a β€ b) : Vec (Fin G.n) Γ β := | |
| (basicFrom (operator G) (operator_laws G).mono a b hab a | |
| β¨le_refl a, habβ© (boxStep_in_box (operator G) hab a).1).val | |
| theorem basic_spec (G : Game) (a b : Vec (Fin G.n)) (hab : a β€ b) : | |
| Subsolution (operator G) a b (basic G a b hab).1 β§ | |
| Supersolution (operator G) a b (basic G a b hab).1 β§ | |
| (basic G a b hab).2 β€ volume b a + 1 := by | |
| have h := (basicFrom (operator G) (operator_laws G).mono a b hab a | |
| β¨le_refl a, habβ© (boxStep_in_box (operator G) hab a).1).property | |
| have hc := (fixed_iff_comparisons (operator G) hab).mp h.2.1 | |
| exact β¨hc.1, hc.2, h.2.2β© | |
| theorem box_solution_exists_unique (G : Game) (a b : Vec (Fin G.n)) (hab : a β€ b) : | |
| β! x, Subsolution (operator G) a b x β§ Supersolution (operator G) a b x := by | |
| refine β¨(basic G a b hab).1, β¨(basic_spec G a b hab).1, | |
| (basic_spec G a b hab).2.1β©, ?_β© | |
| intro y hy | |
| apply le_antisymm | |
| Β· exact box_comparison G hy.1 (basic_spec G a b hab).2.1 | |
| Β· exact box_comparison G (basic_spec G a b hab).1 hy.2 | |
| theorem no_tight_segment (G : Game) (p : Vec (Fin G.n)) | |
| (v : β β Fin G.n) (w : β β β€) | |
| (h : β k < G.n, p (v k) = (G.n + 1 : β€) * w k + 1 + p (v (k + 1))) : False := by | |
| have hmod : β k : β, k β€ G.n β | |
| p (v k) + (k : β€) β‘ p (v 0) [ZMOD (G.n + 1 : β€)] := by | |
| intro k | |
| induction k with | |
| | zero => intro _; simp | |
| | succ k ih => | |
| intro hk | |
| apply Int.ModEq.trans _ (ih (by omega)) | |
| apply Int.modEq_iff_dvd.mpr | |
| use w k | |
| have hstep := h k (by omega) | |
| push_cast | |
| linarith | |
| have hinj : Function.Injective (fun k : Fin (G.n + 1) => v k.val) := by | |
| intro i j hij | |
| change v i.val = v j.val at hij | |
| apply Fin.ext | |
| have hm := (hmod i.val (by omega)).trans (hmod j.val (by omega)).symm | |
| rw [hij] at hm | |
| have hc := Int.ModEq.add_left_cancel' (p (v j.val)) hm | |
| have hn : i.val β‘ j.val [MOD (G.n + 1)] := | |
| Int.natCast_modEq_iff.mp (by simpa only [Nat.cast_add, Nat.cast_one] using hc) | |
| exact hn.eq_of_lt_of_lt i.isLt j.isLt | |
| have hc := Fintype.card_le_of_injective _ hinj | |
| simp only [Fintype.card_fin] at hc | |
| omega | |
| theorem operator_attained (G : Game) (p : Vec (Fin G.n)) (i : Fin G.n) : | |
| β e : Fin G.m, G.tail e = i β§ operator G p i = transformed G e + p (G.head e) := by | |
| by_cases ho : G.maxOwner i = true | |
| Β· obtain β¨e, he, heqβ© := Finset.exists_mem_eq_sup' (outgoing_nonempty G i) | |
| (fun e => transformed G e + p (G.head e)) | |
| exact β¨e, (Finset.mem_filter.mp he).2, by simpa [operator, ho] using heqβ© | |
| Β· obtain β¨e, he, heqβ© := Finset.exists_mem_eq_inf' (outgoing_nonempty G i) | |
| (fun e => transformed G e + p (G.head e)) | |
| exact β¨e, (Finset.mem_filter.mp he).2, by simpa [operator, ho] using heqβ© | |
| theorem solution_near_boundary (G : Game) {x : Vec (Fin G.n)} {B W : β€} | |
| (hW : 0 β€ W) (hweights : β e, |transformed G e| β€ W) | |
| (hx : Subsolution (operator G) (fun _ => 0) (fun _ => B) x β§ | |
| Supersolution (operator G) (fun _ => 0) (fun _ => B) x) : | |
| β i, x i β€ G.n * W β¨ B - G.n * W β€ x i := by | |
| classical | |
| choose edge hedge using operator_attained G x | |
| let next : Fin G.n β Fin G.n := fun i => | |
| if 0 < x i β§ x i < B then G.head (edge i) else i | |
| have hstep : β i, |x (next i) - x i| β€ W := by | |
| intro i | |
| by_cases hi : 0 < x i β§ x i < B | |
| Β· have hsub := hx.1.2 i hi.1 | |
| have hsuper := hx.2.2 i hi.2 | |
| have he := (hedge i).2 | |
| have hw := hweights (edge i) | |
| simp only [next, ite_eq_left hi] | |
| rw [show x (G.head (edge i)) - x i = -transformed G (edge i) by omega, | |
| abs_neg] | |
| exact hw | |
| Β· simp only [next, ite_eq_right hi, sub_self, abs_zero]; exact hW | |
| intro start | |
| let path : β β Fin G.n := fun k => next^[k] start | |
| have hmove : β k, |x (path k) - x start| β€ k * W := by | |
| intro k | |
| induction k with | |
| | zero => simp [path] | |
| | succ k ih => | |
| have hs := hstep (path k) | |
| have hp : path (k + 1) = next (path k) := Function.iterate_succ_apply' next k start | |
| rw [β hp] at hs | |
| calc | |
| |x (path (k + 1)) - x start| = | |
| |(x (path (k + 1)) - x (path k)) + (x (path k) - x start)| := by congr 1; ring | |
| _ β€ |x (path (k + 1)) - x (path k)| + |x (path k) - x start| := abs_add_le _ _ | |
| _ β€ W + k * W := add_le_add hs ih | |
| _ = (β(k + 1) : β€) * W := by push_cast; ring | |
| have hboundary : β k < G.n, Β¬ (0 < x (path k) β§ x (path k) < B) := by | |
| by_contra h | |
| push Not at h | |
| apply no_tight_segment G x path (fun k => G.weight (edge (path k))) | |
| intro k hk | |
| have hi := h k hk | |
| have hsub := hx.1.2 (path k) hi.1 | |
| have hsuper := hx.2.2 (path k) hi.2 | |
| have hp : path (k + 1) = G.head (edge (path k)) := by | |
| change next^[k + 1] start = _ | |
| rw [Function.iterate_succ_apply'] | |
| exact ite_eq_left hi | |
| rw [hp] | |
| have he := (hedge (path k)).2 | |
| change x (path k) = transformed G (edge (path k)) + x (G.head (edge (path k))) | |
| omega | |
| obtain β¨k, hk, hboundβ© := hboundary | |
| have hlo : 0 β€ x (path k) := hx.1.1.1 (path k) | |
| have hhi : x (path k) β€ B := hx.1.1.2 (path k) | |
| have hm := hmove k | |
| have hk' : (k : β€) β€ G.n := by omega | |
| have hkn := mul_le_mul_of_nonneg_right hk' hW | |
| have ha := (abs_le.mp hm) | |
| by_cases he : x (path k) = 0 | |
| Β· left; omega | |
| Β· right; have he' : x (path k) = B := by omega | |
| omega | |
| theorem exists_rounding_shift {n : β} (p : Vec (Fin n)) : | |
| β c : β€, β i, (p i - c) % (n + 1 : β€) β 0 := by | |
| classical | |
| have hN : (0 : β€) < n + 1 := by omega | |
| let residue : Fin n β Fin (n + 1) := fun i => | |
| β¨(p i % (n + 1 : β€)).toNat, | |
| (Int.toNat_lt (Int.emod_nonneg _ (ne_of_gt hN))).mpr (by | |
| simpa only [Nat.cast_add, Nat.cast_one] using Int.emod_lt_of_pos (p i) hN)β© | |
| have hns : Β¬ Function.Surjective residue := by | |
| intro hs | |
| have hc := Fintype.card_le_of_surjective residue hs | |
| simp only [Fintype.card_fin] at hc | |
| omega | |
| have hex : β c : Fin (n + 1), β i, residue i β c := by | |
| simpa only [Function.Surjective, not_forall, not_exists] using hns | |
| obtain β¨c, hcβ© := hex | |
| refine β¨c.val, ?_β© | |
| intro i hi | |
| apply hc i | |
| apply Fin.ext | |
| change (p i % (n + 1 : β€)).toNat = c.val | |
| have hm : (c.val : β€) β‘ p i [ZMOD (n + 1 : β€)] := | |
| Int.modEq_iff_dvd.mpr (Int.dvd_of_emod_eq_zero hi) | |
| have hcmod : (c.val : β€) % (n + 1 : β€) = c.val := | |
| Int.emod_eq_of_lt (by omega) (by exact_mod_cast c.isLt) | |
| change (c.val : β€) % (n + 1 : β€) = p i % (n + 1 : β€) at hm | |
| rw [hcmod] at hm | |
| rw [β hm] | |
| simp | |
| theorem rounded_high_edge {N a b w c : β€} (hN : 0 < N) | |
| (hgap : (a - c) % N β 0) (h : a β€ N * w + 1 + b) : | |
| (a - c) / N β€ w + (b - c) / N := by | |
| have ha := Int.ediv_emod_unique (a := a - c) (b := N) | |
| (r := (a - c) % N) (q := (a - c) / N) hN | |
| have hb := Int.ediv_emod_unique (a := b - c) (b := N) | |
| (r := (b - c) % N) (q := (b - c) / N) hN | |
| have hqa := ha.mp β¨rfl, rflβ© | |
| have hqb := hb.mp β¨rfl, rflβ© | |
| by_contra hn | |
| have hq : w + (b - c) / N + 1 β€ (a - c) / N := by omega | |
| have hp := mul_le_mul_of_nonneg_left hq (le_of_lt hN) | |
| have hra : 1 β€ (a - c) % N := by omega | |
| have hrb : (b - c) % N β€ N - 1 := by omega | |
| nlinarith [hqa.1, hqb.1] | |
| def weightBound (G : Game) : β€ := | |
| max 1 ((Finset.univ.sup (fun e : Fin G.m => (transformed G e).natAbs) : β) : β€) | |
| def topWidth (G : Game) : β€ := 8 * G.n * weightBound G | |
| theorem weightBound_positive (G : Game) : 0 < weightBound G := by | |
| have := le_max_left (1 : β€) ((Finset.univ.sup (fun e : Fin G.m => (transformed G e).natAbs) : β) : β€) | |
| change 0 < max 1 _ | |
| omega | |
| theorem transformed_le_bound (G : Game) (e : Fin G.m) : |transformed G e| β€ weightBound G := by | |
| have h := Finset.le_sup (f := fun e : Fin G.m => (transformed G e).natAbs) (Finset.mem_univ e) | |
| have hc : ((transformed G e).natAbs : β€) β€ | |
| ((Finset.univ.sup (fun e : Fin G.m => (transformed G e).natAbs) : β) : β€) := by exact_mod_cast h | |
| rw [Int.natCast_natAbs] at hc | |
| exact hc.trans (le_max_right _ _) | |
| theorem top_bands (G : Game) {x : Vec (Fin G.n)} | |
| (hx : Subsolution (operator G) (fun _ => 0) (fun _ => topWidth G) x β§ | |
| Supersolution (operator G) (fun _ => 0) (fun _ => topWidth G) x) : | |
| β i, x i β€ G.n * weightBound G β¨ 7 * G.n * weightBound G β€ x i := by | |
| intro i | |
| have h := solution_near_boundary G (le_of_lt (weightBound_positive G)) | |
| (transformed_le_bound G) hx i | |
| simpa only [topWidth, show 8 * (G.n : β€) * weightBound G - G.n * weightBound G = | |
| 7 * G.n * weightBound G by ring] using h | |
| theorem max_edge_le_operator (G : Game) (p : Vec (Fin G.n)) | |
| {i : Fin G.n} (ho : G.maxOwner i = true) {e : Fin G.m} (he : G.tail e = i) : | |
| transformed G e + p (G.head e) β€ operator G p i := by | |
| rw [operator, ite_eq_left ho] | |
| exact Finset.le_sup' (fun e => transformed G e + p (G.head e)) (by simp [outgoing, he]) | |
| theorem operator_le_min_edge (G : Game) (p : Vec (Fin G.n)) | |
| {i : Fin G.n} (ho : G.maxOwner i β true) {e : Fin G.m} (he : G.tail e = i) : | |
| operator G p i β€ transformed G e + p (G.head e) := by | |
| rw [operator, ite_eq_right ho] | |
| exact Finset.inf'_le (fun e => transformed G e + p (G.head e)) (by simp [outgoing, he]) | |
| theorem move_tail (G : Game) (Ο Ο : Strategy G) (v : Fin G.n) | |
| (history : List (Fin G.m)) : G.tail (move G Ο Ο v history) = v := by | |
| unfold move | |
| split | |
| Β· exact (Ο history v).property | |
| Β· exact (Ο history v).property | |
| theorem next_position (G : Game) (Ο Ο : Strategy G) (v : Fin G.n) (t : β) : | |
| (position G Ο Ο v (t + 1)).1 = G.head (play G Ο Ο v t) := rfl | |
| theorem high_edge_stays_high (G : Game) {x : Vec (Fin G.n)} | |
| (hbands : β i, x i β€ G.n * weightBound G β¨ 7 * G.n * weightBound G β€ x i) | |
| {i : Fin G.n} {e : Fin G.m} | |
| (hi : 7 * G.n * weightBound G β€ x i) | |
| (he : x i β€ transformed G e + x (G.head e)) : | |
| 7 * G.n * weightBound G β€ x (G.head e) := by | |
| rcases hbands (G.head e) with hl | hh | |
| Β· have hw := (abs_le.mp (transformed_le_bound G e)).2 | |
| have hn : (1 : β€) β€ G.n := by exact_mod_cast G.positive | |
| have hW := weightBound_positive G | |
| have hnW : weightBound G β€ G.n * weightBound G := by nlinarith | |
| nlinarith | |
| Β· exact hh | |
| theorem low_edge_stays_low (G : Game) {x : Vec (Fin G.n)} | |
| (hbands : β i, x i β€ G.n * weightBound G β¨ 7 * G.n * weightBound G β€ x i) | |
| {i : Fin G.n} {e : Fin G.m} | |
| (hi : x i β€ G.n * weightBound G) | |
| (he : transformed G e + x (G.head e) β€ x i) : | |
| x (G.head e) β€ G.n * weightBound G := by | |
| rcases hbands (G.head e) with hl | hh | |
| Β· exact hl | |
| Β· have hw := (abs_le.mp (transformed_le_bound G e)).1 | |
| have hn : (1 : β€) β€ G.n := by exact_mod_cast G.positive | |
| have hW := weightBound_positive G | |
| have hnW : weightBound G β€ G.n * weightBound G := by nlinarith | |
| nlinarith | |
| theorem high_strategy (G : Game) {x : Vec (Fin G.n)} | |
| (hx : Subsolution (operator G) (fun _ => 0) (fun _ => topWidth G) x β§ | |
| Supersolution (operator G) (fun _ => 0) (fun _ => topWidth G) x) : | |
| β Ο : Strategy G, β Ο : Strategy G, β start : Fin G.n, | |
| 7 * G.n * weightBound G β€ x start β β t : β, | |
| 7 * G.n * weightBound G β€ x (position G Ο Ο start t).1 β§ | |
| x (position G Ο Ο start t).1 β€ | |
| transformed G (play G Ο Ο start t) + x (position G Ο Ο start (t + 1)).1 := by | |
| classical | |
| choose edge hedge using operator_attained G x | |
| let Ο : Strategy G := fun _ i => β¨edge i, (hedge i).1β© | |
| refine β¨Ο, ?_β© | |
| intro Ο start hstart | |
| have hlocal (i : Fin G.n) (history : List (Fin G.m)) | |
| (hi : 7 * G.n * weightBound G β€ x i) : | |
| x i β€ transformed G (move G Ο Ο i history) + x (G.head (move G Ο Ο i history)) := by | |
| have hn : (0 : β€) < G.n := by exact_mod_cast G.positive | |
| have hW := weightBound_positive G | |
| have hpos : 0 < x i := by nlinarith | |
| have hsub := hx.1.2 i hpos | |
| by_cases ho : G.maxOwner i = true | |
| Β· simpa only [move, ite_eq_left ho, Ο] using hsub.trans_eq (hedge i).2 | |
| Β· exact hsub.trans (operator_le_min_edge G x ho (move_tail G Ο Ο i history)) | |
| have hstay : β t : β, 7 * G.n * weightBound G β€ x (position G Ο Ο start t).1 := by | |
| intro t | |
| induction t with | |
| | zero => exact hstart | |
| | succ t ih => | |
| rw [next_position] | |
| exact high_edge_stays_high G (top_bands G hx) ih | |
| (hlocal (position G Ο Ο start t).1 (position G Ο Ο start t).2 ih) | |
| intro t | |
| refine β¨hstay t, ?_β© | |
| rw [next_position] | |
| exact hlocal (position G Ο Ο start t).1 (position G Ο Ο start t).2 (hstay t) | |
| theorem low_strategy (G : Game) {x : Vec (Fin G.n)} | |
| (hx : Subsolution (operator G) (fun _ => 0) (fun _ => topWidth G) x β§ | |
| Supersolution (operator G) (fun _ => 0) (fun _ => topWidth G) x) : | |
| β Ο : Strategy G, β Ο : Strategy G, β start : Fin G.n, | |
| x start β€ G.n * weightBound G β β t : β, | |
| x (position G Ο Ο start t).1 β€ G.n * weightBound G β§ | |
| transformed G (play G Ο Ο start t) + x (position G Ο Ο start (t + 1)).1 β€ | |
| x (position G Ο Ο start t).1 := by | |
| classical | |
| choose edge hedge using operator_attained G x | |
| let Ο : Strategy G := fun _ i => β¨edge i, (hedge i).1β© | |
| refine β¨Ο, ?_β© | |
| intro Ο start hstart | |
| have hlocal (i : Fin G.n) (history : List (Fin G.m)) | |
| (hi : x i β€ G.n * weightBound G) : | |
| transformed G (move G Ο Ο i history) + x (G.head (move G Ο Ο i history)) β€ x i := by | |
| have hn : (0 : β€) < G.n := by exact_mod_cast G.positive | |
| have hW := weightBound_positive G | |
| have hlt : x i < topWidth G := by unfold topWidth; nlinarith | |
| have hsuper := hx.2.2 i hlt | |
| by_cases ho : G.maxOwner i = true | |
| Β· exact (max_edge_le_operator G x ho (move_tail G Ο Ο i history)).trans hsuper | |
| Β· simpa only [move, ite_eq_right ho, Ο] using (hedge i).2.symm.trans_le hsuper | |
| have hstay : β t : β, x (position G Ο Ο start t).1 β€ G.n * weightBound G := by | |
| intro t | |
| induction t with | |
| | zero => exact hstart | |
| | succ t ih => | |
| rw [next_position] | |
| exact low_edge_stays_low G (top_bands G hx) ih | |
| (hlocal (position G Ο Ο start t).1 (position G Ο Ο start t).2 ih) | |
| intro t | |
| refine β¨hstay t, ?_β© | |
| rw [next_position] | |
| exact hlocal (position G Ο Ο start t).1 (position G Ο Ο start t).2 (hstay t) | |
| def vectorBound {n : β} (p : Fin n β β€) : β := | |
| Finset.univ.sup (fun i => (p i).natAbs) | |
| theorem le_vectorBound {n : β} (p : Fin n β β€) (i : Fin n) : | |
| |p i| β€ (vectorBound p : β€) := by | |
| have h := Finset.le_sup (f := fun i => (p i).natAbs) (Finset.mem_univ i) | |
| rw [β Int.natCast_natAbs] | |
| exact_mod_cast h | |
| noncomputable def average (w : β β β) (T : β) : β := (β j β Finset.range T, w j) / T | |
| theorem average_bounds {w : β β β} {M : β} (hM : 0 β€ M) | |
| (hw : β t, |w t| β€ M) (T : β) : -M β€ average w T β§ average w T β€ M := by | |
| by_cases hT : T = 0 | |
| Β· simp [hT, average, hM, neg_nonpos.mpr hM] | |
| have ht : (0 : β) < T := by exact_mod_cast Nat.pos_of_ne_zero hT | |
| constructor | |
| Β· apply (le_div_iffβ ht).2 | |
| calc | |
| -M * (T : β) = β j β Finset.range T, -M := by simp; ring | |
| _ β€ β j β Finset.range T, w j := | |
| Finset.sum_le_sum (fun j _ => (abs_le.mp (hw j)).1) | |
| Β· apply (div_le_iffβ ht).2 | |
| calc | |
| (β j β Finset.range T, w j) β€ β j β Finset.range T, M := | |
| Finset.sum_le_sum (fun j _ => (abs_le.mp (hw j)).2) | |
| _ = M * (T : β) := by simp; ring | |
| theorem payoff_bounded (G : Game) (Ο : β β Fin G.m) : | |
| Filter.IsBoundedUnder (Β· β€ Β·) Filter.atTop | |
| (average (fun t => (G.weight (Ο t) : β))) β§ | |
| Filter.IsBoundedUnder (Β· β₯ Β·) Filter.atTop | |
| (average (fun t => (G.weight (Ο t) : β))) := by | |
| let M : β := vectorBound G.weight | |
| have hM : 0 β€ M := by positivity | |
| have hw (t : β) : |(G.weight (Ο t) : β)| β€ M := by | |
| dsimp [M] | |
| exact_mod_cast le_vectorBound G.weight (Ο t) | |
| exact β¨Filter.isBoundedUnder_of_eventually_le | |
| (Filter.Eventually.of_forall fun t => (average_bounds hM hw t).2), | |
| Filter.isBoundedUnder_of_eventually_ge | |
| (Filter.Eventually.of_forall fun t => (average_bounds hM hw t).1)β© | |
| theorem lower_average_from_potential {w p : β β β} {K : β} | |
| (hp : β t, |p t| β€ K) (he : β t, p t - p (t + 1) β€ w t) (T : β) : | |
| (-2 * K) / (T : β) β€ average w T := by | |
| apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg T) | |
| calc | |
| -2 * K β€ p 0 - p T := by | |
| have h0 := (abs_le.mp (hp 0)).1 | |
| have hT := (abs_le.mp (hp T)).2 | |
| linarith | |
| _ = β j β Finset.range T, (p j - p (j + 1)) := (Finset.sum_range_sub' p T).symm | |
| _ β€ β j β Finset.range T, w j := Finset.sum_le_sum fun j _ => he j | |
| theorem upper_average_from_potential {w p : β β β} {K N Ξ΄ : β} | |
| (hN : 0 < N) (hp : β t, |p t| β€ K) | |
| (he : β t, N * w t + Ξ΄ β€ p t - p (t + 1)) | |
| {T : β} (hT : 0 < T) : | |
| average w T β€ (2 * K / N) / (T : β) - Ξ΄ / N := by | |
| have ht : (0 : β) < T := by exact_mod_cast hT | |
| have hs : N * (β j β Finset.range T, w j) + (T : β) * Ξ΄ β€ 2 * K := by | |
| calc | |
| N * (β j β Finset.range T, w j) + (T : β) * Ξ΄ = | |
| β j β Finset.range T, (N * w j + Ξ΄) := by | |
| simp [Finset.sum_add_distrib, Finset.mul_sum] | |
| _ β€ β j β Finset.range T, (p j - p (j + 1)) := | |
| Finset.sum_le_sum fun j _ => he j | |
| _ = p 0 - p T := Finset.sum_range_sub' p T | |
| _ β€ 2 * K := by | |
| have h0 := (abs_le.mp (hp 0)).2 | |
| have hT := (abs_le.mp (hp T)).1 | |
| linarith | |
| have hd := div_le_div_of_nonneg_right hs (le_of_lt (mul_pos hN ht)) | |
| have hleft : (N * (β j β Finset.range T, w j) + (T : β) * Ξ΄) / (N * T) = | |
| average w T + Ξ΄ / N := by | |
| unfold average | |
| field_simp | |
| have hright : 2 * K / (N * (T : β)) = (2 * K / N) / T := by ring | |
| rw [hleft, hright] at hd | |
| linarith | |
| theorem high_payoff (G : Game) {x : Vec (Fin G.n)} (Ο Ο : Strategy G) | |
| (start : Fin G.n) | |
| (he : β t, x (position G Ο Ο start t).1 β€ | |
| transformed G (play G Ο Ο start t) + x (position G Ο Ο start (t + 1)).1) : | |
| 0 β€ meanPayoff G (play G Ο Ο start) := by | |
| obtain β¨c, hcβ© := exists_rounding_shift x | |
| let q (i : Fin G.n) : β€ := (x i - c) / (G.n + 1 : β€) | |
| let p (t : β) : β := q (position G Ο Ο start t).1 | |
| let K : β := vectorBound q | |
| have hp (t : β) : |p t| β€ K := by | |
| dsimp [p, K] | |
| exact_mod_cast le_vectorBound q (position G Ο Ο start t).1 | |
| have hedge (t : β) : p t - p (t + 1) β€ (G.weight (play G Ο Ο start t) : β) := by | |
| have hN : (0 : β€) < G.n + 1 := by omega | |
| have h := rounded_high_edge hN (hc (position G Ο Ο start t).1) (he t) | |
| change q (position G Ο Ο start t).1 β€ | |
| G.weight (play G Ο Ο start t) + q (position G Ο Ο start (t + 1)).1 at h | |
| have hr : p t β€ (G.weight (play G Ο Ο start t) : β) + p (t + 1) := by | |
| dsimp [p] | |
| exact_mod_cast h | |
| linarith | |
| have hl := lower_average_from_potential hp hedge | |
| have ht := tendsto_const_div_atTop_nhds_zero_nat (-2 * K) | |
| have hb := (payoff_bounded G (play G Ο Ο start)).1 | |
| have hcb : Filter.IsCoboundedUnder (Β· β₯ Β·) Filter.atTop | |
| (average (fun t => (G.weight (play G Ο Ο start t) : β))) := | |
| Filter.IsBounded.isCobounded_flip hb | |
| have hm := Filter.liminf_le_liminf (Filter.Eventually.of_forall hl) | |
| ht.isBoundedUnder_ge hcb | |
| rw [ht.liminf_eq] at hm | |
| exact hm | |
| theorem low_payoff (G : Game) {x : Vec (Fin G.n)} (Ο Ο : Strategy G) | |
| (start : Fin G.n) | |
| (he : β t, transformed G (play G Ο Ο start t) + | |
| x (position G Ο Ο start (t + 1)).1 β€ x (position G Ο Ο start t).1) : | |
| meanPayoff G (play G Ο Ο start) β€ -1 / (G.n + 1 : β) := by | |
| let p (t : β) : β := x (position G Ο Ο start t).1 | |
| let K : β := vectorBound x | |
| have hp (t : β) : |p t| β€ K := by | |
| dsimp [p, K] | |
| exact_mod_cast le_vectorBound x (position G Ο Ο start t).1 | |
| have hedge (t : β) : (G.n + 1 : β) * G.weight (play G Ο Ο start t) + 1 β€ | |
| p t - p (t + 1) := by | |
| have h := he t | |
| unfold transformed at h | |
| have hr : (G.n + 1 : β) * G.weight (play G Ο Ο start t) + 1 + p (t + 1) β€ p t := by | |
| dsimp [p] | |
| exact_mod_cast h | |
| linarith | |
| have hN : (0 : β) < G.n + 1 := by positivity | |
| have hev : βαΆ T : β in Filter.atTop, | |
| average (fun t => (G.weight (play G Ο Ο start t) : β)) T β€ | |
| (2 * K / (G.n + 1 : β)) / T - 1 / (G.n + 1 : β) := by | |
| filter_upwards [Filter.eventually_gt_atTop 0] with T hT | |
| exact upper_average_from_potential hN hp hedge hT | |
| have ht := (tendsto_const_div_atTop_nhds_zero_nat (2 * K / (G.n + 1 : β))).sub_const | |
| (1 / (G.n + 1 : β)) | |
| have hcb : Filter.IsCoboundedUnder (Β· β₯ Β·) Filter.atTop | |
| (fun T : β => (2 * K / (G.n + 1 : β)) / T - 1 / (G.n + 1 : β)) := | |
| Filter.IsBounded.isCobounded_flip ht.isBoundedUnder_le | |
| have hm := Filter.liminf_le_liminf hev (payoff_bounded G (play G Ο Ο start)).2 hcb | |
| rw [ht.liminf_eq] at hm | |
| change meanPayoff G (play G Ο Ο start) β€ (0 : β) - 1 / (G.n + 1 : β) at hm | |
| rw [show (-1 : β) / (G.n + 1 : β) = 0 - 1 / (G.n + 1 : β) by ring] | |
| exact hm | |
| theorem winning_iff_high (G : Game) {x : Vec (Fin G.n)} | |
| (hx : Subsolution (operator G) (fun _ => 0) (fun _ => topWidth G) x β§ | |
| Supersolution (operator G) (fun _ => 0) (fun _ => topWidth G) x) (v : Fin G.n) : | |
| Winning G v β topWidth G / 2 < x v := by | |
| have hn : (0 : β€) < G.n := by exact_mod_cast G.positive | |
| have hW := weightBound_positive G | |
| have hhalf : topWidth G / 2 = 4 * G.n * weightBound G := by | |
| unfold topWidth | |
| rw [show 8 * (G.n : β€) * weightBound G = (4 * G.n * weightBound G) * 2 by ring] | |
| omega | |
| constructor | |
| Β· rintro β¨Ο, hΟβ© | |
| rcases top_bands G hx v with hl | hh | |
| Β· obtain β¨Ο, hΟβ© := low_strategy G hx | |
| have he := fun t => (hΟ Ο v hl t).2 | |
| have hp := low_payoff G Ο Ο v he | |
| have hneg : (-1 : β) / (G.n + 1 : β) < 0 := div_neg_of_neg_of_pos (by norm_num) (by positivity) | |
| exact False.elim (not_lt_of_ge ((hΟ Ο).trans hp) hneg) | |
| Β· rw [hhalf] | |
| nlinarith | |
| Β· intro hv | |
| obtain β¨Ο, hΟβ© := high_strategy G hx | |
| refine β¨Ο, fun Ο => ?_β© | |
| have hh : 7 * G.n * weightBound G β€ x v := by | |
| rcases top_bands G hx v with hl | hh | |
| Β· rw [hhalf] at hv | |
| nlinarith | |
| Β· exact hh | |
| exact high_payoff G Ο Ο v fun t => (hΟ Ο v hh t).2 | |
| def mass {n : β} (a : Fin n β β) (S : Finset (Fin n)) : β := β i β S, a i | |
| def lowerActive {n : β} (a y : Vec (Fin n)) : Finset (Fin n) := | |
| Finset.univ.filter (fun i => a i < y i) | |
| def upperActive {n : β} (b z : Vec (Fin n)) : Finset (Fin n) := | |
| Finset.univ.filter (fun i => z i < b i) | |
| theorem mass_nonneg {n : β} {a : Fin n β β} (ha : β i, 0 β€ a i) (S : Finset (Fin n)) : | |
| 0 β€ mass a S := Finset.sum_nonneg (fun i _ => ha i) | |
| theorem mass_mono {n : β} {a : Fin n β β} (ha : β i, 0 β€ a i) | |
| {S T : Finset (Fin n)} (hST : S β T) : mass a S β€ mass a T := | |
| Finset.sum_le_sum_of_subset_of_nonneg hST (fun i _ _ => ha i) | |
| theorem weight_le_mass {n : β} {a : Fin n β β} (ha : β i, 0 β€ a i) | |
| {S : Finset (Fin n)} {i : Fin n} (hi : i β S) : a i β€ mass a S := | |
| Finset.single_le_sum (fun i _ => ha i) hi | |
| end MeanPayoff | |
| end | |
| end OAI | |