Bernoulli backlog Bellman values and randomized valuation experiments
DefinitionInventoryBounds_StationaryValuationFinite-horizon Bellman recursion and zero-base-stock recursion for unit costs and zero/unit IID demand; a separately defined value polynomial and derivative expression; Bernoulli KL; the two perturbed zero-demand probabilities; IID finite archive weights; and estimator success probability computed from a Markov kernel.
import Definitions.Def_InventoryBounds_Primitives
import Mathlib.Probability.Kernel.Basic
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Analysis.Calculus.Deriv.Basic
set_option autoImplicit false
open MeasureTheory ProbabilityTheory
open scoped BigOperators
namespace InventoryBounds
noncomputable def bernoulliDP : ℕ → ℝ → ℝ → ℝ
| 0, _, _ => 0
| n + 1, ρ, x => sInf
((fun y : ℝ =>
ρ * (stageCost 1 1 y 0 + bernoulliDP n ρ y) +
(1 - ρ) * (stageCost 1 1 y 1 + bernoulliDP n ρ (y - 1))) ''
Set.Ici (max x 0))
noncomputable def zeroBaseStockValue : ℕ → ℝ → ℝ → ℝ
| 0, _, _ => 0
| n + 1, ρ, x =>
let y := max x 0
ρ * (stageCost 1 1 y 0 + zeroBaseStockValue n ρ y) +
(1 - ρ) * (stageCost 1 1 y 1 + zeroBaseStockValue n ρ (y - 1))
noncomputable def valueFormula (T : ℕ) (ρ : ℝ) : ℝ :=
(T : ℝ) * (1 - ρ) + (2 * ρ - 1) * ∑ k ∈ Finset.range T, ρ ^ k
noncomputable def valueDerivative (T : ℕ) (ρ : ℝ) : ℝ :=
-(T : ℝ) + 2 * (∑ k ∈ Finset.range T, ρ ^ k) +
(2 * ρ - 1) * ∑ k ∈ Finset.range T, (k : ℝ) * ρ ^ (k - 1)
noncomputable def binaryKL (p q : ℝ) : ℝ :=
p * Real.log (p / q) + (1 - p) * Real.log ((1 - p) / (1 - q))
noncomputable def rhoMinus (T : ℕ) (ε : ℝ) : ℝ :=
1 - 1 / (2 * (T : ℝ)) - 128 * ε / (T : ℝ) ^ 2
noncomputable def rhoPlus (T : ℕ) (ε : ℝ) : ℝ :=
1 - 1 / (2 * (T : ℝ)) + 128 * ε / (T : ℝ) ^ 2
-- A true bit denotes a zero demand; false denotes a unit demand.
noncomputable def sampleWeight {M : ℕ} (ρ : ℝ) (z : Fin M → Bool) : ℝ :=
∏ i : Fin M, if z i then ρ else 1 - ρ
-- A Markov kernel includes every randomized real-valued estimator on this finite archive.
noncomputable def estimatorSuccess {M : ℕ}
(κ : Kernel (Fin M → Bool) ℝ) (ρ v ε : ℝ) : ℝ :=
∑ z : Fin M → Bool,
sampleWeight ρ z * (κ z (Set.Icc (v - ε) (v + ε))).toReal
end InventoryBounds
Read-back
What the Lean code literally says, in plain math · gpt-6
For every natural number and every real , define recursively by and , where . The infimum is the total real infimum operation; the definition itself supplies no boundedness hypothesis, while its feasible set is always nonempty. All real and are admitted, without a probability or nonnegativity restriction. The second continuation state is exactly , which can be negative; it is not replaced by .
For every natural number and every real , define recursively by and , where and . This definition fixes that single and performs no optimization. There is no restriction on or , and the continuation state can be negative.
For every natural number and real , define , with interpreted as a real number in real arithmetic. The sum is over natural indices ; for it is empty and . Integer powers are total, including when .
For every natural number and real , define , with natural indices and real coercions of and . The subtraction in the exponent is natural-number subtraction, so the exponent at is , and that summand is , also at . Both sums are empty for , giving . This is a definition of a real expression and imposes no restriction on .
For every real , define . No restriction to probabilities or to nonzero denominators is imposed. The divisions use total real division, so division by zero returns ; the real logarithm is also total, with and for . Thus this formula assigns values even outside and at the endpoints.
For every natural number and real , define , interpreting as real. There is no restriction on or . Total real division gives ; for other inputs the definition alone does not assert that the result lies in .
For every natural number and real , define , interpreting as real. There is no restriction on or . Total real division gives ; for other inputs the definition alone does not assert that the result lies in .
For every natural number , real , and function , define , where and . The parameter is implicit in this definition. For there is exactly one such function, the empty function, and its weight is the empty product . No restriction is imposed on , so these weights need not be nonnegative.
For every natural number , every measure kernel from the finite set to the real line with its Borel measurable structure, and every real , define , where , , , and sends a finite extended nonnegative real to the corresponding real and sends to . The parameter is implicit, and no assumption that is a probability kernel is present in this definition. There are no restrictions on . If the closed interval is empty and the value is ; if it is the singleton . For the sum has one term, for the empty function, with weight .