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

Commit 7fd7ea8

Browse files
committed
fix(analysis/real): more irreducible
1 parent 27920e9 commit 7fd7ea8

File tree

3 files changed

+55
-53
lines changed

3 files changed

+55
-53
lines changed

algebra/linear_algebra/prod_module.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,8 @@ lemma is_basis_inl_union_inr {s : set β} {t : set γ}
270270
by rw [span_inl_union_inr]; exact assume ⟨b, c⟩, ⟨hs.2 b, ht.2 c⟩⟩
271271

272272
end module
273+
274+
instance [field α] [vector_space α β] [vector_space α γ] : vector_space α (β × γ) :=
275+
{..prod.module}
276+
273277
end prod

analysis/ennreal.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,17 +911,17 @@ tendsto_orderable
911911
protected lemma tsum_eq_supr_sum : (∑a, f a) = (⨆s:finset α, s.sum f) :=
912912
tsum_eq_is_sum ennreal.is_sum
913913

914-
protected lemma tsum_sigma {β : α → Type*} {f : Πa, β a → ennreal} :
914+
protected lemma tsum_sigma {β : α → Type*} (f : Πa, β a → ennreal) :
915915
(∑p:Σa, β a, f p.1 p.2) = (∑a, ∑b, f a b) :=
916916
tsum_sigma (assume b, ennreal.has_sum) ennreal.has_sum
917917

918918
protected lemma tsum_prod {f : α → β → ennreal} : (∑p:α×β, f p.1 p.2) = (∑a, ∑b, f a b) :=
919919
let j : α × β → (Σa:α, β) := λp, sigma.mk p.1 p.2 in
920920
let i : (Σa:α, β) → α × β := λp, (p.1, p.2) in
921921
let f' : (Σa:α, β) → ennreal := λp, f p.1 p.2 in
922-
calc (∑p:α×β, f' (j p)) = (∑p:Σa:α, β, f' p) :
922+
calc (∑p:α×β, f' (j p)) = (∑p:Σa:α, β, f p.1 p.2) :
923923
tsum_eq_tsum_of_iso j i (assume ⟨a, b⟩, rfl) (assume ⟨a, b⟩, rfl)
924-
... = (∑a, ∑b, f a b) : ennreal.tsum_sigma
924+
... = (∑a, ∑b, f a b) : ennreal.tsum_sigma f
925925

926926
protected lemma tsum_of_real {f : α → ℝ} (h : is_sum f r) (hf : ∀a, 0 ≤ f a) :
927927
(∑a, of_real (f a)) = of_real r :=

analysis/real.lean

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ show (if of_rat r = 0 then 0 else lift_rat_fun has_inv.inv (of_rat r)) = of_rat
483483
have of_rat r ≠ 0, from h ∘ dense_embedding_of_rat.inj _ _,
484484
by simp [this]; exact lift_rat_fun_of_rat (tendsto_inv_rat h)
485485

486-
local attribute [simp] of_rat_zero of_rat_one of_rat_neg of_rat_add of_rat_sub of_rat_mul of_rat_inv
486+
local attribute [simp] of_rat_neg of_rat_add of_rat_sub of_rat_mul of_rat_inv
487487

488488
lemma uniform_continuous_neg_real : uniform_continuous (λp:ℝ, - p) :=
489489
begin
@@ -537,15 +537,21 @@ instance : add_comm_group ℝ :=
537537
(by intros; simp),
538538
add_left_neg := is_closed_property dense_embedding_of_rat.closure_image_univ
539539
(is_closed_eq (continuous_add_real continuous_neg_real continuous_id) continuous_const)
540-
(by simp) }
540+
(by simp [of_rat_zero]) }
541541

542542
instance : topological_add_group ℝ :=
543543
{ continuous_add := continuous_add_real',
544544
continuous_neg := continuous_neg_real }
545545

546546
def nonneg : set ℝ := closure (of_rat '' {q : ℚ | q ≥ 0})
547547

