import Mathlib namespace Gametheory /-- Finite simplex weights as a subset of the space of coordinate functions. -/ def finiteSimplex (R X : Type*) [Semiring R] [PartialOrder R] [Fintype X] : Set (X → R) := {w | (∀ i, 0 ≤ w i) ∧ ∑ i, w i = 1} instance finiteSimplex.compactSpace (X : Type*) [Fintype X] : CompactSpace (finiteSimplex ℝ X) := by apply isCompact_iff_compactSpace.mp have hweights : Continuous (fun w : Convexity.StdSimplex ℝ X => (w.weights : X → ℝ)) := continuous_pi fun i => Convexity.StdSimplex.continuous_weights_apply ℝ i convert isCompact_range hweights using 1 rw [Convexity.StdSimplex.range_toFun_comp_weights] ext w simp only [finiteSimplex, Set.mem_inter_iff, Set.mem_iInter, Set.mem_ofPred_eq] end Gametheory open Gametheory (finiteSimplex) --open Classical /- We use S to denote a mixed stratage -/ variable (α : Type*) [Fintype α] [DecidableEq α] namespace stdSimplex variable (k : Type*) [CommRing k] [LinearOrder k] [IsStrictOrderedRing k] (α : Type*) [Fintype α] instance funlike [DecidableEq α] : FunLike (finiteSimplex k α) α k where coe := Subtype.val coe_injective := Subtype.val_injective omit [IsStrictOrderedRing k] in lemma funlike_eval1 (f : finiteSimplex k α) : f = f.val := rfl omit [IsStrictOrderedRing k] in lemma funlike_eval2 [DecidableEq α] (f : finiteSimplex k α) (x : α) : f.val x = f x := rfl variable {k α} in abbrev pure [DecidableEq α] (i : α) : finiteSimplex k α := ⟨fun j => if i=j then 1 else 0, by { constructor . { intro j by_cases H: i=j repeat simp [H] } . simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] }⟩ variable {k α} in lemma pure_eval_eq [DecidableEq α] {i j: α} (h : i=j): pure i j = (1:k) := by unfold pure; rw [<-funlike_eval2] simp [h] variable {k α} in lemma pure_eval_neq [DecidableEq α] {i j: α} (h : ¬ i=j): pure i j = (0:k) := by unfold pure; rw [<-funlike_eval2] simp [h] noncomputable instance SInhabited_of_Inhabited [DecidableEq α] [Inhabited α]: Inhabited (finiteSimplex k α) where default := pure (default : α) set_option linter.deprecated false in /-- Preserve typeclass inference for callers using Mathlib's former set name. -/ noncomputable instance instInhabited [DecidableEq α] [Inhabited α] : Inhabited (stdSimplex k α) := SInhabited_of_Inhabited k α noncomputable instance SNonempty_of_Inhabited {α : Type*} [DecidableEq α] [Fintype α] [Inhabited α]: Nonempty (finiteSimplex k α) := Nonempty.intro (default : finiteSimplex k α) variable {k α} in lemma wsum_magic_ineq [DecidableEq α] [PosMulMono k] {σ : finiteSimplex k α} {f : α → k} {c : k} : ∑ i : α, (σ i) * f i = c → ∃ i, 0 < σ i ∧ f i ≤ c := by intro H1 by_contra H2 push Not at H2 have h_exists_pos : ∃ i, 0 < σ i := by by_contra h_all_zero push Not at h_all_zero have h_all_eq_zero : ∀ i, σ i = 0 := by intro i exact le_antisymm (h_all_zero i) (σ.2.1 i) have h_sum_zero : ∑ i, σ i = 0 := by simp [h_all_eq_zero] have h_sum_one : ∑ i, σ i = 1 := σ.2.2 rw [h_sum_zero] at h_sum_one exact zero_ne_one h_sum_one obtain ⟨i₀, hi₀⟩ := h_exists_pos have h_ge : c < ∑ i, σ i * f i := by have h_sum_c : ∑ i, σ i * c = c := by have h_sum_eq_one : ∑ i, σ i = 1 := σ.2.2 rw [← Finset.sum_mul, h_sum_eq_one, one_mul] rw [← h_sum_c] apply Finset.sum_lt_sum · intro i _ by_cases h_pos : 0 < σ i · have h_fi_gt_c : c < f i := H2 i h_pos exact mul_le_mul_of_nonneg_left (le_of_lt h_fi_gt_c) (le_of_lt h_pos) · have h_zero : σ i = 0 := le_antisymm (le_of_not_gt h_pos) (σ.2.1 i) simp [h_zero] · use i₀, Finset.mem_univ i₀ have h_fi₀_gt_c : c < f i₀ := H2 i₀ hi₀ exact mul_lt_mul_of_pos_left h_fi₀_gt_c hi₀ rw [H1] at h_ge exact lt_irrefl c h_ge end stdSimplex abbrev S:= finiteSimplex ℝ α namespace S variable {α : Type*} [Fintype α] [DecidableEq α] /- @[simp] noncomputable def pure (i : α) : S α := ⟨fun j => if i=j then 1 else 0, by { constructor . { intro j by_cases H: i=j repeat simp [H] } . simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] }⟩ noncomputable instance SInhabited_of_Inhabited {α : Type*} [Fintype α] [Inhabited α]: Inhabited (S α) where default := pure (default : α) noncomputable instance SNonempty_of_Inhabited {α : Type*} [Fintype α] [Inhabited α]: Nonempty (S α) := Nonempty.intro (default : S α) -/