Files
proofs/lean/Protocol/Quasar.lean
zooqueenandHanzo Dev d3bff5e2dc proofs: drive Lean library to 0 errors, eliminate proof-by-assumption axioms
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]>
2026-06-02 05:54:28 -07:00

98 lines
2.9 KiB
Lean4

/-
Authors: Antje Worring, Zach Kelling
Quasar Protocol Formal Model
Models protocol/quasar/ -- BLS+Corona hybrid quantum consensus.
Quasar is the finality engine. It collects blocks from all chains
and produces quantum-final aggregate blocks with dual signatures:
- BLS (classical, fast): 96-byte aggregated signatures
- Corona (post-quantum, larger): ~4KB lattice-based threshold signatures
Maps to:
- quasar/bls.go: BLS signature aggregation (quorum = 2f+1)
- quasar/core.go: Quasar struct, chain buffers, quantum finality
- quasar/engine.go: Engine implementation
- quasar/horizon.go: Event horizon (pending blocks)
Properties:
- BLS aggregation correctness: agg_verify(agg_sig, agg_pk, msg) iff all individual sigs valid
- Quorum threshold: 2f+1 signatures required for finality
- Dual signature: quantum block has both BLS and Corona sigs
- Epoch monotonicity: quantum height only increases
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Tactic
namespace Protocol.Quasar
/-- Signature types -/
structure BLSSig where
bytes : List UInt8
valid : Bool
structure CoronaSig where
bytes : List UInt8
valid : Bool
/-- Quasar signature = BLS + Corona (models quasar.QuasarSig) -/
structure QuasarSig where
bls : BLSSig
corona : CoronaSig
/-- Quantum block (models quasar.QuantumBlock) -/
structure QuantumBlock where
height : Nat
sourceBlocks : List Nat -- block hashes
signature : QuasarSig
/-- Quasar state -/
structure QuasarState where
quantumHeight : Nat
finalized : List QuantumBlock
/-- BLS aggregation: aggregate of valid sigs is valid -/
axiom bls_aggregation_sound :
∀ (sigs : List BLSSig),
(∀ s ∈ sigs, s.valid = true) →
sigs ≠ [] →
-- Aggregated signature is valid (bilinear pairing property)
∃ (agg : BLSSig), agg.valid = true
/-- Quantum height is monotonically increasing -/
def addBlock (s : QuasarState) (b : QuantumBlock)
(_h : b.height > s.quantumHeight) : QuasarState :=
{ quantumHeight := b.height
, finalized := b :: s.finalized }
theorem height_monotone (s : QuasarState) (b : QuantumBlock)
(h : b.height > s.quantumHeight) :
(addBlock s b h).quantumHeight > s.quantumHeight := by
simp [addBlock]
exact h
/-- Quorum intersection for BLS signatures:
Two quorums of 2f+1 from n=3f+1 validators share f+1 members.
At least one shared member is honest. -/
theorem bls_quorum_intersection
(n f : Nat) (hn : n ≤ 3 * f + 1)
(q1 q2 : Nat)
(hq1 : q1 ≥ 2 * f + 1) (hq2 : q2 ≥ 2 * f + 1) :
q1 + q2 > n := by
omega
/-- Dual signature validity: both components must be valid -/
def isValidQuantumSig (qs : QuasarSig) : Bool :=
qs.bls.valid && qs.corona.valid
/-- A finalized block has both BLS and Corona valid -/
theorem quantum_finality_requires_both
(qs : QuasarSig) (h : isValidQuantumSig qs = true) :
qs.bls.valid = true ∧ qs.corona.valid = true := by
simp [isValidQuantumSig] at h
exact h
end Protocol.Quasar