548-
instance : has_le ℝ := ⟨λa b, b - a ∈ nonneg⟩
548+
@[irreducible] protected def real.le : ℝ → ℝ → Prop := λa b, b - a ∈ nonneg
549+
550+
instance : has_le ℝ := ⟨real.le⟩
551+
552+
theorem real.le_def {a b : ℝ} : a ≤ b ↔ b - a ∈ nonneg :=
553+
by dsimp [(≤), real.has_le, real.le]; refl
554+
open real
549555

550556
lemma of_rat_mem_nonneg {q : ℚ} (h : 0 ≤ q) : of_rat q ∈ nonneg :=
551557
have of_rat q ∈ of_rat '' {q:ℚ | q ≥ 0}, from ⟨q, h, rfl⟩,
@@ -560,11 +566,10 @@ lemma of_rat_mem_nonneg_iff {q : ℚ} : of_rat q ∈ nonneg ↔ 0 ≤ q :=
560566
end,
561567
of_rat_mem_nonneg⟩
562568

563-
lemma of_rat_le_of_rat {q₁ q₂ : ℚ} : of_rat q₁ ≤ of_rat q₂ ↔ q₁ ≤ q₂ :=
564-
show (of_rat q₂ - of_rat q₁) ∈ nonneg ↔ q₁ ≤ q₂,
565-
by rw [of_rat_sub, of_rat_mem_nonneg_iff, le_sub_iff_add_le]; simp
569+
lemma of_rat_le {q₁ q₂ : ℚ} : of_rat q₁ ≤ of_rat q₂ ↔ q₁ ≤ q₂ :=
570+
by rw [le_def, of_rat_sub, of_rat_mem_nonneg_iff, le_sub_iff_add_le]; simp
566571

567-
lemma two_eq_of_rat_two : 2 = of_rat 2 := by simp [bit0, -of_rat_add, of_rat_add.symm]
572+
lemma two_eq_of_rat_two : 2 = of_rat 2 := by simp [bit0, of_rat_add, of_rat_one]
568573

569574
lemma mem_nonneg_of_continuous2 {f : ℝ → ℝ → ℝ} {a b : ℝ}
570575
(hf : continuous (λp:ℝ×ℝ, f p.1 p.2)) (ha : a ∈ nonneg) (hb : b ∈ nonneg)
@@ -573,7 +578,7 @@ lemma mem_nonneg_of_continuous2 {f : ℝ → ℝ → ℝ} {a b : ℝ}
573578
mem_closure_of_continuous2 hf ha hb $ assume a ⟨a', ha, ha'⟩ b ⟨b', hb, hb'⟩, ha' ▸ hb' ▸ h ha hb
574579

575580
lemma zero_le_iff_nonneg {r : ℝ} : 0 ≤ r ↔ r ∈ nonneg :=
576-
show (r - 0) ∈ nonneg ↔ r ∈ nonneg, by simp [-of_rat_zero]
581+
by simp [le_def, -of_rat_zero]
577582

578583
private def abs_real := lift_rat_fun abs
579584

@@ -624,7 +629,7 @@ have ∀ r∈nonneg, f r ∈ closure ({0} : set ℝ),
624629
from assume r hr, @mem_closure_of_continuous ℝ ℝ _ _ f r _ _ this hr $
625630
show ∀ (a : ℝ), a ∈ of_rat '' {q : ℚ | q ≥ 0} → abs_real (- a) + (- a) ∈ closure ({0}:set ℝ),
626631
from assume a ⟨q, (hq : 0 ≤ q), hrq⟩,
627-
by simp [hrq.symm, of_rat_abs_real, abs_neg, abs_of_nonneg hq],
632+
by simp [hrq.symm, of_rat_zero, of_rat_abs_real, abs_neg, abs_of_nonneg hq],
628633
have h₁ : ∀{r}, r ∈ nonneg → abs_real (- r) + (- r) = 0,
629634
from assume r hr, show f r = 0, by specialize this _ hr; simpa [closure_singleton],
630635
have h₂ : ∀r, r = d (r + r),
@@ -635,7 +640,7 @@ have r + r = 0,
635640
from calc r + r = (abs_real (- - r) + (- - r)) - (abs_real (-r) + - r) : by simp [abs_real_neg, -of_rat_zero]
636641
... = 0 : by rw [h₁ hp, h₁ hn]; simp,
637642
calc r = d (r + r) : h₂ r
638-
... = 0 : by rw [this]; simp [d_of_rat]
643+
... = 0 : by rw [this]; simp [d_of_rat, of_rat_zero]
639644

