Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Mathlib/Algebra/Quaternion.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,18 @@ instance instRatCast : RatCast ℍ[R] where ratCast q := (q : R)

@[norm_cast] lemma coe_ratCast (q : ℚ) : ↑(q : R) = (q : ℍ[R]) := rfl

section ofScientific
open OfScientific (ofScientific)
variable (m : ℕ) (s : Bool) (e : ℕ)

@[norm_cast] lemma coe_ofScientific : ((ofScientific m s e : R) : ℍ[R]) = ofScientific m s e := rfl
@[simp] lemma re_ofScientific : (ofScientific m s e : ℍ[R]).re = ofScientific m s e := rfl
@[simp] lemma imI_ofScientific : (ofScientific m s e : ℍ[R]).imI = 0 := rfl
@[simp] lemma imJ_ofScientific : (ofScientific m s e : ℍ[R]).imJ = 0 := rfl
@[simp] lemma imK_ofScientific : (ofScientific m s e : ℍ[R]).imK = 0 := rfl

end ofScientific
Comment on lines +1176 to +1186

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite hard to think of how we'd ever use these but I guess they're very cheap to add / maintain.


variable [LinearOrder R] [IsStrictOrderedRing R] (a b : ℍ[R])

@[simps -isSimp]
Expand Down
14 changes: 14 additions & 0 deletions Mathlib/Analysis/RCLike/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,20 @@ theorem ratCast_re (q : ℚ) : re (q : K) = q := by rw [← ofReal_ratCast, ofRe
@[simp, rclike_simps, norm_cast]
theorem ratCast_im (q : ℚ) : im (q : K) = 0 := by rw [← ofReal_ratCast, ofReal_im]

open OfScientific (ofScientific)

@[rclike_simps, norm_cast]
theorem ofReal_ofScientific (m : ℕ) (s : Bool) (e : ℕ) :
((ofScientific m s e : ℝ) : K) = ofScientific m s e := ofReal_nnratCast _

@[simp, rclike_simps]
theorem ofScientific_re (m : ℕ) (s : Bool) (e : ℕ) :
re (ofScientific m s e : K) = ofScientific m s e := by rw [← ofReal_ofScientific, ofReal_re]

@[simp, rclike_simps, norm_cast]
theorem ofScientific_im (m : ℕ) (s : Bool) (e : ℕ) :
im (ofScientific m s e : K) = 0 := by rw [← ofReal_ofScientific, ofReal_im]
Comment thread
ocfnash marked this conversation as resolved.

/-! ### Norm -/

theorem norm_of_nonneg {r : ℝ} (h : 0 ≤ r) : ‖(r : K)‖ = r :=
Expand Down
6 changes: 6 additions & 0 deletions Mathlib/Data/Complex/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ instance instRatCast : RatCast ℂ where ratCast q := ofReal q
@[simp, norm_cast] lemma ofReal_intCast (n : ℤ) : ofReal n = n := rfl
@[simp, norm_cast] lemma ofReal_nnratCast (q : ℚ≥0) : ofReal q = q := rfl
@[simp, norm_cast] lemma ofReal_ratCast (q : ℚ) : ofReal q = q := rfl
@[simp, norm_cast] lemma ofReal_ofScientific (m : ℕ) (s : Bool) (e : ℕ) :
ofReal (OfScientific.ofScientific m s e : ℝ) = OfScientific.ofScientific m s e := rfl

@[simp] lemma re_ofNat (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : ℂ).re = ofNat(n) := rfl
@[simp] lemma im_ofNat (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : ℂ).im = 0 := rfl
Expand All @@ -358,6 +360,10 @@ instance instRatCast : RatCast ℂ where ratCast q := ofReal q
@[simp, norm_cast] lemma im_nnratCast (q : ℚ≥0) : (q : ℂ).im = 0 := rfl
@[simp, norm_cast] lemma ratCast_re (q : ℚ) : (q : ℂ).re = q := rfl
@[simp, norm_cast] lemma ratCast_im (q : ℚ) : (q : ℂ).im = 0 := rfl
@[simp] lemma re_ofScientific (m : ℕ) (s : Bool) (e : ℕ) :
(OfScientific.ofScientific m s e : ℂ).re = OfScientific.ofScientific m s e := rfl
@[simp] lemma im_ofScientific (m : ℕ) (s : Bool) (e : ℕ) :
(OfScientific.ofScientific m s e : ℂ).im = 0 := rfl


/-! ### Ring structure -/
Expand Down
Loading