Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit a2517af

Browse files
committed
refactor(data/fin,*): redefine insert_nth, add lemmas (#9349)
### `data/fin` * add `fin.succ_above_cast_lt`, `fin.succ_above_pred`, `fin.cast_lt_succ_above`, `fin.pred_succ_above`; * add `fin.exists_succ_above_eq` and `fin.exists_succ_above_eq_iff`, use the latter to prove `fin.range_succ_above`; * add `@[simp]` to `fin.succ_above_left_inj`; * add `fin.cases_succ_above` induction principle, redefine `fin.insert_nth` to be `fin.cases_succ_above`; * add lemmas about `fin.insert_nth` and some algebraic operations. ### `data/fintype/basic` * add `finset.insert_compl_self`; * add `fin.image_succ_above_univ`, `fin.image_succ_univ`, `fin.image_cast_succ` and use them to prove `fin.univ_succ`, `fin.univ_cast_succ`, and `fin.univ_succ_above` using `by simp`; ### `data/fintype/card` * slightly golf the proof of `fin.prod_univ_succ_above`; * use `@[to_additive]` to generate some proofs. ### `topology/*` * prove continuity of `fin.insert_nth` in both arguments and add all the standard dot-notation `*.fin_insert_nth` lemmas (`*` is one of `filter.tendsto`, `continuous_at`, `continuous_within_at`, `continuous_on`, `continuous`).
1 parent 83470af commit a2517af

File tree

5 files changed

+162
-146
lines changed

5 files changed

+162
-146
lines changed

src/data/fin.lean

Lines changed: 101 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,28 +1137,43 @@ begin
11371137
{ simpa [succ_above_above _ _ (le_of_not_lt H)] using succ_pos _ },
11381138
end
11391139

1140-
/-- The range of `p.succ_above` is everything except `p`. -/
1141-
lemma range_succ_above (p : fin (n + 1)) : set.range (p.succ_above) = { i | i ≠ p } :=
1140+
@[simp] lemma succ_above_cast_lt {x y : fin (n + 1)} (h : x < y)
1141+
(hx : x.1 < n := lt_of_lt_of_le h y.le_last) :
1142+
y.succ_above (x.cast_lt hx) = x :=
1143+
by { rw [succ_above_below, cast_succ_cast_lt], exact h }
1144+
1145+
@[simp] lemma succ_above_pred {x y : fin (n + 1)} (h : x < y)
1146+
(hy : y ≠ 0 := (x.zero_le.trans_lt h).ne') :
1147+
x.succ_above (y.pred hy) = y :=
1148+
by { rw [succ_above_above, succ_pred], simpa [le_iff_coe_le_coe] using nat.le_pred_of_lt h }
1149+
1150+
lemma cast_lt_succ_above {x : fin n} {y : fin (n + 1)} (h : cast_succ x < y)
1151+
(h' : (y.succ_above x).1 < n := lt_of_lt_of_le ((succ_above_lt_iff _ _).2 h) (le_last y)) :
1152+
(y.succ_above x).cast_lt h' = x :=
1153+
by simp only [succ_above_below _ _ h, cast_lt_cast_succ]
1154+
1155+
lemma pred_succ_above {x : fin n} {y : fin (n + 1)} (h : y ≤ cast_succ x)
1156+
(h' : y.succ_above x ≠ 0 := (y.zero_le.trans_lt $ (lt_succ_above_iff _ _).2 h).ne') :
1157+
(y.succ_above x).pred h' = x :=
1158+
by simp only [succ_above_above _ _ h, pred_succ]
1159+
1160+
lemma exists_succ_above_eq {x y : fin (n + 1)} (h : x ≠ y) : ∃ z, y.succ_above z = x :=
11421161
begin
1143-
ext,
1144-
simp only [set.mem_range, ne.def, set.mem_set_of_eq],
1145-
split,
1146-
{ rintro ⟨y, rfl⟩,
1147-
exact succ_above_ne _ _ },
1148-
{ intro h,
1149-
cases lt_or_gt_of_ne h with H H,
1150-
{ refine ⟨x.cast_lt _, _⟩,
1151-
{ exact lt_of_lt_of_le H p.le_last },
1152-
{ rw succ_above_below,
1153-
{ simp },
1154-
{ exact H } } },
1155-
{ refine ⟨x.pred _, _⟩,
1156-
{ exact (ne_of_lt (lt_of_le_of_lt p.zero_le H)).symm },
1157-
{ rw succ_above_above,
1158-
{ simp },
1159-
{ simpa [le_iff_coe_le_coe] using nat.le_pred_of_lt H } } } }
1162+
cases h.lt_or_lt with hlt hlt,
1163+
exacts [⟨_, succ_above_cast_lt hlt⟩, ⟨_, succ_above_pred hlt⟩],
1164+
end
1165+
1166+
@[simp] lemma exists_succ_above_eq_iff {x y : fin (n + 1)} : (∃ z, x.succ_above z = y) ↔ y ≠ x :=
1167+
begin
1168+
refine ⟨_, exists_succ_above_eq⟩,
1169+
rintro ⟨y, rfl⟩,
1170+
exact succ_above_ne _ _
11601171
end
11611172

1173+
/-- The range of `p.succ_above` is everything except `p`. -/
1174+
@[simp] lemma range_succ_above (p : fin (n + 1)) : set.range (p.succ_above) = {p}ᶜ :=
1175+
set.ext $ λ _, exists_succ_above_eq_iff
1176+
11621177
/-- Given a fixed pivot `x : fin (n + 1)`, `x.succ_above` is injective -/
11631178
lemma succ_above_right_injective {x : fin (n + 1)} : injective (succ_above x) :=
11641179
(succ_above x).injective
@@ -1173,7 +1188,7 @@ lemma succ_above_left_injective : injective (@succ_above n) :=
11731188
λ _ _ h, by simpa [range_succ_above] using congr_arg (λ f : fin n ↪o fin (n + 1), (set.range f)ᶜ) h
11741189

11751190
/-- `succ_above` is injective at the pivot -/
1176-
lemma succ_above_left_inj {x y : fin (n + 1)} :
1191+
@[simp] lemma succ_above_left_inj {x y : fin (n + 1)} :
11771192
x.succ_above = y.succ_above ↔ x = y :=
11781193
succ_above_left_injective.eq_iff
11791194

@@ -1390,24 +1405,6 @@ begin
13901405
simp }
13911406
end
13921407

1393-
lemma forall_iff_succ_above {p : fin (n + 1) → Prop} (i : fin (n + 1)) :
1394-
(∀ j, p j) ↔ p i ∧ ∀ j, p (i.succ_above j) :=
1395-
⟨λ h, ⟨h _, λ j, h _⟩,
1396-
λ h j, if hj : j = i then (hj.symm ▸ h.1) else
1397-
begin
1398-
cases n,
1399-
{ convert h.1 },
1400-
{ cases lt_or_gt_of_ne hj with lt gt,
1401-
{ rcases j.zero_le.eq_or_lt with rfl|H,
1402-
{ convert h.2 0, rw succ_above_below; simp [lt] },
1403-
{ have ltl : j < last _ := lt.trans_le i.le_last,
1404-
convert h.2 j.cast_pred,
1405-
simp [succ_above_below, cast_succ_cast_pred ltl, lt] } },
1406-
{ convert h.2 (j.pred (i.zero_le.trans_lt gt).ne.symm),
1407-
rw succ_above_above;
1408-
simp [le_cast_succ_iff, gt.lt] } }
1409-
end
1410-
14111408
end pred_above
14121409

14131410
/-- `min n m` as an element of `fin (m + 1)` -/
@@ -1721,58 +1718,49 @@ section insert_nth
17211718

17221719
variables {α : fin (n+1) → Type u} {β : Type v}
17231720

1724-
/-- Insert an element into a tuple at a given position, auxiliary definition.
1725-
For the general definition, see `insert_nth`. -/
1726-
def insert_nth' {α : fin (n + 2) → Type u} (i : fin (n + 2)) (x : α i)
1727-
(p : Π j : fin (n + 1), α (i.succ_above j)) (j : fin (n + 2)) : α j :=
1728-
if h : i = j
1729-
then _root_.cast (congr_arg α h) x
1730-
else if h' : j < i then _root_.cast (congr_arg α $ begin
1731-
obtain ⟨k, hk⟩ : ∃ (k : fin (n + 1)), k.cast_succ = j,
1732-
{ refine ⟨⟨(j : ℕ), _⟩, _⟩,
1733-
{ exact lt_of_lt_of_le h' i.is_le, },
1734-
{ simp } },
1735-
subst hk,
1736-
simp [succ_above_below, h'],
1737-
end)
1738-
(p j.cast_pred) else _root_.cast (congr_arg α $ begin
1739-
have lt : i < j := lt_of_le_of_ne (le_of_not_lt h') h,
1740-
have : j ≠ 0 := (ne_of_gt (lt_of_le_of_lt i.zero_le lt)),
1741-
rw [←succ_pred j this, ←le_cast_succ_iff] at lt,
1742-
simp [pred_above_zero this, succ_above_above _ _ lt]
1743-
end) (p (fin.pred_above 0 j))
1721+
/-- Define a function on `fin (n + 1)` from a value on `i : fin (n + 1)` and values on each
1722+
`fin.succ_above i j`, `j : fin n`. This version is elaborated as eliminator and works for
1723+
propositions, see also `fin.insert_nth` for a version without an `@[elab_as_eliminator]`
1724+
attribute. -/
1725+
@[elab_as_eliminator]
1726+
def succ_above_cases {α : fin (n + 1) → Sort u} (i : fin (n + 1)) (x : α i)
1727+
(p : Π j : fin n, α (i.succ_above j)) (j : fin (n + 1)) : α j :=
1728+
if hj : j = i then eq.rec x hj.symm
1729+
else if hlt : j < i then eq.rec_on (succ_above_cast_lt hlt) (p _)
1730+
else eq.rec_on (succ_above_pred $ (ne.lt_or_lt hj).resolve_left hlt) (p _)
1731+
1732+
lemma forall_iff_succ_above {p : fin (n + 1) → Prop} (i : fin (n + 1)) :
1733+
(∀ j, p j) ↔ p i ∧ ∀ j, p (i.succ_above j) :=
1734+
⟨λ h, ⟨h _, λ j, h _⟩, λ h, succ_above_cases i h.1 h.2
17441735

17451736
/-- Insert an element into a tuple at a given position. For `i = 0` see `fin.cons`,
1746-
for `i = fin.last n` see `fin.snoc`. -/
1747-
def insert_nth : Π {n : ℕ} {α : fin (n + 1) → Type u} (i : fin (n + 1)) (x : α i)
1748-
(p : Π j : fin n, α (i.succ_above j)) (j : fin (n + 1)), α j
1749-
| 0 _ _ x _ _ := _root_.cast (by congr) x
1750-
| (n + 1) _ i x p j := insert_nth' i x p j
1737+
for `i = fin.last n` see `fin.snoc`. See also `fin.succ_above_cases` for a version elaborated
1738+
as an eliminator. -/
1739+
def insert_nth (i : fin (n + 1)) (x : α i) (p : Π j : fin n, α (i.succ_above j)) (j : fin (n + 1)) :
1740+
α j :=
1741+
succ_above_cases i x p j
17511742

17521743
@[simp] lemma insert_nth_apply_same (i : fin (n + 1)) (x : α i) (p : Π j, α (i.succ_above j)) :
17531744
insert_nth i x p i = x :=
1754-
by { cases n; simp [insert_nth, insert_nth'] }
1745+
by simp [insert_nth, succ_above_cases]
17551746

17561747
@[simp] lemma insert_nth_apply_succ_above (i : fin (n + 1)) (x : α i) (p : Π j, α (i.succ_above j))
17571748
(j : fin n) :
17581749
insert_nth i x p (i.succ_above j) = p j :=
17591750
begin
1760-
cases n,
1761-
{ exact j.elim0 },
1762-
simp only [insert_nth, insert_nth', dif_neg (succ_above_ne _ _).symm],
1763-
cases succ_above_lt_ge i j with h h,
1764-
{ rw dif_pos,
1765-
refine eq_of_heq ((cast_heq _ _).trans _),
1766-
{ simp [h] },
1767-
{ congr,
1768-
simp [succ_above_below, h] } },
1769-
{ rw dif_neg,
1770-
refine eq_of_heq ((cast_heq _ _).trans _),
1771-
{ simp [h] },
1772-
{ congr,
1773-
simp [succ_above_above, h, succ_ne_zero] } }
1751+
simp only [insert_nth, succ_above_cases, dif_neg (succ_above_ne _ _)],
1752+
by_cases hlt : j.cast_succ < i,
1753+
{ rw [dif_pos ((succ_above_lt_iff _ _).2 hlt)],
1754+
apply eq_of_heq ((eq_rec_heq _ _).trans _),
1755+
rw [cast_lt_succ_above hlt] },
1756+
{ rw [dif_neg (mt (succ_above_lt_iff _ _).1 hlt)],
1757+
apply eq_of_heq ((eq_rec_heq _ _).trans _),
1758+
rw [pred_succ_above (le_of_not_lt hlt)] }
17741759
end
17751760

1761+
@[simp] lemma succ_above_cases_eq_insert_nth :
1762+
@succ_above_cases.{u + 1} = @insert_nth.{u} := rfl
1763+
17761764
@[simp] lemma insert_nth_comp_succ_above (i : fin (n + 1)) (x : β) (p : fin n → β) :
17771765
insert_nth i x p ∘ i.succ_above = p :=
17781766
funext $ insert_nth_apply_succ_above i x p
@@ -1814,6 +1802,41 @@ end
18141802
@insert_nth _ (λ _, β) (last n) x p = snoc p x :=
18151803
by simp [insert_nth_last]
18161804

1805+
@[simp] lemma insert_nth_zero_right [Π j, has_zero (α j)] (i : fin (n + 1)) (x : α i) :
1806+
i.insert_nth x 0 = pi.single i x :=
1807+
insert_nth_eq_iff.2 $ by simp [succ_above_ne, pi.zero_def]
1808+
1809+
lemma insert_nth_binop (op : Π j, α j → α j → α j) (i : fin (n + 1))
1810+
(x y : α i) (p q : Π j, α (i.succ_above j)) :
1811+
i.insert_nth (op i x y) (λ j, op _ (p j) (q j)) =
1812+
λ j, op j (i.insert_nth x p j) (i.insert_nth y q j) :=
1813+
insert_nth_eq_iff.2 $ by simp
1814+
1815+
@[simp] lemma insert_nth_mul [Π j, has_mul (α j)] (i : fin (n + 1))
1816+
(x y : α i) (p q : Π j, α (i.succ_above j)) :
1817+
i.insert_nth (x * y) (p * q) = i.insert_nth x p * i.insert_nth y q :=
1818+
insert_nth_binop (λ _, (*)) i x y p q
1819+
1820+
@[simp] lemma insert_nth_add [Π j, has_add (α j)] (i : fin (n + 1))
1821+
(x y : α i) (p q : Π j, α (i.succ_above j)) :
1822+
i.insert_nth (x + y) (p + q) = i.insert_nth x p + i.insert_nth y q :=
1823+
insert_nth_binop (λ _, (+)) i x y p q
1824+
1825+
@[simp] lemma insert_nth_div [Π j, has_div (α j)] (i : fin (n + 1))
1826+
(x y : α i) (p q : Π j, α (i.succ_above j)) :
1827+
i.insert_nth (x / y) (p / q) = i.insert_nth x p / i.insert_nth y q :=
1828+
insert_nth_binop (λ _, (/)) i x y p q
1829+
1830+
@[simp] lemma insert_nth_sub [Π j, has_sub (α j)] (i : fin (n + 1))
1831+
(x y : α i) (p q : Π j, α (i.succ_above j)) :
1832+
i.insert_nth (x - y) (p - q) = i.insert_nth x p - i.insert_nth y q :=
1833+
insert_nth_binop (λ _, has_sub.sub) i x y p q
1834+
1835+
@[simp] lemma insert_nth_sub_same [Π j, add_group (α j)] (i : fin (n + 1))
1836+
(x y : α i) (p : Π j, α (i.succ_above j)) :
1837+
i.insert_nth x p - i.insert_nth y p = pi.single i (x - y) :=
1838+
by simp_rw [← insert_nth_sub, ← insert_nth_zero_right, pi.sub_def, sub_self, pi.zero_def]
1839+
18171840
variables [Π i, preorder (α i)]
18181841

18191842
lemma insert_nth_le_iff {i : fin (n + 1)} {x : α i} {p : Π j, α (i.succ_above j)} {q : Π j, α j} :

src/data/fintype/basic.lean

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ set.ext $ λ x, mem_compl
130130
@[simp] theorem union_compl [decidable_eq α] (s : finset α) : s ∪ sᶜ = finset.univ :=
131131
sup_compl_eq_top
132132

133+
@[simp] theorem insert_compl_self [decidable_eq α] (x : α) : insert x ({x}ᶜ : finset α) = univ :=
134+
by { ext y, simp [eq_or_ne] }
135+
133136
@[simp] lemma compl_filter [decidable_eq α] (p : α → Prop) [decidable_pred p]
134137
[Π x, decidable (¬p x)] :
135138
(univ.filter p)ᶜ = univ.filter (λ x, ¬p x) :=
@@ -661,57 +664,32 @@ by simpa only [fintype.card_fin] using s.card_le_univ
661664
lemma fin.equiv_iff_eq {m n : ℕ} : nonempty (fin m ≃ fin n) ↔ m = n :=
662665
⟨λ ⟨h⟩, by simpa using fintype.card_congr h, λ h, ⟨equiv.cast $ h ▸ rfl ⟩ ⟩
663666

667+
@[simp] lemma fin.image_succ_above_univ {n : ℕ} (i : fin (n + 1)) :
668+
univ.image i.succ_above = {i}ᶜ :=
669+
by { ext m, simp }
670+
671+
@[simp] lemma fin.image_succ_univ (n : ℕ) : (univ : finset (fin n)).image fin.succ = {0}ᶜ :=
672+
by rw [← fin.succ_above_zero, fin.image_succ_above_univ]
673+
674+
@[simp] lemma fin.image_cast_succ (n : ℕ) :
675+
(univ : finset (fin n)).image fin.cast_succ = {fin.last n}ᶜ :=
676+
by rw [← fin.succ_above_last, fin.image_succ_above_univ]
677+
664678
/-- Embed `fin n` into `fin (n + 1)` by prepending zero to the `univ` -/
665679
lemma fin.univ_succ (n : ℕ) :
666680
(univ : finset (fin (n + 1))) = insert 0 (univ.image fin.succ) :=
667-
begin
668-
ext m,
669-
simp only [mem_univ, mem_insert, true_iff, mem_image, exists_prop],
670-
exact fin.cases (or.inl rfl) (λ i, or.inr ⟨i, trivial, rfl⟩) m
671-
end
681+
by simp
672682

673683
/-- Embed `fin n` into `fin (n + 1)` by appending a new `fin.last n` to the `univ` -/
674684
lemma fin.univ_cast_succ (n : ℕ) :
675685
(univ : finset (fin (n + 1))) = insert (fin.last n) (univ.image fin.cast_succ) :=
676-
begin
677-
ext m,
678-
simp only [mem_univ, mem_insert, true_iff, mem_image, exists_prop, true_and],
679-
by_cases h : m.val < n,
680-
{ right,
681-
use fin.cast_lt m h,
682-
rw fin.cast_succ_cast_lt },
683-
{ left,
684-
exact fin.eq_last_of_not_lt h }
685-
end
686+
by simp
686687

687688
/-- Embed `fin n` into `fin (n + 1)` by inserting
688689
around a specified pivot `p : fin (n + 1)` into the `univ` -/
689690
lemma fin.univ_succ_above (n : ℕ) (p : fin (n + 1)) :
690691
(univ : finset (fin (n + 1))) = insert p (univ.image (fin.succ_above p)) :=
691-
begin
692-
obtain hl | rfl := (fin.le_last p).lt_or_eq,
693-
{ ext m,
694-
simp only [finset.mem_univ, finset.mem_insert, true_iff, finset.mem_image, exists_prop],
695-
refine or_iff_not_imp_left.mpr (λ h, _),
696-
cases n,
697-
{ have : m = p := by simp,
698-
exact absurd this h },
699-
use p.cast_pred.pred_above m,
700-
rw fin.pred_above,
701-
split_ifs with H,
702-
{ simp only [fin.coe_cast_succ, true_and, fin.coe_coe_eq_self, coe_coe],
703-
rw fin.lt_last_iff_coe_cast_pred at hl,
704-
rw fin.succ_above_above,
705-
{ simp },
706-
{ simp only [fin.lt_iff_coe_lt_coe, fin.coe_cast_succ] at H,
707-
simpa [fin.le_iff_coe_le_coe, ←hl] using nat.le_pred_of_lt H } },
708-
{ rw fin.succ_above_below,
709-
{ simp },
710-
{ simp only [fin.cast_succ_cast_pred hl, not_lt] at H,
711-
simpa using lt_of_le_of_ne H h } } },
712-
{ rw fin.succ_above_last,
713-
exact fin.univ_cast_succ n }
714-
end
692+
by simp
715693

716694
@[instance, priority 10] def unique.fintype {α : Type*} [unique α] : fintype α :=
717695
fintype.of_subsingleton (default α)

src/data/fintype/card.lean

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,51 +126,35 @@ theorem fin.prod_univ_zero [comm_monoid β] (f : fin 0 → β) : ∏ i, f i = 1
126126

127127
/-- A product of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
128128
is the product of `f x`, for some `x : fin (n + 1)` times the remaining product -/
129-
theorem fin.prod_univ_succ_above [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) (x : fin (n + 1)) :
129+
@[to_additive
130+
/- A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
131+
is the sum of `f x`, for some `x : fin (n + 1)` plus the remaining product -/]
132+
theorem fin.prod_univ_succ_above [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β)
133+
(x : fin (n + 1)) :
130134
∏ i, f i = f x * ∏ i : fin n, f (x.succ_above i) :=
131135
begin
132-
rw [fin.univ_succ_above, finset.prod_insert, finset.prod_image],
133-
{ intros x _ y _ hxy, exact fin.succ_above_right_inj.mp hxy },
134-
{ simp [fin.succ_above_ne] }
136+
rw [fintype.prod_eq_mul_prod_compl x, ← fin.image_succ_above_univ, prod_image],
137+
exact λ _ _ _ _ h, x.succ_above.injective h
135138
end
136139

137-
/-- A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
138-
is the sum of `f x`, for some `x : fin (n + 1)` plus the remaining product -/
139-
theorem fin.sum_univ_succ_above [add_comm_monoid β] {n : ℕ} (f : fin (n + 1) → β)
140-
(x : fin (n + 1)) :
141-
∑ i, f i = f x + ∑ i : fin n, f (x.succ_above i) :=
142-
by apply @fin.prod_univ_succ_above (multiplicative β)
143-
144-
attribute [to_additive] fin.prod_univ_succ_above
145-
146140
/-- A product of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
147141
is the product of `f 0` plus the remaining product -/
142+
@[to_additive
143+
/- A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
144+
is the sum of `f 0` plus the remaining product -/]
148145
theorem fin.prod_univ_succ [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) :
149146
∏ i, f i = f 0 * ∏ i : fin n, f i.succ :=
150147
fin.prod_univ_succ_above f 0
151148

152-
/-- A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
153-
is the sum of `f 0` plus the remaining product -/
154-
theorem fin.sum_univ_succ [add_comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) :
155-
∑ i, f i = f 0 + ∑ i : fin n, f i.succ :=
156-
fin.sum_univ_succ_above f 0
157-
158-
attribute [to_additive] fin.prod_univ_succ
159-
160149
/-- A product of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
161150
is the product of `f (fin.last n)` plus the remaining product -/
151+
@[to_additive
152+
/- A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
153+
is the sum of `f (fin.last n)` plus the remaining sum -/]
162154
theorem fin.prod_univ_cast_succ [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) :
163155
∏ i, f i = (∏ i : fin n, f i.cast_succ) * f (fin.last n) :=
164156
by simpa [mul_comm] using fin.prod_univ_succ_above f (fin.last n)
165157

166-
/-- A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
167-
is the sum of `f (fin.last n)` plus the remaining sum -/
168-
theorem fin.sum_univ_cast_succ [add_comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) :
169-
∑ i, f i = ∑ i : fin n, f i.cast_succ + f (fin.last n) :=
170-
by apply @fin.prod_univ_cast_succ (multiplicative β)
171-
172-
attribute [to_additive] fin.prod_univ_cast_succ
173-
174158
open finset
175159

176160
@[simp] theorem fintype.card_sigma {α : Type*} (β : α → Type*)

0 commit comments

Comments
 (0)