Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
6 changes: 1 addition & 5 deletions Mathlib/Algebra/Homology/Single.lean
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ noncomputable def single (j : ι) : V ⥤ HomologicalComplex V c where
split_ifs with h
· subst h
simp
· #adaptation_note /-- nightly-2024-03-07
the previous sensible proof `rw [if_neg h]; simp` fails with "motive not type correct".
The following is horrible. -/
convert (id_zero (C := V)).symm
all_goals simp [if_neg h]
· change OfNat.ofNat 0 = _; dsimp only [id_eq]; rw [if_neg h, id_zero]
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.

I'm not so sure about the change; otherwise, I like this one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was the best thing I could find.

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.

The issue here is that dsimp does not simplify number literals, otherwise this could be done much more nicely.

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.

I made a thread about it #lean4 > dsimp doesn't visit numerals

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.

And three weeks later, nothing happened on zulip. I don't think we should paper over that core issue; at the very least, there should be a comment about the core issue (and perhaps a Lean issue filed).

Copy link
Copy Markdown
Contributor

@JovanGerb JovanGerb May 21, 2025

Choose a reason for hiding this comment

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

I'm attempting a fix at leanprover/lean4#8433

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.

Thanks! Let's land this PR now, and clean this up when the Lean change lands in mathlib.

map_comp f g := by
ext
dsimp
Expand Down
16 changes: 4 additions & 12 deletions Mathlib/Combinatorics/Enumerative/DyckWord.lean
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,12 @@ def firstReturn : ℕ :=

include h in
lemma firstReturn_pos : 0 < p.firstReturn := by
by_contra! f
rw [Nat.le_zero, firstReturn, findIdx_eq] at f
#adaptation_note
/--
If we don't swap, then the second goal is dropped after completing the first goal.
What's going on?
-/
swap
rw [← not_le, Nat.le_zero, firstReturn, findIdx_eq, getElem_range]
· simp
rw [← p.cons_tail_dropLast_concat h]
simp
· rw [length_range, length_pos_iff]
exact toList_ne_nil.mpr h
· rw [getElem_range] at f
simp at f
rw [← p.cons_tail_dropLast_concat h] at f
simp at f

include h in
lemma firstReturn_lt_length : p.firstReturn < p.toList.length := by
Expand Down
9 changes: 2 additions & 7 deletions Mathlib/Data/Finsupp/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1306,10 +1306,7 @@ theorem extendDomain_subtypeDomain (f : α →₀ M) (hf : ∀ a ∈ f.support,
ext a
by_cases h : P a
· exact dif_pos h
· #adaptation_note /-- nightly-2024-06-18
this `rw` was done by `dsimp`. -/
rw [extendDomain_toFun]
dsimp
· dsimp [extendDomain_toFun]
rw [if_neg h, eq_comm, ← not_mem_support_iff]
refine mt ?_ h
exact @hf _
Expand All @@ -1318,9 +1315,7 @@ theorem extendDomain_subtypeDomain (f : α →₀ M) (hf : ∀ a ∈ f.support,
theorem extendDomain_single (a : Subtype P) (m : M) :
(single a m).extendDomain = single a.val m := by
ext a'
#adaptation_note /-- nightly-2024-06-18
this `rw` was instead `dsimp only`. -/
rw [extendDomain_toFun]
dsimp only [extendDomain_toFun]
obtain rfl | ha := eq_or_ne a.val a'
· simp_rw [single_eq_same, dif_pos a.prop]
· simp_rw [single_eq_of_ne ha, dite_eq_right_iff]
Expand Down
11 changes: 7 additions & 4 deletions Mathlib/Data/Int/Cast/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ theorem cast_negOfNat (n : ℕ) : ((negOfNat n : ℤ) : R) = -n := by simp [Int.
@[simp, norm_cast]
theorem cast_add : ∀ m n, ((m + n : ℤ) : R) = m + n
| (m : ℕ), (n : ℕ) => by simp [-Int.natCast_add, ← Int.natCast_add]
| (m : ℕ), -[n+1] => by erw [cast_subNatNat, cast_natCast, cast_negSucc, sub_eq_add_neg]
| -[m+1], (n : ℕ) => by
erw [cast_subNatNat, cast_natCast, cast_negSucc, sub_eq_iff_eq_add, add_assoc,
eq_neg_add_iff_add_eq, ← Nat.cast_add, ← Nat.cast_add, Nat.add_comm]
| (m : ℕ), -[n+1] =>
show (subNatNat m n.succ : R) = _ by
rw [cast_subNatNat, cast_natCast, cast_negSucc, sub_eq_add_neg]
| -[m+1], (n : ℕ) =>
show (subNatNat n m.succ : R) = _ by
rw [cast_subNatNat, cast_natCast, cast_negSucc, sub_eq_iff_eq_add, add_assoc,
eq_neg_add_iff_add_eq, ← Nat.cast_add, ← Nat.cast_add, Nat.add_comm]
| -[m+1], -[n+1] =>
show (-[m + n + 1+1] : R) = _ by
rw [cast_negSucc, cast_negSucc, cast_negSucc, ← neg_add_rev, ← Nat.cast_add,
Expand Down
5 changes: 1 addition & 4 deletions Mathlib/NumberTheory/DiophantineApproximation/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,8 @@ private theorem invariant : ContfracLegendre.Ass (fract ξ)⁻¹ v (u - ⌊ξ⌋
· obtain hv₀' := (aux₀ (zero_lt_two.trans_le hv)).2
have Hv : (v * (2 * v - 1) : ℝ)⁻¹ + (v : ℝ)⁻¹ = 2 / (2 * v - 1) := by
field_simp; ring
#adaptation_note
/-- `_root_` can be removed again after
https://github.com/leanprover/lean4/pull/7359 lands in nightly-2025-03-06. -/
have Huv : (u / v : ℝ) = ⌊ξ⌋ + (v : ℝ)⁻¹ := by
rw [_root_.sub_eq_iff_eq_add'.mp huv]; field_simp
rw [sub_eq_iff_eq_add'.mp huv]; field_simp
have h' := (abs_sub_lt_iff.mp h.2.2).1
rw [Huv, ← sub_sub, sub_lt_iff_lt_add, self_sub_floor, Hv] at h'
rwa [lt_sub_iff_add_lt', (by ring : (v : ℝ) + -(1 / 2) = (2 * v - 1) / 2),
Expand Down
Loading