Bar.lean

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

/-
Bar.lean. Chapter 8 section 8.3 and chapter 1 section 1.5, the bar.

A bar is a threshold a statistic must reach, written down before the measurement. Passing
a higher bar passes every lower one, a larger statistic passes every bar a smaller one
passes, a bar discriminates when the null fails it and the real system passes it, no bar
discriminates when the null scores at least as high as the real system, some bar does when
the real system scores higher, and a bar the null passes is vacuous.
-/
import Mathlib

namespace DMO.Bar

/-- The statistic `s` passes the bar `b`. -/
def passes (s b : ℝ) : Prop := b ≤ s

/-- **Passing a higher bar passes every lower one.** -/
theorem passes_anti {s b b' : ℝ} (h : b ≤ b') (hp : passes s b') : passes s b :=
  le_trans h hp

/-- **A larger statistic passes every bar a smaller one passes.** -/
theorem passes_mono {s s' b : ℝ} (h : s ≤ s') (hp : passes s b) : passes s' b :=
  le_trans hp h

/-- The bar discriminates: the null fails it and the real system passes it. -/
def discriminates (b sNull sReal : ℝ) : Prop := ¬ passes sNull b ∧ passes sReal b

/-- **A bar discriminates exactly when it sits strictly above the null and at or below the
real system.** -/
theorem discriminates_iff (b sNull sReal : ℝ) :
    discriminates b sNull sReal ↔ sNull < b ∧ b ≤ sReal := by
  unfold discriminates passes
  rw [not_le]

/-- **No bar discriminates when the null scores at least as high as the real system.** -/
theorem no_bar_of_null_ge (sNull sReal : ℝ) (h : sReal ≤ sNull) (b : ℝ) :
    ¬ discriminates b sNull sReal := fun hb => by
  rw [discriminates_iff] at hb
  linarith [hb.1, hb.2]

/-- **Some bar discriminates when the real system scores higher than the null.** -/
theorem exists_bar_of_lt (sNull sReal : ℝ) (h : sNull < sReal) : ∃ b, discriminates b sNull sReal :=
  ⟨sReal, (discriminates_iff _ _ _).mpr ⟨h, le_rfl⟩⟩

/-- **A bar the null passes is vacuous.** -/
theorem vacuous_of_null_passes (b sNull : ℝ) (h : passes sNull b) (sReal : ℝ) :
    ¬ discriminates b sNull sReal :=
  fun hb => hb.1 h

end DMO.Bar