Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Poisson, Erlang and base-stock cost functions

Definition
LostSalesRQ_poisson_functions

by Ming Hu · Nov 17, 2026 · Mathlib 0df444a (Lean v4.33.1)

approximation-guaranteeinventorylost-salesoperations-research

Deterministic functions of a lead-time demand mean μ≥0\mu\ge0μ≥0 used throughout the paper.

  1. Poisson mass pj(t)=e−ttj/j!p_j(t)=e^{-t}t^j/j!pj​(t)=e−ttj/j!, distribution function Fj(t)=∑i=0jpi(t)F_j(t)=\sum_{i=0}^{j}p_i(t)Fj​(t)=∑i=0j​pi​(t), upper tail P(N(t)≥l)=1−∑i<lpi(t)\mathbb P(N(t)\ge l)=1-\sum_{i<l}p_i(t)P(N(t)≥l)=1−∑i<l​pi​(t) and expected shortfall Gl(t)=E(l−N(t))+=∑i=0l(l−i)pi(t)G_l(t)=\mathbb E(l-N(t))^+=\sum_{i=0}^{l}(l-i)p_i(t)Gl​(t)=E(l−N(t))+=∑i=0l​(l−i)pi​(t), where N(t)N(t)N(t) is Poisson with mean ttt.
  2. For base stock jjj: the loss fraction ej=pj(μ)/Fj(μ)e_j=p_j(\mu)/F_j(\mu)ej​=pj​(μ)/Fj​(μ), the Erlang normalizer Aj=Fj(μ)/pj(μ)A_j=F_j(\mu)/p_j(\mu)Aj​=Fj​(μ)/pj​(μ), the mean on-hand inventory Hj=j−μ+μejH_j=j-\mu+\mu e_jHj​=j−μ+μej​, and the variance vjv_jvj​ of the on-hand inventory IjI_jIj​, whose law is P(Ij=l)=pj−l(μ)/Fj(μ)\mathbb P(I_j=l)=p_{j-l}(\mu)/F_j(\mu)P(Ij​=l)=pj−l​(μ)/Fj​(μ) for 0≤l≤j0\le l\le j0≤l≤j.
  3. The zero-setup normalized cost of base stock jjj and its minimum over integer levels,
Lj(a)=Hj+a ej,Uμ(a)=min⁡j≥0Lj(a).L_j(a)=H_j+a\,e_j,\qquad U_\mu(a)=\min_{j\ge0}L_j(a).Lj​(a)=Hj​+aej​,Uμ​(a)=j≥0min​Lj​(a).
  1. The intersection penalty aj=(ej−ej+1)−1−μa_j=(e_j-e_{j+1})^{-1}-\muaj​=(ej​−ej+1​)−1−μ of the cost lines of base stocks jjj and j+1j+1j+1.
  2. The integer lot Qk=max⁡{1,⌊2k⌋}Q_k=\max\{1,\lfloor\sqrt{2k}\rfloor\}Qk​=max{1,⌊2k​⌋} and the batching surcharge bk=(Qk−1)/2+k/Qkb_k=(Q_k-1)/2+k/Q_kbk​=(Qk​−1)/2+k/Qk​.

These are the closed-form quantities that the selection algorithm computes and that the analytic comparisons manipulate.

