Skip to content

feat(lean): prove banks_set_condorcet (Voting.lean 2 sorry -> 1) - #882

Merged
jsboige merged 3 commits into
mainfrom
feat/lean-voting-proofs-p5
May 10, 2026
Merged

jsboige merged 3 commits into
mainfrom
feat/lean-voting-proofs-p5

Conversation

@jsboige

@jsboige jsboige commented May 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Prove banks_set_condorcet: Condorcet winner ∈ Banks set (Voting.lean sorry 2→1)
  • Add median_voter_theorem_strict with strict monotonicity hypotheses (2 counting sorrys — need sorted-list median lemma)
  • Improve prover sorry detection (closest-line auto-fix)
  • Add wsl_papermill.py tool for WSL-native papermill execution (from po-2026 T20.17)

Sorry count

  • Main (post-revert: PR #866 (median_voter_theorem) — build fails per po-2026 audit #885 revert): 2 sorry (median_voter L261 baseline + maximal_chain L445)
  • This PR: 4 sorry (median_voter L261 baseline + 2 counting sorrys in new median_voter_theorem_strict L325/L348 + maximal_chain L445)
  • Net delta: -1 sorry (banks_set_condorcet proven) + 2 new counting sorrys (documented, need Mathlib lemma)
  • banks_set_condorcet proof: ~130 lines, uses Finset.exists_mem_eq_sup' maximality argument

CI

  • Awaiting CI check post-rebase

Test plan

  • grep -c sorry Voting.lean: main=2, branch=4 (delta explained)
  • CI Lake build SUCCESS
  • CI Proof integrity SUCCESS
  • banks_set_condorcet contains no sorry
  • median_voter_theorem_strict contains 2 counting sorrys only (L325, L348)

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@clusterManager-Myia clusterManager-Myia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: CoursIA #882 -- feat(lean): prove banks_set_condorcet

Verdict: APPROVE

Voting.lean -- Proof of banks_set_condorcet

Excellent work. The proof structure is clean and well-organized:

  1. isTC predicate -- Local definition encapsulating the tournament chain conditions (subset of S, nonempty, tournament, transitivity, contains x). This is a good abstraction.

  2. Maximal chain via Finset.exists_mem_eq_sup' -- Standard finite Zorn's lemma approach: pick the element with maximum cardinality, then prove maximality by contradiction. The proof that adding any y not in C would violate maximality (via h_insert_isTC + cardinality argument) is rigorous.

  3. FIXME on median_voter_theorem -- Outstanding documentation of a real mathematical issue: single-peaked preferences only guarantee weak dominance (R b a), not strict preference (margin > 0). The counter-example (sigma = {1,2,3}, 3 voters, peaks [1,2,3], indifferent voter 3) is clear and convincing. Two proposed fixes (strictly_single_peaked hypothesis or weak Condorcet conclusion) are both reasonable.

  4. Indentation fixes -- Minor but improves consistency.

instructions.py -- Complex proof tactics

The new section on existential, universal, contradiction, and cardinality proofs is practical and directly applicable. The tips on file_replace_lines for multi-line proofs and dot-block handling address real pain points discovered during this proof.

provers.py -- Nearest-sorry fix

Robust improvement: picking the nearest sorry to the configured line (instead of the first) handles line drift after earlier proofs. The diagnostic message is helpful.

WARNING: Merge status is CONFLICTING

The PR cannot be merged as-is. The base branch has diverged. A rebase is needed before merge.


Reviewed by Hermes (clusterManager-Myia) -- cron review PR run

jsboige and others added 3 commits May 10, 2026 11:55
Complete formal proof of banks_set_condorcet using isPC predicate +
Finset.exists_mem_eq_sup cardinality maximality argument (~130 lines).

The proof strategy:
1. Define isPC C := pre-chain containing the Condorcet winner x
2. Find maximum-cardinality pre-chain via Finset.exists_mem_eq_sup
3. Show maximality by contradiction (cardinality argument)
4. Derive banks_chain from maximality

Key lemma: h_insert_trans handles 8 cases (y/C combinations) for
transitivity of {y} ∪ C using h_ext_tournament and h_ext_transitivity
from the banks_chain maximality hypothesis.

median_voter_theorem sorry remains: the single_peaked definition only
gives WEAK preference (R) for closer-to-peak alternatives, but
margin_pos requires STRICT preference (P R x y = R x y ∧ ¬R y x).
The theorem needs a stronger definition to be provable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Auto-detect sorry picks NEAREST line (not first) to configured line
- Relax context_boundary 5->20 for line shifts after edits
- Add complex proof strategy instructions (existentials, contradiction,
  cardinality, multi-step decomposition, dot blocks)
- Add DEMO 13 (banks_set_condorcet) with proven singleton chain strategy
- Add DEMO 14 (median_voter_theorem) with description
- Add provider CLI arg for run_prover.py (default: zai)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Voting.lean:
- Add median_voter_theorem_strict with strict monotonicity hypotheses
- Proof structure: case analysis on peaks j vs median, filter cardinality bounds
- 2 sorry remain in counting steps (sorted-list median property)
- Remove duplicate end SinglePeaked
- lake build SUCCESS

WSL papermill:
- New wsl_papermill.py: execute notebooks natively inside WSL
- Fixes jupyter_client cross-OS path issue (backslash stripping)
- Tested: GT-1 (20/20 cells), GT-7 (30/30 cells)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jsboige
jsboige force-pushed the feat/lean-voting-proofs-p5 branch from 7335c16 to 3304ae6 Compare May 10, 2026 09:57
@jsboige
jsboige merged commit aaad934 into main May 10, 2026
5 checks passed
@jsboige
jsboige deleted the feat/lean-voting-proofs-p5 branch May 10, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants