Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 96198b9

Browse files
agjftuckerjohoelzl
authored andcommitted
feat(contraction_mapping): proof the Banach fixed-point theorem (closes #553)
1 parent 8a0fd0b commit 96198b9

File tree

6 files changed

+213
-1
lines changed

6 files changed

+213
-1
lines changed

src/algebra/pi_instances.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,20 @@ end
124124
end pi
125125

126126
namespace prod
127+
open lattice
128+
127129
variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {p q : α × β}
128130

131+
def prod_semilattice_sup [semilattice_sup α] [semilattice_sup β] : semilattice_sup (α × β) :=
132+
{ le := λ p q, p.1 ≤ q.1 ∧ p.2 ≤ q.2,
133+
le_refl := λ p, ⟨le_refl p.1, le_refl p.2⟩,
134+
le_trans := λ p q r h₁ h₂, ⟨le_trans h₁.1 h₂.1, le_trans h₁.2 h₂.2⟩,
135+
le_antisymm := λ p q h₁ h₂, prod.ext (le_antisymm h₁.1 h₂.1) (le_antisymm h₁.2 h₂.2),
136+
sup := λ p q, ⟨p.1 ⊔ q.1, p.2 ⊔ q.2⟩,
137+
le_sup_left := λ p q, ⟨le_sup_left, le_sup_left⟩,
138+
le_sup_right := λ p q, ⟨le_sup_right, le_sup_right⟩,
139+
sup_le := λ p q r h₁ h₂, ⟨sup_le h₁.1 h₂.1, sup_le h₁.2 h₂.2⟩ }
140+
129141
instance [has_add α] [has_add β] : has_add (α × β) :=
130142
⟨λp q, (p.1 + q.1, p.2 + q.2)⟩
131143
@[to_additive prod.has_add]

src/contraction_mapping.lean

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/-
2+
Copyright (c) 2018 Rohan Mitta. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker
5+
-/
6+
import analysis.limits analysis.normed_space
7+
open nat filter
8+
9+
lemma fixed_point_of_iteration_limit {α : Type*} [topological_space α] [t2_space α] {f : α → α}
10+
{x : α} : continuous f → (∃ x₀ : α, tendsto (λ n, f^[n] x₀) at_top (nhds x)) → x = f x :=
11+
begin
12+
intros hf hx,
13+
cases hx with x₀ hx,
14+
apply @tendsto_nhds_unique α ℕ _ _ (λ n, f^[succ n] x₀) at_top x (f x),
15+
{ exact at_top_ne_bot },
16+
{ rewrite @tendsto_comp_succ_at_top_iff α (λ n, f^[n] x₀) (nhds x),
17+
exact hx },
18+
{ rewrite funext (λ n, iterate_succ' f n x₀),
19+
exact tendsto.comp hx (continuous.tendsto hf x) },
20+
end
21+
22+
def lipschitz {α : Type*} [metric_space α] (K : ℝ) (f : α → α) :=
23+
0 ≤ K ∧ ∀ (x y : α), dist (f x) (f y) ≤ K * (dist x y)
24+
25+
lemma uniform_continuous_of_lipschitz {α : Type*} [metric_space α] {K : ℝ} {f : α → α} :
26+
lipschitz K f → uniform_continuous f :=
27+
λ hf, uniform_continuous_of_metric.mpr (λ ε hε, or.elim (lt_or_le K ε)
28+
(λ h, ⟨(1 : ℝ), zero_lt_one, (λ x y hd, lt_of_le_of_lt (hf.right x y)
29+
(lt_of_le_of_lt (mul_le_mul_of_nonneg_left (le_of_lt hd) hf.left) (symm (mul_one K) ▸ h)))⟩)
30+
(λ h, ⟨ε / K, div_pos_of_pos_of_pos hε (lt_of_lt_of_le hε h),
31+
(λ x y hd, lt_of_le_of_lt (hf.right x y)
32+
(mul_comm (dist x y) K ▸ mul_lt_of_lt_div (lt_of_lt_of_le hε h) hd))⟩))
33+
34+
lemma iterated_lipschitz_of_lipschitz {α : Type*} [metric_space α] {K : ℝ} {f : α → α} :
35+
lipschitz K f → ∀ (n : ℕ), lipschitz (K ^ n) (f^[n]) :=
36+
begin
37+
intros hf n,
38+
induction n with n ih,
39+
{ apply and.intro,
40+
{ exact pow_zero K ▸ zero_le_one, },
41+
{ intros x y,
42+
rewrite [pow_zero K, one_mul, iterate_zero f x, iterate_zero f y], }, },
43+
{ apply and.intro,
44+
{ exact mul_nonneg hf.left ih.left, },
45+
{ intros x y,
46+
rewrite [iterate_succ', iterate_succ'],
47+
apply le_trans (hf.right (f^[n] x) (f^[n] y)),
48+
rewrite [pow_succ K n, mul_assoc],
49+
exact mul_le_mul_of_nonneg_left (ih.right x y) hf.left, }, },
50+
end
51+
52+
lemma dist_inequality_of_contraction {α : Type*} [metric_space α] {K : ℝ} {f : α → α} (hK₁ : K < 1) :
53+
lipschitz K f → ∀ (x y : α), dist x y ≤ (dist x (f x) + dist y (f y)) / (1 - K) :=
54+
begin
55+
intros hf x y,
56+
apply le_div_of_mul_le (sub_pos_of_lt hK₁),
57+
rewrite [mul_comm, sub_mul, one_mul],
58+
apply sub_left_le_of_le_add,
59+
apply le_trans,
60+
exact dist_triangle_right x y (f x),
61+
apply le_trans,
62+
apply add_le_add_left,
63+
exact dist_triangle_right y (f x) (f y),
64+
rewrite [←add_assoc, add_comm],
65+
apply add_le_add_right,
66+
exact hf.right x y,
67+
end
68+
69+
theorem fixed_point_unique_of_contraction {α : Type*} [metric_space α] {K : ℝ} {f : α → α} :
70+
K < 1 → lipschitz K f → ∀ (x : α), x = f x → ∀ (y : α), y = f y → x = y :=
71+
begin
72+
intros hK₁ hf x hx y hy,
73+
apply iff.mp dist_le_zero,
74+
apply le_trans,
75+
exact dist_inequality_of_contraction hK₁ hf x y,
76+
rewrite [iff.mpr dist_eq_zero hx, iff.mpr dist_eq_zero hy],
77+
norm_num,
78+
end
79+
80+
lemma dist_bound_of_contraction {α : Type*} [metric_space α] {K : ℝ} {f : α → α} :
81+
K < 1 → lipschitz K f → ∀ (x₀ : α) (n : ℕ × ℕ),
82+
dist (f^[n.1] x₀) (f^[n.2] x₀) ≤ (K ^ n.1 + K ^ n.2) * dist x₀ (f x₀) / (1 - K) :=
83+
begin
84+
intros hK₁ hf x₀ n,
85+
apply le_trans,
86+
exact dist_inequality_of_contraction hK₁ hf (f^[n.1] x₀) (f^[n.2] x₀),
87+
apply div_le_div_of_le_of_pos _ (sub_pos_of_lt hK₁),
88+
have h : ∀ (m : ℕ), dist (f^[m] x₀) (f (f^[m] x₀)) ≤ K ^ m * dist x₀ (f x₀),
89+
intro m,
90+
rewrite [←iterate_succ' f m x₀, iterate_succ f m x₀],
91+
exact and.right (iterated_lipschitz_of_lipschitz hf m) x₀ (f x₀),
92+
rewrite add_mul,
93+
apply add_le_add,
94+
{ exact h n.1, },
95+
{ exact h n.2, },
96+
end
97+
98+
lemma continuous_prod_snd {α β γ : Type*} [topological_space α] [topological_space β]
99+
[topological_space γ] {f : α × β → γ} {a : α} (hf : continuous f) : continuous (λ b, f (a, b)) :=
100+
continuous.comp (continuous.prod_mk continuous_const continuous_id) hf
101+
102+
local attribute [instance] prod.prod_semilattice_sup
103+
104+
lemma tendsto_dist_bound_at_top_nhds_0 {K : ℝ} (hK₀ : 0 ≤ K) (hK₁ : K < 1) (z : ℝ) :
105+
tendsto (λ (n : ℕ × ℕ), (K ^ n.1 + K ^ n.2) * z / (1 - K)) at_top (nhds 0) :=
106+
begin
107+
let f := λ (n : ℕ × ℕ), (K ^ n.1, K ^ n.2),
108+
let g := λ (y : ℝ × ℝ), (y.1 + y.2) * z / (1 - K),
109+
show tendsto (g ∘ f) at_top (nhds 0),
110+
apply tendsto.comp,
111+
{ show tendsto f at_top (nhds (0, 0)),
112+
rw ←prod_at_top_at_top_eq,
113+
apply tendsto_prod_mk_nhds,
114+
{ apply tendsto.comp tendsto_fst,
115+
exact tendsto_pow_at_top_nhds_0_of_lt_1 hK₀ hK₁, },
116+
{ apply tendsto.comp tendsto_snd,
117+
exact tendsto_pow_at_top_nhds_0_of_lt_1 hK₀ hK₁, }, },
118+
{ show tendsto g (nhds (0, 0)) (nhds 0),
119+
have hg : g = λ (y : ℝ × ℝ), z / (1 - K) * (y.1 + y.2),
120+
ext,
121+
rewrite [mul_comm, ←mul_div_assoc],
122+
have hc : continuous g,
123+
rewrite hg,
124+
apply continuous.comp,
125+
exact continuous_add',
126+
exact continuous_prod_snd continuous_mul',
127+
have h₀ := continuous.tendsto hc (0, 0),
128+
suffices h : g (0, 0) = 0,
129+
rewrite h at h₀,
130+
exact h₀,
131+
rewrite hg,
132+
norm_num, },
133+
end
134+
135+
theorem fixed_point_exists_of_contraction {α : Type*} [inhabited α] [metric_space α]
136+
[complete_space α] {K : ℝ} {f : α → α} : K < 1 → lipschitz K f → ∃ (x : α), x = f x :=
137+
begin
138+
intros hK₁ hf,
139+
let x₀ := default α,
140+
suffices h : cauchy_seq (λ n, f^[n] x₀),
141+
cases cauchy_seq_tendsto_of_complete h with x hx,
142+
use x,
143+
apply @fixed_point_of_iteration_limit α _,
144+
{ exact uniform_continuous.continuous (uniform_continuous_of_lipschitz hf), },
145+
{ exact ⟨x₀, hx⟩, },
146+
apply iff.mpr cauchy_seq_iff_tendsto_dist_at_top_0,
147+
apply squeeze_zero,
148+
{ intro x,
149+
exact dist_nonneg, },
150+
{ exact dist_bound_of_contraction hK₁ hf x₀, },
151+
{ exact tendsto_dist_bound_at_top_nhds_0 hf.left hK₁ (dist x₀ (f x₀)), },
152+
end

src/data/prod.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ by rw [← @mk.eta _ _ p, ← @mk.eta _ _ q, mk.inj_iff]
3333
lemma ext {α β} {p q : α × β} (h₁ : p.1 = q.1) (h₂ : p.2 = q.2) : p = q :=
3434
ext_iff.2 ⟨h₁, h₂⟩
3535

36+
lemma map_def {f : α → γ} {g : β → δ} : prod.map f g = λ (p : α × β), (f p.1, g p.2) :=
37+
funext (λ p, ext (map_fst f g p) (map_snd f g p))
38+
3639
lemma id_prod : (λ (p : α × α), (p.1, p.2)) = id :=
3740
funext $ λ ⟨a, b⟩, rfl
3841

src/order/filter.lean

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Theory of filters on sets.
77
-/
88
import order.galois_connection order.zorn
99
import data.set.finite data.list
10-
import category.applicative
10+
import category.applicative algebra.pi_instances
1111
open lattice set
1212

1313
universes u v w x y
@@ -1769,6 +1769,26 @@ tendsto_infi.2 $ assume s, tendsto_infi' (s.image i) $ tendsto_principal_princip
17691769
by simp only [finset.image_image, (∘), h]; exact finset.image_id.symm
17701770
... ⊆ t.image j : finset.image_subset_image ht
17711771

1772+
section prod
1773+
local attribute [instance] prod.prod_semilattice_sup
1774+
1775+
lemma prod_at_top_at_top_eq {β₁ β₂ : Type*} [inhabited β₁] [inhabited β₂] [semilattice_sup β₁]
1776+
[semilattice_sup β₂] : filter.prod (@at_top β₁ _) (@at_top β₂ _) = @at_top (β₁ × β₂) _ :=
1777+
filter.ext (λ s, iff.intro
1778+
(λ h, let ⟨t₁, ht₁, t₂, ht₂, hs⟩ := mem_prod_iff.mp h in
1779+
let ⟨N₁, hN₁⟩ := iff.mp mem_at_top_sets ht₁ in
1780+
let ⟨N₂, hN₂⟩ := iff.mp mem_at_top_sets ht₂ in
1781+
mem_at_top_sets.mpr ⟨⟨N₁, N₂⟩, (λ n hn, hs ⟨hN₁ n.1 hn.1, hN₂ n.2 hn.2⟩)⟩)
1782+
(λ h, let ⟨N, hN⟩ := mem_at_top_sets.mp h in mem_prod_iff.mpr
1783+
⟨{n₁ | N.1 ≤ n₁}, mem_at_top N.1, {n₂ | N.2 ≤ n₂}, mem_at_top N.2, (λ n hn, hN n hn)⟩))
1784+
1785+
lemma prod_map_at_top_eq {α₁ α₂ β₁ β₂ : Type*} [inhabited β₁] [inhabited β₂]
1786+
[semilattice_sup β₁] [semilattice_sup β₂] (u₁ : β₁ → α₁) (u₂ : β₂ → α₂) :
1787+
filter.prod (map u₁ at_top) (map u₂ at_top) = map (prod.map u₁ u₂) at_top :=
1788+
by rw [prod_map_map_eq, prod_at_top_at_top_eq, prod.map_def]
1789+
1790+
end prod
1791+
17721792
/- ultrafilter -/
17731793

17741794
section ultrafilter

src/topology/metric_space/basic.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,22 @@ lemma closed_ball_Icc {x r : ℝ} : closed_ball x r = Icc (x-r) (x+r) :=
480480
by ext y; rw [mem_closed_ball, dist_comm, real.dist_eq,
481481
abs_sub_le_iff, mem_Icc, ← sub_le_iff_le_add', sub_le]
482482

483+
local attribute [instance] prod.prod_semilattice_sup
484+
485+
lemma dist_prod_eq_dist_0 {β₁ β₂ : Type*} (u₁ : β₁ → α) (u₂ : β₂ → α) (n : β₁ × β₂) :
486+
dist (prod.map u₁ u₂ n).1 (prod.map u₁ u₂ n).2 = dist (dist (u₁ n.1) (u₂ n.2)) 0 :=
487+
by rw [prod.map_fst, prod.map_snd, real.dist_0_eq_abs, abs_of_nonneg dist_nonneg]
488+
489+
lemma cauchy_seq_iff_tendsto_dist_at_top_0 [inhabited β] [semilattice_sup β] {u : β → α} :
490+
cauchy_seq u ↔ tendsto (λ (n : β × β), dist (u n.1) (u n.2)) at_top (nhds 0) :=
491+
iff.trans cauchy_seq_iff_prod_map (iff.symm (iff.trans tendsto_nhds_topo_metric
492+
⟨(λ h s hs, let ⟨ε, hε, hε'⟩ := mem_uniformity_dist.mp hs in
493+
let ⟨t, ht, ht'⟩ := h ε hε in mem_map_sets_iff.mpr
494+
⟨t, ht, (λ p hp, @prod.mk.eta α α p ▸ hε' (let ⟨n, hn, hn'⟩ := hp in
495+
show dist p.1 p.2 < ε, from hn' ▸ symm (dist_prod_eq_dist_0 u u n) ▸ ht' n hn))⟩),
496+
(λ h ε hε, let ⟨s, hs, hs'⟩ := mem_map_sets_iff.mp (h (dist_mem_uniformity hε)) in
497+
⟨s, hs, (λ n hn, dist_prod_eq_dist_0 u u n ▸ hs' (set.mem_image_of_mem (prod.map u u) hn))⟩)⟩))
498+
483499
end real
484500

485501
section cauchy_seq

src/topology/uniform_space/basic.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,15 @@ defined on ℝ is Cauchy at +∞ to deduce convergence. Therefore, we define it
905905
is general enough to cover both ℕ and ℝ, which are the main motivating examples. -/
906906
def cauchy_seq [inhabited β] [semilattice_sup β] (u : β → α) := cauchy (at_top.map u)
907907

908+
section prod
909+
local attribute [instance] prod.prod_semilattice_sup
910+
911+
lemma cauchy_seq_iff_prod_map [inhabited β] [semilattice_sup β] {u : β → α} :
912+
cauchy_seq u ↔ map (prod.map u u) at_top ≤ uniformity :=
913+
iff.trans (and_iff_right (map_ne_bot at_top_ne_bot)) (prod_map_at_top_eq u u ▸ iff.rfl)
914+
915+
end prod
916+
908917
/-- A complete space is defined here using uniformities. A uniform space
909918
is complete if every Cauchy filter converges. -/
910919
class complete_space (α : Type u) [uniform_space α] : Prop :=

0 commit comments

Comments
 (0)