Formalization Note Uμ(a)U_\mu(a)Uμ​(a) is the real infimum over all j∈Nj\in\mathbb Nj∈N; the family is bounded below, so it is the true infimum (attained, by the paper's argument). Divisions are Lean's total divisions; for μ≥0\mu\ge0μ≥0 every Fj(μ)F_j(\mu)Fj​(μ) is positive.

Definition code
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Analysis.Real.Sqrt
import Mathlib.Data.Nat.Factorial.Basic

/-!
# Poisson, Erlang and base-stock functions

Deterministic functions of the lead-time demand mean `μ` used in
M. Hu, "A 1.932 Guarantee for (r,Q) Policies in Continuous-Review Lost-Sales
Inventory Systems" (Section 3.4, Appendix A, Section 4.6).
-/

namespace LostSalesRQ

open Finset

/-- Poisson probability mass `p_j(t) = e^{-t} t^j / j!`. -/
noncomputable def poisMass (t : ℝ) (j : ℕ) : ℝ :=
  Real.exp (-t) * t ^ j / (Nat.factorial j : ℝ)

/-- Poisson distribution function `F_j(t) = ∑_{i=0}^{j} p_i(t)`. -/
noncomputable def poisCdf (t : ℝ) (j : ℕ) : ℝ :=
  ∑ i ∈ range (j + 1), poisMass t i

/-- Poisson upper tail `P(N(t) ≥ l) = 1 - ∑_{i<l} p_i(t)` (equal to `1` when `l = 0`). -/
noncomputable def poisTail (t : ℝ) (l : ℕ) : ℝ :=
  1 - ∑ i ∈ range l, poisMass t i

/-- Expected shortfall `G_l(t) = E (l - N(t))^+ = ∑_{i=0}^{l} (l - i) p_i(t)`. -/
noncomputable def expectedShortfall (t : ℝ) (l : ℕ) : ℝ :=
  ∑ i ∈ range (l + 1), ((l : ℝ) - (i : ℝ)) * poisMass t i

/-- Loss fraction `e_j = p_j / F_j` of base stock `j` (Erlang loss probability) at lead-time
demand mean `μ`. -/
noncomputable def lossFraction (μ : ℝ) (j : ℕ) : ℝ :=
  poisMass μ j / poisCdf μ j

/-- Erlang normalizer `A_j = F_j / p_j` (the reciprocal of `e_j`). -/
noncomputable def erlangNormalizer (μ : ℝ) (j : ℕ) : ℝ :=
  poisCdf μ j / poisMass μ j

/-- Mean on-hand inventory of base stock `j`: `H_j = j - μ + μ e_j`. -/
noncomputable def meanOnHand (μ : ℝ) (j : ℕ) : ℝ :=
  (j : ℝ) - μ + μ * lossFraction μ j

/-- Variance `v_j = Var(I_j)` of the stationary on-hand inventory `I_j` of base stock `j`,
where `P(I_j = l) = p_{j-l}(μ) / F_j(μ)` for `0 ≤ l ≤ j`. -/
noncomputable def onHandVariance (μ : ℝ) (j : ℕ) : ℝ :=
  ∑ l ∈ range (j + 1), ((l : ℝ) - meanOnHand μ j) ^ 2 * (poisMass μ (j - l) / poisCdf μ j)

/-- Normalized zero-setup cost of base stock `j`: `L_j(a) = H_j + a e_j`. -/
noncomputable def baseStockCost (μ a : ℝ) (j : ℕ) : ℝ :=
  meanOnHand μ j + a * lossFraction μ j

/-- Minimum base-stock cost `U_μ(a) = min_{j ≥ 0} L_j(a)` (infimum over all integer levels). -/
noncomputable def minBaseStockCost (μ a : ℝ) : ℝ :=
  ⨅ j : ℕ, baseStockCost μ a j

/-- Intersection penalty `a_j = (e_j - e_{j+1})^{-1} - μ` of the cost lines of base stocks
`j` and `j + 1`. -/
noncomputable def intersectionPenalty (μ : ℝ) (j : ℕ) : ℝ :=
  (lossFraction μ j - lossFraction μ (j + 1))⁻¹ - μ

/-- Integer lot size `Q_k = max{1, ⌊√(2k)⌋}`. -/
noncomputable def lotSize (k : ℝ) : ℕ :=
  max 1 ⌊Real.sqrt (2 * k)⌋₊

/-- Batching surcharge `b_k = (Q_k - 1)/2 + k / Q_k`. -/
noncomputable def batchSurcharge (k : ℝ) : ℝ :=
  ((lotSize k : ℝ) - 1) / 2 + k / (lotSize k : ℝ)

end LostSalesRQ
Source
M. Hu, "A 1.932 Guarantee for (r,Q) Policies in Continuous-Review Lost-Sales Inventory Systems", arXiv:2610.34576, 2026; Section 3.4 (p. 8), Appendix A (pp. A1-A2), eq. (15) (p. 16), Section 4.6.1 (p. 21).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me