|
2 | 2 | // Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> |
3 | 3 | = Statistikles Formal Proofs (Agda) |
4 | 4 |
|
5 | | -Constructive proofs of core statistical identities used by Statistikles. |
6 | | -Verified by Agda's dependent type checker — no postulates, no holes. |
| 5 | +*Status: EXPERIMENTAL.* These modules type-check under `agda --safe` with no |
| 6 | +postulates and no holes — but they are *not yet* proofs of the statistical |
| 7 | +theorems Statistikles relies on. Every lemma below is stated and proven over |
| 8 | +the natural numbers (`ℕ`). The runtime computes over `Float64` (IEEE-754 |
| 9 | +doubles), so each entry is a *discrete proxy for* — not a proof of — the |
| 10 | +statistical target in the right-hand column. |
| 11 | + |
| 12 | +[IMPORTANT] |
| 13 | +==== |
| 14 | +*Scope: current proofs quantify over `ℕ`, not `Float64`.* None of them quantify |
| 15 | +over `ℝ` or over the IEEE-754 `Float64` the runtime actually uses. The gap |
| 16 | +between the ℕ lemma proven here and the ℝ/`Float64` statement the statistic |
| 17 | +needs is real and is tracked below as "target (pending)". Read "Proven (ℕ)" as |
| 18 | +"this discrete lemma type-checks", *not* as "the statistic is verified". |
| 19 | +Restating these over the reals is deferred future work (production-readiness |
| 20 | +reframe W2-4); it is deliberately *not* attempted here. |
| 21 | +==== |
7 | 22 |
|
8 | 23 | == Proof Catalogue |
9 | 24 |
|
10 | | -[cols="1,2,2,1"] |
| 25 | +Each row gives the *exact* lemma the Agda source proves (its type signature), |
| 26 | +the module it lives in, and the statistical result it is intended to |
| 27 | +approximate. The middle column is *proven over ℕ*; the right-hand target is |
| 28 | +*pending*. |
| 29 | + |
| 30 | +[cols="1,5,2,4",options="header"] |
11 | 31 | |=== |
12 | | -| # | Identity | File | Status |
13 | | - |
14 | | -| 1 | Tropical addition associative | TropicalSemiring.agda | Proven |
15 | | -| 2 | Tropical addition commutative | TropicalSemiring.agda | Proven |
16 | | -| 3 | Tropical distributivity | TropicalSemiring.agda | Proven |
17 | | -| 4 | Tropical idempotence | TropicalSemiring.agda | Proven |
18 | | -| 5 | Tropical multiplicative identity | TropicalSemiring.agda | Proven |
19 | | -| 6 | Chi-square df identity | RankIdentities.agda | Proven |
20 | | -| 7 | Rank sum (concrete to n=100) | RankIdentities.agda | Proven |
21 | | -| 8 | Bonferroni (elem ≤ sum) | Inequalities.agda | Proven |
22 | | -| 9 | Tie correction bound (sq-mono) | Inequalities.agda | Proven |
23 | | -| 10 | Mean ordering transitivity | Inequalities.agda | Proven |
| 32 | +| # | Lemma actually proven (over `ℕ`) | File | Statistical target (pending) |
| 33 | + |
| 34 | +| 1 |
| 35 | +| `min-assoc : ∀ a b c → min a (min b c) ≡ min (min a b) c` — `min` on `ℕ` is associative |
| 36 | +| TropicalSemiring.agda |
| 37 | +| Associativity of tropical addition `⊕ = min` on `ℝ ∪ {+∞}` |
| 38 | + |
| 39 | +| 2 |
| 40 | +| `min-comm : ∀ a b → min a b ≡ min b a` — `min` on `ℕ` is commutative |
| 41 | +| TropicalSemiring.agda |
| 42 | +| Commutativity of tropical `⊕ = min` on `ℝ ∪ {+∞}` |
| 43 | + |
| 44 | +| 3 |
| 45 | +| `+-distrib-min : ∀ a b c → a + min b c ≡ min (a + b) (a + c)` — `+` distributes over `min` on `ℕ` |
| 46 | +| TropicalSemiring.agda |
| 47 | +| Tropical `⊗ = +` distributes over `⊕ = min` on `ℝ ∪ {+∞}` |
| 48 | + |
| 49 | +| 4 |
| 50 | +| `min-idem : ∀ a → min a a ≡ a` — `min` on `ℕ` is idempotent |
| 51 | +| TropicalSemiring.agda |
| 52 | +| Idempotence of tropical `⊕` on `ℝ ∪ {+∞}` |
| 53 | + |
| 54 | +| 5 |
| 55 | +| `tropical-mul-identity : ∀ a → zero + a ≡ a` — `0` is the left identity of `+` on `ℕ` (definitional) |
| 56 | +| TropicalSemiring.agda |
| 57 | +| `0` is the tropical `⊗`-identity (and `+∞` the `⊕`-identity) on `ℝ ∪ {+∞}` |
| 58 | + |
| 59 | +| 6 |
| 60 | +| `df-identity : ∀ k → suc k ∸ 1 ≡ k` and `df-nonneg : ∀ k → zero ≤ k` — truncated subtraction on `ℕ` |
| 61 | +| RankIdentities.agda |
| 62 | +| χ² degrees of freedom `= (categories − 1)` is well-defined and non-negative |
| 63 | + |
| 64 | +| 7 |
| 65 | +| `sum-to` running-sum recursion with concrete checks (`sum-to 5 ≡ 15`, …, `sum-to 100 ≡ 5050`) and `sum-to-mono : n ≤ m → sum-to n ≤ sum-to m` on `ℕ` |
| 66 | +| RankIdentities.agda |
| 67 | +| Rank/midrank sum identity `Σᵢ₌₁ⁿ i = n(n+1)/2` over `ℝ` (tie handling) |
| 68 | + |
| 69 | +| 8 |
| 70 | +| `elem-le-sum : ∀ x xs → x ≤ x + list-sum xs` — a list element is `≤` the list sum, on `ℕ` |
| 71 | +| Inequalities.agda |
| 72 | +| Bonferroni inequality `P(⋃ Aᵢ) ≤ Σ P(Aᵢ)` over `ℝ` |
| 73 | + |
| 74 | +| 9 |
| 75 | +| `sq-mono : a ≤ b → a * a ≤ b * b` — squaring is monotone on `ℕ` |
| 76 | +| Inequalities.agda |
| 77 | +| Monotonicity of the tie-correction term `Σ(tᵢ³ − tᵢ)` in `N` over `ℝ` |
| 78 | + |
| 79 | +| 10 |
| 80 | +| `mean-ordering-transitive : a ≤ b → b ≤ c → a ≤ c` — transitivity of `≤` on `ℕ` |
| 81 | +| Inequalities.agda |
| 82 | +| Transitivity of the power-mean ordering `M_p ≤ M_q ≤ M_r ⇒ M_p ≤ M_r` over `ℝ` |
24 | 83 | |=== |
25 | 84 |
|
| 85 | +All ten lemmas are `Proven (ℕ)`; all ten statistical targets remain `pending`. |
| 86 | + |
26 | 87 | == Building |
27 | 88 |
|
28 | | -Requires Agda 2.6.4+ and agda-stdlib. |
| 89 | +Requires Agda 2.6.4+ and agda-stdlib 2.x (library `statistikles-proofs.agda-lib` |
| 90 | +depends on `standard-library`). Every module must type-check under `--safe` |
| 91 | +(no weakening): |
29 | 92 |
|
30 | 93 | ```bash |
31 | 94 | agda --safe Statistikles/TropicalSemiring.agda |
32 | 95 | agda --safe Statistikles/RankIdentities.agda |
33 | 96 | agda --safe Statistikles/Inequalities.agda |
34 | 97 | ``` |
35 | 98 |
|
36 | | -== Integration with ECHIDNA |
| 99 | +CI runs exactly this on every `proofs/**/*.agda` module — see |
| 100 | +`.github/workflows/agda.yml`. That workflow also fails if a new `.agda` file is |
| 101 | +added under `proofs/` without being type-checked, and rejects any `postulate`. |
| 102 | + |
| 103 | +== Integration with ECHIDNA (aspirational) |
37 | 104 |
|
38 | | -These proofs correspond to the `StatProofObligation` entries in |
39 | | -`src/bridge/echidna_adapter.jl`. ECHIDNA dispatches verification |
40 | | -requests to Agda for constructive proofs and Z3 for arithmetic. |
| 105 | +The intended design is for these proofs to back the `StatProofObligation` |
| 106 | +entries in `src/bridge/echidna_adapter.jl`, with ECHIDNA dispatching |
| 107 | +constructive obligations to Agda and arithmetic obligations to Z3. That wiring |
| 108 | +is *not yet in place*, and the correspondence between these `ℕ` lemmas and the |
| 109 | +runtime's `Float64` statistics is future work — intentionally out of scope here. |
0 commit comments