Zulip Chat Archive
Stream: PrimeNumberTheorem+
Topic: Riemann integrability
Harald Helfgott (Jan 27 2026 at 22:30):
I’m working on a barebones Riemann-Stieltjes integration theory (Montgomery–Vaughan Appendix A), and I want it to interface cleanly with Mathlib’s existing integration framework.
The natural way to do so is through Riemann integrability; for instance, one can show (as in Theorem A.3 of Montgomery-Vaughan) that, if is Riemann integrable and is , then the Riemann-Stieltjes integral equals , where this last integral is to be understood as a Riemann integral (which is the same as a Riemann-Stieltjes integral when it comes to ).
Then one can use existing results on when a function is Riemann integrable to show when Riemann-Stieltjes integration theory is applicable.
In Mathlib, Riemann integration appears to be accessible as a special case of BoxIntegral, via IntegrationParams with bRiemann = true. In particular, results such as
BoxIntegral.integrable_of_bounded_and_ae_continuousWithinAt
seem to encode the classical fact that a bounded function which is continuous a.e. on an interval is Riemann integrable, and then of course the Riemann integral equals the Lebesgue integral.
What I am missing is a clear bridge between this BoxIntegral notion of Riemann integrability and a completely elementary, mesh-based definition of Riemann integrability. Concretely, suppose one defines tagged partitions, mesh, and Riemann sums in the usual way - say, keeping things simple:
structure RPartition (a b : ℝ) where
n : ℕ
x : Fin (n + 1) → ℝ
monotone : Monotone x
left : x 0 = a
right : x (Fin.last n) = b
def RPartition.mesh {a b : ℝ} (P : RPartition a b) : ℝ :=
((Finset.univ : Finset (Fin P.n)).image (fun i => P.x i.succ - P.x i.castSucc)).max.getD 0
/-- A tagged Riemann partition includes points `xi` in each subinterval `[x_i, x_{i+1}]`. -/
structure TaggedRPartition (a b : ℝ) extends RPartition a b where
xi : Fin n → ℝ
h_xi : ∀ i : Fin n, x i.castSucc ≤ xi i ∧ xi i ≤ x i.succ
def RiemannSumR {a b : ℝ} (f : ℝ → ℝ) (P : TaggedRPartition a b) : ℝ :=
∑ i : Fin P.n, f (P.xi i) * (P.x i.succ - P.x i.castSucc)
def HasRIntegral (f : ℝ → ℝ) (a b I : ℝ) : Prop :=
∀ ε > 0, ∃ δ > 0, ∀ P : TaggedRPartition a b,
P.mesh ≤ δ → |RiemannSumR f P - I| < ε
Question: is there already a lemma proving that HasRIntegral f a b I (or something very close to it; people must have worked with simple implementations such as this) is equivalent to BoxIntegral’s Riemann integrability? If not, can anybody more experienced with BoxIntegral show us how to do it?
I would like, at the very least, have a lemma showing that HasRIntegral f a b I holds if f is bounded and continuous a.e. on [a,b], and also a lemma showing that the Riemann integral I then equals the Lebesgue integral. Again, the proof should simply use the theory developed in BoxIntegral, rather than do anything from scratch.
Harald Helfgott (Jan 27 2026 at 22:46):
(Also, if there is an appropriate place to ask this so that it reaches a wider Lean audience, I’d be happy to repost — this doesn’t really seem specific to PNT+.)
Moritz Doll (Jan 27 2026 at 22:50):
Harald Helfgott said:
(Also, if there is an appropriate place to ask this so that it reaches a wider Lean audience, I’d be happy to repost — this doesn’t really seem specific to PNT+.)
I think this is a perfect question for the Is there code for X channel. (I can't help unfortunately, I have never used Riemann integration in mathlib)
Last updated: Feb 28 2026 at 14:05 UTC