File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Mathlib/Topology/Algebra/InfiniteSum Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -314,3 +314,29 @@ theorem Summable.tendsto_atTop_of_pos [LinearOrderedField α] [TopologicalSpace
314314 inv_inv f ▸ Filter.Tendsto.inv_tendsto_nhdsGT_zero <|
315315 tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hf.tendsto_atTop_zero <|
316316 Eventually.of_forall fun _ ↦ inv_pos.2 (hf' _)
317+
318+ namespace Mathlib.Meta.Positivity
319+
320+ open Qq Lean Meta Finset
321+
322+ attribute [local instance] monadLiftOptionMetaM in
323+ /-- Positivity extension for infinite sums.
324+
325+ This extension only proves non-negativity, strict positivity is more delicate for infinite sums and
326+ requires more assumptions. -/
327+ @[positivity tsum _]
328+ def evalTsum : PositivityExt where eval {u α} zα pα e := do
329+ match e with
330+ | ~q(@tsum _ $instCommMonoid $instTopSpace $ι $f) =>
331+ lambdaBoundedTelescope f 1 fun args (body : Q($α)) => do
332+ let #[(i : Q($ι))] := args | failure
333+ let rbody ← core zα pα body
334+ let pbody ← rbody.toNonneg
335+ let pr : Q(∀ i, 0 ≤ $f i) ← mkLambdaFVars #[i] pbody
336+ let pα' ← synthInstanceQ q(OrderedAddCommMonoid $α)
337+ let instOrderClosed ← synthInstanceQ q(OrderClosedTopology $α)
338+ assertInstancesCommute
339+ return .nonnegative q(@tsum_nonneg $ι $α $pα' $instTopSpace $instOrderClosed $f $pr)
340+ | _ => throwError "not tsum"
341+
342+ end Mathlib.Meta.Positivity
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Mathlib.Analysis.Normed.Group.Basic
55import Mathlib.Analysis.SpecialFunctions.Pow.Real
66import Mathlib.Analysis.SpecialFunctions.Log.Basic
77import Mathlib.MeasureTheory.Integral.Bochner
8+ import Mathlib.Topology.Algebra.InfiniteSum.Order
89
910/-! # Tests for the `positivity` tactic
1011
@@ -380,6 +381,19 @@ example (f : D → E) (c : ℝ) (hc : 0 < c): 0 ≤ ∫ x, c * ‖f x‖ ∂μ :
380381
381382end Integral
382383
384+ /-! ## Infinite Sums -/
385+
386+ example (f : ℕ → ℝ) : 0 ≤ ∑' n, f n ^ 2 := by positivity
387+ example (f : ℕ → ℝ≥0 ) (c : ℝ) (hc : 0 < c) : 0 ≤ ∑' n, c * f n := by positivity
388+ example [LinearOrderedField α] [TopologicalSpace α] [OrderClosedTopology α] (f : ℚ → α) :
389+ 0 ≤ ∑' q, (f q)^2 := by
390+ positivity
391+
392+ -- Make sure that the extension doesn't produce an invalid term by accidentally unifying `?n` with
393+ -- `0` because of the `hf` assumption
394+ set_option linter.unusedVariables false in
395+ example (f : ℕ → ℕ) (hf : 0 ≤ f 0 ) : 0 ≤ ∑' n, f n := by positivity
396+
383397/-! ## Big operators -/
384398
385399example (n : ℕ) (f : ℕ → ℤ) : 0 ≤ ∑ j ∈ range n, f j ^ 2 := by positivity
You can’t perform that action at this time.
0 commit comments