Skip to content

Commit 0ebdad3

Browse files
committed
Prove argmin_unique in the Lean formalization (D-805)
Replace the `sorry` with a complete proof: from the two min-bounds the selected costs are equal (Int.le_antisymm), then trichotomy on the indices — either side's smallest-index tie-break contradicts equality (Int.lt_irrefl). No Mathlib. `lean lean/ProvableWorldModel/Freivalds.lean` now compiles with zero warnings. The verify_argmin soundness contract is fully formalized; the Freivalds probability bound (Mathlib finite-field counting) remains the open target.
1 parent f704495 commit 0ebdad3

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

lean/ProvableWorldModel/Freivalds.lean

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,22 @@ def IsArgmin (costs : List Int) (sel : Nat) (c : Int) : Prop :=
2424

2525
/-- Soundness: the argmin is unique. If two indices both satisfy the contract they
2626
are equal — so a verifier that accepts the contract pins down exactly one
27-
selection (a wrong selection cannot also satisfy it). Proof pending (D-805). -/
27+
selection (a wrong selection cannot also satisfy it). -/
2828
theorem argmin_unique {costs : List Int} {i j : Nat} {ci cj : Int}
29-
(_hi : IsArgmin costs i ci) (_hj : IsArgmin costs j cj) : i = j := by
30-
sorry
29+
(hi : IsArgmin costs i ci) (hj : IsArgmin costs j cj) : i = j := by
30+
obtain ⟨hi_get, hi_min, hi_tie⟩ := hi
31+
obtain ⟨hj_get, hj_min, hj_tie⟩ := hj
32+
-- Costs at i and j are equal (each ≤ the other).
33+
have hcc : ci = cj := Int.le_antisymm (hi_min j cj hj_get) (hj_min i ci hi_get)
34+
rcases Nat.lt_trichotomy i j with hlt | heq | hgt
35+
· -- i < j: tie-break at j forces cj < ci = cj, impossible.
36+
have h : cj < ci := hj_tie i ci hlt hi_get
37+
rw [hcc] at h
38+
exact absurd h (Int.lt_irrefl cj)
39+
· exact heq
40+
· -- j < i: tie-break at i forces ci < cj = ci, impossible.
41+
have h : ci < cj := hi_tie j cj hgt hj_get
42+
rw [hcc] at h
43+
exact absurd h (Int.lt_irrefl cj)
3144

3245
end ProvableWorldModel

lean/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ intent of CommitLLM's `lean/` tree for the parts this project relies on.
55

66
| File | Status |
77
|---|---|
8-
| `ProvableWorldModel/Freivalds.lean` | **Compiles** (self-contained, no Mathlib). States the `verify_argmin` soundness contract (`IsArgmin`) and the argmin-uniqueness theorem (proof pending, `sorry`); documents the Freivalds probability-bound theorem to be proved next. |
8+
| `ProvableWorldModel/Freivalds.lean` | **Compiles, no `sorry`** (self-contained, no Mathlib). States the `verify_argmin` soundness contract (`IsArgmin`) and **proves** `argmin_unique` (the accepted selection is unique); documents the Freivalds probability-bound theorem to be proved next. |
99

1010
Build (Lean toolchain pinned by `lean-toolchain`):
1111

1212
```bash
13-
lean lean/ProvableWorldModel/Freivalds.lean # warns on `sorry`, no errors
13+
lean lean/ProvableWorldModel/Freivalds.lean # compiles cleanly, no warnings
1414
```
1515

1616
Remaining formalization work:
17-
- Prove `argmin_unique` (elementary; core Lean).
1817
- The **Freivalds soundness bound** (`#{r | r·z = r·(W·x)} ≤ |F|^(m-1)` when
1918
`z ≠ W·x`) needs a finite-field counting development — `ZMod p`, `Fintype.card`,
2019
nonzero-linear-functional kernel size — i.e. a Mathlib dependency (a `lakefile`

0 commit comments

Comments
 (0)