mirror of
https://github.com/luxfi/proofs.git
synced 2026-10-30 15:21:05 +00:00
The lean/ library (112 files) had ~110 type-check errors across 52 files (the
prior "green" status was a grep artifact). It now verifies at 0 errors under
the project's strict setting: `lake env lean -D autoImplicit=false`, all 112
files.
Fixed:
- Quasar/Consensus: replaced `by native_decide` with `by decide` (kernel-checked
rather than compiler-trusted).
- Vault/KeyIsolation, Bridge/{YieldVault,OmnichainRouter,FillIntegrity},
Storage/{ZapDB,Replicate}: PRF/string-encoding lemmas, division-bound vault
accounting, renamed/removed deprecated List lemmas, noncomputable.
- Crypto (Pulsar/Magnetar/Corona/CGGMP21/MLKEM/FROST/FHE/P3Q): missing local
dependency oleans compiled in dependency order; theorem→noncomputable def for
Type-valued re-exports; deriving Inhabited for opaque artifact types; dead
Mathlib imports removed.
- DeFi (AMM/staking/fees/flashloan/HFT/router) + Protocol + GPU + Warp + Trust +
Compute + Network + Build: Nat-division/AMM-invariant proofs via
Nat.div_le_of_le_mul / Nat.div_mul_le_self; omega in-scope invariants;
record-projection opacity; dead tactics; stale Nat.Basic import → Nat.Defs;
BFT quorum theorems tightened to n=3f+1.
Integrity: no sorry/admit/native_decide remaining (verified); no
proof-by-assumption axiom cheats. Statement changes only tightened false draft
theorems to true invariants. Remaining axioms are trusted-base only (opaque
crypto groups/pairings, RLWE/MLWE/MSIS hardness, FIPS 203/204/205 correctness,
VSS/Paillier, protocol modeling).
Co-authored-by: Hanzo Dev <[email protected]>
72 lines
2.3 KiB
Lean4
72 lines
2.3 KiB
Lean4
/-
|
|
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
|