-
Notifications
You must be signed in to change notification settings - Fork 297
[Merged by Bors] - feat(data/complex/is_R_or_C): add typeclass for real or complex #3934
Conversation
Nice! I think (eventually) we want to move away from using |
I'm fairly ignorant of the application here but I'm wondering, is there a reason to not define the class as: class is_R_or_C (K : Type) :=
(from_R : R -> K)
(to_C : K -> C)
(to_C_from_R : \forall x : R, to_C (from_R x) = coe x) and derive the rest from that? That could probably be generalized into an interval between types and applied to other situations like |
@cipher1024 I don't think you can define/proof the current fields of |
@cipher1024 Right -- more precisely, I don't see how to avoid being able to prove things like |
@fpvandoorn For |
src/data/complex/R_or_C.lean
Outdated
@[simp] lemma conj_re (z : K) : re (conj z) = re z := is_R_or_C.conj_re_ax z | ||
@[simp] lemma conj_im (z : K) : im (conj z) = -(im z) := is_R_or_C.conj_im_ax z | ||
@[simp] lemma conj_of_real (r : ℝ) : conj (𝓚 r) = (𝓚 r) := | ||
(@is_R_or_C.ext_iff K _ _ _ (conj (𝓚 r)) (𝓚 r)).mpr $ by simp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@is_R_or_C.ext_iff K _ _ _ (conj (𝓚 r)) (𝓚 r)).mpr $ by simp | |
by { rw ext_iff, simp only [of_real_im, conj_im, eq_self_iff_true, conj_re, and_self, neg_zero] } |
squeezing this simp makes the file compile a bit faster. I don't have a profiler output, but the orange bar hangs around noticeably long with a raw simp
and goes away immediately with this simp only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the proofs of conj_neg_I and conj_conj take a while, too. Maybe we've made a bad choice with our simp normal form?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't been too careful with the simp lemmas, I basically left things the way they were in complex.lean
.
Co-authored-by: Jalex Stark <alexmaplegm@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the file be named is_R_or_C.lean
instead of R_or_C.lean
too?
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
@fpvandoorn Thanks for the suggestions! Regarding |
I am a little bit confused about the intended applications of this file. For instance, in the file |
@sgouezel The main application I have in mind is defining the complex inner product, and other cases in which the real case follows directly from the complex case by replacing |
ok, thanks for the clarification. It might be a good idea to explain this in the file-level docstring, and to sketch an application there. |
I've added some more details to the file-level docstring, and changed the |
I didn't go into too much detail regarding the applications, since I plan to PR inner products based on this fairly soon. |
LGTM bors merge |
Co-authored-by: jalex-stark <alexmaplegm@gmail.com> Co-authored-by: Frédéric Dupuis <31101893+dupuisf@users.noreply.github.com>
Pull request successfully merged into master. Build succeeded: |
Co-authored-by: jalex-stark <alexmaplegm@gmail.com> Co-authored-by: Frédéric Dupuis <31101893+dupuisf@users.noreply.github.com>
Co-authored-by: jalex-stark <alexmaplegm@gmail.com> Co-authored-by: Frédéric Dupuis <31101893+dupuisf@users.noreply.github.com>
This PR 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 thereal and the complex case, such as inner products and Hilbert spaces. Its API
follows closely that of
ℂ
.