@@ -483,7 +483,7 @@ show (if of_rat r = 0 then 0 else lift_rat_fun has_inv.inv (of_rat r)) = of_rat
483
483
have of_rat r ≠ 0 , from h ∘ dense_embedding_of_rat.inj _ _,
484
484
by simp [this ]; exact lift_rat_fun_of_rat (tendsto_inv_rat h)
485
485
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
487
487
488
488
lemma uniform_continuous_neg_real : uniform_continuous (λp:ℝ, - p) :=
489
489
begin
@@ -537,15 +537,21 @@ instance : add_comm_group ℝ :=
537
537
(by intros; simp),
538
538
add_left_neg := is_closed_property dense_embedding_of_rat.closure_image_univ
539
539
(is_closed_eq (continuous_add_real continuous_neg_real continuous_id) continuous_const)
540
- (by simp) }
540
+ (by simp [of_rat_zero] ) }
541
541
542
542
instance : topological_add_group ℝ :=
543
543
{ continuous_add := continuous_add_real',
544
544
continuous_neg := continuous_neg_real }
545
545
546
546
def nonneg : set ℝ := closure (of_rat '' {q : ℚ | q ≥ 0 })
547
547
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
549
555
550
556
lemma of_rat_mem_nonneg {q : ℚ} (h : 0 ≤ q) : of_rat q ∈ nonneg :=
551
557
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 :=
560
566
end ,
561
567
of_rat_mem_nonneg⟩
562
568
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
566
571
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 ]
568
573
569
574
lemma mem_nonneg_of_continuous2 {f : ℝ → ℝ → ℝ} {a b : ℝ}
570
575
(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 : ℝ}
573
578
mem_closure_of_continuous2 hf ha hb $ assume a ⟨a', ha, ha'⟩ b ⟨b', hb, hb'⟩, ha' ▸ hb' ▸ h ha hb
574
579
575
580
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]
577
582
578
583
private def abs_real := lift_rat_fun abs
579
584
@@ -624,7 +629,7 @@ have ∀ r∈nonneg, f r ∈ closure ({0} : set ℝ),
624
629
from assume r hr, @mem_closure_of_continuous ℝ ℝ _ _ f r _ _ this hr $
625
630
show ∀ (a : ℝ), a ∈ of_rat '' {q : ℚ | q ≥ 0 } → abs_real (- a) + (- a) ∈ closure ({0 }:set ℝ),
626
631
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],
628
633
have h₁ : ∀{r}, r ∈ nonneg → abs_real (- r) + (- r) = 0 ,
629
634
from assume r hr, show f r = 0 , by specialize this _ hr; simpa [closure_singleton],
630
635
have h₂ : ∀r, r = d (r + r),
@@ -635,7 +640,7 @@ have r + r = 0,
635
640
from calc r + r = (abs_real (- - r) + (- - r)) - (abs_real (-r) + - r) : by simp [abs_real_neg, -of_rat_zero]
636
641
... = 0 : by rw [h₁ hp, h₁ hn]; simp,
637
642
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 ]
639
644
640
645
lemma preimage_neg_real : preimage (has_neg.neg : ℝ → ℝ) = image (has_neg.neg : ℝ → ℝ) :=
641
646
(image_eq_preimage_of_inverse neg_neg neg_neg).symm
@@ -652,17 +657,17 @@ by rw [preimage_neg_real]; exact
652
657
653
658
instance : linear_order ℝ :=
654
659
{ 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),
657
663
have (c - b) + (b - a) = c - a,
658
664
from calc (c - b) + (b - a) = c + - a + (b + -b) : by simp [-add_right_neg]
659
665
... = c - a : by simp [-of_rat_zero],
660
666
show (c - a) ∈ nonneg, by rw ← this ;
661
667
refine mem_nonneg_of_continuous2 continuous_add' h₂ h₁ (λ a b ha hb, _);
662
668
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]),
666
671
le_total := assume a b,
667
672
have b - a ∈ nonneg ∪ (λr, -r) ⁻¹' nonneg,
668
673
from calc b - a ∈ closure (of_rat '' univ) : dense_embedding_of_rat.dense _
@@ -677,30 +682,24 @@ instance : linear_order ℝ :=
677
682
by rw [closure_union]; exact subset.refl _
678
683
... ⊆ nonneg ∪ (λr, -r) ⁻¹' nonneg : by rw [←neg_preimage_closure]; exact subset.refl _,
679
684
have b - a ∈ nonneg ∨ - (b - a) ∈ nonneg, from this ,
680
- show b - a ∈ nonneg ∨ a - b ∈ nonneg , by simp [*] at * }
685
+ show a ≤ b ∨ b ≤ a , by simp [le_def, *] at * }
681
686
682
687
@[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
684
689
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]
688
692
689
693
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,
700
697
decidable_eq := by apply_instance,
701
698
decidable_le := by apply_instance,
702
699
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
704
703
705
704
lemma preimage_neg_rat : preimage (has_neg.neg : ℚ → ℚ) = image (has_neg.neg : ℚ → ℚ) :=
706
705
(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)
714
713
private lemma is_closed_le_real [topological_space α] {f g : α → ℝ}
715
714
(hf : continuous f) (hg : continuous g) : is_closed {a:α | f a ≤ g a} :=
716
715
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 ],
718
717
have is_closed ((λa, g a - f a) ⁻¹' nonneg),
719
718
from continuous_iff_is_closed.mp (continuous_sub hg hf) _ is_closed_closure,
720
719
by rw [h]; exact this
721
720
722
721
private lemma is_open_lt_real [topological_space α] {f g : α → ℝ}
723
722
(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 ,
725
724
by rw this ; exact is_open_compl_iff.mpr (is_closed_le_real hg hf)
726
725
727
726
lemma abs_real_eq_abs : abs_real = abs :=
728
727
funext $ assume r,
729
728
match le_total 0 r with
730
729
| or.inl h := by simp [abs_of_nonneg h, abs_real_of_nonneg h]
731
730
| or.inr h :=
732
- have 0 ≤ -r, from le_neg_of_le_neg $ by simp [-of_rat_zero, h],
733
731
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) ]
735
733
... = _ : by simp [abs_of_nonpos h]
736
734
end
737
735
@@ -744,11 +742,11 @@ continuous_of_uniform uniform_continuous_abs_real
744
742
lemma of_rat_abs {q : ℚ} : of_rat (abs q) = abs (of_rat q) :=
745
743
by rw [←abs_real_eq_abs]; exact of_rat_abs_real.symm
746
744
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 ]
749
747
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 ]
752
750
753
751
lemma exists_pos_of_rat {r : ℝ} (hr : 0 < r) : ∃q:ℚ, 0 < q ∧ of_rat q < r :=
754
752
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,
771
769
from @mem_closure_of_continuous _ _ _ _ (λr, r - of_rat i) _ (u ∩ of_rat '' {q | 0 ≤ q}) _
772
770
(continuous_sub continuous_id continuous_const) ‹r ∈ closure (u ∩ of_rat '' {q | 0 ≤ q})› this ,
773
771
⟨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 ) ⟩
775
773
776
774
lemma mem_uniformity_real_iff {s : set (ℝ × ℝ)} :
777
775
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 (ℝ × ℝ)} :
805
803
assume ⟨q₁, q₂⟩ hq,
806
804
have (of_rat q₁, of_rat q₂) ∈ t, from interior_subset hq,
807
805
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,
809
807
uniformity.upwards_sets (interior_mem_uniformity ht) $
810
808
assume p hp,
811
809
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}),
856
854
by simp [h₂.symm] at *; apply le_of_lt h₁,
857
855
subset.antisymm
858
856
(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})
860
858
(is_closed_le continuous_const continuous_id)) $
861
859
calc {r:ℝ | of_rat q ≤ r} ⊆ {of_rat q} ∪ {r | of_rat q < r} :
862
860
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,
884
882
from subset.trans subset_closure $ closure_mono $
885
883
by simp [subset_def, or_imp_distrib, forall_and_distrib, hab, le_refl],
886
884
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}) $
888
886
is_closed_inter (is_closed_le continuous_const continuous_id) (is_closed_le continuous_id continuous_const))
889
887
(calc {r:ℝ | of_rat a ≤ r ∧ r ≤ of_rat b} ⊆ {of_rat a, of_rat b} ∪ (a_lt ∩ lt_b) :
890
888
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 :
1005
1003
top_unique $ assume x _,
1006
1004
have of_rat '' univ - {0 } ⊆ of_rat ∘ (@subtype.val ℚ (λq, q ≠ 0 )) '' univ,
1007
1005
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 *,
1009
1007
⟨⟨q, assume hq, hr $ by simp [hq]⟩, trivial, by simp [hq, (∘)]⟩,
1010
1008
begin
1011
1009
rw [closure_subtype, ←image_comp],
@@ -1029,10 +1027,10 @@ instance : discrete_field ℝ :=
1029
1027
inv := has_inv.inv,
1030
1028
mul_one := is_closed_property dense_embedding_of_rat.closure_image_univ
1031
1029
(is_closed_eq (continuous_mul_real' continuous_id continuous_const) continuous_id)
1032
- (by simp),
1030
+ (by simp [of_rat_one] ),
1033
1031
one_mul := is_closed_property dense_embedding_of_rat.closure_image_univ
1034
1032
(is_closed_eq (continuous_mul_real' continuous_const continuous_id) continuous_id)
1035
- (by simp),
1033
+ (by simp [of_rat_one] ),
1036
1034
mul_comm := is_closed_property2 dense_embedding_of_rat
1037
1035
(is_closed_eq (continuous_mul_real' continuous_fst continuous_snd) (continuous_mul_real' continuous_snd continuous_fst))
1038
1036
(by simp [mul_comm]),
@@ -1067,14 +1065,14 @@ instance : discrete_field ℝ :=
1067
1065
is_closed_property closure_compl_zero_image_univ
1068
1066
(is_closed_eq (continuous_mul_real' continuous_subtype_val continuous_inv_real') continuous_const)
1069
1067
(assume ⟨a, (ha : a ≠ 0 )⟩,
1070
- by simp [*, mul_inv_cancel ha] at *),
1068
+ by simp [*, of_rat_one, mul_inv_cancel ha] at *),
1071
1069
inv_mul_cancel :=
1072
1070
suffices ∀a:{a:ℝ // a ≠ 0 }, a.val⁻¹ * a.val = 1 ,
1073
1071
from subtype.forall.1 this ,
1074
1072
is_closed_property closure_compl_zero_image_univ
1075
1073
(is_closed_eq (continuous_mul_real' continuous_inv_real' continuous_subtype_val) continuous_const)
1076
1074
(assume ⟨a, (ha : a ≠ 0 )⟩,
1077
- by simp [*, inv_mul_cancel ha] at *),
1075
+ by simp [*, of_rat_one, inv_mul_cancel ha] at *),
1078
1076
inv_zero := show (0 :ℝ)⁻¹ = 0 , from by simp [has_inv.inv],
1079
1077
has_decidable_eq := by apply_instance,
1080
1078
..real.add_comm_group }
@@ -1113,8 +1111,8 @@ instance : semiring ℝ := by apply_instance
1113
1111
instance : topological_semiring ℝ := topological_ring.to_topological_semiring
1114
1112
1115
1113
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 ],
1118
1116
rat.num_denom_cases_on r $ λ n d h c,
1119
1117
by rw [rat.cast_mk, rat.mk_eq_div, this , this , int.cast_coe_nat,
1120
1118
division_def, division_def, ← of_rat_mul, ← of_rat_inv]
0 commit comments