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]>
74 lines
2.3 KiB
Lean4
74 lines
2.3 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zach Kelling
|
|
|
|
Nova Protocol Formal Model
|
|
|
|
Models protocol/nova/nova.go -- linear blockchain consensus mode.
|
|
|
|
Nova wraps Ray (linear decision engine) and provides blockchain semantics.
|
|
It is the simplest consensus mode: blocks form a chain, decided sequentially.
|
|
|
|
Maps to:
|
|
- nova.go: Nova struct wrapping ray.Driver
|
|
- nova.go: Config{SampleSize, Alpha, Beta, RoundTO, GenesisHash}
|
|
- nova.go: NewNova, Start, Stop, Status
|
|
|
|
Nova delegates all consensus logic to Ray, which delegates voting to Wave.
|
|
The composition: Nova -> Ray -> Wave -> Prism (sampling)
|
|
|
|
Properties:
|
|
- Chain property: decided blocks form a valid chain (parent links)
|
|
- Genesis: genesis block is always the first decided block
|
|
- Height monotonicity: block heights are strictly increasing
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Tactic
|
|
|
|
namespace Protocol.Nova
|
|
|
|
/-- Block in linear chain -/
|
|
structure Block where
|
|
id : Nat
|
|
parentId : Nat
|
|
height : Nat
|
|
|
|
/-- Nova chain state -/
|
|
structure NovaState where
|
|
chain : List Block
|
|
lastHeight : Nat
|
|
|
|
/-- Genesis state -/
|
|
def genesis (genesisBlock : Block) (_hg : genesisBlock.height = 0) : NovaState :=
|
|
{ chain := [genesisBlock], lastHeight := 0 }
|
|
|
|
/-- Append block to chain -/
|
|
def appendBlock (s : NovaState) (b : Block)
|
|
(_hparent : b.parentId = (s.chain.head?.map Block.id).getD 0)
|
|
(_hheight : b.height = s.lastHeight + 1) : NovaState :=
|
|
{ chain := b :: s.chain, lastHeight := b.height }
|
|
|
|
/-- Height is strictly increasing -/
|
|
theorem height_increases (s : NovaState) (b : Block)
|
|
(hparent : b.parentId = (s.chain.head?.map Block.id).getD 0)
|
|
(hheight : b.height = s.lastHeight + 1) :
|
|
(appendBlock s b hparent hheight).lastHeight > s.lastHeight := by
|
|
simp [appendBlock, hheight]
|
|
|
|
/-- Chain grows on append -/
|
|
theorem chain_grows (s : NovaState) (b : Block)
|
|
(hp : b.parentId = (s.chain.head?.map Block.id).getD 0)
|
|
(hh : b.height = s.lastHeight + 1) :
|
|
(appendBlock s b hp hh).chain.length = s.chain.length + 1 := by
|
|
simp [appendBlock, List.length_cons]
|
|
|
|
/-- Genesis has height 0 -/
|
|
theorem genesis_height (b : Block) (hg : b.height = 0) :
|
|
(genesis b hg).lastHeight = 0 := rfl
|
|
|
|
/-- Genesis chain has exactly one block -/
|
|
theorem genesis_single (b : Block) (hg : b.height = 0) :
|
|
(genesis b hg).chain.length = 1 := rfl
|
|
|
|
end Protocol.Nova
|