Skip to content

Commit 5fd4afc

Browse files
gebnerPaul-Nicolas Madelaine
and
Paul-Nicolas Madelaine
committed
refactor(tactic/norm_cast): simplified attributes and numeral support (leanprover-community#2407)
This is @pnmadelaine's work, I'm just updating it to work with current mathlib. New and improved version of `norm_cast` as described in the paper "normalizing casts and coercions": https://arxiv.org/abs/2001.10594 The main new user-facing feature are the simplified attributes. There is now only the `@[norm_cast]` attribute which subsumes the previous `norm_cast`, `elim_cast`, `squash_cast`, and `move_cast` attributes. There is a new `set_option trace.norm_cast true` option to enable debugging output. Co-authored-by: Paul-Nicolas Madelaine <[email protected]> Co-authored-by: Paul-Nicolas Madelaine <[email protected]>
1 parent 7270af9 commit 5fd4afc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1424
-943
lines changed

src/algebra/char_zero.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ variables {α : Type*} [add_monoid α] [has_one α] [char_zero α]
4949
theorem cast_injective : function.injective (coe : ℕ → α) :=
5050
char_zero.cast_injective
5151

52-
@[simp, elim_cast] theorem cast_inj {m n : ℕ} : (m : α) = n ↔ m = n :=
52+
@[simp, norm_cast] theorem cast_inj {m n : ℕ} : (m : α) = n ↔ m = n :=
5353
cast_injective.eq_iff
5454

55-
@[simp, elim_cast] theorem cast_eq_zero {n : ℕ} : (n : α) = 0 ↔ n = 0 :=
55+
@[simp, norm_cast] theorem cast_eq_zero {n : ℕ} : (n : α) = 0 ↔ n = 0 :=
5656
by rw [← cast_zero, cast_inj]
5757

58-
@[elim_cast] theorem cast_ne_zero {n : ℕ} : (n : α) ≠ 0 ↔ n ≠ 0 :=
58+
@[norm_cast] theorem cast_ne_zero {n : ℕ} : (n : α) ≠ 0 ↔ n ≠ 0 :=
5959
not_congr cast_eq_zero
6060

6161
end nat

src/algebra/continued_fractions/basic.lean

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ variables {α} {β : Type*} [has_coe α β]
6060
instance has_coe_to_generalized_continued_fraction_pair : has_coe (gcf.pair α) (gcf.pair β) :=
6161
⟨λ ⟨a, b⟩, ⟨(a : β), (b : β)⟩⟩
6262

63-
@[simp, move_cast]
63+
@[simp, norm_cast]
6464
lemma coe_to_generalized_continued_fraction_pair {a b : α} :
6565
(↑(gcf.pair.mk a b) : gcf.pair β) = gcf.pair.mk (a : β) (b : β) :=
6666
rfl
@@ -130,7 +130,7 @@ local attribute [instance] seq.coe_to_seq
130130
instance has_coe_to_generalized_continued_fraction : has_coe (gcf α) (gcf β) :=
131131
⟨λ ⟨h, s⟩, ⟨(h : β), (s : seq $ gcf.pair β)⟩⟩
132132

133-
@[simp, move_cast]
133+
@[simp, norm_cast]
134134
lemma coe_to_generalized_continued_fraction {g : gcf α} :
135135
(↑(g : gcf α) : gcf β) = ⟨(g.h : β), (g.s : seq $ gcf.pair β)⟩ :=
136136
by { cases g, refl }
@@ -196,7 +196,7 @@ instance : inhabited (scf α) := ⟨of_integer 1⟩
196196
instance has_coe_to_generalized_continued_fraction : has_coe (scf α) (gcf α) :=
197197
by {unfold scf, apply_instance}
198198

199-
@[simp, elim_cast]
199+
@[simp, norm_cast]
200200
lemma coe_to_generalized_continued_fraction {s : scf α} : (↑s : gcf α) = s.val := rfl
201201

202202
end simple_continued_fraction
@@ -239,13 +239,13 @@ instance : inhabited (cf α) := ⟨of_integer 0⟩
239239
instance has_coe_to_simple_continued_fraction : has_coe (cf α) (scf α) :=
240240
by {unfold cf, apply_instance}
241241

242-
@[simp, elim_cast]
242+
@[simp, norm_cast]
243243
lemma coe_to_simple_continued_fraction {c : cf α} : (↑c : scf α) = c.val := rfl
244244

245245
/-- Lift a cf to a scf using the inclusion map. -/
246246
instance has_coe_to_generalized_continued_fraction : has_coe (cf α) (gcf α) := ⟨λ c, ↑(↑c : scf α)⟩
247247

248-
@[simp, elim_cast]
248+
@[simp, norm_cast squash]
249249
lemma coe_to_generalized_continued_fraction {c : cf α} : (↑c : gcf α) = c.val := rfl
250250

251251
end continued_fraction

src/algebra/field_power.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ end ordered
148148
section
149149
variables {K : Type*} [field K]
150150

151-
@[simp, move_cast] theorem rat.cast_fpow [char_zero K] (q : ℚ) (n : ℤ) :
151+
@[simp, norm_cast] theorem rat.cast_fpow [char_zero K] (q : ℚ) (n : ℤ) :
152152
((q ^ n : ℚ) : K) = q ^ n :=
153153
(rat.cast_hom K).map_fpow q n
154154

src/algebra/group_power.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,10 @@ by rw [add_monoid.smul_eq_mul, add_monoid.smul_eq_mul, mul_assoc]
393393
lemma zero_pow [semiring R] : ∀ {n : ℕ}, 0 < n → (0 : R) ^ n = 0
394394
| (n+1) _ := zero_mul _
395395

396-
@[simp, move_cast] theorem nat.cast_pow [semiring R] (n m : ℕ) : (↑(n ^ m) : R) = ↑n ^ m :=
396+
@[simp, norm_cast] theorem nat.cast_pow [semiring R] (n m : ℕ) : (↑(n ^ m) : R) = ↑n ^ m :=
397397
by induction m with m ih; [exact nat.cast_one, rw [nat.pow_succ, pow_succ', nat.cast_mul, ih]]
398398

399-
@[simp, move_cast] theorem int.coe_nat_pow (n m : ℕ) : ((n ^ m : ℕ) : ℤ) = n ^ m :=
399+
@[simp, norm_cast] theorem int.coe_nat_pow (n m : ℕ) : ((n ^ m : ℕ) : ℤ) = n ^ m :=
400400
by induction m with m ih; [exact int.coe_nat_one, rw [nat.pow_succ, pow_succ', int.coe_nat_mul, ih]]
401401

402402
theorem int.nat_abs_pow (n : ℤ) (k : ℕ) : int.nat_abs (n ^ k) = (int.nat_abs n) ^ k :=
@@ -451,7 +451,7 @@ lemma gsmul_int_int (a b : ℤ) : a •ℤ b = a * b := by simp [gsmul_eq_mul]
451451

452452
lemma gsmul_int_one (n : ℤ) : n •ℤ 1 = n := by simp
453453

454-
@[simp, move_cast] theorem int.cast_pow [ring R] (n : ℤ) (m : ℕ) : (↑(n ^ m) : R) = ↑n ^ m :=
454+
@[simp, norm_cast] theorem int.cast_pow [ring R] (n : ℤ) (m : ℕ) : (↑(n ^ m) : R) = ↑n ^ m :=
455455
by induction m with m ih; [exact int.cast_one,
456456
rw [pow_succ, pow_succ, int.cast_mul, ih]]
457457

src/algebra/module.lean

+6-6
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,11 @@ instance : inhabited p := ⟨0⟩
382382
instance : has_neg p := ⟨λx, ⟨-x.1, neg_mem _ x.2⟩⟩
383383
instance : has_scalar R p := ⟨λ c x, ⟨c • x.1, smul_mem _ c x.2⟩⟩
384384

385-
@[simp, move_cast] lemma coe_add (x y : p) : (↑(x + y) : M) = ↑x + ↑y := rfl
386-
@[simp, elim_cast] lemma coe_zero : ((0 : p) : M) = 0 := rfl
387-
@[simp, move_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl
388-
@[simp, move_cast] lemma coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • ↑x := rfl
389-
@[simp, elim_cast] lemma coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl
385+
@[simp, norm_cast] lemma coe_add (x y : p) : (↑(x + y) : M) = ↑x + ↑y := rfl
386+
@[simp, norm_cast] lemma coe_zero : ((0 : p) : M) = 0 := rfl
387+
@[simp, norm_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl
388+
@[simp, norm_cast] lemma coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • ↑x := rfl
389+
@[simp, norm_cast] lemma coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl
390390

391391
@[simp] protected lemma eta (x : p) (hx : (x : M) ∈ p) : (⟨x, hx⟩ : p) = x := subtype.eta x hx
392392

@@ -399,7 +399,7 @@ instance submodule_is_add_subgroup : is_add_subgroup (p : set M) :=
399399
add_mem := p.add,
400400
neg_mem := λ _, p.neg_mem }
401401

402-
@[simp, move_cast] lemma coe_sub (x y : p) : (↑(x - y) : M) = ↑x - ↑y := rfl
402+
@[simp, norm_cast] lemma coe_sub (x y : p) : (↑(x - y) : M) = ↑x - ↑y := rfl
403403

404404
instance : module R p :=
405405
by refine {smul := (•), ..};

src/algebra/ring.lean

+7-2
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,16 @@ instance {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} : has
358358
instance {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} : has_coe (α →+* β) (α →+ β) :=
359359
⟨ring_hom.to_add_monoid_hom⟩
360360

361-
@[squash_cast] lemma coe_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) (a : α) :
361+
lemma coe_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) (a : α) :
362362
((f : α →* β) : α → β) a = (f : α → β) a := rfl
363-
@[squash_cast] lemma coe_add_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) (a : α) :
363+
lemma coe_add_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) (a : α) :
364364
((f : α →+ β) : α → β) a = (f : α → β) a := rfl
365365

366+
@[norm_cast] lemma coe_monoid_hom' {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) :
367+
((f : α →* β) : α → β) = (f : α → β) := by { apply funext, intro, apply coe_monoid_hom }
368+
@[norm_cast] lemma coe_add_monoid_hom' {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) :
369+
((f : α →+ β) : α → β) = (f : α → β) := by { apply funext, intro, apply coe_add_monoid_hom }
370+
366371
namespace ring_hom
367372

368373
variables {β : Type v} {γ : Type w} [rα : semiring α] [rβ : semiring β]

src/analysis/complex/exponential.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ noncomputable instance : has_pow nnreal ℝ := ⟨rpow⟩
19211921

19221922
@[simp] lemma rpow_eq_pow (x : nnreal) (y : ℝ) : rpow x y = x ^ y := rfl
19231923

1924-
@[simp, move_cast] lemma coe_rpow (x : nnreal) (y : ℝ) : ((x ^ y : nnreal) : ℝ) = (x : ℝ) ^ y := rfl
1924+
@[simp, norm_cast] lemma coe_rpow (x : nnreal) (y : ℝ) : ((x ^ y : nnreal) : ℝ) = (x : ℝ) ^ y := rfl
19251925

19261926
@[simp] lemma rpow_zero (x : nnreal) : x ^ (0 : ℝ) = 1 :=
19271927
by { rw ← nnreal.coe_eq, exact real.rpow_zero _ }

src/analysis/convex/cone.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ instance : has_le (convex_cone E) := ⟨λ S T, S.carrier ⊆ T.carrier⟩
7878

7979
instance : has_lt (convex_cone E) := ⟨λ S T, S.carrier ⊂ T.carrier⟩
8080

81-
@[simp, elim_cast] lemma mem_coe {x : E} : x ∈ (S : set E) ↔ x ∈ S := iff.rfl
81+
@[simp, norm_cast] lemma mem_coe {x : E} : x ∈ (S : set E) ↔ x ∈ S := iff.rfl
8282

8383
@[simp] lemma mem_mk {s : set E} {h₁ h₂ x} : x ∈ mk s h₁ h₂ ↔ x ∈ s := iff.rfl
8484

src/analysis/normed_space/basic.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ instance : normed_ring ℤ :=
637637
norm_mul := λ m n, le_of_eq $ by simp only [norm, int.cast_mul, abs_mul],
638638
dist_eq := λ m n, by simp only [int.dist_eq, norm, int.cast_sub] }
639639

640-
@[elim_cast] lemma int.norm_cast_real (m : ℤ) : ∥(m : ℝ)∥ = ∥m∥ := rfl
640+
@[norm_cast] lemma int.norm_cast_real (m : ℤ) : ∥(m : ℝ)∥ = ∥m∥ := rfl
641641

642642
instance : normed_field ℚ :=
643643
{ norm := λ r, ∥(r : ℝ)∥,
@@ -647,9 +647,9 @@ instance : normed_field ℚ :=
647647
instance : nondiscrete_normed_field ℚ :=
648648
{ non_trivial := ⟨2, by { unfold norm, rw abs_of_nonneg; norm_num }⟩ }
649649

650-
@[elim_cast, simp] lemma rat.norm_cast_real (r : ℚ) : ∥(r : ℝ)∥ = ∥r∥ := rfl
650+
@[norm_cast, simp] lemma rat.norm_cast_real (r : ℚ) : ∥(r : ℝ)∥ = ∥r∥ := rfl
651651

652-
@[elim_cast, simp] lemma int.norm_cast_rat (m : ℤ) : ∥(m : ℚ)∥ = ∥m∥ :=
652+
@[norm_cast, simp] lemma int.norm_cast_rat (m : ℤ) : ∥(m : ℚ)∥ = ∥m∥ :=
653653
by rw [← rat.norm_cast_real, ← int.norm_cast_real]; congr' 1; norm_cast
654654

655655
section normed_space

src/analysis/normed_space/operator_norm.lean

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ follow automatically in `linear_map.mk_continuous_norm_le`. -/
6464
def linear_map.mk_continuous_of_exists_bound (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) : E →L[𝕜] F :=
6565
⟨f, let ⟨C, hC⟩ := h in linear_map.continuous_of_bound f C hC⟩
6666

67-
@[simp, elim_cast] lemma linear_map.mk_continuous_coe (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :
67+
@[simp, norm_cast] lemma linear_map.mk_continuous_coe (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :
6868
((f.mk_continuous C h) : E →ₗ[𝕜] F) = f := rfl
6969

7070
@[simp] lemma linear_map.mk_continuous_apply (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) (x : E) :
7171
f.mk_continuous C h x = f x := rfl
7272

73-
@[simp, elim_cast] lemma linear_map.mk_continuous_of_exists_bound_coe (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) :
73+
@[simp, norm_cast] lemma linear_map.mk_continuous_of_exists_bound_coe (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) :
7474
((f.mk_continuous_of_exists_bound h) : E →ₗ[𝕜] F) = f := rfl
7575

7676
@[simp] lemma linear_map.mk_continuous_of_exists_bound_apply (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) (x : E) :
@@ -567,10 +567,10 @@ def restrict_scalars (f : E' →L[𝕜'] F') : E' →L[𝕜] F' :=
567567
{ cont := f.cont,
568568
..linear_map.restrict_scalars 𝕜 (f.to_linear_map) }
569569

570-
@[simp, move_cast] lemma restrict_scalars_coe_eq_coe (f : E' →L[𝕜'] F') :
570+
@[simp, norm_cast] lemma restrict_scalars_coe_eq_coe (f : E' →L[𝕜'] F') :
571571
(f.restrict_scalars 𝕜 : E' →ₗ[𝕜] F') = (f : E' →ₗ[𝕜'] F').restrict_scalars 𝕜 := rfl
572572

573-
@[simp, squash_cast] lemma restrict_scalars_coe_eq_coe' (f : E' →L[𝕜'] F') :
573+
@[simp, norm_cast squash] lemma restrict_scalars_coe_eq_coe' (f : E' →L[𝕜'] F') :
574574
(f.restrict_scalars 𝕜 : E' → F') = f := rfl
575575

576576
end restrict_scalars

src/data/complex/basic.lean

+25-25
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ def of_real (r : ℝ) : ℂ := ⟨r, 0⟩
3030
instance : has_coe ℝ ℂ := ⟨of_real⟩
3131
@[simp] lemma of_real_eq_coe (r : ℝ) : of_real r = r := rfl
3232

33-
@[simp, elim_cast] lemma of_real_re (r : ℝ) : (r : ℂ).re = r := rfl
34-
@[simp, elim_cast] lemma of_real_im (r : ℝ) : (r : ℂ).im = 0 := rfl
33+
@[simp, norm_cast] lemma of_real_re (r : ℝ) : (r : ℂ).re = r := rfl
34+
@[simp, norm_cast] lemma of_real_im (r : ℝ) : (r : ℂ).im = 0 := rfl
3535

36-
@[simp, elim_cast] theorem of_real_inj {z w : ℝ} : (z : ℂ) = w ↔ z = w :=
36+
@[simp, norm_cast] theorem of_real_inj {z w : ℝ} : (z : ℂ) = w ↔ z = w :=
3737
⟨congr_arg re, congr_arg _⟩
3838

3939
instance : has_zero ℂ := ⟨(0 : ℝ)⟩
4040
instance : inhabited ℂ := ⟨0
4141

4242
@[simp] lemma zero_re : (0 : ℂ).re = 0 := rfl
4343
@[simp] lemma zero_im : (0 : ℂ).im = 0 := rfl
44-
@[simp, squash_cast] lemma of_real_zero : ((0 : ℝ) : ℂ) = 0 := rfl
44+
@[simp, norm_cast] lemma of_real_zero : ((0 : ℝ) : ℂ) = 0 := rfl
4545

4646
@[simp] theorem of_real_eq_zero {z : ℝ} : (z : ℂ) = 0 ↔ z = 0 := of_real_inj
4747
theorem of_real_ne_zero {z : ℝ} : (z : ℂ) ≠ 0 ↔ z ≠ 0 := not_congr of_real_eq_zero
@@ -50,7 +50,7 @@ instance : has_one ℂ := ⟨(1 : ℝ)⟩
5050

5151
@[simp] lemma one_re : (1 : ℂ).re = 1 := rfl
5252
@[simp] lemma one_im : (1 : ℂ).im = 0 := rfl
53-
@[simp, squash_cast] lemma of_real_one : ((1 : ℝ) : ℂ) = 1 := rfl
53+
@[simp, norm_cast] lemma of_real_one : ((1 : ℝ) : ℂ) = 1 := rfl
5454

5555
def I : ℂ := ⟨0, 1
5656

@@ -61,22 +61,22 @@ instance : has_add ℂ := ⟨λ z w, ⟨z.re + w.re, z.im + w.im⟩⟩
6161

6262
@[simp] lemma add_re (z w : ℂ) : (z + w).re = z.re + w.re := rfl
6363
@[simp] lemma add_im (z w : ℂ) : (z + w).im = z.im + w.im := rfl
64-
@[simp, move_cast] lemma of_real_add (r s : ℝ) : ((r + s : ℝ) : ℂ) = r + s := ext_iff.2 $ by simp
64+
@[simp, norm_cast] lemma of_real_add (r s : ℝ) : ((r + s : ℝ) : ℂ) = r + s := ext_iff.2 $ by simp
6565

66-
@[simp, squash_cast, move_cast] lemma of_real_bit0 (r : ℝ) : ((bit0 r : ℝ) : ℂ) = bit0 r := ext_iff.2 $ by simp [bit0]
67-
@[simp, squash_cast, move_cast] lemma of_real_bit1 (r : ℝ) : ((bit1 r : ℝ) : ℂ) = bit1 r := ext_iff.2 $ by simp [bit1]
66+
@[simp, norm_cast] lemma of_real_bit0 (r : ℝ) : ((bit0 r : ℝ) : ℂ) = bit0 r := ext_iff.2 $ by simp [bit0]
67+
@[simp, norm_cast] lemma of_real_bit1 (r : ℝ) : ((bit1 r : ℝ) : ℂ) = bit1 r := ext_iff.2 $ by simp [bit1]
6868

6969
instance : has_neg ℂ := ⟨λ z, ⟨-z.re, -z.im⟩⟩
7070

7171
@[simp] lemma neg_re (z : ℂ) : (-z).re = -z.re := rfl
7272
@[simp] lemma neg_im (z : ℂ) : (-z).im = -z.im := rfl
73-
@[simp, move_cast] lemma of_real_neg (r : ℝ) : ((-r : ℝ) : ℂ) = -r := ext_iff.2 $ by simp
73+
@[simp, norm_cast] lemma of_real_neg (r : ℝ) : ((-r : ℝ) : ℂ) = -r := ext_iff.2 $ by simp
7474

7575
instance : has_mul ℂ := ⟨λ z w, ⟨z.re * w.re - z.im * w.im, z.re * w.im + z.im * w.re⟩⟩
7676

7777
@[simp] lemma mul_re (z w : ℂ) : (z * w).re = z.re * w.re - z.im * w.im := rfl
7878
@[simp] lemma mul_im (z w : ℂ) : (z * w).im = z.re * w.im + z.im * w.re := rfl
79-
@[simp, move_cast] lemma of_real_mul (r s : ℝ) : ((r * s : ℝ) : ℂ) = r * s := ext_iff.2 $ by simp
79+
@[simp, norm_cast] lemma of_real_mul (r s : ℝ) : ((r * s : ℝ) : ℂ) = r * s := ext_iff.2 $ by simp
8080

8181
lemma smul_re (r : ℝ) (z : ℂ) : (↑r * z).re = r * z.re := by simp
8282
lemma smul_im (r : ℝ) (z : ℂ) : (↑r * z).im = r * z.im := by simp
@@ -201,8 +201,8 @@ by refine { zero := 0, add := (+), neg := has_neg.neg, one := 1, mul := (*), ..}
201201

202202
@[simp] lemma sub_re (z w : ℂ) : (z - w).re = z.re - w.re := rfl
203203
@[simp] lemma sub_im (z w : ℂ) : (z - w).im = z.im - w.im := rfl
204-
@[simp, move_cast] lemma of_real_sub (r s : ℝ) : ((r - s : ℝ) : ℂ) = r - s := ext_iff.2 $ by simp
205-
@[simp, move_cast] lemma of_real_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : ℂ) = r ^ n :=
204+
@[simp, norm_cast] lemma of_real_sub (r s : ℝ) : ((r - s : ℝ) : ℂ) = r - s := ext_iff.2 $ by simp
205+
@[simp, norm_cast] lemma of_real_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : ℂ) = r ^ n :=
206206
by induction n; simp [*, of_real_mul, pow_succ]
207207

208208
theorem sub_conj (z : ℂ) : z - conj z = (2 * z.im : ℝ) * I :=
@@ -223,7 +223,7 @@ theorem inv_def (z : ℂ) : z⁻¹ = conj z * ((norm_sq z)⁻¹:ℝ) := rfl
223223
@[simp] lemma inv_re (z : ℂ) : (z⁻¹).re = z.re / norm_sq z := by simp [inv_def, division_def]
224224
@[simp] lemma inv_im (z : ℂ) : (z⁻¹).im = -z.im / norm_sq z := by simp [inv_def, division_def]
225225

226-
@[simp, move_cast] lemma of_real_inv (r : ℝ) : ((r⁻¹ : ℝ) : ℂ) = r⁻¹ :=
226+
@[simp, norm_cast] lemma of_real_inv (r : ℝ) : ((r⁻¹ : ℝ) : ℂ) = r⁻¹ :=
227227
ext_iff.2 $ begin
228228
simp,
229229
by_cases r = 0, {simp [h]},
@@ -261,18 +261,18 @@ by simp [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, add_left_comm]
261261
lemma div_im (z w : ℂ) : (z / w).im = z.im * w.re / norm_sq w - z.re * w.im / norm_sq w :=
262262
by simp [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, add_left_comm]
263263

264-
@[simp, move_cast] lemma of_real_div (r s : ℝ) : ((r / s : ℝ) : ℂ) = r / s :=
264+
@[simp, norm_cast] lemma of_real_div (r s : ℝ) : ((r / s : ℝ) : ℂ) = r / s :=
265265
is_ring_hom.map_div coe
266266

267-
@[simp, move_cast] lemma of_real_fpow (r : ℝ) (n : ℤ) : ((r ^ n : ℝ) : ℂ) = (r : ℂ) ^ n :=
267+
@[simp, norm_cast] lemma of_real_fpow (r : ℝ) (n : ℤ) : ((r ^ n : ℝ) : ℂ) = (r : ℂ) ^ n :=
268268
is_ring_hom.map_fpow of_real r n
269269

270-
@[simp, squash_cast] theorem of_real_int_cast : ∀ n : ℤ, ((n : ℝ) : ℂ) = n :=
270+
@[simp, norm_cast] theorem of_real_int_cast : ∀ n : ℤ, ((n : ℝ) : ℂ) = n :=
271271
int.eq_cast (λ n, ((n : ℝ) : ℂ))
272272
(by rw [int.cast_one, of_real_one])
273273
(λ _ _, by rw [int.cast_add, of_real_add])
274274

275-
@[simp, squash_cast] theorem of_real_nat_cast (n : ℕ) : ((n : ℝ) : ℂ) = n :=
275+
@[simp, norm_cast] theorem of_real_nat_cast (n : ℕ) : ((n : ℝ) : ℂ) = n :=
276276
by rw [← int.cast_coe_nat, of_real_int_cast]; refl
277277

278278
@[simp] lemma conj_sub (z w : ℂ) : conj (z - w) = conj z - conj w :=
@@ -297,28 +297,28 @@ instance char_zero_complex : char_zero ℂ :=
297297
add_group.char_zero_of_inj_zero $ λ n h,
298298
by rwa [← of_real_nat_cast, of_real_eq_zero, nat.cast_eq_zero] at h
299299

300-
@[simp, squash_cast] theorem of_real_rat_cast : ∀ n : ℚ, ((n : ℝ) : ℂ) = n :=
300+
@[simp, norm_cast] theorem of_real_rat_cast : ∀ n : ℚ, ((n : ℝ) : ℂ) = n :=
301301
by apply rat.eq_cast (λ n, ((n : ℝ) : ℂ)); simp
302302

303303
theorem re_eq_add_conj (z : ℂ) : (z.re : ℂ) = (z + conj z) / 2 :=
304304
by rw [add_conj]; simp; rw [mul_div_cancel_left (z.re:ℂ) two_ne_zero']
305305

306-
@[simp, elim_cast] lemma nat_cast_re (n : ℕ) : (n : ℂ).re = n :=
306+
@[simp, norm_cast] lemma nat_cast_re (n : ℕ) : (n : ℂ).re = n :=
307307
by rw [← of_real_nat_cast, of_real_re]
308308

309-
@[simp, elim_cast] lemma nat_cast_im (n : ℕ) : (n : ℂ).im = 0 :=
309+
@[simp, norm_cast] lemma nat_cast_im (n : ℕ) : (n : ℂ).im = 0 :=
310310
by rw [← of_real_nat_cast, of_real_im]
311311

312-
@[simp, elim_cast] lemma int_cast_re (n : ℤ) : (n : ℂ).re = n :=
312+
@[simp, norm_cast] lemma int_cast_re (n : ℤ) : (n : ℂ).re = n :=
313313
by rw [← of_real_int_cast, of_real_re]
314314

315-
@[simp, elim_cast] lemma int_cast_im (n : ℤ) : (n : ℂ).im = 0 :=
315+
@[simp, norm_cast] lemma int_cast_im (n : ℤ) : (n : ℂ).im = 0 :=
316316
by rw [← of_real_int_cast, of_real_im]
317317

318-
@[simp, elim_cast] lemma rat_cast_re (q : ℚ) : (q : ℂ).re = q :=
318+
@[simp, norm_cast] lemma rat_cast_re (q : ℚ) : (q : ℂ).re = q :=
319319
by rw [← of_real_rat_cast, of_real_re]
320320

321-
@[simp, elim_cast] lemma rat_cast_im (q : ℚ) : (q : ℂ).im = 0 :=
321+
@[simp, norm_cast] lemma rat_cast_im (q : ℚ) : (q : ℂ).im = 0 :=
322322
by rw [← of_real_rat_cast, of_real_im]
323323

324324
noncomputable def abs (z : ℂ) : ℝ := (norm_sq z).sqrt
@@ -417,7 +417,7 @@ if hz : z = 0 then by simp [hz, zero_le_one]
417417
else by rw [_root_.abs_div, abs_abs]; exact
418418
div_le_of_le_mul (abs_pos.2 hz) (by rw mul_one; exact abs_im_le_abs _)
419419

420-
@[simp, elim_cast] lemma abs_cast_nat (n : ℕ) : abs (n : ℂ) = n :=
420+
@[simp, norm_cast] lemma abs_cast_nat (n : ℕ) : abs (n : ℂ) = n :=
421421
by rw [← of_real_nat_cast, abs_of_nonneg (nat.cast_nonneg n)]
422422

423423
lemma norm_sq_eq_abs (x : ℂ) : norm_sq x = abs x ^ 2 :=

src/data/equiv/ring.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ instance has_coe_to_mul_equiv : has_coe (R ≃+* S) (R ≃* S) := ⟨ring_equiv.
5454

5555
instance has_coe_to_add_equiv : has_coe (R ≃+* S) (R ≃+ S) := ⟨ring_equiv.to_add_equiv⟩
5656

57-
@[squash_cast] lemma coe_mul_equiv (f : R ≃+* S) (a : R) :
57+
@[norm_cast] lemma coe_mul_equiv (f : R ≃+* S) (a : R) :
5858
(f : R ≃* S) a = f a := rfl
5959

60-
@[squash_cast] lemma coe_add_equiv (f : R ≃+* S) (a : R) :
60+
@[norm_cast] lemma coe_add_equiv (f : R ≃+* S) (a : R) :
6161
(f : R ≃+ S) a = f a := rfl
6262

6363
variable (R)

src/data/fin.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ instance fin_to_nat (n : ℕ) : has_coe (fin n) nat := ⟨fin.val⟩
8787

8888
lemma mk_val {m n : ℕ} (h : m < n) : (⟨m, h⟩ : fin n).val = m := rfl
8989

90-
@[simp, elim_cast] lemma coe_mk {m n : ℕ} (h : m < n) : ((⟨m, h⟩ : fin n) : ℕ) = m := rfl
90+
@[simp, norm_cast] lemma coe_mk {m n : ℕ} (h : m < n) : ((⟨m, h⟩ : fin n) : ℕ) = m := rfl
9191

9292
lemma coe_eq_val (a : fin n) : (a : ℕ) = a.val := rfl
9393

@@ -212,7 +212,7 @@ le_of_lt_succ i.is_lt
212212

213213
@[simp] lemma last_val (n : ℕ) : (last n).val = n := rfl
214214

215-
@[simp, elim_cast] lemma coe_last {n : ℕ} : (last n : ℕ) = n := rfl
215+
@[simp, norm_cast] lemma coe_last {n : ℕ} : (last n : ℕ) = n := rfl
216216

217217
@[simp] lemma succ_last (n : ℕ) : (last n).succ = last (n.succ) := rfl
218218

0 commit comments

Comments
 (0)