640645
lemma preimage_neg_real : preimage (has_neg.neg : ℝ → ℝ) = image (has_neg.neg : ℝ → ℝ) :=
641646
(image_eq_preimage_of_inverse neg_neg neg_neg).symm
@@ -652,17 +657,17 @@ by rw [preimage_neg_real]; exact
652657

653658
instance : linear_order ℝ :=
654659
{ le := (≤),
655-
le_refl := assume a, show (a - a) ∈ nonneg, by simp; exact of_rat_mem_nonneg (le_refl _),
656-
le_trans := assume a b c (h₁ : b - a ∈ nonneg) (h₂ : c - b ∈ nonneg),
660+
le_refl := assume a, by simp [le_def]; exact of_rat_mem_nonneg (le_refl _),
661+
le_trans := by simp [le_def]; exact
662+
assume a b c (h₁ : b - a ∈ nonneg) (h₂ : c - b ∈ nonneg),
657663
have (c - b) + (b - a) = c - a,
658664
from calc (c - b) + (b - a) = c + - a + (b + -b) : by simp [-add_right_neg]
659665
... = c - a : by simp [-of_rat_zero],
660666
show (c - a) ∈ nonneg, by rw ← this;
661667
refine mem_nonneg_of_continuous2 continuous_add' h₂ h₁ (λ a b ha hb, _);
662668
rw [of_rat_add]; exact of_rat_mem_nonneg (le_add_of_le_of_nonneg ha hb),
663-
le_antisymm := assume a b (h₁ : b - a ∈ nonneg) (h₂ : a - b ∈ nonneg),
664-
have h₁ : - (a - b) ∈ nonneg, by simp at h₁; simp [*],
665-
eq_of_sub_eq_zero $ nonneg_antisymm h₂ h₁,
669+
le_antisymm := assume a b h₁ h₂,
670+
eq_of_sub_eq_zero $ nonneg_antisymm (le_def.1 h₂) (by rwa [neg_sub, ← le_def]),
666671
le_total := assume a b,
667672
have b - a ∈ nonneg ∪ (λr, -r) ⁻¹' nonneg,
668673
from calc b - a ∈ closure (of_rat '' univ) : dense_embedding_of_rat.dense _
@@ -677,30 +682,24 @@ instance : linear_order ℝ :=
677682
by rw [closure_union]; exact subset.refl _
678683
... ⊆ nonneg ∪ (λr, -r) ⁻¹' nonneg : by rw [←neg_preimage_closure]; exact subset.refl _,
679684
have b - a ∈ nonneg ∨ - (b - a) ∈ nonneg, from this,
680-
show b - a ∈ nonnega - b ∈ nonneg, by simp [*] at * }
685+
show a ≤ bb ≤ a, by simp [le_def, *] at * }
681686

682687
@[simp] lemma of_rat_lt {q₁ q₂ : ℚ} : of_rat q₁ < of_rat q₂ ↔ q₁ < q₂ :=
683-
by simp [lt_iff_le_not_le, -not_le, of_rat_le_of_rat]
688+
le_iff_le_iff_lt_iff_lt.1 of_rat_le
684689

685-
private lemma add_le_add_left_iff {a b c : ℝ} : (c + a ≤ c + b) ↔ a ≤ b :=
686-
show (c + b) - (c + a) ∈ nonneg ↔ b - a ∈ nonneg,
687-
by rwa [add_sub_add_left_eq_sub]
690+
private lemma add_le_add_left_iff {a b c : ℝ} : c + a ≤ c + b ↔ a ≤ b :=
691+
by rwa [le_def, le_def, add_sub_add_left_eq_sub]
688692

