@@ -233,10 +233,12 @@ lemma eq_conj_iff_im {z : ℂ} : conj z = z ↔ z.im = 0 :=
233
233
λ h, ext rfl (neg_eq_iff_add_eq_zero.mpr (add_self_eq_zero.mpr h))⟩
234
234
235
235
instance : star_ring ℂ :=
236
- { star := λ z, conj z,
237
- star_involutive := λ z, by simp,
238
- star_mul := λ r s, by { ext; simp [mul_comm], },
239
- star_add := by simp, }
236
+ { star := (conj : ℂ → ℂ),
237
+ star_involutive := conj_conj,
238
+ star_mul := λ a b, (conj.map_mul a b).trans (mul_comm _ _),
239
+ star_add := conj.map_add }
240
+
241
+ @[simp] lemma star_def : (has_star.star : ℂ → ℂ) = conj := rfl
240
242
241
243
/-! ### Norm squared -/
242
244
@@ -533,126 +535,45 @@ by rw [abs, sq, real.mul_self_sqrt (norm_sq_nonneg _)]
533
535
We put a partial order on ℂ so that `z ≤ w` exactly if `w - z` is real and nonnegative.
534
536
Complex numbers with different imaginary parts are incomparable.
535
537
-/
536
- def complex_order : partial_order ℂ :=
537
- { le := λ z w, ∃ x : ℝ, 0 ≤ x ∧ w = z + x,
538
- le_refl := λ x, ⟨0 , by simp⟩,
539
- le_trans := λ x y z h₁ h₂,
540
- begin
541
- obtain ⟨w₁, l₁, rfl⟩ := h₁,
542
- obtain ⟨w₂, l₂, rfl⟩ := h₂,
543
- refine ⟨w₁ + w₂, _, _⟩,
544
- { linarith, },
545
- { simp [add_assoc], },
546
- end ,
547
- le_antisymm := λ z w h₁ h₂,
548
- begin
549
- obtain ⟨w₁, l₁, rfl⟩ := h₁,
550
- obtain ⟨w₂, l₂, e⟩ := h₂,
551
- have h₃ : w₁ + w₂ = 0 ,
552
- { symmetry,
553
- rw add_assoc at e,
554
- apply of_real_inj.mp,
555
- apply add_left_cancel,
556
- convert e; simp, },
557
- have h₄ : w₁ = 0 , linarith,
558
- simp [h₄],
559
- end , }
560
-
561
- localized " attribute [instance] complex_order" in complex_order
538
+ protected def partial_order : partial_order ℂ :=
539
+ { le := λ z w, z.re ≤ w.re ∧ z.im = w.im,
540
+ lt := λ z w, z.re < w.re ∧ z.im = w.im,
541
+ lt_iff_le_not_le := λ z w, by { dsimp, rw lt_iff_le_not_le, tauto },
542
+ le_refl := λ x, ⟨le_rfl, rfl⟩,
543
+ le_trans := λ x y z h₁ h₂, ⟨h₁.1 .trans h₂.1 , h₁.2 .trans h₂.2 ⟩,
544
+ le_antisymm := λ z w h₁ h₂, ext (h₁.1 .antisymm h₂.1 ) h₁.2 }
562
545
563
546
section complex_order
564
- open_locale complex_order
565
547
566
- lemma le_def {z w : ℂ} : z ≤ w ↔ ∃ x : ℝ, 0 ≤ x ∧ w = z + x := iff.refl _
567
- lemma lt_def {z w : ℂ} : z < w ↔ ∃ x : ℝ, 0 < x ∧ w = z + x :=
568
- begin
569
- rw [lt_iff_le_not_le],
570
- fsplit,
571
- { rintro ⟨⟨x, l, rfl⟩, h⟩,
572
- by_cases hx : x = 0 ,
573
- { simpa [hx] using h },
574
- { replace l : 0 < x := l.lt_of_ne (ne.symm hx),
575
- exact ⟨x, l, rfl⟩, } },
576
- { rintro ⟨x, l, rfl⟩,
577
- fsplit,
578
- { exact ⟨x, l.le, rfl⟩, },
579
- { rintro ⟨x', l', e⟩,
580
- rw [add_assoc] at e,
581
- replace e := add_left_cancel (by { convert e, simp }),
582
- norm_cast at e,
583
- linarith, } }
584
- end
548
+ localized " attribute [instance] complex.partial_order" in complex_order
549
+
550
+ lemma le_def {z w : ℂ} : z ≤ w ↔ z.re ≤ w.re ∧ z.im = w.im := iff.rfl
551
+ lemma lt_def {z w : ℂ} : z < w ↔ z.re < w.re ∧ z.im = w.im := iff.rfl
552
+
553
+ @[simp, norm_cast] lemma real_le_real {x y : ℝ} : (x : ℂ) ≤ (y : ℂ) ↔ x ≤ y := by simp [le_def]
554
+
555
+ @[simp, norm_cast] lemma real_lt_real {x y : ℝ} : (x : ℂ) < (y : ℂ) ↔ x < y := by simp [lt_def]
585
556
586
- @[simp, norm_cast] lemma real_le_real {x y : ℝ} : (x : ℂ) ≤ (y : ℂ) ↔ x ≤ y :=
587
- begin
588
- rw [le_def],
589
- fsplit,
590
- { rintro ⟨r, l, e⟩,
591
- norm_cast at e,
592
- subst e,
593
- exact le_add_of_nonneg_right l, },
594
- { intro h,
595
- exact ⟨y - x, sub_nonneg.mpr h, (by simp)⟩, },
596
- end
597
- @[simp, norm_cast] lemma real_lt_real {x y : ℝ} : (x : ℂ) < (y : ℂ) ↔ x < y :=
598
- begin
599
- rw [lt_def],
600
- fsplit,
601
- { rintro ⟨r, l, e⟩,
602
- norm_cast at e,
603
- subst e,
604
- exact lt_add_of_pos_right x l, },
605
- { intro h,
606
- exact ⟨y - x, sub_pos.mpr h, (by simp)⟩, },
607
- end
608
557
@[simp, norm_cast] lemma zero_le_real {x : ℝ} : (0 : ℂ) ≤ (x : ℂ) ↔ 0 ≤ x := real_le_real
609
558
@[simp, norm_cast] lemma zero_lt_real {x : ℝ} : (0 : ℂ) < (x : ℂ) ↔ 0 < x := real_lt_real
610
559
560
+ lemma not_le_iff {z w : ℂ} : ¬(z ≤ w) ↔ w.re < z.re ∨ z.im ≠ w.im :=
561
+ by rw [le_def, not_and_distrib, not_le]
562
+
563
+ lemma not_le_zero_iff {z : ℂ} : ¬z ≤ 0 ↔ 0 < z.re ∨ z.im ≠ 0 := not_le_iff
564
+
611
565
/--
612
566
With `z ≤ w` iff `w - z` is real and nonnegative, `ℂ` is an ordered ring.
613
567
-/
614
- def complex_ordered_comm_ring : ordered_comm_ring ℂ :=
615
- { zero_le_one := ⟨1 , zero_le_one, by simp⟩,
616
- add_le_add_left := λ w z h y,
617
- begin
618
- obtain ⟨x, l, rfl⟩ := h,
619
- exact ⟨x, l, by simp [add_assoc]⟩,
620
- end ,
568
+ protected def ordered_comm_ring : ordered_comm_ring ℂ :=
569
+ { zero_le_one := ⟨zero_le_one, rfl⟩,
570
+ add_le_add_left := λ w z h y, ⟨add_le_add_left h.1 _, congr_arg2 (+) rfl h.2 ⟩,
621
571
mul_pos := λ z w hz hw,
622
- begin
623
- obtain ⟨zx, lz, rfl⟩ := lt_def.mp hz,
624
- obtain ⟨wx, lw, rfl⟩ := lt_def.mp hw,
625
- norm_cast,
626
- simp only [mul_pos, lz, lw, zero_add],
627
- end ,
628
- le_of_add_le_add_left := λ u v z h,
629
- begin
630
- obtain ⟨x, l, e⟩ := h,
631
- rw add_assoc at e,
632
- exact ⟨x, l, add_left_cancel e⟩,
633
- end ,
634
- mul_lt_mul_of_pos_left := λ u v z h₁ h₂,
635
- begin
636
- obtain ⟨x₁, l₁, rfl⟩ := lt_def.mp h₁,
637
- obtain ⟨x₂, l₂, rfl⟩ := lt_def.mp h₂,
638
- simp only [mul_add, zero_add],
639
- exact lt_def.mpr ⟨x₂ * x₁, mul_pos l₂ l₁, (by norm_cast)⟩,
640
- end ,
641
- mul_lt_mul_of_pos_right := λ u v z h₁ h₂,
642
- begin
643
- obtain ⟨x₁, l₁, rfl⟩ := lt_def.mp h₁,
644
- obtain ⟨x₂, l₂, rfl⟩ := lt_def.mp h₂,
645
- simp only [add_mul, zero_add],
646
- exact lt_def.mpr ⟨x₁ * x₂, mul_pos l₁ l₂, (by norm_cast)⟩,
647
- end ,
648
- -- we need more instances here because comm_ring doesn't have zero_add et al as fields,
649
- -- they are derived as lemmas
650
- ..(by apply_instance : partial_order ℂ),
651
- ..(by apply_instance : comm_ring ℂ),
652
- ..(by apply_instance : comm_semiring ℂ),
653
- ..(by apply_instance : add_cancel_monoid ℂ) }
654
-
655
- localized " attribute [instance] complex_ordered_comm_ring" in complex_order
572
+ by simp [lt_def, mul_re, mul_im, ← hz.2 , ← hw.2 , mul_pos hz.1 hw.1 ],
573
+ .. complex.partial_order,
574
+ .. complex.comm_ring }
575
+
576
+ localized " attribute [instance] complex.ordered_comm_ring" in complex_order
656
577
657
578
/--
658
579
With `z ≤ w` iff `w - z` is real and nonnegative, `ℂ` is a star ordered ring.
@@ -662,16 +583,10 @@ In fact, the nonnegative elements are precisely those of this form.
662
583
This hold in any `C^*`-algebra, e.g. `ℂ`,
663
584
but we don't yet have `C^*`-algebras in mathlib.
664
585
-/
665
- def complex_star_ordered_ring : star_ordered_ring ℂ :=
666
- { star_mul_self_nonneg := λ z,
667
- begin
668
- refine ⟨z.abs^2 , pow_nonneg (abs_nonneg z) 2 , _⟩,
669
- simp only [has_star.star, of_real_pow, zero_add],
670
- norm_cast,
671
- rw [←norm_sq_eq_abs, norm_sq_eq_conj_mul_self],
672
- end , }
673
-
674
- localized " attribute [instance] complex_star_ordered_ring" in complex_order
586
+ protected def star_ordered_ring : star_ordered_ring ℂ :=
587
+ { star_mul_self_nonneg := λ z, ⟨by simp [add_nonneg, mul_self_nonneg], by simp [mul_comm]⟩ }
588
+
589
+ localized " attribute [instance] complex.star_ordered_ring" in complex_order
675
590
676
591
end complex_order
677
592
0 commit comments