Skip to content

Commit 8854cbc

Browse files
kim-emjcommelin
andcommitted
chore: further backports for leanprover/lean4#6397 (#20098)
Co-authored-by: Johan Commelin <johan@commelin.net>
1 parent aceed3d commit 8854cbc

File tree

27 files changed

+72
-59
lines changed

27 files changed

+72
-59
lines changed

Mathlib/Algebra/FreeMonoid/Count.lean

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ In this file we define `FreeMonoid.countP`, `FreeMonoid.count`, `FreeAddMonoid.c
1414
additive homomorphisms from `FreeMonoid` and `FreeAddMonoid`.
1515
1616
We do not use `to_additive` because it can't map `Multiplicative ℕ` to `ℕ`.
17+
18+
## TODO
19+
20+
There is lots of defeq abuse here of `FreeAddMonoid α = List α`, e.g. in statements like
21+
```
22+
theorem countP_apply (l : FreeAddMonoid α) : countP p l = List.countP p l := rfl
23+
```
24+
This needs cleaning up.
25+
1726
-/
1827

1928
variable {α : Type*} (p : α → Prop) [DecidablePred p]
@@ -27,7 +36,8 @@ def countP : FreeAddMonoid α →+ ℕ where
2736
map_add' := List.countP_append _
2837

2938
theorem countP_of (x : α) : countP p (of x) = if p x = true then 1 else 0 := by
30-
simp [countP, List.countP, List.countP.go]
39+
change List.countP p [x] = _
40+
simp [List.countP_cons]
3141

3242
theorem countP_apply (l : FreeAddMonoid α) : countP p l = List.countP p l := rfl
3343

@@ -36,8 +46,8 @@ theorem countP_apply (l : FreeAddMonoid α) : countP p l = List.countP p l := rf
3646
def count [DecidableEq α] (x : α) : FreeAddMonoid α →+ ℕ := countP (· = x)
3747

3848
theorem count_of [DecidableEq α] (x y : α) : count x (of y) = (Pi.single x 1 : α → ℕ) y := by
39-
simp [Pi.single, Function.update, count, countP, List.countP, List.countP.go,
40-
Bool.beq_eq_decide_eq]
49+
change List.count x [y] = _
50+
simp [Pi.single, Function.update, List.count_cons]
4151

4252
theorem count_apply [DecidableEq α] (x : α) (l : FreeAddMonoid α) : count x l = List.count x l :=
4353
rfl

Mathlib/Algebra/Group/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ theorem npowRec'_two_mul {M : Type*} [Semigroup M] [One M] (k : ℕ) (m : M) :
451451
match k' with
452452
| 0 => rfl
453453
| 1 => simp [npowRec']
454-
| k + 2 => simp [npowRec', ← mul_assoc, ← ih]
454+
| k + 2 => simp [npowRec', ← mul_assoc, Nat.mul_add, ← ih]
455455

456456
@[to_additive]
457457
theorem npowRec'_mul_comm {M : Type*} [Semigroup M] [One M] {k : ℕ} (k0 : k ≠ 0) (m : M) :

Mathlib/Analysis/SpecialFunctions/Gaussian/GaussianIntegral.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ lemma Real.Gamma_nat_add_one_add_half (k : ℕ) :
361361
induction k with
362362
| zero => simp [-one_div, add_comm (1 : ℝ), Gamma_add_one, Gamma_one_half_eq]; ring
363363
| succ k ih =>
364-
rw [add_right_comm, Gamma_add_one (by positivity), Nat.cast_add, Nat.cast_one, ih]
364+
rw [add_right_comm, Gamma_add_one (by positivity), Nat.cast_add, Nat.cast_one, ih, Nat.mul_add]
365365
field_simp
366366
ring
367367

Mathlib/CategoryTheory/Functor/OfSequence.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ lemma map_comp (i j k : ℕ) (hij : i ≤ j) (hjk : j ≤ k) :
8181
· omega
8282
· obtain rfl : j = 0 := by omega
8383
rw [map_id, comp_id]
84-
· dsimp [map]
84+
· simp only [map, Nat.reduceAdd]
8585
rw [hj (fun n ↦ f (n + 1)) (k + 1) (by omega) (by omega)]
8686
obtain _|j := j
8787
all_goals simp [map]

Mathlib/Combinatorics/Quiver/SingleObj.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ theorem listToPath_pathToList {x : SingleObj α} (p : Path (star α) x) :
113113
listToPath (pathToList p) = p.cast rfl ext := by
114114
induction p with
115115
| nil => rfl
116-
| cons _ _ ih => dsimp at *; rw [ih]
116+
| cons _ _ ih => dsimp [pathToList] at *; rw [ih]
117117

118118
theorem pathToList_listToPath (l : List α) : pathToList (listToPath l) = l := by
119119
induction l with

Mathlib/Computability/PartrecCode.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,10 @@ theorem eval_const : ∀ n m, eval (Code.const n) m = Part.some n
495495
| n + 1, m => by simp! [eval_const n m]
496496

497497
@[simp]
498-
theorem eval_id (n) : eval Code.id n = Part.some n := by simp! [Seq.seq]
498+
theorem eval_id (n) : eval Code.id n = Part.some n := by simp! [Seq.seq, Code.id]
499499

500500
@[simp]
501-
theorem eval_curry (c n x) : eval (curry c n) x = eval c (Nat.pair n x) := by simp! [Seq.seq]
501+
theorem eval_curry (c n x) : eval (curry c n) x = eval c (Nat.pair n x) := by simp! [Seq.seq, curry]
502502

503503
theorem const_prim : Primrec Code.const :=
504504
(_root_.Primrec.id.nat_iterate (_root_.Primrec.const zero)

Mathlib/Computability/RegularExpressions.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
364364
@[simp]
365365
protected theorem map_pow (f : α → β) (P : RegularExpression α) :
366366
∀ n : ℕ, map f (P ^ n) = map f P ^ n
367-
| 0 => by dsimp; rfl
367+
| 0 => by unfold map; rfl
368368
| n + 1 => (congr_arg (· * map f P) (RegularExpression.map_pow f P n) : _)
369369

370370
#adaptation_note /-- around nightly-2024-02-25,

Mathlib/Computability/TMToPartrec.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,11 @@ def Cont.then : Cont → Cont → Cont
515515
theorem Cont.then_eval {k k' : Cont} {v} : (k.then k').eval v = k.eval v >>= k'.eval := by
516516
induction k generalizing v with
517517
| halt => simp only [Cont.eval, Cont.then, pure_bind]
518-
| cons₁ => simp only [Cont.eval, bind_assoc, *]
519-
| cons₂ => simp only [Cont.eval, *]
520-
| comp _ _ k_ih => simp only [Cont.eval, bind_assoc, ← k_ih]
518+
| cons₁ => simp only [Cont.eval, Cont.then, bind_assoc, *]
519+
| cons₂ => simp only [Cont.eval, Cont.then, *]
520+
| comp _ _ k_ih => simp only [Cont.eval, Cont.then, bind_assoc, ← k_ih]
521521
| fix _ _ k_ih =>
522-
simp only [Cont.eval, *]
522+
simp only [Cont.eval, Cont.then, *]
523523
split_ifs <;> [rfl; simp only [← k_ih, bind_assoc]]
524524

525525
/-- The `then k` function is a "configuration homomorphism". Its operation on states is to append

Mathlib/Data/List/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,11 +1233,11 @@ theorem getElem_succ_scanl {i : ℕ} (h : i + 1 < (scanl f b l).length) :
12331233
induction i generalizing b l with
12341234
| zero =>
12351235
cases l
1236-
· simp only [length, zero_eq, lt_self_iff_false] at h
1236+
· simp only [scanl, length, zero_eq, lt_self_iff_false] at h
12371237
· simp
12381238
| succ i hi =>
12391239
cases l
1240-
· simp only [length] at h
1240+
· simp only [scanl, length] at h
12411241
exact absurd h (by omega)
12421242
· simp_rw [scanl_cons]
12431243
rw [getElem_append_right]

Mathlib/Data/List/DropRight.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (
188188
induction' l using List.reverseRecOn with l a
189189
· simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
190190
intro f; contradiction
191-
· simp only [rtakeWhile, reverse_append, takeWhile, ne_eq, not_false_eq_true,
192-
getLast_append_of_ne_nil, getLast_singleton, reduceCtorEq]
191+
· simp only [rtakeWhile, reverse_append, reverse_cons, reverse_nil, nil_append, singleton_append,
192+
takeWhile, ne_eq, cons_ne_self, not_false_eq_true, getLast_append_of_ne_nil,
193+
getLast_singleton]
193194
refine ⟨fun h => ?_ , fun h => ?_⟩
194195
· split at h <;> simp_all
195196
· simp [h]

0 commit comments

Comments
 (0)