state
stringlengths 0
159k
| srcUpToTactic
stringlengths 387
167k
| nextTactic
stringlengths 3
9k
| declUpToTactic
stringlengths 22
11.5k
| declId
stringlengths 38
95
| decl
stringlengths 16
1.89k
| file_tag
stringlengths 17
73
|
---|---|---|---|---|---|---|
case refine'_1
x z✝ z : ℂ
hre : z.re < 0
him : z.im = 0
this : arg =ᶠ[𝓝[{z | 0 ≤ z.im}] z] fun x => arcsin ((-x).im / abs x) + π
⊢ abs z ≠ 0 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
| lift z to ℝ using him | theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.597_0.CflASCTDE9UCom5 | theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case refine'_1.intro
x z✝ : ℂ
z : ℝ
hre : (↑z).re < 0
this : arg =ᶠ[𝓝[{z | 0 ≤ z.im}] ↑z] fun x => arcsin ((-x).im / abs x) + π
⊢ abs ↑z ≠ 0 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
| simpa using hre.ne | theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.597_0.CflASCTDE9UCom5 | theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case refine'_2
x z✝ z : ℂ
hre : z.re < 0
him : z.im = 0
this : arg =ᶠ[𝓝[{z | 0 ≤ z.im}] z] fun x => arcsin ((-x).im / abs x) + π
⊢ arg z = arcsin ((-z).im / abs z) + π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· | rw [arg, if_neg hre.not_le, if_pos him.ge] | theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· | Mathlib.Analysis.SpecialFunctions.Complex.Arg.597_0.CflASCTDE9UCom5 | theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
x z✝ z : ℂ
hre : z.re < 0
him : z.im = 0
⊢ Tendsto arg (𝓝[{z | 0 ≤ z.im}] z) (𝓝 π) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
| simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto | theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.615_0.CflASCTDE9UCom5 | theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
x z : ℂ
h : x ≠ 0
⊢ ContinuousAt (Angle.coe ∘ arg) x | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
| by_cases hs : 0 < x.re ∨ x.im ≠ 0 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case pos
x z : ℂ
h : x ≠ 0
hs : 0 < x.re ∨ x.im ≠ 0
⊢ ContinuousAt (Angle.coe ∘ arg) x | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· | exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs) | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· | Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ ContinuousAt (Angle.coe ∘ arg) x | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· | rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc] | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· | Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ ContinuousAt (((Angle.coe ∘ arg) ∘ Neg.neg) ∘ Neg.neg) x | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
| refine' ContinuousAt.comp _ continuous_neg.continuousAt | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ ContinuousAt ((Angle.coe ∘ arg) ∘ Neg.neg) (-x) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
| suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
this : ContinuousAt (Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π) (-x)
⊢ ContinuousAt ((Angle.coe ∘ arg) ∘ Neg.neg) (-x) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
| rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ ContinuousAt (Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π) (-x) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
| have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩ | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π = fun z => ↑(arg z) + ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
| rw [Function.update_eq_iff] | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ ↑π = ↑(arg 0) + ↑π ∧ ∀ (x : ℂ), x ≠ 0 → ((Angle.coe ∘ arg) ∘ Neg.neg) x = ↑(arg x) + ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
| exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩ | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
⊢ ↑π = ↑(arg 0) + ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by | simp | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by | Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
ha : Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π = fun z => ↑(arg z) + ↑π
⊢ ContinuousAt (Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π) (-x) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
| rw [ha] | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
hs : ¬(0 < x.re ∨ x.im ≠ 0)
ha : Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π = fun z => ↑(arg z) + ↑π
⊢ ContinuousAt (fun z => ↑(arg z) + ↑π) (-x) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
| push_neg at hs | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
ha : Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π = fun z => ↑(arg z) + ↑π
hs : x.re ≤ 0 ∧ x.im = 0
⊢ ContinuousAt (fun z => ↑(arg z) + ↑π) (-x) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
push_neg at hs
| refine'
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl _))).add
continuousAt_const | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
push_neg at hs
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
ha : Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π = fun z => ↑(arg z) + ↑π
hs : x.re ≤ 0 ∧ x.im = 0
⊢ 0 < (-x).re | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
push_neg at hs
refine'
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl _))).add
continuousAt_const
| rw [neg_re, neg_pos] | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
push_neg at hs
refine'
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl _))).add
continuousAt_const
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
case neg
x z : ℂ
h : x ≠ 0
ha : Function.update ((Angle.coe ∘ arg) ∘ Neg.neg) 0 ↑π = fun z => ↑(arg z) + ↑π
hs : x.re ≤ 0 ∧ x.im = 0
⊢ x.re < 0 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
noncomputable section
namespace Complex
open ComplexConjugate Real Topology
open Filter Set
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine' ⟨fun hz => ⟨arg z, _⟩, _⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [ofReal_mul_re, ofReal_mul_im, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine' Real.cos_pos_of_mem_Ioo ⟨_, _⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz); simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine' ⟨fun h => _, _⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0; simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_cos_add_sin_mul_I_eq_toIocMod
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_sub Complex.arg_mul_cos_add_sin_mul_I_sub
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_sub Complex.arg_cos_add_sin_mul_I_sub
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_coe_angle Complex.arg_mul_cos_add_sin_mul_I_coe_angle
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I_coe_angle Complex.arg_cos_add_sin_mul_I_coe_angle
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
#align complex.arg_mul_coe_angle Complex.arg_mul_coe_angle
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
#align complex.arg_div_coe_angle Complex.arg_div_coe_angle
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
#align complex.arg_coe_angle_to_real_eq_arg Complex.arg_coe_angle_toReal_eq_arg
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff_eq_to_real Complex.arg_coe_angle_eq_iff_eq_toReal
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
#align complex.arg_coe_angle_eq_iff Complex.arg_coe_angle_eq_iff
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section Continuity
variable {x z : ℂ}
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
#align complex.arg_eq_nhds_of_re_pos Complex.arg_eq_nhds_of_re_pos
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
#align complex.arg_eq_nhds_of_re_neg_of_im_pos Complex.arg_eq_nhds_of_re_neg_of_im_pos
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0
exact h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine' IsOpen.eventually_mem _ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
#align complex.arg_eq_nhds_of_re_neg_of_im_neg Complex.arg_eq_nhds_of_re_neg_of_im_neg
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
#align complex.arg_eq_nhds_of_im_pos Complex.arg_eq_nhds_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
#align complex.arg_eq_nhds_of_im_neg Complex.arg_eq_nhds_of_im_neg
theorem continuousAt_arg (h : 0 < x.re ∨ x.im ≠ 0) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
rintro rfl
simp at h
rw [← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
#align complex.continuous_at_arg Complex.continuousAt_arg
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H :
Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π) (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π))
· refine' H.congr' _
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
-- Porting note: need to specify the `nhdsWithin` set
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | z.im < 0 }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
-- Porting note: added type hint to assist in goal state below
continuous_abs.continuousWithinAt (s := { z : ℂ | z.im < 0 }) (_ : abs z ≠ 0))
-- Porting note: specify constant precisely to assist in goal below
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
#align complex.tendsto_arg_nhds_within_im_neg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine' ContinuousWithinAt.congr_of_eventuallyEq _ this _
· refine'
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
#align complex.continuous_within_at_arg_of_re_neg_of_im_zero Complex.continuousWithinAt_arg_of_re_neg_of_im_zero
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
#align complex.tendsto_arg_nhds_within_im_nonneg_of_re_neg_of_im_zero Complex.tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
push_neg at hs
refine'
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl _))).add
continuousAt_const
rw [neg_re, neg_pos]
| exact hs.1.lt_of_ne fun h0 => h (ext_iff.2 ⟨h0, hs.2⟩) | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : 0 < x.re ∨ x.im ≠ 0
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp.right_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine' ContinuousAt.comp _ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
push_neg at hs
refine'
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl _))).add
continuousAt_const
rw [neg_re, neg_pos]
| Mathlib.Analysis.SpecialFunctions.Complex.Arg.621_0.CflASCTDE9UCom5 | theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x | Mathlib_Analysis_SpecialFunctions_Complex_Arg |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁴ : NormedField 𝕜
inst✝³ : NormedField 𝕜'
inst✝² : SeminormedAddCommGroup E
inst✝¹ : NormedSpace 𝕜 E
inst✝ : NormedSpace 𝕜' E
r : ℝ
c : ↑(closedBall 0 1)
x : ↑(ball 0 r)
⊢ ‖↑c • ↑x‖ < r | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
| simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos | instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
| Mathlib.Analysis.NormedSpace.BallAction.29_0.NWEJH2CyESYnSt3 | instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x | Mathlib_Analysis_NormedSpace_BallAction |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁴ : NormedField 𝕜
inst✝³ : NormedField 𝕜'
inst✝² : SeminormedAddCommGroup E
inst✝¹ : NormedSpace 𝕜 E
inst✝ : NormedSpace 𝕜' E
r : ℝ
c : ↑(closedBall 0 1)
x : ↑(closedBall 0 r)
⊢ ‖↑c • ↑x‖ ≤ r | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_ball mulActionClosedBallBall
instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_ball continuousSMul_closedBall_ball
instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
| simpa only [norm_smul, one_mul] using
mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _)
zero_le_one | instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
| Mathlib.Analysis.NormedSpace.BallAction.44_0.NWEJH2CyESYnSt3 | instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x | Mathlib_Analysis_NormedSpace_BallAction |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁴ : NormedField 𝕜
inst✝³ : NormedField 𝕜'
inst✝² : SeminormedAddCommGroup E
inst✝¹ : NormedSpace 𝕜 E
inst✝ : NormedSpace 𝕜' E
r : ℝ
c : ↑(sphere 0 1)
x : ↑(sphere 0 r)
⊢ ‖↑c • ↑x‖ = r | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_ball mulActionClosedBallBall
instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_ball continuousSMul_closedBall_ball
instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _)
zero_le_one⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_closed_ball mulActionClosedBallClosedBall
instance continuousSMul_closedBall_closedBall :
ContinuousSMul (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_closed_ball continuousSMul_closedBall_closedBall
end ClosedBall
section Sphere
instance mulActionSphereBall : MulAction (sphere (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_ball mulActionSphereBall
instance continuousSMul_sphere_ball : ContinuousSMul (sphere (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_ball continuousSMul_sphere_ball
instance mulActionSphereClosedBall : MulAction (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_closed_ball mulActionSphereClosedBall
instance continuousSMul_sphere_closedBall :
ContinuousSMul (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_closed_ball continuousSMul_sphere_closedBall
instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_sphere_zero_iff_norm.2 <| by
| rw [norm_smul, mem_sphere_zero_iff_norm.1 c.coe_prop, mem_sphere_zero_iff_norm.1 x.coe_prop,
one_mul] | instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_sphere_zero_iff_norm.2 <| by
| Mathlib.Analysis.NormedSpace.BallAction.86_0.NWEJH2CyESYnSt3 | instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x | Mathlib_Analysis_NormedSpace_BallAction |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedField 𝕜'
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedSpace 𝕜' E
r✝ : ℝ
inst✝ : CharZero 𝕜
r : ℝ
hr : r ≠ 0
x : ↑(sphere 0 r)
h : x = -x
⊢ ↑x = -↑x | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_ball mulActionClosedBallBall
instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_ball continuousSMul_closedBall_ball
instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _)
zero_le_one⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_closed_ball mulActionClosedBallClosedBall
instance continuousSMul_closedBall_closedBall :
ContinuousSMul (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_closed_ball continuousSMul_closedBall_closedBall
end ClosedBall
section Sphere
instance mulActionSphereBall : MulAction (sphere (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_ball mulActionSphereBall
instance continuousSMul_sphere_ball : ContinuousSMul (sphere (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_ball continuousSMul_sphere_ball
instance mulActionSphereClosedBall : MulAction (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_closed_ball mulActionSphereClosedBall
instance continuousSMul_sphere_closedBall :
ContinuousSMul (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_closed_ball continuousSMul_sphere_closedBall
instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_sphere_zero_iff_norm.2 <| by
rw [norm_smul, mem_sphere_zero_iff_norm.1 c.coe_prop, mem_sphere_zero_iff_norm.1 x.coe_prop,
one_mul]⟩
one_smul x := Subtype.ext <| one_smul _ _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_sphere mulActionSphereSphere
instance continuousSMul_sphere_sphere : ContinuousSMul (sphere (0 : 𝕜) 1) (sphere (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_sphere continuousSMul_sphere_sphere
end Sphere
section IsScalarTower
variable [NormedAlgebra 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' E]
instance isScalarTower_closedBall_closedBall_closedBall :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_closed_ball isScalarTower_closedBall_closedBall_closedBall
instance isScalarTower_closedBall_closedBall_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_ball isScalarTower_closedBall_closedBall_ball
instance isScalarTower_sphere_closedBall_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_closed_ball isScalarTower_sphere_closedBall_closedBall
instance isScalarTower_sphere_closedBall_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_ball isScalarTower_sphere_closedBall_ball
instance isScalarTower_sphere_sphere_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_closed_ball isScalarTower_sphere_sphere_closedBall
instance isScalarTower_sphere_sphere_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_ball isScalarTower_sphere_sphere_ball
instance isScalarTower_sphere_sphere_sphere :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_sphere isScalarTower_sphere_sphere_sphere
instance isScalarTower_sphere_ball_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_sphere_ball_ball isScalarTower_sphere_ball_ball
instance isScalarTower_closedBall_ball_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_closed_ball_ball_ball isScalarTower_closedBall_ball_ball
end IsScalarTower
section SMulCommClass
variable [SMulCommClass 𝕜 𝕜' E]
instance instSMulCommClass_closedBall_closedBall_closedBall :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_closed_ball instSMulCommClass_closedBall_closedBall_closedBall
instance instSMulCommClass_closedBall_closedBall_ball :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_ball instSMulCommClass_closedBall_closedBall_ball
instance instSMulCommClass_sphere_closedBall_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_closed_ball instSMulCommClass_sphere_closedBall_closedBall
instance instSMulCommClass_sphere_closedBall_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_ball instSMulCommClass_sphere_closedBall_ball
instance instSMulCommClass_sphere_ball_ball [NormedAlgebra 𝕜 𝕜'] :
SMulCommClass (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align smul_comm_class_sphere_ball_ball instSMulCommClass_sphere_ball_ball
instance instSMulCommClass_sphere_sphere_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_closed_ball instSMulCommClass_sphere_sphere_closedBall
instance instSMulCommClass_sphere_sphere_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_ball instSMulCommClass_sphere_sphere_ball
instance instSMulCommClass_sphere_sphere_sphere :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_sphere instSMulCommClass_sphere_sphere_sphere
end SMulCommClass
variable (𝕜)
variable [CharZero 𝕜]
theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by | conv_lhs => rw [h] | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by | Mathlib.Analysis.NormedSpace.BallAction.203_0.NWEJH2CyESYnSt3 | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x | Mathlib_Analysis_NormedSpace_BallAction |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedField 𝕜'
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedSpace 𝕜' E
r✝ : ℝ
inst✝ : CharZero 𝕜
r : ℝ
hr : r ≠ 0
x : ↑(sphere 0 r)
h : x = -x
| ↑x | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_ball mulActionClosedBallBall
instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_ball continuousSMul_closedBall_ball
instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _)
zero_le_one⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_closed_ball mulActionClosedBallClosedBall
instance continuousSMul_closedBall_closedBall :
ContinuousSMul (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_closed_ball continuousSMul_closedBall_closedBall
end ClosedBall
section Sphere
instance mulActionSphereBall : MulAction (sphere (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_ball mulActionSphereBall
instance continuousSMul_sphere_ball : ContinuousSMul (sphere (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_ball continuousSMul_sphere_ball
instance mulActionSphereClosedBall : MulAction (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_closed_ball mulActionSphereClosedBall
instance continuousSMul_sphere_closedBall :
ContinuousSMul (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_closed_ball continuousSMul_sphere_closedBall
instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_sphere_zero_iff_norm.2 <| by
rw [norm_smul, mem_sphere_zero_iff_norm.1 c.coe_prop, mem_sphere_zero_iff_norm.1 x.coe_prop,
one_mul]⟩
one_smul x := Subtype.ext <| one_smul _ _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_sphere mulActionSphereSphere
instance continuousSMul_sphere_sphere : ContinuousSMul (sphere (0 : 𝕜) 1) (sphere (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_sphere continuousSMul_sphere_sphere
end Sphere
section IsScalarTower
variable [NormedAlgebra 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' E]
instance isScalarTower_closedBall_closedBall_closedBall :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_closed_ball isScalarTower_closedBall_closedBall_closedBall
instance isScalarTower_closedBall_closedBall_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_ball isScalarTower_closedBall_closedBall_ball
instance isScalarTower_sphere_closedBall_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_closed_ball isScalarTower_sphere_closedBall_closedBall
instance isScalarTower_sphere_closedBall_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_ball isScalarTower_sphere_closedBall_ball
instance isScalarTower_sphere_sphere_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_closed_ball isScalarTower_sphere_sphere_closedBall
instance isScalarTower_sphere_sphere_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_ball isScalarTower_sphere_sphere_ball
instance isScalarTower_sphere_sphere_sphere :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_sphere isScalarTower_sphere_sphere_sphere
instance isScalarTower_sphere_ball_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_sphere_ball_ball isScalarTower_sphere_ball_ball
instance isScalarTower_closedBall_ball_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_closed_ball_ball_ball isScalarTower_closedBall_ball_ball
end IsScalarTower
section SMulCommClass
variable [SMulCommClass 𝕜 𝕜' E]
instance instSMulCommClass_closedBall_closedBall_closedBall :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_closed_ball instSMulCommClass_closedBall_closedBall_closedBall
instance instSMulCommClass_closedBall_closedBall_ball :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_ball instSMulCommClass_closedBall_closedBall_ball
instance instSMulCommClass_sphere_closedBall_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_closed_ball instSMulCommClass_sphere_closedBall_closedBall
instance instSMulCommClass_sphere_closedBall_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_ball instSMulCommClass_sphere_closedBall_ball
instance instSMulCommClass_sphere_ball_ball [NormedAlgebra 𝕜 𝕜'] :
SMulCommClass (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align smul_comm_class_sphere_ball_ball instSMulCommClass_sphere_ball_ball
instance instSMulCommClass_sphere_sphere_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_closed_ball instSMulCommClass_sphere_sphere_closedBall
instance instSMulCommClass_sphere_sphere_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_ball instSMulCommClass_sphere_sphere_ball
instance instSMulCommClass_sphere_sphere_sphere :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_sphere instSMulCommClass_sphere_sphere_sphere
end SMulCommClass
variable (𝕜)
variable [CharZero 𝕜]
theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by conv_lhs => | rw [h] | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by conv_lhs => | Mathlib.Analysis.NormedSpace.BallAction.203_0.NWEJH2CyESYnSt3 | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x | Mathlib_Analysis_NormedSpace_BallAction |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedField 𝕜'
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedSpace 𝕜' E
r✝ : ℝ
inst✝ : CharZero 𝕜
r : ℝ
hr : r ≠ 0
x : ↑(sphere 0 r)
h : x = -x
| ↑x | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_ball mulActionClosedBallBall
instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_ball continuousSMul_closedBall_ball
instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _)
zero_le_one⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_closed_ball mulActionClosedBallClosedBall
instance continuousSMul_closedBall_closedBall :
ContinuousSMul (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_closed_ball continuousSMul_closedBall_closedBall
end ClosedBall
section Sphere
instance mulActionSphereBall : MulAction (sphere (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_ball mulActionSphereBall
instance continuousSMul_sphere_ball : ContinuousSMul (sphere (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_ball continuousSMul_sphere_ball
instance mulActionSphereClosedBall : MulAction (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_closed_ball mulActionSphereClosedBall
instance continuousSMul_sphere_closedBall :
ContinuousSMul (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_closed_ball continuousSMul_sphere_closedBall
instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_sphere_zero_iff_norm.2 <| by
rw [norm_smul, mem_sphere_zero_iff_norm.1 c.coe_prop, mem_sphere_zero_iff_norm.1 x.coe_prop,
one_mul]⟩
one_smul x := Subtype.ext <| one_smul _ _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_sphere mulActionSphereSphere
instance continuousSMul_sphere_sphere : ContinuousSMul (sphere (0 : 𝕜) 1) (sphere (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_sphere continuousSMul_sphere_sphere
end Sphere
section IsScalarTower
variable [NormedAlgebra 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' E]
instance isScalarTower_closedBall_closedBall_closedBall :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_closed_ball isScalarTower_closedBall_closedBall_closedBall
instance isScalarTower_closedBall_closedBall_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_ball isScalarTower_closedBall_closedBall_ball
instance isScalarTower_sphere_closedBall_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_closed_ball isScalarTower_sphere_closedBall_closedBall
instance isScalarTower_sphere_closedBall_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_ball isScalarTower_sphere_closedBall_ball
instance isScalarTower_sphere_sphere_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_closed_ball isScalarTower_sphere_sphere_closedBall
instance isScalarTower_sphere_sphere_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_ball isScalarTower_sphere_sphere_ball
instance isScalarTower_sphere_sphere_sphere :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_sphere isScalarTower_sphere_sphere_sphere
instance isScalarTower_sphere_ball_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_sphere_ball_ball isScalarTower_sphere_ball_ball
instance isScalarTower_closedBall_ball_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_closed_ball_ball_ball isScalarTower_closedBall_ball_ball
end IsScalarTower
section SMulCommClass
variable [SMulCommClass 𝕜 𝕜' E]
instance instSMulCommClass_closedBall_closedBall_closedBall :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_closed_ball instSMulCommClass_closedBall_closedBall_closedBall
instance instSMulCommClass_closedBall_closedBall_ball :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_ball instSMulCommClass_closedBall_closedBall_ball
instance instSMulCommClass_sphere_closedBall_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_closed_ball instSMulCommClass_sphere_closedBall_closedBall
instance instSMulCommClass_sphere_closedBall_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_ball instSMulCommClass_sphere_closedBall_ball
instance instSMulCommClass_sphere_ball_ball [NormedAlgebra 𝕜 𝕜'] :
SMulCommClass (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align smul_comm_class_sphere_ball_ball instSMulCommClass_sphere_ball_ball
instance instSMulCommClass_sphere_sphere_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_closed_ball instSMulCommClass_sphere_sphere_closedBall
instance instSMulCommClass_sphere_sphere_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_ball instSMulCommClass_sphere_sphere_ball
instance instSMulCommClass_sphere_sphere_sphere :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_sphere instSMulCommClass_sphere_sphere_sphere
end SMulCommClass
variable (𝕜)
variable [CharZero 𝕜]
theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by conv_lhs => | rw [h] | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by conv_lhs => | Mathlib.Analysis.NormedSpace.BallAction.203_0.NWEJH2CyESYnSt3 | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x | Mathlib_Analysis_NormedSpace_BallAction |
𝕜 : Type u_1
𝕜' : Type u_2
E : Type u_3
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedField 𝕜'
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedSpace 𝕜' E
r✝ : ℝ
inst✝ : CharZero 𝕜
r : ℝ
hr : r ≠ 0
x : ↑(sphere 0 r)
h : x = -x
| ↑x | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.normed_space.ball_action from "leanprover-community/mathlib"@"3339976e2bcae9f1c81e620836d1eb736e3c4700"
/-!
# Multiplicative actions of/on balls and spheres
Let `E` be a normed vector space over a normed field `𝕜`. In this file we define the following
multiplicative actions.
- The closed unit ball in `𝕜` acts on open balls and closed balls centered at `0` in `E`.
- The unit sphere in `𝕜` acts on open balls, closed balls, and spheres centered at `0` in `E`.
-/
open Metric Set
variable {𝕜 𝕜' E : Type*} [NormedField 𝕜] [NormedField 𝕜'] [SeminormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedSpace 𝕜' E] {r : ℝ}
section ClosedBall
instance mulActionClosedBallBall : MulAction (closedBall (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_ball_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _)
one_pos⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_ball mulActionClosedBallBall
instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_ball continuousSMul_closedBall_ball
instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r)
where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_closedBall_zero_iff.2 <| by
simpa only [norm_smul, one_mul] using
mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _)
zero_le_one⟩
one_smul x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_closed_ball_closed_ball mulActionClosedBallClosedBall
instance continuousSMul_closedBall_closedBall :
ContinuousSMul (closedBall (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_closed_ball_closed_ball continuousSMul_closedBall_closedBall
end ClosedBall
section Sphere
instance mulActionSphereBall : MulAction (sphere (0 : 𝕜) 1) (ball (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_ball mulActionSphereBall
instance continuousSMul_sphere_ball : ContinuousSMul (sphere (0 : 𝕜) 1) (ball (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_ball continuousSMul_sphere_ball
instance mulActionSphereClosedBall : MulAction (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) where
smul c x := inclusion sphere_subset_closedBall c • x
one_smul _ := Subtype.ext <| one_smul _ _
mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_closed_ball mulActionSphereClosedBall
instance continuousSMul_sphere_closedBall :
ContinuousSMul (sphere (0 : 𝕜) 1) (closedBall (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_closed_ball continuousSMul_sphere_closedBall
instance mulActionSphereSphere : MulAction (sphere (0 : 𝕜) 1) (sphere (0 : E) r) where
smul c x :=
⟨(c : 𝕜) • ↑x,
mem_sphere_zero_iff_norm.2 <| by
rw [norm_smul, mem_sphere_zero_iff_norm.1 c.coe_prop, mem_sphere_zero_iff_norm.1 x.coe_prop,
one_mul]⟩
one_smul x := Subtype.ext <| one_smul _ _
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul _ _ _
#align mul_action_sphere_sphere mulActionSphereSphere
instance continuousSMul_sphere_sphere : ContinuousSMul (sphere (0 : 𝕜) 1) (sphere (0 : E) r) :=
⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩
#align has_continuous_smul_sphere_sphere continuousSMul_sphere_sphere
end Sphere
section IsScalarTower
variable [NormedAlgebra 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' E]
instance isScalarTower_closedBall_closedBall_closedBall :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_closed_ball isScalarTower_closedBall_closedBall_closedBall
instance isScalarTower_closedBall_closedBall_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_closed_ball_closed_ball_ball isScalarTower_closedBall_closedBall_ball
instance isScalarTower_sphere_closedBall_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_closed_ball isScalarTower_sphere_closedBall_closedBall
instance isScalarTower_sphere_closedBall_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_closed_ball_ball isScalarTower_sphere_closedBall_ball
instance isScalarTower_sphere_sphere_closedBall :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_closed_ball isScalarTower_sphere_sphere_closedBall
instance isScalarTower_sphere_sphere_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_ball isScalarTower_sphere_sphere_ball
instance isScalarTower_sphere_sphere_sphere :
IsScalarTower (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : E)⟩
#align is_scalar_tower_sphere_sphere_sphere isScalarTower_sphere_sphere_sphere
instance isScalarTower_sphere_ball_ball :
IsScalarTower (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_sphere_ball_ball isScalarTower_sphere_ball_ball
instance isScalarTower_closedBall_ball_ball :
IsScalarTower (closedBall (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_assoc (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align is_scalar_tower_closed_ball_ball_ball isScalarTower_closedBall_ball_ball
end IsScalarTower
section SMulCommClass
variable [SMulCommClass 𝕜 𝕜' E]
instance instSMulCommClass_closedBall_closedBall_closedBall :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_closed_ball instSMulCommClass_closedBall_closedBall_closedBall
instance instSMulCommClass_closedBall_closedBall_ball :
SMulCommClass (closedBall (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_closed_ball_closed_ball_ball instSMulCommClass_closedBall_closedBall_ball
instance instSMulCommClass_sphere_closedBall_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_closed_ball instSMulCommClass_sphere_closedBall_closedBall
instance instSMulCommClass_sphere_closedBall_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (closedBall (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_closed_ball_ball instSMulCommClass_sphere_closedBall_ball
instance instSMulCommClass_sphere_ball_ball [NormedAlgebra 𝕜 𝕜'] :
SMulCommClass (sphere (0 : 𝕜) 1) (ball (0 : 𝕜') 1) (ball (0 : 𝕜') 1) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : 𝕜')⟩
#align smul_comm_class_sphere_ball_ball instSMulCommClass_sphere_ball_ball
instance instSMulCommClass_sphere_sphere_closedBall :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (closedBall (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_closed_ball instSMulCommClass_sphere_sphere_closedBall
instance instSMulCommClass_sphere_sphere_ball :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (ball (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_ball instSMulCommClass_sphere_sphere_ball
instance instSMulCommClass_sphere_sphere_sphere :
SMulCommClass (sphere (0 : 𝕜) 1) (sphere (0 : 𝕜') 1) (sphere (0 : E) r) :=
⟨fun a b c => Subtype.ext <| smul_comm (a : 𝕜) (b : 𝕜') (c : E)⟩
#align smul_comm_class_sphere_sphere_sphere instSMulCommClass_sphere_sphere_sphere
end SMulCommClass
variable (𝕜)
variable [CharZero 𝕜]
theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by conv_lhs => | rw [h] | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by conv_lhs => | Mathlib.Analysis.NormedSpace.BallAction.203_0.NWEJH2CyESYnSt3 | theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x | Mathlib_Analysis_NormedSpace_BallAction |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b : R
s : S
inst✝³ : SMul R M
inst✝² : SMul R S
inst✝¹ : SMul S M
inst✝ : IsScalarTower R S M
a : R
ab : IsSMulRegular M (a • s)
c d : M
cd : ((fun m => a • m) ∘ fun x => s • x) c = ((fun m => a • m) ∘ fun x => s • x) d
⊢ c = d | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
| dsimp only [Function.comp_def] at cd | /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
| Mathlib.Algebra.Regular.SMul.72_0.jyFiiORgtZ4G1XR | /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b : R
s : S
inst✝³ : SMul R M
inst✝² : SMul R S
inst✝¹ : SMul S M
inst✝ : IsScalarTower R S M
a : R
ab : IsSMulRegular M (a • s)
c d : M
cd : a • s • c = a • s • d
⊢ c = d | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
| rw [← smul_assoc, ← smul_assoc] at cd | /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
| Mathlib.Algebra.Regular.SMul.72_0.jyFiiORgtZ4G1XR | /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b : R
s : S
inst✝³ : SMul R M
inst✝² : SMul R S
inst✝¹ : SMul S M
inst✝ : IsScalarTower R S M
a : R
ab : IsSMulRegular M (a • s)
c d : M
cd : (a • s) • c = (a • s) • d
⊢ c = d | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
| exact ab cd | /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
| Mathlib.Algebra.Regular.SMul.72_0.jyFiiORgtZ4G1XR | /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
ab : IsSMulRegular M (a * b)
⊢ IsSMulRegular M b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
| rw [← smul_eq_mul] at ab | theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
| Mathlib.Algebra.Regular.SMul.102_0.jyFiiORgtZ4G1XR | theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
ab : IsSMulRegular M (a • b)
⊢ IsSMulRegular M b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
| exact ab.of_smul _ | theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
| Mathlib.Algebra.Regular.SMul.102_0.jyFiiORgtZ4G1XR | theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
⊢ IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
| refine' ⟨_, _⟩ | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
| Mathlib.Algebra.Regular.SMul.114_0.jyFiiORgtZ4G1XR | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
case refine'_1
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
⊢ IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) → IsSMulRegular M a ∧ IsSMulRegular M b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· | rintro ⟨ab, ba⟩ | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· | Mathlib.Algebra.Regular.SMul.114_0.jyFiiORgtZ4G1XR | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
case refine'_1.intro
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
ab : IsSMulRegular M (a * b)
ba : IsSMulRegular M (b * a)
⊢ IsSMulRegular M a ∧ IsSMulRegular M b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
| refine' ⟨ba.of_mul, ab.of_mul⟩ | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
| Mathlib.Algebra.Regular.SMul.114_0.jyFiiORgtZ4G1XR | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
case refine'_2
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
⊢ IsSMulRegular M a ∧ IsSMulRegular M b → IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· | rintro ⟨ha, hb⟩ | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· | Mathlib.Algebra.Regular.SMul.114_0.jyFiiORgtZ4G1XR | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
case refine'_2.intro
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁵ : SMul R M
inst✝⁴ : SMul R S
inst✝³ : SMul S M
inst✝² : IsScalarTower R S M
inst✝¹ : Mul R
inst✝ : IsScalarTower R R M
ha : IsSMulRegular M a
hb : IsSMulRegular M b
⊢ IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
| exact ⟨ha.mul hb, hb.mul ha⟩ | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
| Mathlib.Algebra.Regular.SMul.114_0.jyFiiORgtZ4G1XR | /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
a b : M
ab : (fun x => 1 • x) a = (fun x => 1 • x) b
⊢ a = b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
| dsimp only [Function.comp_def] at ab | /-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
| Mathlib.Algebra.Regular.SMul.133_0.jyFiiORgtZ4G1XR | /-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
a b : M
ab : 1 • a = 1 • b
⊢ a = b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
| rw [one_smul, one_smul] at ab | /-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
| Mathlib.Algebra.Regular.SMul.133_0.jyFiiORgtZ4G1XR | /-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
a b : M
ab : a = b
⊢ a = b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
| assumption | /-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
| Mathlib.Algebra.Regular.SMul.133_0.jyFiiORgtZ4G1XR | /-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
h : a * b = 1
⊢ IsSMulRegular M (?m.10627 h * b) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
| rw [h] | /-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
| Mathlib.Algebra.Regular.SMul.143_0.jyFiiORgtZ4G1XR | /-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
h : a * b = 1
⊢ IsSMulRegular M 1 | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
| exact one M | /-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
| Mathlib.Algebra.Regular.SMul.143_0.jyFiiORgtZ4G1XR | /-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
n : ℕ
ra : IsSMulRegular M a
⊢ IsSMulRegular M (a ^ n) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
| induction' n with n hn | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
| Mathlib.Algebra.Regular.SMul.151_0.jyFiiORgtZ4G1XR | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) | Mathlib_Algebra_Regular_SMul |
case zero
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
ra : IsSMulRegular M a
⊢ IsSMulRegular M (a ^ Nat.zero) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· | rw [pow_zero] | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· | Mathlib.Algebra.Regular.SMul.151_0.jyFiiORgtZ4G1XR | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) | Mathlib_Algebra_Regular_SMul |
case zero
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
ra : IsSMulRegular M a
⊢ IsSMulRegular M 1 | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; | simp only [one] | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; | Mathlib.Algebra.Regular.SMul.151_0.jyFiiORgtZ4G1XR | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) | Mathlib_Algebra_Regular_SMul |
case succ
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
ra : IsSMulRegular M a
n : ℕ
hn : IsSMulRegular M (a ^ n)
⊢ IsSMulRegular M (a ^ Nat.succ n) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· | rw [pow_succ] | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· | Mathlib.Algebra.Regular.SMul.151_0.jyFiiORgtZ4G1XR | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) | Mathlib_Algebra_Regular_SMul |
case succ
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
ra : IsSMulRegular M a
n : ℕ
hn : IsSMulRegular M (a ^ n)
⊢ IsSMulRegular M (a * a ^ n) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
| exact (ra.smul_iff (a ^ n)).mpr hn | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
| Mathlib.Algebra.Regular.SMul.151_0.jyFiiORgtZ4G1XR | /-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
n : ℕ
n0 : 0 < n
⊢ IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
| refine' ⟨_, pow n⟩ | /-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
| Mathlib.Algebra.Regular.SMul.159_0.jyFiiORgtZ4G1XR | /-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
n : ℕ
n0 : 0 < n
⊢ IsSMulRegular M (a ^ n) → IsSMulRegular M a | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
| rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul] | /-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
| Mathlib.Algebra.Regular.SMul.159_0.jyFiiORgtZ4G1XR | /-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
n : ℕ
n0 : 0 < n
⊢ IsSMulRegular M (a ^ Nat.pred n • a) → IsSMulRegular M a | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
| exact of_smul _ | /-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
| Mathlib.Algebra.Regular.SMul.159_0.jyFiiORgtZ4G1XR | /-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁴ : Monoid S
inst✝³ : SMul R M
inst✝² : SMul R S
inst✝¹ : MulAction S M
inst✝ : IsScalarTower R S M
h : a • s = 1
⊢ IsSMulRegular M (a • s) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
| rw [h] | /-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
| Mathlib.Algebra.Regular.SMul.172_0.jyFiiORgtZ4G1XR | /-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁴ : Monoid S
inst✝³ : SMul R M
inst✝² : SMul R S
inst✝¹ : MulAction S M
inst✝ : IsScalarTower R S M
h : a • s = 1
⊢ IsSMulRegular M 1 | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
| exact one M | /-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
| Mathlib.Algebra.Regular.SMul.172_0.jyFiiORgtZ4G1XR | /-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
h : IsSMulRegular M 0
a b : M
⊢ (fun x => 0 • x) a = (fun x => 0 • x) b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by | dsimp only [Function.comp_def] | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by | Mathlib.Algebra.Regular.SMul.187_0.jyFiiORgtZ4G1XR | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
h : IsSMulRegular M 0
a b : M
⊢ 0 • a = 0 • b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; | repeat' rw [MulActionWithZero.zero_smul] | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; | Mathlib.Algebra.Regular.SMul.187_0.jyFiiORgtZ4G1XR | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
h : IsSMulRegular M 0
a b : M
⊢ 0 • a = 0 • b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' | rw [MulActionWithZero.zero_smul] | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' | Mathlib.Algebra.Regular.SMul.187_0.jyFiiORgtZ4G1XR | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a✝ b✝ : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
h : IsSMulRegular M 0
a b : M
⊢ 0 = 0 • b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' | rw [MulActionWithZero.zero_smul] | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' | Mathlib.Algebra.Regular.SMul.187_0.jyFiiORgtZ4G1XR | /-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
⊢ ¬IsSMulRegular M 0 ↔ Nontrivial M | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
| rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff] | /-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
| Mathlib.Algebra.Regular.SMul.197_0.jyFiiORgtZ4G1XR | /-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
⊢ (¬∃ x y, x ≠ y) ↔ ∀ (x y : M), x = y | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
| push_neg | /-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
| Mathlib.Algebra.Regular.SMul.197_0.jyFiiORgtZ4G1XR | /-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝⁶ : MonoidWithZero R
inst✝⁵ : MonoidWithZero S
inst✝⁴ : Zero M
inst✝³ : MulActionWithZero R M
inst✝² : MulActionWithZero R S
inst✝¹ : MulActionWithZero S M
inst✝ : IsScalarTower R S M
⊢ (∀ (x y : M), x = y) ↔ ∀ (x y : M), x = y | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
| exact Iff.rfl | /-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
| Mathlib.Algebra.Regular.SMul.197_0.jyFiiORgtZ4G1XR | /-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝² : CommSemigroup R
inst✝¹ : SMul R M
inst✝ : IsScalarTower R R M
⊢ IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
| rw [← mul_and_mul_iff] | /-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
| Mathlib.Algebra.Regular.SMul.220_0.jyFiiORgtZ4G1XR | /-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝² : CommSemigroup R
inst✝¹ : SMul R M
inst✝ : IsScalarTower R R M
⊢ IsSMulRegular M (a * b) ↔ IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
| exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩ | /-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
| Mathlib.Algebra.Regular.SMul.220_0.jyFiiORgtZ4G1XR | /-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝² : CommSemigroup R
inst✝¹ : SMul R M
inst✝ : IsScalarTower R R M
ab : IsSMulRegular M (a * b)
⊢ IsSMulRegular M (b * a) | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by | rwa [mul_comm] | /-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by | Mathlib.Algebra.Regular.SMul.220_0.jyFiiORgtZ4G1XR | /-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
G : Type u_4
inst✝¹ : Group G
inst✝ : MulAction G R
g : G
⊢ IsSMulRegular R g | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩
#align is_smul_regular.mul_iff IsSMulRegular.mul_iff
end CommSemigroup
end IsSMulRegular
section Group
variable {G : Type*} [Group G]
/-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
| intro x y h | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
| Mathlib.Algebra.Regular.SMul.234_0.jyFiiORgtZ4G1XR | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
G : Type u_4
inst✝¹ : Group G
inst✝ : MulAction G R
g : G
x y : R
h : (fun x => g • x) x = (fun x => g • x) y
⊢ x = y | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩
#align is_smul_regular.mul_iff IsSMulRegular.mul_iff
end CommSemigroup
end IsSMulRegular
section Group
variable {G : Type*} [Group G]
/-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
| convert congr_arg (g⁻¹ • ·) h using 1 | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
| Mathlib.Algebra.Regular.SMul.234_0.jyFiiORgtZ4G1XR | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g | Mathlib_Algebra_Regular_SMul |
case h.e'_2
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
G : Type u_4
inst✝¹ : Group G
inst✝ : MulAction G R
g : G
x y : R
h : (fun x => g • x) x = (fun x => g • x) y
⊢ x = g⁻¹ • (fun x => g • x) x | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩
#align is_smul_regular.mul_iff IsSMulRegular.mul_iff
end CommSemigroup
end IsSMulRegular
section Group
variable {G : Type*} [Group G]
/-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
convert congr_arg (g⁻¹ • ·) h using 1 <;> | simp [← smul_assoc] | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
convert congr_arg (g⁻¹ • ·) h using 1 <;> | Mathlib.Algebra.Regular.SMul.234_0.jyFiiORgtZ4G1XR | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g | Mathlib_Algebra_Regular_SMul |
case h.e'_3
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
G : Type u_4
inst✝¹ : Group G
inst✝ : MulAction G R
g : G
x y : R
h : (fun x => g • x) x = (fun x => g • x) y
⊢ y = g⁻¹ • (fun x => g • x) y | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩
#align is_smul_regular.mul_iff IsSMulRegular.mul_iff
end CommSemigroup
end IsSMulRegular
section Group
variable {G : Type*} [Group G]
/-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
convert congr_arg (g⁻¹ • ·) h using 1 <;> | simp [← smul_assoc] | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
convert congr_arg (g⁻¹ • ·) h using 1 <;> | Mathlib.Algebra.Regular.SMul.234_0.jyFiiORgtZ4G1XR | /-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g | Mathlib_Algebra_Regular_SMul |
R : Type u_1
S : Type u_2
M : Type u_3
a b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
ua : IsUnit a
⊢ IsSMulRegular M a | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩
#align is_smul_regular.mul_iff IsSMulRegular.mul_iff
end CommSemigroup
end IsSMulRegular
section Group
variable {G : Type*} [Group G]
/-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
convert congr_arg (g⁻¹ • ·) h using 1 <;> simp [← smul_assoc]
#align is_smul_regular_of_group isSMulRegular_of_group
end Group
section Units
variable [Monoid R] [MulAction R M]
/-- Any element in `Rˣ` is `M`-regular. -/
theorem Units.isSMulRegular (a : Rˣ) : IsSMulRegular M (a : R) :=
IsSMulRegular.of_mul_eq_one a.inv_val
#align units.is_smul_regular Units.isSMulRegular
/-- A unit is `M`-regular. -/
theorem IsUnit.isSMulRegular (ua : IsUnit a) : IsSMulRegular M a := by
| rcases ua with ⟨a, rfl⟩ | /-- A unit is `M`-regular. -/
theorem IsUnit.isSMulRegular (ua : IsUnit a) : IsSMulRegular M a := by
| Mathlib.Algebra.Regular.SMul.252_0.jyFiiORgtZ4G1XR | /-- A unit is `M`-regular. -/
theorem IsUnit.isSMulRegular (ua : IsUnit a) : IsSMulRegular M a | Mathlib_Algebra_Regular_SMul |
case intro
R : Type u_1
S : Type u_2
M : Type u_3
b : R
s : S
inst✝¹ : Monoid R
inst✝ : MulAction R M
a : Rˣ
⊢ IsSMulRegular M ↑a | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.SMulWithZero
import Mathlib.Algebra.Regular.Basic
#align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
/-!
# Action of regular elements on a module
We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding
predicate is called `IsSMulRegular`.
There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest
is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there
is no actual requirement of having an addition, but there is a zero in both `R` and `M`.
SMultiplications involving `0` are, of course, all trivial.
The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map
`M → M`, defined by `m ↦ a • m`, is injective.
This property is the direct generalization to modules of the property `IsLeftRegular` defined in
`Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions
coincide.
-/
variable {R S : Type*} (M : Type*) {a b : R} {s : S}
/-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an
injective map `M → M`. -/
def IsSMulRegular [SMul R M] (c : R) :=
Function.Injective ((c • ·) : M → M)
#align is_smul_regular IsSMulRegular
theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c :=
h
#align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular
/-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/
theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a :=
Iff.rfl
#align is_left_regular_iff isLeftRegular_iff
theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) :
IsSMulRegular R (MulOpposite.op c) :=
h
#align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular
/-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/
theorem isRightRegular_iff [Mul R] {a : R} :
IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) :=
Iff.rfl
#align is_right_regular_iff isRightRegular_iff
namespace IsSMulRegular
variable {M}
section SMul
variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M]
/-- The product of `M`-regular elements is `M`-regular. -/
theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) :=
fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _))))
#align is_smul_regular.smul IsSMulRegular.smul
/-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular
element, then `b` is `M`-regular. -/
theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s :=
@Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by
dsimp only [Function.comp_def] at cd
rw [← smul_assoc, ← smul_assoc] at cd
exact ab cd
#align is_smul_regular.of_smul IsSMulRegular.of_smul
/-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element
is `M`-regular. -/
@[simp]
theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b :=
⟨of_smul _, ha.smul⟩
#align is_smul_regular.smul_iff IsSMulRegular.smul_iff
theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a :=
h
#align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular
theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) :
IsRightRegular a :=
h
#align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular
theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) :
IsSMulRegular M (a * b) :=
ra.smul rb
#align is_smul_regular.mul IsSMulRegular.mul
theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) :
IsSMulRegular M b := by
rw [← smul_eq_mul] at ab
exact ab.of_smul _
#align is_smul_regular.of_mul IsSMulRegular.of_mul
@[simp]
theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) :
IsSMulRegular M (a * b) ↔ IsSMulRegular M b :=
⟨of_mul, ha.mul⟩
#align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right
/-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a`
are `M`-regular. -/
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] :
IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine' ⟨_, _⟩
· rintro ⟨ab, ba⟩
refine' ⟨ba.of_mul, ab.of_mul⟩
· rintro ⟨ha, hb⟩
exact ⟨ha.mul hb, hb.mul ha⟩
#align is_smul_regular.mul_and_mul_iff IsSMulRegular.mul_and_mul_iff
end SMul
section Monoid
variable [Monoid R] [MulAction R M]
variable (M)
/-- One is always `M`-regular. -/
@[simp]
theorem one : IsSMulRegular M (1 : R) := fun a b ab => by
dsimp only [Function.comp_def] at ab
rw [one_smul, one_smul] at ab
assumption
#align is_smul_regular.one IsSMulRegular.one
variable {M}
/-- An element of `R` admitting a left inverse is `M`-regular. -/
theorem of_mul_eq_one (h : a * b = 1) : IsSMulRegular M b :=
of_mul
(by
rw [h]
exact one M)
#align is_smul_regular.of_mul_eq_one IsSMulRegular.of_mul_eq_one
/-- Any power of an `M`-regular element is `M`-regular. -/
theorem pow (n : ℕ) (ra : IsSMulRegular M a) : IsSMulRegular M (a ^ n) := by
induction' n with n hn
· rw [pow_zero]; simp only [one]
· rw [pow_succ]
exact (ra.smul_iff (a ^ n)).mpr hn
#align is_smul_regular.pow IsSMulRegular.pow
/-- An element `a` is `M`-regular if and only if a positive power of `a` is `M`-regular. -/
theorem pow_iff {n : ℕ} (n0 : 0 < n) : IsSMulRegular M (a ^ n) ↔ IsSMulRegular M a := by
refine' ⟨_, pow n⟩
rw [← Nat.succ_pred_eq_of_pos n0, pow_succ', ← smul_eq_mul]
exact of_smul _
#align is_smul_regular.pow_iff IsSMulRegular.pow_iff
end Monoid
section MonoidSMul
variable [Monoid S] [SMul R M] [SMul R S] [MulAction S M] [IsScalarTower R S M]
/-- An element of `S` admitting a left inverse in `R` is `M`-regular. -/
theorem of_smul_eq_one (h : a • s = 1) : IsSMulRegular M s :=
of_smul a
(by
rw [h]
exact one M)
#align is_smul_regular.of_smul_eq_one IsSMulRegular.of_smul_eq_one
end MonoidSMul
section MonoidWithZero
variable [MonoidWithZero R] [MonoidWithZero S] [Zero M] [MulActionWithZero R M]
[MulActionWithZero R S] [MulActionWithZero S M] [IsScalarTower R S M]
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
protected theorem subsingleton (h : IsSMulRegular M (0 : R)) : Subsingleton M :=
⟨fun a b => h (by dsimp only [Function.comp_def]; repeat' rw [MulActionWithZero.zero_smul])⟩
#align is_smul_regular.subsingleton IsSMulRegular.subsingleton
/-- The element `0` is `M`-regular if and only if `M` is trivial. -/
theorem zero_iff_subsingleton : IsSMulRegular M (0 : R) ↔ Subsingleton M :=
⟨fun h => h.subsingleton, fun H a b _ => @Subsingleton.elim _ H a b⟩
#align is_smul_regular.zero_iff_subsingleton IsSMulRegular.zero_iff_subsingleton
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero_iff : ¬IsSMulRegular M (0 : R) ↔ Nontrivial M := by
rw [nontrivial_iff, not_iff_comm, zero_iff_subsingleton, subsingleton_iff]
push_neg
exact Iff.rfl
#align is_smul_regular.not_zero_iff IsSMulRegular.not_zero_iff
/-- The element `0` is `M`-regular when `M` is trivial. -/
theorem zero [sM : Subsingleton M] : IsSMulRegular M (0 : R) :=
zero_iff_subsingleton.mpr sM
#align is_smul_regular.zero IsSMulRegular.zero
/-- The `0` element is not `M`-regular, on a non-trivial module. -/
theorem not_zero [nM : Nontrivial M] : ¬IsSMulRegular M (0 : R) :=
not_zero_iff.mpr nM
#align is_smul_regular.not_zero IsSMulRegular.not_zero
end MonoidWithZero
section CommSemigroup
variable [CommSemigroup R] [SMul R M] [IsScalarTower R R M]
/-- A product is `M`-regular if and only if the factors are. -/
theorem mul_iff : IsSMulRegular M (a * b) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
rw [← mul_and_mul_iff]
exact ⟨fun ab => ⟨ab, by rwa [mul_comm]⟩, fun rab => rab.1⟩
#align is_smul_regular.mul_iff IsSMulRegular.mul_iff
end CommSemigroup
end IsSMulRegular
section Group
variable {G : Type*} [Group G]
/-- An element of a group acting on a Type is regular. This relies on the availability
of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/
theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by
intro x y h
convert congr_arg (g⁻¹ • ·) h using 1 <;> simp [← smul_assoc]
#align is_smul_regular_of_group isSMulRegular_of_group
end Group
section Units
variable [Monoid R] [MulAction R M]
/-- Any element in `Rˣ` is `M`-regular. -/
theorem Units.isSMulRegular (a : Rˣ) : IsSMulRegular M (a : R) :=
IsSMulRegular.of_mul_eq_one a.inv_val
#align units.is_smul_regular Units.isSMulRegular
/-- A unit is `M`-regular. -/
theorem IsUnit.isSMulRegular (ua : IsUnit a) : IsSMulRegular M a := by
rcases ua with ⟨a, rfl⟩
| exact a.isSMulRegular M | /-- A unit is `M`-regular. -/
theorem IsUnit.isSMulRegular (ua : IsUnit a) : IsSMulRegular M a := by
rcases ua with ⟨a, rfl⟩
| Mathlib.Algebra.Regular.SMul.252_0.jyFiiORgtZ4G1XR | /-- A unit is `M`-regular. -/
theorem IsUnit.isSMulRegular (ua : IsUnit a) : IsSMulRegular M a | Mathlib_Algebra_Regular_SMul |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝¹ : NonUnitalNonAssocSemiring α
inst✝ : NonUnitalNonAssocSemiring β
f g : α →ₙ+* β
h : (fun f => f.toFun) f = (fun f => f.toFun) g
⊢ f = g | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
| cases f | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
| Mathlib.Algebra.Ring.Hom.Defs.104_0.KyHvVYrIs9pW9ZQ | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝¹ : NonUnitalNonAssocSemiring α
inst✝ : NonUnitalNonAssocSemiring β
g : α →ₙ+* β
toMulHom✝ : α →ₙ* β
map_zero'✝ : MulHom.toFun toMulHom✝ 0 = 0
map_add'✝ : ∀ (x y : α), MulHom.toFun toMulHom✝ (x + y) = MulHom.toFun toMulHom✝ x + MulHom.toFun toMulHom✝ y
h : (fun f => f.toFun) { toMulHom := toMulHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } = (fun f => f.toFun) g
⊢ { toMulHom := toMulHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } = g | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
| cases g | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
| Mathlib.Algebra.Ring.Hom.Defs.104_0.KyHvVYrIs9pW9ZQ | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk.mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝¹ : NonUnitalNonAssocSemiring α
inst✝ : NonUnitalNonAssocSemiring β
toMulHom✝¹ : α →ₙ* β
map_zero'✝¹ : MulHom.toFun toMulHom✝¹ 0 = 0
map_add'✝¹ : ∀ (x y : α), MulHom.toFun toMulHom✝¹ (x + y) = MulHom.toFun toMulHom✝¹ x + MulHom.toFun toMulHom✝¹ y
toMulHom✝ : α →ₙ* β
map_zero'✝ : MulHom.toFun toMulHom✝ 0 = 0
map_add'✝ : ∀ (x y : α), MulHom.toFun toMulHom✝ (x + y) = MulHom.toFun toMulHom✝ x + MulHom.toFun toMulHom✝ y
h :
(fun f => f.toFun) { toMulHom := toMulHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
(fun f => f.toFun) { toMulHom := toMulHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ { toMulHom := toMulHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
{ toMulHom := toMulHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
| congr | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
| Mathlib.Algebra.Ring.Hom.Defs.104_0.KyHvVYrIs9pW9ZQ | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk.mk.e_toMulHom
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝¹ : NonUnitalNonAssocSemiring α
inst✝ : NonUnitalNonAssocSemiring β
toMulHom✝¹ : α →ₙ* β
map_zero'✝¹ : MulHom.toFun toMulHom✝¹ 0 = 0
map_add'✝¹ : ∀ (x y : α), MulHom.toFun toMulHom✝¹ (x + y) = MulHom.toFun toMulHom✝¹ x + MulHom.toFun toMulHom✝¹ y
toMulHom✝ : α →ₙ* β
map_zero'✝ : MulHom.toFun toMulHom✝ 0 = 0
map_add'✝ : ∀ (x y : α), MulHom.toFun toMulHom✝ (x + y) = MulHom.toFun toMulHom✝ x + MulHom.toFun toMulHom✝ y
h :
(fun f => f.toFun) { toMulHom := toMulHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
(fun f => f.toFun) { toMulHom := toMulHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ toMulHom✝¹ = toMulHom✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
| apply FunLike.coe_injective' | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
| Mathlib.Algebra.Ring.Hom.Defs.104_0.KyHvVYrIs9pW9ZQ | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk.mk.e_toMulHom.a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝¹ : NonUnitalNonAssocSemiring α
inst✝ : NonUnitalNonAssocSemiring β
toMulHom✝¹ : α →ₙ* β
map_zero'✝¹ : MulHom.toFun toMulHom✝¹ 0 = 0
map_add'✝¹ : ∀ (x y : α), MulHom.toFun toMulHom✝¹ (x + y) = MulHom.toFun toMulHom✝¹ x + MulHom.toFun toMulHom✝¹ y
toMulHom✝ : α →ₙ* β
map_zero'✝ : MulHom.toFun toMulHom✝ 0 = 0
map_add'✝ : ∀ (x y : α), MulHom.toFun toMulHom✝ (x + y) = MulHom.toFun toMulHom✝ x + MulHom.toFun toMulHom✝ y
h :
(fun f => f.toFun) { toMulHom := toMulHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
(fun f => f.toFun) { toMulHom := toMulHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ ⇑toMulHom✝¹ = ⇑toMulHom✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
| exact h | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
| Mathlib.Algebra.Ring.Hom.Defs.104_0.KyHvVYrIs9pW9ZQ | instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ α →ₙ+* α | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
| refine' { toFun := id.. } | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
| Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
case refine'_1
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ ∀ (x y : α), id (x * y) = id x * id y | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> | intros | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> | Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
case refine'_2
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } 0 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> | intros | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> | Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
case refine'_3
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ ∀ (x y : α),
MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } (x + y) =
MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } x +
MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id x * id y) } y | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> | intros | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> | Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
case refine'_1
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
x✝ y✝ : α
⊢ id (x✝ * y✝) = id x✝ * id y✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> | rfl | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> | Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
case refine'_2
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
⊢ MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } 0 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> | rfl | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> | Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
case refine'_3
F : Type u_1
α✝ : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α✝
inst✝¹ : NonUnitalNonAssocSemiring β
α : Type u_5
inst✝ : NonUnitalNonAssocSemiring α
x✝ y✝ : α
⊢ MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } (x✝ + y✝) =
MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } x✝ +
MulHom.toFun { toFun := id, map_mul' := (_ : ∀ (x y : α), id (x * y) = id (x * y)) } y✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> | rfl | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> | Mathlib.Algebra.Ring.Hom.Defs.199_0.KyHvVYrIs9pW9ZQ | /-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g✝ : β →ₙ+* γ
f : α →ₙ+* β
g : β →ₙ+* γ
⊢ comp g 0 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
| ext | @[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
| Mathlib.Algebra.Ring.Hom.Defs.272_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 | Mathlib_Algebra_Ring_Hom_Defs |
case a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g✝ : β →ₙ+* γ
f : α →ₙ+* β
g : β →ₙ+* γ
x✝ : α
⊢ (comp g 0) x✝ = 0 x✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
| simp | @[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
| Mathlib.Algebra.Ring.Hom.Defs.272_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g : β →ₙ+* γ
f✝ f : α →ₙ+* β
⊢ comp 0 f = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
| ext | @[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
| Mathlib.Algebra.Ring.Hom.Defs.278_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 | Mathlib_Algebra_Ring_Hom_Defs |
case a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g : β →ₙ+* γ
f✝ f : α →ₙ+* β
x✝ : α
⊢ (comp 0 f) x✝ = 0 x✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
| rfl | @[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
| Mathlib.Algebra.Ring.Hom.Defs.278_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonUnitalNonAssocSemiring α
inst✝¹ : NonUnitalNonAssocSemiring β
inst✝ : NonUnitalNonAssocSemiring γ
g✝ : β →ₙ+* γ
f : α →ₙ+* β
g : β →ₙ+* γ
f₁ f₂ : α →ₙ+* β
hg : Injective ⇑g
h : comp g f₁ = comp g f₂
x : α
⊢ g (f₁ x) = g (f₂ x) | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by | rw [← comp_apply, h, comp_apply] | @[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by | Mathlib.Algebra.Ring.Hom.Defs.328_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : NonAssocSemiring α
inst✝¹ : NonAssocSemiring β
inst✝ : RingHomClass F α β
f : F
a : α
⊢ f (bit1 a) = bit1 (f a) | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by | simp [bit1] | set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by | Mathlib.Algebra.Ring.Hom.Defs.380_0.KyHvVYrIs9pW9ZQ | set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f g : α →+* β
h : (fun f => f.toFun) f = (fun f => f.toFun) g
⊢ f = g | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
| cases f | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
| Mathlib.Algebra.Ring.Hom.Defs.416_0.KyHvVYrIs9pW9ZQ | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
g : α →+* β
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } =
(fun f => f.toFun) g
⊢ { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } = g | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
| cases g | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
| Mathlib.Algebra.Ring.Hom.Defs.416_0.KyHvVYrIs9pW9ZQ | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk.mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
toMonoidHom✝¹ : α →* β
map_zero'✝¹ : OneHom.toFun (↑toMonoidHom✝¹) 0 = 0
map_add'✝¹ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝¹) (x + y) = OneHom.toFun (↑toMonoidHom✝¹) x + OneHom.toFun (↑toMonoidHom✝¹) y
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
{ toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ } | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
| congr | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
| Mathlib.Algebra.Ring.Hom.Defs.416_0.KyHvVYrIs9pW9ZQ | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk.mk.e_toMonoidHom
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
toMonoidHom✝¹ : α →* β
map_zero'✝¹ : OneHom.toFun (↑toMonoidHom✝¹) 0 = 0
map_add'✝¹ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝¹) (x + y) = OneHom.toFun (↑toMonoidHom✝¹) x + OneHom.toFun (↑toMonoidHom✝¹) y
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ toMonoidHom✝¹ = toMonoidHom✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
| apply FunLike.coe_injective' | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
| Mathlib.Algebra.Ring.Hom.Defs.416_0.KyHvVYrIs9pW9ZQ | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
case mk.mk.e_toMonoidHom.a
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
toMonoidHom✝¹ : α →* β
map_zero'✝¹ : OneHom.toFun (↑toMonoidHom✝¹) 0 = 0
map_add'✝¹ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝¹) (x + y) = OneHom.toFun (↑toMonoidHom✝¹) x + OneHom.toFun (↑toMonoidHom✝¹) y
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
h :
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝¹, map_zero' := map_zero'✝¹, map_add' := map_add'✝¹ } =
(fun f => f.toFun) { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }
⊢ ⇑toMonoidHom✝¹ = ⇑toMonoidHom✝ | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
| exact h | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
| Mathlib.Algebra.Ring.Hom.Defs.416_0.KyHvVYrIs9pW9ZQ | instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f : α →+* β
⊢ ⇑(toMonoidWithZeroHom f) = ⇑f | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
| rfl | theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
| Mathlib.Algebra.Ring.Hom.Defs.474_0.KyHvVYrIs9pW9ZQ | theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f | Mathlib_Algebra_Ring_Hom_Defs |
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
⊢ f (if p then 0 else 1) = if p then 0 else 1 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
| split_ifs with h | @[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
| Mathlib.Algebra.Ring.Hom.Defs.573_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 | Mathlib_Algebra_Ring_Hom_Defs |
case pos
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : p
⊢ f 0 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> | simp [h] | @[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> | Mathlib.Algebra.Ring.Hom.Defs.573_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 | Mathlib_Algebra_Ring_Hom_Defs |
case neg
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : ¬p
⊢ f 1 = 1 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> | simp [h] | @[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> | Mathlib.Algebra.Ring.Hom.Defs.573_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 | Mathlib_Algebra_Ring_Hom_Defs |
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
⊢ f (if p then 1 else 0) = if p then 1 else 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
| split_ifs with h | @[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
| Mathlib.Algebra.Ring.Hom.Defs.579_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 | Mathlib_Algebra_Ring_Hom_Defs |
case pos
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : p
⊢ f 1 = 1 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> | simp [h] | @[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> | Mathlib.Algebra.Ring.Hom.Defs.579_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 | Mathlib_Algebra_Ring_Hom_Defs |
case neg
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f✝ : α →+* β
x y : α
F : Type u_5
inst✝¹ : RingHomClass F α β
f : F
p : Prop
inst✝ : Decidable p
h : ¬p
⊢ f 0 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> | simp [h] | @[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> | Mathlib.Algebra.Ring.Hom.Defs.579_0.KyHvVYrIs9pW9ZQ | @[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f : α →+* β
x y : α
⊢ 0 = 1 ↔ f 1 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_one_zero RingHom.map_ite_one_zero
/-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by | rw [map_one, eq_comm] | /-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by | Mathlib.Algebra.Ring.Hom.Defs.585_0.KyHvVYrIs9pW9ZQ | /-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝² : NonAssocSemiring α
x✝¹ : NonAssocSemiring β
f : α →+* β
x✝ y : α
h : f 1 = 0
x : α
⊢ f x = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_one_zero RingHom.map_ite_one_zero
/-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by rw [map_one, eq_comm]
#align ring_hom.codomain_trivial_iff_map_one_eq_zero RingHom.codomain_trivial_iff_map_one_eq_zero
/-- `f : α →+* β` has a trivial codomain iff it has a trivial range. -/
theorem codomain_trivial_iff_range_trivial : (0 : β) = 1 ↔ ∀ x, f x = 0 :=
f.codomain_trivial_iff_map_one_eq_zero.trans
⟨fun h x => by | rw [← mul_one x, map_mul, h, mul_zero] | /-- `f : α →+* β` has a trivial codomain iff it has a trivial range. -/
theorem codomain_trivial_iff_range_trivial : (0 : β) = 1 ↔ ∀ x, f x = 0 :=
f.codomain_trivial_iff_map_one_eq_zero.trans
⟨fun h x => by | Mathlib.Algebra.Ring.Hom.Defs.589_0.KyHvVYrIs9pW9ZQ | /-- `f : α →+* β` has a trivial codomain iff it has a trivial range. -/
theorem codomain_trivial_iff_range_trivial : (0 : β) = 1 ↔ ∀ x, f x = 0 | Mathlib_Algebra_Ring_Hom_Defs |
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
x✝¹ : NonAssocSemiring α
x✝ : NonAssocSemiring β
f : α →+* β
x y : α
inst✝ : Nontrivial β
h : 1 = 0
⊢ f 1 = 0 | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.Ring.Basic
import Mathlib.Data.Pi.Algebra
#align_import algebra.hom.ring from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9"
/-!
# Homomorphisms of semirings and rings
This file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and
groups, we use the same structure `RingHom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.
## Main definitions
* `NonUnitalRingHom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which
preserve multiplication.
* `RingHom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid
homomorphism.
## Notations
* `→ₙ+*`: Non-unital (semi)ring homs
* `→+*`: (Semi)ring homs
## Implementation notes
* There's a coercion from bundled homs to fun, and the canonical notation is to
use the bundled hom as a function via this coercion.
* There is no `SemiringHom` -- the idea is that `RingHom` is used.
The constructor for a `RingHom` between semirings needs a proof of `map_zero`,
`map_one` and `map_add` as well as `map_mul`; a separate constructor
`RingHom.mk'` will construct ring homs between rings from monoid homs given
only a proof that addition is preserved.
## Tags
`RingHom`, `SemiringHom`
-/
open Function
variable {F α β γ : Type*}
/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring
homomorphisms too.
When possible, instead of parametrizing results over `(f : α →ₙ+* β)`,
you should parametrize over `(F : Type*) [NonUnitalRingHomClass F α β] (f : F)`.
When you extend this structure, make sure to extend `NonUnitalRingHomClass`. -/
structure NonUnitalRingHom (α β : Type*) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β
#align non_unital_ring_hom NonUnitalRingHom
/-- `α →ₙ+* β` denotes the type of non-unital ring homomorphisms from `α` to `β`. -/
infixr:25 " →ₙ+* " => NonUnitalRingHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup
homomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/
add_decl_doc NonUnitalRingHom.toMulHom
#align non_unital_ring_hom.to_mul_hom NonUnitalRingHom.toMulHom
/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive
monoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc NonUnitalRingHom.toAddMonoidHom
#align non_unital_ring_hom.to_add_monoid_hom NonUnitalRingHom.toAddMonoidHom
section NonUnitalRingHomClass
/-- `NonUnitalRingHomClass F α β` states that `F` is a type of non-unital (semi)ring
homomorphisms. You should extend this class when you extend `NonUnitalRingHom`. -/
class NonUnitalRingHomClass (F : Type*) (α β : outParam (Type*)) [NonUnitalNonAssocSemiring α]
[NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β
#align non_unital_ring_hom_class NonUnitalRingHomClass
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]
/-- Turn an element of a type `F` satisfying `NonUnitalRingHomClass F α β` into an actual
`NonUnitalRingHom`. This is declared as the default coercion from `F` to `α →ₙ+* β`. -/
@[coe]
def NonUnitalRingHomClass.toNonUnitalRingHom (f : F) : α →ₙ+* β :=
{ (f : α →ₙ* β), (f : α →+ β) with }
/-- Any type satisfying `NonUnitalRingHomClass` can be cast into `NonUnitalRingHom` via
`NonUnitalRingHomClass.toNonUnitalRingHom`. -/
instance : CoeTC F (α →ₙ+* β) :=
⟨NonUnitalRingHomClass.toNonUnitalRingHom⟩
end NonUnitalRingHomClass
namespace NonUnitalRingHom
section coe
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
instance : NonUnitalRingHomClass (α →ₙ+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := NonUnitalRingHom.map_add'
map_zero := NonUnitalRingHom.map_zero'
map_mul f := f.map_mul'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly. -/
-- instance : CoeFun (α →ₙ+* β) fun _ => α → β :=
-- ⟨fun f => f.toFun⟩
-- Porting note: removed due to new `coe` in Lean4
#noalign non_unital_ring_hom.to_fun_eq_coe
#noalign non_unital_ring_hom.coe_mk
#noalign non_unital_ring_hom.coe_coe
initialize_simps_projections NonUnitalRingHom (toFun → apply)
@[simp]
theorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=
rfl
#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom
@[simp]
theorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=
rfl
#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk
theorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f := rfl
#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :
((⟨⟨f, h₁⟩, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨⟨f, h₂⟩, h₃⟩ :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=
{ f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align non_unital_ring_hom.copy NonUnitalRingHom.copy
@[simp]
theorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy
theorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq
end coe
section
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
variable (f : α →ₙ+* β) {x y : α}
@[ext]
theorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align non_unital_ring_hom.ext NonUnitalRingHom.ext
theorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff
@[simp]
theorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk (MulHom.mk f h₁) h₂ h₃ = f :=
ext fun _ => rfl
#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective fun f : α →ₙ+* β => (f : α →+ β) :=
fun _ _ h => ext <| FunLike.congr_fun (F := α →+ β) h
#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_mulHom_injective : Injective fun f : α →ₙ+* β => (f : α →ₙ* β) := fun _ _ h =>
ext <| MulHom.congr_fun h
#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective
end
variable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β]
/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/
protected def id (α : Type*) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by
refine' { toFun := id.. } <;> intros <;> rfl
#align non_unital_ring_hom.id NonUnitalRingHom.id
instance : Zero (α →ₙ+* β) :=
⟨{ toFun := 0, map_mul' := fun _ _ => (mul_zero (0 : β)).symm, map_zero' := rfl,
map_add' := fun _ _ => (add_zero (0 : β)).symm }⟩
instance : Inhabited (α →ₙ+* β) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=
rfl
#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero
@[simp]
theorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=
rfl
#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply
@[simp]
theorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=
rfl
#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply
@[simp]
theorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=
rfl
#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id
@[simp]
theorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=
rfl
#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id
variable [NonUnitalNonAssocSemiring γ]
/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/
def comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=
{ g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }
#align non_unital_ring_hom.comp NonUnitalRingHom.comp
/-- Composition of non-unital ring homomorphisms is associative. -/
theorem comp_assoc {δ} {_ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)
(h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc
@[simp]
theorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=
rfl
#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp
@[simp]
theorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=
rfl
#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply
variable (g : β →ₙ+* γ) (f : α →ₙ+* β)
@[simp]
theorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
AddMonoidHom.mk ⟨g ∘ f, (g.comp f).map_zero'⟩ (g.comp f).map_add' = (g : β →+ γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom
@[simp]
theorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :
MulHom.mk (g ∘ f) (g.comp f).map_mul' = (g : β →ₙ* γ).comp f :=
rfl
#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom
@[simp]
theorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 := by
ext
simp
#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero
@[simp]
theorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 := by
ext
rfl
#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp
@[simp]
theorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=
ext fun _ => rfl
#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id
@[simp]
theorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=
ext fun _ => rfl
#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp
instance : MonoidWithZero (α →ₙ+* α) where
one := NonUnitalRingHom.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
zero := 0
mul_zero := comp_zero
zero_mul := zero_comp
theorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=
rfl
#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def
@[simp]
theorem coe_one : ⇑(1 : α →ₙ+* α) = id :=
rfl
#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one
theorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=
rfl
#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def
@[simp]
theorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=
rfl
#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul
@[simp]
theorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right
@[simp]
theorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left
end NonUnitalRingHom
/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.
This extends from both `MonoidHom` and `MonoidWithZeroHom` in order to put the fields in a
sensible order, even though `MonoidWithZeroHom` already extends `MonoidHom`. -/
structure RingHom (α : Type*) (β : Type*) [NonAssocSemiring α] [NonAssocSemiring β] extends
α →* β, α →+ β, α →ₙ+* β, α →*₀ β
#align ring_hom RingHom
/-- `α →+* β` denotes the type of ring homomorphisms from `α` to `β`. -/
infixr:25 " →+* " => RingHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.
The `simp`-normal form is `(f : α →*₀ β)`. -/
add_decl_doc RingHom.toMonoidWithZeroHom
#align ring_hom.to_monoid_with_zero_hom RingHom.toMonoidWithZeroHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.
The `simp`-normal form is `(f : α →* β)`. -/
add_decl_doc RingHom.toMonoidHom
#align ring_hom.to_monoid_hom RingHom.toMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.
The `simp`-normal form is `(f : α →+ β)`. -/
add_decl_doc RingHom.toAddMonoidHom
#align ring_hom.to_add_monoid_hom RingHom.toAddMonoidHom
/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The
`simp`-normal form is `(f : α →ₙ+* β)`. -/
add_decl_doc RingHom.toNonUnitalRingHom
#align ring_hom.to_non_unital_ring_hom RingHom.toNonUnitalRingHom
section RingHomClass
/-- `RingHomClass F α β` states that `F` is a type of (semi)ring homomorphisms.
You should extend this class when you extend `RingHom`.
This extends from both `MonoidHomClass` and `MonoidWithZeroHomClass` in
order to put the fields in a sensible order, even though
`MonoidWithZeroHomClass` already extends `MonoidHomClass`. -/
class RingHomClass (F : Type*) (α β : outParam (Type*)) [NonAssocSemiring α]
[NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,
MonoidWithZeroHomClass F α β
#align ring_hom_class RingHomClass
set_option linter.deprecated false in
/-- Ring homomorphisms preserve `bit1`. -/
@[simp] lemma map_bit1 [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]
(f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]
#align map_bit1 map_bit1
-- Porting note: marked `{}` rather than `[]` to prevent dangerous instances
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} [RingHomClass F α β]
/-- Turn an element of a type `F` satisfying `RingHomClass F α β` into an actual
`RingHom`. This is declared as the default coercion from `F` to `α →+* β`. -/
@[coe]
def RingHomClass.toRingHom (f : F) : α →+* β :=
{ (f : α →* β), (f : α →+ β) with }
/-- Any type satisfying `RingHomClass` can be cast into `RingHom` via `RingHomClass.toRingHom`. -/
instance : CoeTC F (α →+* β) :=
⟨RingHomClass.toRingHom⟩
instance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=
{ ‹RingHomClass F α β› with }
#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass
end RingHomClass
namespace RingHom
section coe
/-!
Throughout this section, some `Semiring` arguments are specified with `{}` instead of `[]`.
See note [implicit instance arguments].
-/
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β}
instance instRingHomClass : RingHomClass (α →+* β) α β where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply FunLike.coe_injective'
exact h
map_add := RingHom.map_add'
map_zero := RingHom.map_zero'
map_mul f := f.map_mul'
map_one f := f.map_one'
-- Porting note:
-- These helper instances are unhelpful in Lean 4, so omitting:
-- /-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
-- directly.
-- -/
-- instance : CoeFun (α →+* β) fun _ => α → β :=
-- ⟨RingHom.toFun⟩
initialize_simps_projections RingHom (toFun → apply)
-- Porting note: is this lemma still needed in Lean4?
-- Porting note: because `f.toFun` really means `f.toMonoidHom.toOneHom.toFun` and
-- `toMonoidHom_eq_coe` wants to simplify `f.toMonoidHom` to `(↑f : M →* N)`, this can't
-- be a simp lemma anymore
-- @[simp]
theorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=
rfl
#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe
@[simp]
theorem coe_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_mk RingHom.coe_mk
@[simp]
theorem coe_coe {F : Type*} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=
rfl
#align ring_hom.coe_coe RingHom.coe_coe
attribute [coe] RingHom.toMonoidHom
instance coeToMonoidHom : Coe (α →+* β) (α →* β) :=
⟨RingHom.toMonoidHom⟩
#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_monoid_hom
@[simp]
theorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=
rfl
#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe
-- Porting note: this can't be a simp lemma anymore
-- @[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f := by
rfl
#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe
@[simp]
theorem coe_monoidHom_mk (f : α →* β) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : α →+* β) : α →* β) = f :=
rfl
#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk
-- Porting note: `dsimp only` can prove this
#noalign ring_hom.coe_add_monoid_hom
@[simp]
theorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=
rfl
#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe
@[simp]
theorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨⟨f, h₃⟩, h₄⟩ :=
rfl
#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk
/-- Copy of a `RingHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
def copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=
{ f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }
#align ring_hom.copy RingHom.copy
@[simp]
theorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align ring_hom.coe_copy RingHom.coe_copy
theorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
FunLike.ext' h
#align ring_hom.copy_eq RingHom.copy_eq
end coe
section
variable {_ : NonAssocSemiring α} {_ : NonAssocSemiring β} (f : α →+* β) {x y : α}
theorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=
FunLike.congr_fun h x
#align ring_hom.congr_fun RingHom.congr_fun
theorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=
FunLike.congr_arg f h
#align ring_hom.congr_arg RingHom.congr_arg
theorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=
FunLike.coe_injective h
#align ring_hom.coe_inj RingHom.coe_inj
@[ext]
theorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=
FunLike.ext _ _
#align ring_hom.ext RingHom.ext
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
FunLike.ext_iff
#align ring_hom.ext_iff RingHom.ext_iff
@[simp]
theorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk ⟨⟨f, h₁⟩, h₂⟩ h₃ h₄ = f :=
ext fun _ => rfl
#align ring_hom.mk_coe RingHom.mk_coe
theorem coe_addMonoidHom_injective : Injective (fun f : α →+* β => (f : α →+ β)) := fun _ _ h =>
ext <| FunLike.congr_fun (F := α →+ β) h
#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective
set_option linter.deprecated false in
theorem coe_monoidHom_injective : Injective (fun f : α →+* β => (f : α →* β)) := fun _ _ h =>
ext <| MonoidHom.congr_fun h
#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective
/-- Ring homomorphisms map zero to zero. -/
protected theorem map_zero (f : α →+* β) : f 0 = 0 :=
map_zero f
#align ring_hom.map_zero RingHom.map_zero
/-- Ring homomorphisms map one to one. -/
protected theorem map_one (f : α →+* β) : f 1 = 1 :=
map_one f
#align ring_hom.map_one RingHom.map_one
/-- Ring homomorphisms preserve addition. -/
protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
map_add f
#align ring_hom.map_add RingHom.map_add
/-- Ring homomorphisms preserve multiplication. -/
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
map_mul f
#align ring_hom.map_mul RingHom.map_mul
@[simp]
theorem map_ite_zero_one {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 0 1) = ite p 0 1 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one
@[simp]
theorem map_ite_one_zero {F : Type*} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :
f (ite p 1 0) = ite p 1 0 := by
split_ifs with h <;> simp [h]
#align ring_hom.map_ite_one_zero RingHom.map_ite_one_zero
/-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by rw [map_one, eq_comm]
#align ring_hom.codomain_trivial_iff_map_one_eq_zero RingHom.codomain_trivial_iff_map_one_eq_zero
/-- `f : α →+* β` has a trivial codomain iff it has a trivial range. -/
theorem codomain_trivial_iff_range_trivial : (0 : β) = 1 ↔ ∀ x, f x = 0 :=
f.codomain_trivial_iff_map_one_eq_zero.trans
⟨fun h x => by rw [← mul_one x, map_mul, h, mul_zero], fun h => h 1⟩
#align ring_hom.codomain_trivial_iff_range_trivial RingHom.codomain_trivial_iff_range_trivial
/-- `f : α →+* β` doesn't map `1` to `0` if `β` is nontrivial -/
theorem map_one_ne_zero [Nontrivial β] : f 1 ≠ 0 :=
mt f.codomain_trivial_iff_map_one_eq_zero.mpr zero_ne_one
#align ring_hom.map_one_ne_zero RingHom.map_one_ne_zero
/-- If there is a homomorphism `f : α →+* β` and `β` is nontrivial, then `α` is nontrivial. -/
theorem domain_nontrivial [Nontrivial β] : Nontrivial α :=
⟨⟨1, 0, mt (fun h => show f 1 = 0 by | rw [h, map_zero] | /-- If there is a homomorphism `f : α →+* β` and `β` is nontrivial, then `α` is nontrivial. -/
theorem domain_nontrivial [Nontrivial β] : Nontrivial α :=
⟨⟨1, 0, mt (fun h => show f 1 = 0 by | Mathlib.Algebra.Ring.Hom.Defs.600_0.KyHvVYrIs9pW9ZQ | /-- If there is a homomorphism `f : α →+* β` and `β` is nontrivial, then `α` is nontrivial. -/
theorem domain_nontrivial [Nontrivial β] : Nontrivial α | Mathlib_Algebra_Ring_Hom_Defs |