roseking's picture
Add lean source and binary files (part 84)
cdec422 verified
Raw History Blame Contribute Delete
9.95 kB
import FixedPointTheorems.brouwer
import Mathlib.Analysis.Convex.PartitionOfUnity
namespace OAI
/-! Fixed points of continuous maps on compact convex sets of real-valued functions. -/
namespace MatrixMultiplication.AuxiliarySeparation
open Set
open scoped BigOperators
private def weightSimplex (J : Type*) [Fintype J] : Set (J → ℝ) :=
{w | (∀ j, 0 ≤ w j) ∧ ∑ j, w j = 1}
private theorem weightSimplex_convex (J : Type*) [Fintype J] :
Convex ℝ (weightSimplex J) := by
intro x hx y hy a b ha hb hab
constructor
· intro j
exact add_nonneg (mul_nonneg ha (hx.1 j)) (mul_nonneg hb (hy.1 j))
· simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul]
rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, hx.2, hy.2]
simpa using hab
private theorem weightSimplex_compact (J : Type*) [Fintype J] :
IsCompact (weightSimplex J) := by
have hc : IsClosed (weightSimplex J) := by
change IsClosed ({w : J → ℝ | ∀ j, 0 ≤ w j} ∩ {w | ∑ j, w j = 1})
have hn : IsClosed {w : J → ℝ | ∀ j, 0 ≤ w j} := by
simp only [ofPred_forall]
exact isClosed_iInter fun j => isClosed_le continuous_const
(continuous_apply j : Continuous (fun w : J → ℝ => w j))
exact hn.inter
(isClosed_eq (continuous_finsetSum _ fun _ _ => continuous_apply _) continuous_const)
apply isCompact_Icc.of_isClosed_subset hc
intro w hw
constructor
· exact hw.1
· intro j
calc
w j ≤ ∑ k, w k := Finset.single_le_sum (fun k _ => hw.1 k) (Finset.mem_univ j)
_ = 1 := hw.2
/-- A finite continuous system of barycentric weights gives an approximate fixed point.
The approximation is measured on any prescribed finite set of coordinates. -/
theorem exists_approximate_fixedPoint_of_weights
{I J : Type*} [Fintype J] [Nonempty J]
{K : Set (I → ℝ)} (hK : Convex ℝ K) (f : C(K, K))
(a : J → K) (w : J → C(K, ℝ))
(hw0 : ∀ j x, 0 ≤ w j x) (hw1 : ∀ x, ∑ j, w j x = 1)
(s : Finset I) (ε : ℝ)
(hclose : ∀ x j, w j x ≠ 0 → ∀ i ∈ s, |(a j).val i - x.val i| ≤ ε) :
∃ x : K, ∀ i ∈ s, |(f x).val i - x.val i| ≤ ε := by
classical
let D := weightSimplex J
let b : D → K := fun v =>
⟨∑ j, v.val j • (a j).val,
hK.sum_mem (fun j _ => v.property.1 j) v.property.2 (fun j _ => (a j).property)⟩
have hb : Continuous b := by
apply Continuous.subtype_mk
exact continuous_finsetSum _ fun j _ =>
((continuous_apply j).comp continuous_subtype_val).smul continuous_const
let q : K → D := fun x => ⟨fun j => w j x, (fun j => hw0 j x), hw1 x⟩
have hq : Continuous q := by
exact (continuous_pi fun j => (w j).continuous).subtype_mk _
let g : C(D, D) := ⟨fun v => q (f (b v)), hq.comp (f.continuous.comp hb)⟩
have hDne : D.Nonempty := by
let j₀ : J := Classical.choice inferInstance
refine ⟨Pi.single j₀ 1, ?_, ?_⟩
· intro j
by_cases h : j = j₀ <;> simp [h]
· simp
obtain ⟨v, hv⟩ := brouwer_fixed_point D (weightSimplex_convex J)
(weightSimplex_compact J) hDne g
let x := b v
have hwv (j : J) : w j (f x) = v.val j := congrArg (fun t : D => t.val j) hv
refine ⟨x, fun i hi => ?_⟩
have hx : x.val i - (f x).val i = ∑ j, v.val j * ((a j).val i - (f x).val i) := by
change (∑ j, v.val j • (a j).val) i - (f x).val i = _
simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul]
simp_rw [mul_sub]
rw [Finset.sum_sub_distrib, ← Finset.sum_mul, v.property.2, one_mul]
rw [abs_sub_comm, hx]
calc
|∑ j, v.val j * ((a j).val i - (f x).val i)|
≤ ∑ j, |v.val j * ((a j).val i - (f x).val i)| :=
Finset.abs_sum_le_sum_abs _ _
_ = ∑ j, v.val j * |(a j).val i - (f x).val i| := by
apply Finset.sum_congr rfl
intro j _
rw [abs_mul, abs_of_nonneg (v.property.1 j)]
_ ≤ ∑ j, v.val j * ε := by
apply Finset.sum_le_sum
intro j _
by_cases hj : v.val j = 0
· simp [hj]
· exact mul_le_mul_of_nonneg_left
(hclose (f x) j (by rwa [hwv]) i hi) (v.property.1 j)
_ = ε := by rw [← Finset.sum_mul, v.property.2, one_mul]
theorem exists_finite_partition_weights {I : Type*} {K : Set (I → ℝ)}
(hK : IsCompact K) (s : Finset I) {ε : ℝ} (hε : 0 < ε) :
∃ n : ℕ, ∃ a : Fin n → K, ∃ w : Fin n → C(K, ℝ),
(∀ x j, 0 ≤ w j x) ∧ (∀ x, ∑ j, w j x = 1) ∧
(∀ x j, w j x ≠ 0 → ∀ i ∈ s, |(a j).val i - x.val i| < ε) := by
classical
let : CompactSpace K := isCompact_iff_compactSpace.mp hK
let U : K → Set K := fun a => {x | ∀ i ∈ s, |a.val i - x.val i| < ε}
have hUo : ∀ a, IsOpen (U a) := by
intro a
have hUa : U a = ⋂ i ∈ s, {x : K | |a.val i - x.val i| < ε} := by
ext x
simp [U]
rw [hUa]
apply isOpen_biInter_finset
intro i hi
exact isOpen_lt (continuous_const.sub ((continuous_apply i).comp continuous_subtype_val)).abs continuous_const
have hUc : (univ : Set K) ⊆ ⋃ a, U a := by
intro x hx
refine mem_iUnion.mpr ⟨x, ?_⟩
intro i hi
simpa using hε
obtain ⟨t, ht⟩ := isCompact_univ.elim_finite_subcover U hUo hUc
have htc : (univ : Set K) ⊆ ⋃ a : t, U a.val := by
intro x hx
obtain ⟨a, ha⟩ := mem_iUnion.mp (ht hx)
obtain ⟨hat, hax⟩ := mem_iUnion.mp ha
exact mem_iUnion.mpr ⟨⟨a, hat⟩, hax⟩
obtain ⟨w, hw⟩ := PartitionOfUnity.exists_isSubordinate isClosed_univ
(fun a : t => U a.val) (fun a => hUo a.val) htc
let e : Fin (Fintype.card t) ≃ t := (Fintype.equivFin t).symm
refine ⟨Fintype.card t, (fun j => (e j).val), (fun j => w (e j)), ?_, ?_, ?_⟩
· intro x j
exact w.nonneg (e j) x
· intro x
change ∑ j, w (e j) x = 1
calc
∑ j, w (e j) x = ∑ a : t, w a x := e.sum_comp (fun a => w a x)
_ = 1 := by simpa only [finsum_eq_sum_of_fintype] using w.sum_eq_one (mem_univ x)
· intro x j hj i hi
exact hw (e j) (subset_closure hj) i hi
theorem exists_finite_partition_weights_nonempty {I : Type*} {K : Set (I → ℝ)}
(hK : IsCompact K) (hne : K.Nonempty) (s : Finset I) {ε : ℝ} (hε : 0 < ε) :
∃ n : ℕ, 0 < n ∧ ∃ a : Fin n → K, ∃ w : Fin n → C(K, ℝ),
(∀ x j, 0 ≤ w j x) ∧ (∀ x, ∑ j, w j x = 1) ∧
(∀ x j, w j x ≠ 0 → ∀ i ∈ s, |(a j).val i - x.val i| < ε) := by
obtain ⟨n, a, w, hw0, hw1, hwa⟩ := exists_finite_partition_weights hK s hε
have hn : 0 < n := by
by_contra hn
have hn0 : n = 0 := Nat.eq_zero_of_not_pos hn
subst n
obtain ⟨x, hx⟩ := hne
simpa using hw1 ⟨x, hx⟩
exact ⟨n, hn, a, w, hw0, hw1, hwa⟩
theorem compact_approx_limit {I : Type*} {K : Set (I → ℝ)}
(hK : IsCompact K) (_hne : K.Nonempty) (f : K → (I → ℝ)) (hf : Continuous f)
(happrox : ∀ s : Finset I, ∀ ε : ℝ, 0 < ε →
∃ x : K, ∀ i ∈ s, |f x i - x.val i| ≤ ε) :
∃ x : K, f x = x.val := by
classical
let : CompactSpace K := isCompact_iff_compactSpace.mp hK
let C : (I × {ε : ℝ // 0 < ε}) → Set K :=
fun p => {x | |f x p.1 - x.val p.1| ≤ p.2.val}
have hclosed (p : I × {ε : ℝ // 0 < ε}) : IsClosed (C p) := by
exact isClosed_le
(((continuous_apply p.1).comp hf).sub
((continuous_apply p.1).comp continuous_subtype_val)).abs continuous_const
have hfinite (s : Finset (I × {ε : ℝ // 0 < ε})) :
(⋂ p ∈ s, C p).Nonempty := by
let es : Finset ℝ := insert 1 (s.image fun p => p.2.val)
have hes : es.Nonempty := ⟨1, by simp [es]⟩
have he : 0 < es.min' hes := by
rw [Finset.lt_min'_iff]
intro e he
rcases Finset.mem_insert.mp he with rfl | he
· norm_num
· obtain ⟨p, _, rfl⟩ := Finset.mem_image.mp he
exact p.2.property
obtain ⟨x, hx⟩ := happrox (s.image Prod.fst) (es.min' hes) he
refine ⟨x, ?_⟩
simp only [Set.mem_iInter]
intro p hp
exact (hx p.1 (Finset.mem_image.mpr ⟨p, hp, rfl⟩)).trans
(Finset.min'_le es p.2.val (Finset.mem_insert_of_mem
(Finset.mem_image.mpr ⟨p, hp, rfl⟩)))
obtain ⟨x, hx⟩ := CompactSpace.iInter_nonempty hclosed hfinite
refine ⟨x, funext fun i => ?_⟩
have hzero : |f x i - x.val i| ≤ 0 := by
apply le_of_forall_pos_le_add
intro ε hε
simpa only [C, Set.mem_ofPred_eq, zero_add] using
(Set.mem_iInter.mp hx (i, ⟨ε, hε⟩))
exact sub_eq_zero.mp (abs_eq_zero.mp (le_antisymm hzero (abs_nonneg _)))
/-- Schauder--Tychonoff for an arbitrary product of real lines. Compactness of the
set, rather than finite dimensionality of the ambient space, is the hypothesis. -/
theorem compact_convex_fixedPoint {I : Type*} {K : Set (I → ℝ)}
(hKcompact : IsCompact K) (hKconvex : Convex ℝ K) (hKne : K.Nonempty)
(f : C(K, K)) : ∃ x : K, f x = x := by
have happrox : ∀ s : Finset I, ∀ ε : ℝ, 0 < ε →
∃ x : K, ∀ i ∈ s, |(f x).val i - x.val i| ≤ ε := by
intro s ε hε
obtain ⟨n, hn, a, w, hw0, hw1, hwa⟩ :=
exists_finite_partition_weights_nonempty hKcompact hKne s hε
let : Nonempty (Fin n) := ⟨⟨0, hn⟩⟩
exact exists_approximate_fixedPoint_of_weights hKconvex f a w
(fun j x => hw0 x j) hw1 s ε
(fun x j hj i hi => (hwa x j hj i hi).le)
obtain ⟨x, hx⟩ := compact_approx_limit hKcompact hKne
(fun x => (f x).val) (continuous_subtype_val.comp f.continuous) happrox
exact ⟨x, Subtype.ext hx⟩
/-- An unbundled form of the product-space fixed-point theorem. -/
theorem compact_convex_fixedPoint_of_continuous {I : Type*} {K : Set (I → ℝ)}
(hKcompact : IsCompact K) (hKconvex : Convex ℝ K) (hKne : K.Nonempty)
(f : K → K) (hf : Continuous f) : ∃ x : K, f x = x :=
compact_convex_fixedPoint hKcompact hKconvex hKne ⟨f, hf⟩
end MatrixMultiplication.AuxiliarySeparation
end OAI