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

feat(topology/algebra/infinite_sum): Extract none from a sum over option types #19150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
27 changes: 26 additions & 1 deletion src/topology/algebra/infinite_sum/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ begin
exact if_neg hb'
end

lemma has_sum_singleton (f : β → α) (b : β) : has_sum (f ∘ coe : ({b} : set β) → α) (f b) :=
Copy link
Member

Choose a reason for hiding this comment

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

Please add it for a [unique] type, not just a singleton.

suffices has_sum ((f ∘ coe : ({b} : set β) → α)) (∑ b' : ({b} : set β), f ↑b'),
by simpa only [univ_unique, sum_singleton] using this,
has_sum_sum_of_ne_finset_zero (λ x h, (h (finset.mem_univ x)).elim)

lemma has_sum_pi_single [decidable_eq β] (b : β) (a : α) :
has_sum (pi.single b a) a :=
show has_sum (λ x, pi.single b a x) a, by simpa only [pi.single_apply] using has_sum_ite_eq b a
Expand Down Expand Up @@ -313,6 +318,16 @@ lemma has_sum.compl_add {s : set β} (ha : has_sum (f ∘ coe : sᶜ → α) a)
has_sum f (a + b) :=
ha.add_is_compl is_compl_compl.symm hb

lemma has_sum.sum_t {f : β ⊕ γ → α} {a_inl a_inr : α} (h_inl : has_sum (f ∘ sum.inl) a_inl)
Copy link
Member

@urkud urkud Jun 21, 2023

Choose a reason for hiding this comment

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

There are two ways to state this lemma: starting with β ⊕ γ → α and starting with two functions and combining them using sum.elim. Please add the second version too (the proof should be by application of this version). I'm not sure about the naming convention for this kind of lemmas. sum_dom? I would ask on Zulip.

(h_inr : has_sum (f ∘ sum.inr) a_inr) : has_sum f (a_inl + a_inr) :=
has_sum.add_is_compl (set.is_compl_range_inl_range_inr)
(sum.inl_injective.has_sum_range_iff.2 h_inl) (sum.inr_injective.has_sum_range_iff.2 h_inr)

lemma has_sum.option {f : option β → α} {a_some : α} (hf : has_sum (f ∘ option.some) a_some) :
Copy link
Member

Choose a reason for hiding this comment

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

Please make it protected.

Copy link
Member

Choose a reason for hiding this comment

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

Also, please add summable versions of your lemmas (with iff versions whenever we can apply summable.comp_injective).

has_sum f (f none + a_some) :=
has_sum.add_is_compl (set.is_compl_range_some_none β).symm (has_sum_singleton f none)
((option.some_injective β).has_sum_range_iff.2 hf)

lemma has_sum.even_add_odd {f : ℕ → α} (he : has_sum (λ k, f (2 * k)) a)
(ho : has_sum (λ k, f (2 * k + 1)) b) :
has_sum f (a + b) :=
Expand Down Expand Up @@ -565,7 +580,7 @@ lemma tsum_sum {f : γ → β → α} {s : finset γ} (hf : ∀i∈s, summable (

/-- Version of `tsum_eq_add_tsum_ite` for `add_comm_monoid` rather than `add_comm_group`.
Requires a different convergence assumption involving `function.update`. -/
lemma tsum_eq_add_tsum_ite' {f : β → α} (b : β) (hf : summable (f.update b 0)) :
lemma tsum_eq_add_tsum_ite' [decidable_eq β] {f : β → α} (b : β) (hf : summable (f.update b 0)) :
dtumad marked this conversation as resolved.
Show resolved Hide resolved
∑' x, f x = f b + ∑' x, ite (x = b) 0 (f x) :=
calc ∑' x, f x = ∑' x, ((ite (x = b) (f x) 0) + (f.update b 0 x)) :
tsum_congr (λ n, by split_ifs; simp [function.update_apply, h])
Expand Down Expand Up @@ -673,6 +688,16 @@ lemma tsum_add_tsum_compl {s : set β} (hs : summable (f ∘ coe : s → α))
(∑' x : s, f x) + (∑' x : sᶜ, f x) = ∑' x, f x :=
(hs.has_sum.add_compl hsc.has_sum).tsum_eq.symm

/-- Split a sum over `option β` into `f none` plus the sum of `f ∘ some` on `β`. -/
lemma tsum_option {f : option β → α} (hf : summable (f ∘ option.some)) :
∑' x : option β, f x = f none + ∑' x : β, f (some x) :=
hf.has_sum.option.tsum_eq

/-- Split a sum over `β ⊕ γ` into the sum of `f ∘ inl` over `β` and `f ∘ inr` over `γ`. -/
lemma tsum_sum_t {f : β ⊕ γ → α} (hf : summable (f ∘ sum.inl)) (hf' : summable (f ∘ sum.inr)) :
∑' x : β ⊕ γ, f x = (∑' x : β, f (sum.inl x)) + (∑' x : γ, f (sum.inr x)) :=
(hf.has_sum.sum_t hf'.has_sum).tsum_eq

lemma tsum_union_disjoint {s t : set β} (hd : disjoint s t)
(hs : summable (f ∘ coe : s → α)) (ht : summable (f ∘ coe : t → α)) :
(∑' x : s ∪ t, f x) = (∑' x : s, f x) + (∑' x : t, f x) :=
Expand Down