DeploymentMismatch.lean
Lean 4 source, lean/DataMiningAsObservation/DeploymentMismatch.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.
/-
DeploymentMismatch.lean. Chapter 12 section 12.6 and chapter 13, deployment mismatch.
A deployment score is a weighted mean over the slices the deployment actually serves, so it
lies between the worst slice and the best. A benchmark that samples the best slice reports
a number the deployment mean cannot reach unless every slice matches it. With the chapter's
numbers, a benchmark of 0.909 clears the target of 0.8 and the deployment mean of 0.736
does not.
-/
import Mathlib
namespace DMO.DeploymentMismatch
open Finset
variable {σ : Type*}
/-- The deployment score, a weighted mean over slices. -/
noncomputable def deployment (S : Finset σ) (w score : σ → ℝ) : ℝ := ∑ s ∈ S, w s * score s
/-- **The deployment mean never exceeds the best slice.** -/
theorem deployment_le_max (S : Finset σ) (hS : S.Nonempty) (w score : σ → ℝ)
(hw : ∀ s ∈ S, 0 ≤ w s) (hsum : ∑ s ∈ S, w s = 1) :
deployment S w score ≤ S.sup' hS score := by
unfold deployment
calc ∑ s ∈ S, w s * score s ≤ ∑ s ∈ S, w s * S.sup' hS score := by
apply Finset.sum_le_sum
intro s hs
exact mul_le_mul_of_nonneg_left (Finset.le_sup' score hs) (hw s hs)
_ = S.sup' hS score := by rw [← Finset.sum_mul, hsum, one_mul]
/-- **The deployment mean never falls below the worst slice.** -/
theorem min_le_deployment (S : Finset σ) (hS : S.Nonempty) (w score : σ → ℝ)
(hw : ∀ s ∈ S, 0 ≤ w s) (hsum : ∑ s ∈ S, w s = 1) :
S.inf' hS score ≤ deployment S w score := by
unfold deployment
calc S.inf' hS score = ∑ s ∈ S, w s * S.inf' hS score := by
rw [← Finset.sum_mul, hsum, one_mul]
_ ≤ ∑ s ∈ S, w s * score s := by
apply Finset.sum_le_sum
intro s hs
exact mul_le_mul_of_nonneg_left (Finset.inf'_le score hs) (hw s hs)
/-- **A benchmark equal to the best slice overstates the deployment** unless every weighted
slice matches it. -/
theorem deployment_lt_max_of_gap (S : Finset σ) (hS : S.Nonempty) (w score : σ → ℝ)
(hw : ∀ s ∈ S, 0 ≤ w s) (hsum : ∑ s ∈ S, w s = 1) (s₀ : σ) (hs₀ : s₀ ∈ S)
(hpos : 0 < w s₀) (hlt : score s₀ < S.sup' hS score) :
deployment S w score < S.sup' hS score := by
unfold deployment
calc ∑ s ∈ S, w s * score s < ∑ s ∈ S, w s * S.sup' hS score := by
apply Finset.sum_lt_sum
· intro s hs
exact mul_le_mul_of_nonneg_left (Finset.le_sup' score hs) (hw s hs)
· exact ⟨s₀, hs₀, mul_lt_mul_of_pos_left hlt hpos⟩
_ = S.sup' hS score := by rw [← Finset.sum_mul, hsum, one_mul]
/-- **The chapter's numbers.** The benchmark clears the target and the deployment mean does
not. -/
theorem book_numbers : (0.8 : ℝ) ≤ 0.909 ∧ (0.736 : ℝ) < 0.8 := by
constructor <;> norm_num
end DMO.DeploymentMismatch