Escalation.lean
Lean 4 source, lean/DataMiningAsObservation/Escalation.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.
/-
Escalation.lean. Chapter 14 section 14.9, escalation.
Escalation hands an item to a person rather than deciding it, the single-decision form of
abstention. A rule that escalates every item whose margin is below a bar decides a set that
can only shrink as the bar rises, so coverage can only fall, the decided items all carry at
least the bar's margin, and with a bar of zero nothing is escalated. Coverage times the
decided false-clear rate is the fraction of all items cleared and wrong, as the certificate
file states, so an escalation policy trades coverage for a false-clear rate and reports both.
-/
import Mathlib
import DataMiningAsObservation.Certificate
namespace DMO.Escalation
open Finset
variable {ι : Type*} [DecidableEq ι]
/-- The items decided under an escalation bar `m` on the absolute margin. -/
noncomputable def decided (D : Finset ι) (margin : ι → ℝ) (m : ℝ) : Finset ι := D.filter fun i => m ≤ |margin i|
omit [DecidableEq ι] in
/-- **Raising the bar can only shrink the decided set.** -/
theorem decided_anti (D : Finset ι) (margin : ι → ℝ) (m m' : ℝ) (h : m ≤ m') :
decided D margin m' ⊆ decided D margin m :=
Finset.monotone_filter_right D fun _ _ hi => h.trans hi
omit [DecidableEq ι] in
/-- **Coverage can only fall as the bar rises.** -/
theorem coverage_anti (D : Finset ι) (margin : ι → ℝ) (m m' : ℝ) (h : m ≤ m') :
DMO.Certificate.coverage D (decided D margin m') ≤ DMO.Certificate.coverage D (decided D margin m) := by
unfold DMO.Certificate.coverage
apply div_le_div_of_nonneg_right _ (by positivity)
exact_mod_cast Finset.card_le_card (decided_anti D margin m m' h)
omit [DecidableEq ι] in
/-- **Every decided item carries at least the bar's margin.** -/
theorem decided_margin (D : Finset ι) (margin : ι → ℝ) (m : ℝ) (i : ι) (hi : i ∈ decided D margin m) :
m ≤ |margin i| := (Finset.mem_filter.1 hi).2
omit [DecidableEq ι] in
/-- **A bar of zero escalates nothing.** -/
theorem decided_zero (D : Finset ι) (margin : ι → ℝ) : decided D margin 0 = D := by
unfold decided
exact Finset.filter_true_of_mem fun i _ => abs_nonneg _
/-- **Coverage times the decided false-clear rate is the joint rate**, so the policy reports
both. -/
theorem joint_rate (D : Finset ι) (margin : ι → ℝ) (m : ℝ) (R : Finset ι)
(hne : (decided D margin m).card ≠ 0) :
DMO.Certificate.falseClear (decided D margin m) R * DMO.Certificate.coverage D (decided D margin m)
= ((decided D margin m ∩ R).card : ℝ) / D.card :=
DMO.Certificate.falseClear_mul_coverage D _ R hne
end DMO.Escalation