[Merged by Bors] - chore: Remove unnecessary "rw"s#10704
[Merged by Bors] - chore: Remove unnecessary "rw"s#10704
Conversation
Vierkantor
left a comment
There was a problem hiding this comment.
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?
|
|
||
| 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.
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
| 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.
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] |
| 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.
idem:
| rw [decomposeAux_single, DirectSum.coeAlgHom_of]) | |
| rw [decomposeAux_single, DirectSum.coeAlgHom_of, Subtype.coe_mk]) |
| 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.
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]) |
| 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.
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
| 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.
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 |
| (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.
Structure projection:
| dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate]) | |
| dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate, Subtype.coe_mk]) |
| @[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.
Structure eta:
| rw [out]; dsimp only; rw [dif_pos i.is_lt] | |
| rw [out]; dsimp only; rw [dif_pos i.is_lt, Fin.eta] |
| 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.
Structure projection:
| rw [coeff_truncateFun] | |
| rw [coeff_truncateFun, Fin.val_mk] |
| 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.
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! |
Vierkantor
left a comment
There was a problem hiding this comment.
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?