Abstention.lean

Lean 4 source, lean/DataMiningAsObservation/Abstention.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.

/-
Abstention.lean. Equation 10.7, abstention.

A stratum with too few rows or too few queries to score receives the verdict abstain. The
aggregate verdict is the minimum over the eligible strata, and when no stratum is eligible
the verdict itself is abstain. Abstain is not a pass. And since raising the eligibility bar
can only remove strata from the minimum, it can only raise the verdict, which is why every
abstention is reported beside the verdict rather than dropped.
-/
import Mathlib

namespace DMO.Abstention

open Finset

variable {σ : Type*}

/-- **Equation 10.7.** The verdict over the eligible strata, or abstain when none is eligible. -/
noncomputable def verdict (S : Finset σ) (eligible : σ → Prop) [DecidablePred eligible]
    (score : σ → ℝ) : Option ℝ :=
  if h : (S.filter eligible).Nonempty then some ((S.filter eligible).inf' h score) else none

/-- A verdict passes a bar when it is a score at or above the bar. Abstain never passes. -/
def passes (v : Option ℝ) (bar : ℝ) : Prop := ∃ x, v = some x ∧ bar ≤ x

/-- **Abstain is not a pass.** -/
theorem abstain_not_passes (bar : ℝ) : ¬ passes none bar := by
  rintro ⟨x, h, _⟩
  exact Option.some_ne_none x h.symm

/-- **No eligible stratum, no verdict.** -/
theorem verdict_eq_none_iff (S : Finset σ) (eligible : σ → Prop) [DecidablePred eligible]
    (score : σ → ℝ) : verdict S eligible score = none ↔ ¬ (S.filter eligible).Nonempty := by
  unfold verdict
  split_ifs with h <;> simp [h]

/-- The verdict passes exactly when some stratum is eligible and every eligible stratum
scores at or above the bar. -/
theorem passes_verdict_iff (S : Finset σ) (eligible : σ → Prop) [DecidablePred eligible]
    (score : σ → ℝ) (bar : ℝ) :
    passes (verdict S eligible score) bar ↔
      (S.filter eligible).Nonempty ∧ ∀ s ∈ S, eligible s → bar ≤ score s := by
  unfold verdict passes
  split_ifs with h
  · simp only [Option.some.injEq, exists_eq_left', true_and, h]
    rw [Finset.le_inf'_iff]
    simp [Finset.mem_filter]
  · simp [h]

/-- **Raising the eligibility bar can only raise the verdict.** If every stratum eligible
under the stricter rule is eligible under the looser one, the stricter minimum is at least
the looser one. This is why abstentions are reported: a stratum removed from the minimum
can be the failing one. -/
theorem inf_le_of_subset (S : Finset σ) (loose strict : σ → Prop) [DecidablePred loose]
    [DecidablePred strict] (score : σ → ℝ) (hsub : ∀ s, strict s → loose s)
    (hs : (S.filter strict).Nonempty) :
    (S.filter loose).inf' (hs.mono (Finset.monotone_filter_right S fun s _ h => hsub s h)) score
      ≤ (S.filter strict).inf' hs score :=
  Finset.inf'_mono score (Finset.monotone_filter_right S fun s _ h => hsub s h) hs

end DMO.Abstention