New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - chore: Remove unnecessary "rw"s #10704
Conversation
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.
Impressive work! I hope you used some sort of automation for this, you didn't open up every file and go through every rw
by hand, right?!
I think we should slightly more careful in removing rw
rules here: if the two sides happen to be definitionally equal according to rfl
, we don't always have that rw
sees this too. The latter is important if the context changes and we need to add an additional rw
step. So I went through and suggested to revert every change where the two sides did not end up exactly the same (at least, the same as far as rw
is concerned). On the other hand, it seems much easier to implement automation for trimming a rw
set if the only criteria are that the proof still goes through. And maybe some types of definitional equalities are more acceptable than others, so I labeled each of the suggestions.
What do you think?
@@ -135,7 +135,7 @@ theorem decompose_of_mem {x : M} {i : ι} (hx : x ∈ ℳ i) : | |||
#align direct_sum.decompose_of_mem DirectSum.decompose_of_mem | |||
|
|||
theorem decompose_of_mem_same {x : M} {i : ι} (hx : x ∈ ℳ i) : (decompose ℳ x i : M) = x := by | |||
rw [decompose_of_mem _ hx, DirectSum.of_eq_same, Subtype.coe_mk] | |||
rw [decompose_of_mem _ hx, DirectSum.of_eq_same] |
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.
Closing this goal requires reducing the same projection as Subtype.coe_mk
does, so let's keep it:
rw [decompose_of_mem _ hx, DirectSum.of_eq_same] | |
rw [decompose_of_mem _ hx, DirectSum.of_eq_same, Subtype.coe_mk] |
Mathlib/Algebra/Module/Zlattice.lean
Outdated
@@ -162,7 +162,7 @@ theorem fract_zspan_add (m : E) {v : E} (h : v ∈ span ℤ (Set.range b)) : | |||
simp_rw [repr_fract_apply, Int.fract_eq_fract] | |||
use (b.restrictScalars ℤ).repr ⟨v, h⟩ i | |||
rw [map_add, Finsupp.coe_add, Pi.add_apply, add_tsub_cancel_right, | |||
← eq_intCast (algebraMap ℤ K) _, Basis.restrictScalars_repr_apply, coe_mk] | |||
← eq_intCast (algebraMap ℤ K) _, Basis.restrictScalars_repr_apply] |
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.
This is another projection reduction that I would like to keep:
← eq_intCast (algebraMap ℤ K) _, Basis.restrictScalars_repr_apply] | |
← eq_intCast (algebraMap ℤ K) _, Basis.restrictScalars_repr_apply, coe_mk] |
@@ -183,7 +183,7 @@ instance gradeBy.gradedAlgebra : GradedAlgebra (gradeBy R f) := | |||
ext : 2 | |||
simp only [MonoidHom.coe_comp, MonoidHom.coe_coe, AlgHom.coe_comp, Function.comp_apply, | |||
of_apply, AlgHom.coe_id, id_eq] | |||
rw [decomposeAux_single, DirectSum.coeAlgHom_of, Subtype.coe_mk]) | |||
rw [decomposeAux_single, DirectSum.coeAlgHom_of]) |
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.
idem:
rw [decomposeAux_single, DirectSum.coeAlgHom_of]) | |
rw [decomposeAux_single, DirectSum.coeAlgHom_of, Subtype.coe_mk]) |
@@ -386,7 +386,7 @@ theorem const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f | |||
const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ := | |||
Subtype.eq <| | |||
funext fun x => | |||
IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk]) | |||
IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm]) |
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.
idem:
IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm]) | |
IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk]) |
@@ -115,7 +115,7 @@ theorem applyComposition_ones (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : | |||
intro j hjn hj1 | |||
obtain rfl : j = 0 := by linarith | |||
refine' congr_arg v _ | |||
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding, Fin.val_mk] | |||
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding] |
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.
idem:
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding] | |
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding, Fin.val_mk] |
Mathlib/RingTheory/IsAdjoinRoot.lean
Outdated
_ = Pi.single (f := fun _ => R) ((⟨n, hn⟩ : Fin _) : ℕ) (1 : (fun _ => R) n) | ||
↑(⟨i, _⟩ : Fin _) := by | ||
rw [h.basis.repr_self, ← Finsupp.single_eq_pi_single, | ||
Finsupp.single_apply_left Fin.val_injective] | ||
_ = Pi.single (f := fun _ => R) n 1 i := by rw [Fin.val_mk, Fin.val_mk] | ||
_ = Pi.single (f := fun _ => R) n 1 i := by rw [Fin.val_mk] |
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.
Structure projection:
_ = Pi.single (f := fun _ => R) n 1 i := by rw [Fin.val_mk] | |
_ = Pi.single (f := fun _ => R) n 1 i := by rw [Fin.val_mk, Fin.val_mk] |
or alternatively:
_ = Pi.single (f := fun _ => R) n 1 i := by rw [Fin.val_mk] | |
_ = Pi.single (f := fun _ => R) n 1 i := rfl |
@@ -1696,7 +1696,7 @@ theorem factors_prime_pow [Nontrivial α] {p : Associates α} (hp : Irreducible | |||
eq_of_prod_eq_prod | |||
(by | |||
rw [Associates.factors_prod, FactorSet.prod] | |||
dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate, Subtype.coe_mk]) | |||
dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate]) |
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.
Structure projection:
dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate]) | |
dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate, Subtype.coe_mk]) |
@@ -112,7 +112,7 @@ def out (x : TruncatedWittVector p n R) : 𝕎 R := | |||
|
|||
@[simp] | |||
theorem coeff_out (x : TruncatedWittVector p n R) (i : Fin n) : x.out.coeff i = x.coeff i := by | |||
rw [out]; dsimp only; rw [dif_pos i.is_lt, Fin.eta] | |||
rw [out]; dsimp only; rw [dif_pos i.is_lt] |
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.
Structure eta:
rw [out]; dsimp only; rw [dif_pos i.is_lt] | |
rw [out]; dsimp only; rw [dif_pos i.is_lt, Fin.eta] |
@@ -153,7 +153,7 @@ theorem out_truncateFun (x : 𝕎 R) : (truncateFun n x).out = init n x := by | |||
ext i | |||
dsimp [TruncatedWittVector.out, init, select, coeff_mk] | |||
split_ifs with hi; swap; · rfl | |||
rw [coeff_truncateFun, Fin.val_mk] | |||
rw [coeff_truncateFun] |
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.
Structure projection:
rw [coeff_truncateFun] | |
rw [coeff_truncateFun, Fin.val_mk] |
@@ -858,7 +858,7 @@ theorem totallyBounded {t : Set GHSpace} {C : ℝ} {u : ℕ → ℝ} {K : ℕ | |||
rcases mem_iUnion₂.1 this with ⟨y, ys, hy⟩ | |||
let i : ℕ := E q ⟨y, ys⟩ | |||
let hi := ((E q) ⟨y, ys⟩).2 | |||
have ihi_eq : (⟨i, hi⟩ : Fin (N q)) = (E q) ⟨y, ys⟩ := by rw [Fin.ext_iff, Fin.val_mk] | |||
have ihi_eq : (⟨i, hi⟩ : Fin (N q)) = (E q) ⟨y, ys⟩ := by rw [Fin.ext_iff] |
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.
Structure projection:
have ihi_eq : (⟨i, hi⟩ : Fin (N q)) = (E q) ⟨y, ys⟩ := by rw [Fin.ext_iff] | |
have ihi_eq : (⟨i, hi⟩ : Fin (N q)) = (E q) ⟨y, ys⟩ := by rw [Fin.ext_iff, Fin.val_mk] |
Haha, no! We're working on a system (machine learning) where the unnecessary
Sorry, I'm too new to Lean to have an opinion on this. I implemented your suggested changes. Thanks for the careful review! |
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.
Thanks! I really appreciate the time you took to deal with these little annoyances.
bors r+
Remove unnecessary "rw"s.
Pull request successfully merged into master. Build succeeded: |
Remove unnecessary "rw"s.
Remove unnecessary "rw"s.
This is a non-forked and updated version of #10338. I figure if the proofs still work without these rewrites, then it's best if we remove them, right?