689693
instance : decidable_linear_ordered_comm_group ℝ :=
690-
{ le := (≤),
691-
lt := (<),
692-
le_refl := le_refl,
693-
le_trans := assume a b c, le_trans,
694-
le_antisymm := assume a b, le_antisymm,
695-
le_total := le_total,
696-
lt_iff_le_not_le := assume a b, lt_iff_le_not_le,
697-
add_le_add_left := assume a b h c, by rwa [add_le_add_left_iff],
698-
add_lt_add_left :=
699-
assume a b, by simp [lt_iff_not_ge, ge, -not_le, -add_comm, add_le_add_left_iff] {contextual := tt},
694+
{ add_le_add_left := assume a b h c, add_le_add_left_iff.2 h,
695+
add_lt_add_left := assume a b h c,
696+
(@le_imp_le_iff_lt_imp_lt _ _ _ _ _ _ b a).1 add_le_add_left_iff.1 h,
700697
decidable_eq := by apply_instance,
701698
decidable_le := by apply_instance,
702699
decidable_lt := by apply_instance,
703-
..real.add_comm_group }
700+
..real.linear_order, ..real.add_comm_group }
701+
702+
instance : ordered_comm_group ℝ := by apply_instance
704703

705704
lemma preimage_neg_rat : preimage (has_neg.neg : ℚ → ℚ) = image (has_neg.neg : ℚ → ℚ) :=
706705
(image_eq_preimage_of_inverse neg_neg neg_neg).symm
@@ -714,24 +713,23 @@ funext $ assume f, map_eq_vmap_of_inverse (funext neg_neg) (funext neg_neg)
714713
private lemma is_closed_le_real [topological_space α] {f g : α → ℝ}
715714
(hf : continuous f) (hg : continuous g) : is_closed {a:α | f a ≤ g a} :=
716715
have h : {a:α | f a ≤ g a} = (λa, g a - f a) ⁻¹' nonneg,
717-
from set.ext $ by simp [-of_rat_zero, zero_le_iff_nonneg.symm, -sub_eq_add_neg, le_sub_iff_add_le],
716+
from set.ext $ by simp [le_def],
718717
have is_closed ((λa, g a - f a) ⁻¹' nonneg),
719718
from continuous_iff_is_closed.mp (continuous_sub hg hf) _ is_closed_closure,
720719
by rw [h]; exact this
721720

722721
private lemma is_open_lt_real [topological_space α] {f g : α → ℝ}
723722
(hf : continuous f) (hg : continuous g) : is_open {a | f a < g a} :=
724-
have {a | f a < g a} = - {a | g a ≤ f a}, from set.ext $ by simp [not_le],
723+
have {a | f a < g a} = - {a | g a ≤ f a}, from set.ext $ λ a, not_le.symm,
725724
by rw this; exact is_open_compl_iff.mpr (is_closed_le_real hg hf)
726725

727726
lemma abs_real_eq_abs : abs_real = abs :=
728727
funext $ assume r,
729728
match le_total 0 r with
730729
| or.inl h := by simp [abs_of_nonneg h, abs_real_of_nonneg h]
731730
| or.inr h :=
732-
have 0 ≤ -r, from le_neg_of_le_neg $ by simp [-of_rat_zero, h],
733731
calc abs_real r = abs_real (- - r) : by simp
734-
... = - r : by rw [abs_real_neg, abs_real_of_nonneg this]
732+
... = - r : by rw [abs_real_neg, abs_real_of_nonneg (neg_nonneg.2 h)]
735733
... = _ : by simp [abs_of_nonpos h]
736734
end
737735

@@ -744,11 +742,11 @@ continuous_of_uniform uniform_continuous_abs_real
744742
lemma of_rat_abs {q : ℚ} : of_rat (abs q) = abs (of_rat q) :=
745743
by rw [←abs_real_eq_abs]; exact of_rat_abs_real.symm
746744

747-
lemma min_of_rat_of_rat {a b : ℚ} : min (of_rat a) (of_rat b) = of_rat (min a b) :=
748-
by by_cases a ≤ b; simp [h, min, of_rat_le_of_rat]
745+
lemma min_of_rat {a b : ℚ} : min (of_rat a) (of_rat b) = of_rat (min a b) :=
746+
by by_cases a ≤ b; simp [h, min, of_rat_le]
749747

750-
lemma max_of_rat_of_rat {a b : ℚ} : max (of_rat a) (of_rat b) = of_rat (max a b) :=
751-
by by_cases a ≤ b; simp [h, max, of_rat_le_of_rat]
748+
lemma max_of_rat {a b : ℚ} : max (of_rat a) (of_rat b) = of_rat (max a b) :=
749+
by by_cases a ≤ b; simp [h, max, of_rat_le]
752750

753751
lemma exists_pos_of_rat {r : ℝ} (hr : 0 < r) : ∃q:ℚ, 0 < q ∧ of_rat q < r :=
754752
let ⟨u, v, hu, hv, hru, h0v, huv⟩ := t2_separation (ne_of_gt hr) in
@@ -771,7 +769,7 @@ have r - of_rat i ∈ nonneg,
771769
from @mem_closure_of_continuous _ _ _ _ (λr, r - of_rat i) _ (u ∩ of_rat '' {q | 0 ≤ q}) _
772770
(continuous_sub continuous_id continuous_const) ‹r ∈ closure (u ∩ of_rat '' {q | 0 ≤ q})› this,
773771
⟨i / 2, div_pos_of_pos_of_pos hi two_pos,
774-
lt_of_lt_of_le (of_rat_lt.mpr $ div_two_lt_of_pos hi) this
772+
lt_of_lt_of_le (of_rat_lt.mpr $ div_two_lt_of_pos hi) (le_def.2 this)
775773

776774
lemma mem_uniformity_real_iff {s : set (ℝ × ℝ)} :
777775
s ∈ (@uniformity ℝ _).sets ↔ (∃e>0, ∀r₁ r₂:ℝ, abs (r₁ - r₂) < of_rat e → (r₁, r₂) ∈ s) :=
@@ -805,7 +803,7 @@ lemma mem_uniformity_real_iff {s : set (ℝ × ℝ)} :
805803
assume ⟨q₁, q₂⟩ hq,
806804
have (of_rat q₁, of_rat q₂) ∈ t, from interior_subset hq,
807805
have abs (q₁ - q₂) ≤ e / 2, from le_of_lt $ @hte (q₁, q₂) this,
808-
by simp [-sub_eq_add_neg, of_rat_abs.symm, of_rat_le_of_rat]; assumption,
806+
by simp [-sub_eq_add_neg, of_rat_abs.symm, of_rat_le]; assumption,
809807
uniformity.upwards_sets (interior_mem_uniformity ht) $
810808
assume p hp,
811809
have abs (p.1 - p.2) < of_rat e,
@@ -856,7 +854,7 @@ have {r : ℝ | of_rat q < r} ⊆ closure (of_rat '' {x : ℚ | q ≤ x}),
856854
by simp [h₂.symm] at *; apply le_of_lt h₁,
857855
subset.antisymm
858856
(closure_minimal
859-
(image_subset_iff.mpr $ by simp [of_rat_le_of_rat] {contextual := tt})
857+
(image_subset_iff.mpr $ by simp [of_rat_le] {contextual := tt})
860858
(is_closed_le continuous_const continuous_id)) $
861859
calc {r:ℝ | of_rat q ≤ r} ⊆ {of_rat q} ∪ {r | of_rat q < r} :
862860
assume x, by simp [le_iff_lt_or_eq, or_imp_distrib] {contextual := tt}
@@ -884,7 +882,7 @@ have hab : ({of_rat a, of_rat b}:set ℝ) ⊆ ivl,
884882
from subset.trans subset_closure $ closure_mono $
885883
by simp [subset_def, or_imp_distrib, forall_and_distrib, hab, le_refl],
886884
subset.antisymm
887-
(closure_minimal (by simp [image_subset_iff, of_rat_le_of_rat] {contextual := tt}) $
885+
(closure_minimal (by simp [image_subset_iff, of_rat_le] {contextual := tt}) $
888886
is_closed_inter (is_closed_le continuous_const continuous_id) (is_closed_le continuous_id continuous_const))
889887
(calc {r:ℝ | of_rat a ≤ r ∧ r ≤ of_rat b} ⊆ {of_rat a, of_rat b} ∪ (a_lt ∩ lt_b) :
890888
assume x, by simp [le_iff_lt_or_eq, and_imp, or_imp_distrib] {contextual := tt}
@@ -1005,7 +1003,7 @@ private lemma closure_compl_zero_image_univ :
10051003
top_unique $ assume x _,
10061004
have of_rat '' univ - {0} ⊆ of_rat ∘ (@subtype.val ℚ (λq, q ≠ 0)) '' univ,
10071005
from assume r ⟨⟨q, _, hq⟩, hr⟩,
1008-
have hr : of_rat q ≠ of_rat 0, by simp [*] at *,
1006+
have hr : of_rat q ≠ of_rat 0, by simp [*, of_rat_zero] at *,
10091007
⟨⟨q, assume hq, hr $ by simp [hq]⟩, trivial, by simp [hq, (∘)]⟩,
10101008
begin
10111009
rw [closure_subtype, ←image_comp],
@@ -1029,10 +1027,10 @@ instance : discrete_field ℝ :=
10291027
inv := has_inv.inv,
10301028
mul_one := is_closed_property dense_embedding_of_rat.closure_image_univ
10311029
(is_closed_eq (continuous_mul_real' continuous_id continuous_const) continuous_id)
1032-
(by simp),
1030+
(by simp [of_rat_one]),
10331031
one_mul := is_closed_property dense_embedding_of_rat.closure_image_univ
10341032
(is_closed_eq (continuous_mul_real' continuous_const continuous_id) continuous_id)
1035-
(by simp),
1033+
(by simp [of_rat_one]),
10361034
mul_comm := is_closed_property2 dense_embedding_of_rat
10371035
(is_closed_eq (continuous_mul_real' continuous_fst continuous_snd) (continuous_mul_real' continuous_snd continuous_fst))
10381036
(by simp [mul_comm]),
@@ -1067,14 +1065,14 @@ instance : discrete_field ℝ :=
10671065
is_closed_property closure_compl_zero_image_univ
10681066
(is_closed_eq (continuous_mul_real' continuous_subtype_val continuous_inv_real') continuous_const)
10691067
(assume ⟨a, (ha : a ≠ 0)⟩,
1070-
by simp [*, mul_inv_cancel ha] at *),
1068+
by simp [*, of_rat_one, mul_inv_cancel ha] at *),
10711069
inv_mul_cancel :=
10721070
suffices ∀a:{a:ℝ // a ≠ 0}, a.val⁻¹ * a.val = 1,
10731071
from subtype.forall.1 this,
10741072
is_closed_property closure_compl_zero_image_univ
10751073
(is_closed_eq (continuous_mul_real' continuous_inv_real' continuous_subtype_val) continuous_const)
10761074
(assume ⟨a, (ha : a ≠ 0)⟩,
1077-
by simp [*, inv_mul_cancel ha] at *),
1075+
by simp [*, of_rat_one, inv_mul_cancel ha] at *),
10781076
inv_zero := show (0:ℝ)⁻¹ = 0, from by simp [has_inv.inv],
10791077
has_decidable_eq := by apply_instance,
10801078
..real.add_comm_group }
@@ -1113,8 +1111,8 @@ instance : semiring ℝ := by apply_instance
11131111
instance : topological_semiring ℝ := topological_ring.to_topological_semiring
11141112

11151113
theorem coe_rat_eq_of_rat (r : ℚ) : ↑r = of_rat r :=
1116-
have ∀ n : ℕ, (n:ℝ) = of_rat n, by intro n; induction n; simp *,
1117-
have ∀ n : ℤ, (n:ℝ) = of_rat n, by intro n; cases n; simp [this],
1114+
have ∀ n : ℕ, (n:ℝ) = of_rat n, by intro n; induction n; simp [*, of_rat_zero, of_rat_one],
1115+
have ∀ n : ℤ, (n:ℝ) = of_rat n, by intro n; cases n; simp [this, of_rat_one],
11181116
rat.num_denom_cases_on r $ λ n d h c,
11191117
by rw [rat.cast_mk, rat.mk_eq_div, this, this, int.cast_coe_nat,
11201118
division_def, division_def, ← of_rat_mul, ← of_rat_inv]

0 commit comments

Comments
 (0)