is_R_or_C
: a typeclass for ℝ or ℂ #
This file defines the typeclass is_R_or_C
intended to have only two instances:
ℝ and ℂ. It is meant for definitions and theorems which hold for both the real and the complex case,
and in particular when the real case follows directly from the complex case by setting re
to id
,
im
to zero and so on. Its API follows closely that of ℂ.
Possible applications include defining inner products and Hilbert spaces for both the real and complex case. One would produce the definitions and proof for an arbitrary field of this typeclass, which basically amounts to doing the complex case, and the two cases then fall out immediately from the two instances of the class.
The instance for ℝ
is registered in this file.
The instance for ℂ
is declared in analysis.complex.basic
.
Implementation notes #
The coercion from reals into an is_R_or_C
field is done by registering algebra_map ℝ K
as
a has_coe_t
. For this to work, we must proceed carefully to avoid problems involving circular
coercions in the case K=ℝ
; in particular, we cannot use the plain has_coe
and must set
priorities carefully. This problem was already solved for ℕ
, and we copy the solution detailed
in data/nat/cast
. See also Note [coercion into rings] for more details.
In addition, several lemmas need to be set at priority 900 to make sure that they do not override
their counterparts in complex.lean
(which causes linter errors).
- to_nondiscrete_normed_field : nondiscrete_normed_field K
- to_normed_algebra : normed_algebra ℝ K
- to_complete_space : complete_space K
- re : K →+ ℝ
- im : K →+ ℝ
- conj : K →+* K
- I : K
- I_re_ax : ⇑is_R_or_C.re is_R_or_C.I = 0
- I_mul_I_ax : is_R_or_C.I = 0 ∨ is_R_or_C.I * is_R_or_C.I = -1
- re_add_im_ax : ∀ (z : K), ⇑(algebra_map ℝ K) (⇑is_R_or_C.re z) + (⇑(algebra_map ℝ K) (⇑is_R_or_C.im z)) * is_R_or_C.I = z
- of_real_re_ax : ∀ (r : ℝ), ⇑is_R_or_C.re (⇑(algebra_map ℝ K) r) = r
- of_real_im_ax : ∀ (r : ℝ), ⇑is_R_or_C.im (⇑(algebra_map ℝ K) r) = 0
- mul_re_ax : ∀ (z w : K), ⇑is_R_or_C.re (z * w) = (⇑is_R_or_C.re z) * ⇑is_R_or_C.re w - (⇑is_R_or_C.im z) * ⇑is_R_or_C.im w
- mul_im_ax : ∀ (z w : K), ⇑is_R_or_C.im (z * w) = (⇑is_R_or_C.re z) * ⇑is_R_or_C.im w + (⇑is_R_or_C.im z) * ⇑is_R_or_C.re w
- conj_re_ax : ∀ (z : K), ⇑is_R_or_C.re (⇑is_R_or_C.conj z) = ⇑is_R_or_C.re z
- conj_im_ax : ∀ (z : K), ⇑is_R_or_C.im (⇑is_R_or_C.conj z) = -⇑is_R_or_C.im z
- conj_I_ax : ⇑is_R_or_C.conj is_R_or_C.I = -is_R_or_C.I
- norm_sq_eq_def_ax : ∀ (z : K), ∥z∥ ^ 2 = (⇑is_R_or_C.re z) * ⇑is_R_or_C.re z + (⇑is_R_or_C.im z) * ⇑is_R_or_C.im z
- mul_im_I_ax : ∀ (z : K), (⇑is_R_or_C.im z) * ⇑is_R_or_C.im is_R_or_C.I = ⇑is_R_or_C.im z
- inv_def_ax : ∀ (z : K), z⁻¹ = (⇑is_R_or_C.conj z) * ⇑(algebra_map ℝ K) (∥z∥ ^ 2)⁻¹
- div_I_ax : ∀ (z : K), z / is_R_or_C.I = -z * is_R_or_C.I
This typeclass captures properties shared by ℝ and ℂ, with an API that closely matches that of ℂ.
Instances
Equations
- is_R_or_C.algebra_map_coe = {coe := ⇑(algebra_map ℝ K)}
The imaginary unit, I
#
The imaginary unit.
Conjugation as a ring equivalence. This is used to convert the inner product into a sesquilinear product.
Equations
- is_R_or_C.conj_to_ring_equiv K = {to_fun := opposite.op ∘ ⇑is_R_or_C.conj, inv_fun := ⇑is_R_or_C.conj ∘ opposite.unop, left_inv := _, right_inv := _, map_mul' := _, map_add' := _}
The norm squared function.
Equations
- is_R_or_C.norm_sq = {to_fun := λ (z : K), (⇑is_R_or_C.re z) * ⇑is_R_or_C.re z + (⇑is_R_or_C.im z) * ⇑is_R_or_C.im z, map_zero' := _, map_one' := _, map_mul' := _}
The pseudo-coercion of_real
as a ring_hom
.
Equations
Inversion #
Cast lemmas #
Characteristic zero #
ℝ and ℂ are both of characteristic zero.
Note: This is not registered as an instance to avoid having multiple instances on ℝ and ℂ.
Absolute value #
The complex absolute value function, defined as the square root of the norm squared.
Equations
Cauchy sequences #
The real part of a K Cauchy sequence, as a real Cauchy sequence.
Equations
- is_R_or_C.cau_seq_re f = ⟨λ (n : ℕ), ⇑is_R_or_C.re (⇑f n), _⟩
The imaginary part of a K Cauchy sequence, as a real Cauchy sequence.
Equations
- is_R_or_C.cau_seq_im f = ⟨λ (n : ℕ), ⇑is_R_or_C.im (⇑f n), _⟩
An is_R_or_C
field is finite-dimensional over ℝ
, since it is spanned by {1, I}
.
Over an is_R_or_C
field, we can register the properness of finite-dimensional normed spaces as
an instance.
Equations
- real.is_R_or_C = {to_nondiscrete_normed_field := real.nondiscrete_normed_field, to_normed_algebra := normed_algebra.id ℝ real.normed_field, to_complete_space := real.complete_space, re := add_monoid_hom.id ℝ (add_monoid.to_add_zero_class ℝ), im := 0, conj := ring_hom.id ℝ ring.to_semiring, I := 0, I_re_ax := real.is_R_or_C._proof_1, I_mul_I_ax := real.is_R_or_C._proof_2, re_add_im_ax := real.is_R_or_C._proof_3, of_real_re_ax := real.is_R_or_C._proof_4, of_real_im_ax := real.is_R_or_C._proof_5, mul_re_ax := real.is_R_or_C._proof_6, mul_im_ax := real.is_R_or_C._proof_7, conj_re_ax := real.is_R_or_C._proof_8, conj_im_ax := real.is_R_or_C._proof_9, conj_I_ax := real.is_R_or_C._proof_10, norm_sq_eq_def_ax := real.is_R_or_C._proof_11, mul_im_I_ax := real.is_R_or_C._proof_12, inv_def_ax := real.is_R_or_C._proof_13, div_I_ax := real.is_R_or_C._proof_14}
The real part in a is_R_or_C
field, as a continuous linear map.
Equations
- is_R_or_C.re_clm = is_R_or_C.re_lm.mk_continuous 1 is_R_or_C.re_clm._proof_1
The imaginary part in a is_R_or_C
field, as a continuous linear map.
Equations
- is_R_or_C.im_clm = is_R_or_C.im_lm.mk_continuous 1 is_R_or_C.im_clm._proof_1
Conjugate as a linear map
Equations
- is_R_or_C.conj_lm = {to_fun := λ (x : K), ⇑is_R_or_C.conj x, map_add' := _, map_smul' := _}
Conjugate as a linear isometry
Equations
- is_R_or_C.conj_li = {to_linear_map := is_R_or_C.conj_lm _inst_1, norm_map' := _}
Conjugate as a continuous linear map
The ℝ → K coercion, as a linear isometry
Equations
- is_R_or_C.of_real_li = {to_linear_map := is_R_or_C.of_real_lm _inst_1, norm_map' := _}
The ℝ → K
coercion, as a continuous linear map
Lemma to normalize a vector in a normed space E
over either ℂ
or ℝ
to unit length.