Skip to content

Commit

Permalink
feat: add lemma List.prod_map_one (#11112)
Browse files Browse the repository at this point in the history
Adds the lemma, and `to_additive` tags it
  • Loading branch information
BoltonBailey committed Mar 25, 2024
1 parent 2c429c3 commit 2d2e953
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Mathlib/Data/List/BigOperators/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ variable {ι α M N P M₀ G R : Type*}

namespace List

section Monoid
section MulOneClass

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

@[to_additive (attr := simp)]
theorem prod_nil : ([] : List M).prod = 1 :=
Expand All @@ -40,6 +40,23 @@ theorem prod_singleton : [a].prod = a :=
#align list.prod_singleton List.prod_singleton
#align list.sum_singleton List.sum_singleton

@[to_additive (attr := simp)]
theorem prod_one_cons : (1 :: l).prod = l.prod := by
rw [prod, foldl, mul_one]

@[to_additive]
theorem prod_map_one {l : List ι} :
(l.map fun _ => (1 : M)).prod = 1 := by
induction l with
| nil => rfl
| cons hd tl ih => rw [map_cons, prod_one_cons, ih]

end MulOneClass

section Monoid

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

@[to_additive (attr := simp)]
theorem prod_cons : (a :: l).prod = a * l.prod :=
calc
Expand Down

0 comments on commit 2d2e953

Please sign in to comment.