Skip to content

Commit 1fb8d95

Browse files
chore: adaptations for batteries#1486 (#31182)
After [batteries#1486](leanprover-community/batteries#1486) is merged: - [x] Edit the lakefile to point to leanprover-community/batteries:main - [x] Run lake update batteries - [x] Merge leanprover-community/mathlib4:master - [ ] Wait for CI and merge Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: F. G. Dorais <fgdorais@gmail.com>
1 parent 9634967 commit 1fb8d95

File tree

13 files changed

+34
-74
lines changed

13 files changed

+34
-74
lines changed

Mathlib/Algebra/BigOperators/Group/List/Basic.lean

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,6 @@ section Monoid
3232

3333
variable [Monoid M] [Monoid N] [Monoid P] {l l₁ l₂ : List M} {a : M}
3434

35-
@[to_additive]
36-
theorem prod_eq_foldl : ∀ {l : List M}, l.prod = foldl (· * ·) 1 l
37-
| [] => rfl
38-
| cons a l => by
39-
rw [prod_cons, prod_eq_foldl, ← foldl_assoc (α := M) (op := (· * ·))]
40-
simp
41-
42-
@[to_additive (attr := simp)]
43-
theorem prod_append : (l₁ ++ l₂).prod = l₁.prod * l₂.prod :=
44-
calc
45-
(l₁ ++ l₂).prod = foldr (· * ·) (1 * foldr (· * ·) 1 l₂) l₁ := by simp [List.prod]
46-
_ = l₁.prod * l₂.prod := foldr_assoc
47-
48-
@[to_additive]
49-
theorem prod_concat : (l.concat a).prod = l.prod * a := by
50-
rw [concat_eq_append, prod_append, prod_singleton]
51-
52-
@[to_additive (attr := simp)]
53-
theorem prod_flatten {l : List (List M)} : l.flatten.prod = (l.map List.prod).prod := by
54-
induction l with
55-
| nil => simp
56-
| cons head tail ih => simp only [*, List.flatten_cons, map, prod_append, prod_cons]
57-
5835
open scoped Relator in
5936
@[to_additive]
6037
theorem rel_prod {R : M → N → Prop} (h : R 1 1) (hf : (R ⇒ R ⇒ R) (· * ·) (· * ·)) :
@@ -82,8 +59,8 @@ theorem prod_hom₂_nonempty {l : List ι} (f : M → N → P)
8259
theorem prod_hom₂ (l : List ι) (f : M → N → P) (hf : ∀ a b c d, f (a * b) (c * d) = f a c * f b d)
8360
(hf' : f 1 1 = 1) (f₁ : ι → M) (f₂ : ι → N) :
8461
(l.map fun i => f (f₁ i) (f₂ i)).prod = f (l.map f₁).prod (l.map f₂).prod := by
85-
rw [prod, prod, prod, foldr_map, foldr_map, foldr_map,
86-
← l.foldr_hom₂ f _ _ (fun x y => f (f₁ x) (f₂ x) * y) _ _ (by simp [hf]), hf']
62+
simp only [prod_eq_foldr, foldr_map]
63+
rw [← foldr_hom₂ l f _ _ ((fun x y => f (f₁ x) (f₂ x) * y) ) _ _ (by simp [hf]), hf']
8764

8865
@[to_additive (attr := simp)]
8966
theorem prod_map_mul {M : Type*} [CommMonoid M] {l : List ι} {f g : ι → M} :
@@ -302,7 +279,7 @@ variable [Group G]
302279
@[to_additive /-- This is the `List.sum` version of `add_neg_rev` -/]
303280
theorem prod_inv_reverse : ∀ L : List G, L.prod⁻¹ = (L.map fun x => x⁻¹).reverse.prod
304281
| [] => by simp
305-
| x :: xs => by simp [prod_inv_reverse xs]
282+
| x :: xs => by simp [prod_append, prod_inv_reverse xs]
306283

307284
/-- A non-commutative variant of `List.prod_reverse` -/
308285
@[to_additive /-- A non-commutative variant of `List.sum_reverse` -/]
@@ -324,8 +301,7 @@ theorem prod_range_div' (n : ℕ) (f : ℕ → G) :
324301
((range n).map fun k ↦ f k / f (k + 1)).prod = f 0 / f n := by
325302
induction n with
326303
| zero => exact (div_self' (f 0)).symm
327-
| succ n h =>
328-
rw [range_succ, map_append, map_singleton, prod_append, prod_singleton, h, div_mul_div_cancel]
304+
| succ n h => simp [range_succ, prod_append, map_append, h]
329305

330306
end Group
331307

Mathlib/Algebra/BigOperators/Group/List/Defs.lean

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ variable {ι M N : Type*}
1818
namespace List
1919
section Defs
2020

21-
/-- Product of a list.
22-
23-
`List.prod [a, b, c] = a * (b * (c * 1))` -/
24-
@[to_additive existing]
25-
def prod {α} [Mul α] [One α] : List α → α :=
26-
foldr (· * ·) 1
21+
set_option linter.existingAttributeWarning false in
22+
attribute [to_additive existing] prod prod_nil prod_cons prod_one_cons prod_append prod_concat
23+
prod_flatten prod_eq_foldl
2724

2825
/-- The alternating sum of a list. -/
2926
def alternatingSum {G : Type*} [Zero G] [Add G] [Neg G] : List G → G
@@ -44,13 +41,6 @@ section Mul
4441

4542
variable [Mul M] [One M] {a : M} {l : List M}
4643

47-
@[to_additive existing, simp]
48-
theorem prod_nil : ([] : List M).prod = 1 :=
49-
rfl
50-
51-
@[to_additive existing, simp]
52-
theorem prod_cons : (a :: l).prod = a * l.prod := rfl
53-
5444
@[to_additive]
5545
lemma prod_induction
5646
(p : M → Prop) (hom : ∀ a b, p a → p b → p (a * b)) (unit : p 1) (base : ∀ x ∈ l, p x) :
@@ -68,20 +58,10 @@ section MulOneClass
6858

6959
variable [MulOneClass M] {l : List M} {a : M}
7060

71-
@[to_additive]
72-
theorem prod_singleton : [a].prod = a :=
73-
mul_one a
74-
75-
@[to_additive]
76-
theorem prod_one_cons : (1 :: l).prod = l.prod := by
77-
rw [prod, foldr, one_mul]
78-
7961
@[to_additive]
8062
theorem prod_map_one {l : List ι} :
8163
(l.map fun _ => (1 : M)).prod = 1 := by
82-
induction l with
83-
| nil => rfl
84-
| cons hd tl ih => rw [map_cons, prod_one_cons, ih]
64+
induction l with simp [*]
8565

8666
@[to_additive]
8767
lemma prod_induction_nonempty
@@ -102,9 +82,6 @@ section Monoid
10282

10383
variable [Monoid M] [Monoid N]
10484

105-
@[to_additive]
106-
theorem prod_eq_foldr {l : List M} : l.prod = foldr (· * ·) 1 l := rfl
107-
10885
@[to_additive (attr := simp)]
10986
theorem prod_replicate (n : ℕ) (a : M) : (replicate n a).prod = a ^ n := by
11087
induction n with

Mathlib/Algebra/BigOperators/Group/Multiset/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ theorem prod_map_erase [DecidableEq ι] {a : ι} (h : a ∈ m) :
4444

4545
@[to_additive (attr := simp, grind =)]
4646
theorem prod_add (s t : Multiset M) : prod (s + t) = prod s * prod t :=
47-
Quotient.inductionOn₂ s t fun l₁ l₂ => by simp
47+
Quotient.inductionOn₂ s t fun l₁ l₂ => by simp [List.prod_append]
4848

4949
@[to_additive]
5050
theorem prod_nsmul (m : Multiset M) : ∀ n : ℕ, (n • m).prod = m.prod ^ n

Mathlib/Algebra/Group/Basic.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ section MulOneClass
8080

8181
variable [MulOneClass M]
8282

83+
@[to_additive]
84+
instance Semigroup.to_isLawfulIdentity : Std.LawfulIdentity (α := M) (· * ·) 1 where
85+
left_id := one_mul
86+
right_id := mul_one
87+
8388
@[to_additive]
8489
theorem ite_mul_one {P : Prop} [Decidable P] {a b : M} :
8590
ite P (a * b) 1 = ite P a 1 * ite P b 1 := by

Mathlib/Algebra/Order/BigOperators/Ring/List.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Stuart Presnell
55
-/
66
import Mathlib.Algebra.Order.Ring.Canonical
7-
import Mathlib.Algebra.BigOperators.Group.List.Defs
87

98
/-!
109
# Big operators on a list in ordered rings

Mathlib/Algebra/Polynomial/Degree/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ lemma natDegree_eq_one : p.natDegree = 1 ↔ ∃ a ≠ 0, ∃ b, C a * X + C b =
355355
· rintro ⟨a, ha, b, rfl⟩
356356
simp [ha]
357357

358-
theorem subsingleton_isRoot_of_natDegree_eq_one [IsLeftCancelMulZero R] [IsRightCancelAdd R]
358+
theorem subsingleton_isRoot_of_natDegree_eq_one [IsLeftCancelMulZero R]
359359
(h : p.natDegree = 1) : { x | IsRoot p x }.Subsingleton := by
360360
intro r₁
361361
obtain ⟨r₂, hr₂, r₃, rfl⟩ : ∃ a, a ≠ 0 ∧ ∃ b, C a * X + C b = p := by rwa [natDegree_eq_one] at h

Mathlib/Algebra/Polynomial/Div.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ lemma _root_.Irreducible.isRoot_eq_bot_of_natDegree_ne_one
756756
(hi : Irreducible p) (hdeg : p.natDegree ≠ 1) : p.IsRoot = ⊥ :=
757757
le_bot_iff.mp fun _ ↦ hi.not_isRoot_of_natDegree_ne_one hdeg
758758

759-
lemma _root_.Irreducible.subsingleton_isRoot [IsLeftCancelMulZero R] [IsRightCancelAdd R]
759+
lemma _root_.Irreducible.subsingleton_isRoot [IsLeftCancelMulZero R]
760760
(hi : Irreducible p) : { x | p.IsRoot x }.Subsingleton :=
761761
fun _ hx ↦ (subsingleton_isRoot_of_natDegree_eq_one <| natDegree_eq_of_degree_eq_some <|
762762
degree_eq_one_of_irreducible_of_root hi hx) hx

Mathlib/Data/List/Prime.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ theorem perm_of_prod_eq_prod :
5555
∀ {l₁ l₂ : List M}, l₁.prod = l₂.prod → (∀ p ∈ l₁, Prime p) → (∀ p ∈ l₂, Prime p) → Perm l₁ l₂
5656
| [], [], _, _, _ => Perm.nil
5757
| [], a :: l, h₁, _, h₃ =>
58-
have ha : a ∣ 1 := prod_nil (M := M) ▸ h₁.symm ▸ (prod_cons (l := l)).symm ▸ dvd_mul_right _ _
58+
have ha : a ∣ 1 := prod_nil (α := M) ▸ h₁.symm ▸ (prod_cons (l := l)).symm ▸ dvd_mul_right _ _
5959
absurd ha (Prime.not_dvd_one (h₃ a mem_cons_self))
6060
| a :: l, [], h₁, h₂, _ =>
61-
have ha : a ∣ 1 := prod_nil (M := M) ▸ h₁ ▸ (prod_cons (l := l)).symm ▸ dvd_mul_right _ _
61+
have ha : a ∣ 1 := prod_nil (α := M) ▸ h₁ ▸ (prod_cons (l := l)).symm ▸ dvd_mul_right _ _
6262
absurd ha (Prime.not_dvd_one (h₂ a mem_cons_self))
6363
| a :: l₁, b :: l₂, h, hl₁, hl₂ => by
6464
classical

Mathlib/Data/List/ToFinsupp.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Copyright (c) 2022 Yakov Pechersky. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yakov Pechersky
55
-/
6-
import Mathlib.Algebra.BigOperators.Group.List.Basic
76
import Mathlib.Algebra.Group.Embedding
87
import Mathlib.Algebra.Group.Finsupp
98
import Mathlib.Algebra.Group.Nat.Defs
@@ -126,6 +125,6 @@ theorem toFinsupp_eq_sum_mapIdx_single {R : Type*} [AddMonoid R] (l : List R)
126125
induction l using List.reverseRecOn with
127126
| nil => exact toFinsupp_nil
128127
| append_singleton x xs ih =>
129-
classical simp [toFinsupp_concat_eq_toFinsupp_add_single, ih]
128+
classical simp [toFinsupp_concat_eq_toFinsupp_add_single, sum_append, ih]
130129

131130
end List

Mathlib/GroupTheory/FreeGroup/Basic.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ Copyright (c) 2018 Kenny Lau. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Kenny Lau
55
-/
6-
import Mathlib.Algebra.BigOperators.Group.List.Basic
76
import Mathlib.Algebra.Group.Pi.Basic
87
import Mathlib.Algebra.Group.Subgroup.Ker
98
import Mathlib.Data.List.Chain
9+
import Mathlib.Algebra.Group.Int.Defs
10+
import Mathlib.Algebra.BigOperators.Group.List.Basic
1011

1112
/-!
1213
# Free groups
@@ -662,7 +663,7 @@ def Lift.aux : List (α × Bool) → β := fun L =>
662663

663664
@[to_additive]
664665
theorem Red.Step.lift {f : α → β} (H : Red.Step L₁ L₂) : Lift.aux f L₁ = Lift.aux f L₂ := by
665-
obtain @⟨_, _, _, b⟩ := H; cases b <;> simp [Lift.aux]
666+
obtain @⟨_, _, _, b⟩ := H; cases b <;> simp [Lift.aux, List.prod_append]
666667

667668
/-- If `β` is a group, then any function from `α` to `β` extends uniquely to a group homomorphism
668669
from the free group over `α` to `β` -/
@@ -672,9 +673,9 @@ from the free group over `α` to `β` -/
672673
def lift : (α → β) ≃ (FreeGroup α →* β) where
673674
toFun f :=
674675
MonoidHom.mk' (Quot.lift (Lift.aux f) fun _ _ => Red.Step.lift) <| by
675-
rintro ⟨L₁⟩ ⟨L₂⟩; simp [Lift.aux]
676+
rintro ⟨L₁⟩ ⟨L₂⟩; simp [Lift.aux, List.prod_append]
676677
invFun g := g ∘ of
677-
left_inv f := List.prod_singleton
678+
left_inv f := by ext; simp [of, Lift.aux]
678679
right_inv g := by ext; simp [of, Lift.aux]
679680

680681
variable {f}
@@ -684,8 +685,7 @@ theorem lift_mk : lift f (mk L) = List.prod (L.map fun x => cond x.2 (f x.1) (f
684685
rfl
685686

686687
@[to_additive (attr := simp)]
687-
theorem lift_apply_of {x} : lift f (of x) = f x :=
688-
List.prod_singleton
688+
theorem lift_apply_of {x} : lift f (of x) = f x := by simp [of]
689689

690690
@[to_additive]
691691
theorem lift_unique (g : FreeGroup α →* β) (hg : ∀ x, g (FreeGroup.of x) = f x) {x} :

0 commit comments

Comments
 (0)