mirror of
https://github.com/zooai/proofs.git
synced 2026-10-30 14:49:47 +00:00
The lean/ proof library (88 files) had ~180 type-check errors across ~45 files plus 31 proof-by-assumption axiom cheats. It now type-checks cleanly under Lean 4.14.0 + Mathlib, with every theorem genuinely proven from definitions. Errors fixed: - Stale Mathlib imports: Data.Nat.Basic / Data.Int.Basic were removed this rev -> Data.Nat.Defs / Data.Int.Defs (57 files). - Shared AI/Agent/Governance/Contract/DeFi/Ecology draft files: same proof-rot as the zoo-labs sibling library (now reconciled): omega missing in-scope bounds, dead tactics after simp, simp over-reduction, doc-comment placement, reserved-word binders, deriving Repr on Finset-bearing structs, noncomputable defs over opaque primitives. - Consensus/Liveness: collapsed a 74-error cascade (undefined shared state model inlined from Safety.lean; the |>. pipe-projection vs comparison parse trap on 14 lines rewritten to explicit dot projection). - Crypto (BLS/FROST/Corona/Hybrid/threshold/FHE), Consensus, Protocol, Warp, Trust, GPU, Compute, Network, DeFi: brought structure invariants into scope for omega, Nat-division bounds via Nat.div_le_of_le_mul / Nat.div_mul_le_self, noncomputable over opaque crypto ops, deriving Inhabited for index access. Integrity: - Removed all 31 `theorem X := X_ax` cheats (axiom asserting the identical statement) and proved each from definitions; removed the UNSOUND content_addressed axiom (hash-injectivity over a struct with free fields). - Quorum-intersection theorems (BFT/Quasar/Flare/Warp/BLS/GPU/Bridge): the draft hypothesis 3f<n is insufficient (n unbounded above makes them false); tightened to the optimal-resilience invariant n=3f+1 / 2t>n. Statement intent preserved. - Net axiom change: -35 / +1 (the one addition, honesty_static, is a fixed-validator-set modeling assumption matching sibling files). - Remaining axioms are trusted-base only: opaque crypto primitives (groups, pairings, hardness, hashes, FHE encrypt/decrypt, BLS soundness, forward secrecy, Fisher-Yates uniformity) and protocol modeling assumptions. No sorry/admit/native_decide. Verified all theorems trace to [propext, Classical.choice, Quot.sound] plus those primitives. Co-authored-by: Hanzo Dev <[email protected]>
73 lines
2.1 KiB
Lean4
73 lines
2.1 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zach Kelling
|
|
|
|
DAO Governance Properties
|
|
|
|
Proposals require quorum to pass. Voting power comes from
|
|
token balance. Single voter cannot exceed their balance.
|
|
|
|
Maps to:
|
|
- zoo/ZIPs: 707 governance proposals at zips.zoo.ngo
|
|
- zoo/zoo.vote: DAO voting interface
|
|
- zoo/contracts: governance contracts
|
|
|
|
Properties:
|
|
- Proposal passes iff votes ≥ quorum
|
|
- Single voter bounded by balance
|
|
- Quorum is monotone (more votes ⟹ closer to passing)
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Tactic
|
|
|
|
namespace Governance.ZIP
|
|
|
|
/-- Proposal state -/
|
|
structure Proposal where
|
|
id : Nat
|
|
votesFor : Nat
|
|
votesAgainst : Nat
|
|
quorum : Nat
|
|
deadline : Nat
|
|
|
|
/-- A proposal passes iff votesFor ≥ quorum -/
|
|
def Proposal.passes (p : Proposal) : Bool :=
|
|
p.votesFor ≥ p.quorum
|
|
|
|
/-- Cast a vote (bounded by voter's balance) -/
|
|
def vote (p : Proposal) (amount balance : Nat) (support : Bool) : Proposal :=
|
|
let bounded := min amount balance
|
|
if support then
|
|
{ p with votesFor := p.votesFor + bounded }
|
|
else
|
|
{ p with votesAgainst := p.votesAgainst + bounded }
|
|
|
|
/-- QUORUM: Voting can only increase vote count -/
|
|
theorem vote_monotone_for (p : Proposal) (amount balance : Nat) :
|
|
(vote p amount balance true).votesFor ≥ p.votesFor := by
|
|
simp [vote]
|
|
|
|
/-- BOUNDED: Vote is bounded by balance -/
|
|
theorem vote_bounded_by_balance (p : Proposal) (amount balance : Nat) :
|
|
(vote p amount balance true).votesFor ≤ p.votesFor + balance := by
|
|
simp [vote]
|
|
|
|
/-- QUORUM THRESHOLD: Enough votes ⟹ passes -/
|
|
theorem sufficient_votes_pass (p : Proposal)
|
|
(h : p.votesFor ≥ p.quorum) :
|
|
p.passes = true := by
|
|
simp [Proposal.passes, h]
|
|
|
|
/-- QUORUM THRESHOLD: Insufficient votes ⟹ fails -/
|
|
theorem insufficient_votes_fail (p : Proposal)
|
|
(h : p.votesFor < p.quorum) :
|
|
p.passes = false := by
|
|
simp [Proposal.passes, Nat.not_le.mpr h]
|
|
|
|
/-- Voting against doesn't affect pass condition -/
|
|
theorem against_irrelevant_to_pass (p : Proposal) (amount balance : Nat) :
|
|
(vote p amount balance false).passes = p.passes := by
|
|
simp [vote, Proposal.passes]
|
|
|
|
end Governance.ZIP
|