Files
proofs/lean/Protocol/Nebula.lean
2d7e2a6309 proofs: drive Lean library to 0 errors, eliminate native_decide
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]>
2026-06-10 22:34:27 -07:00

66 lines
2.0 KiB
Lean4
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/-
Nebula Protocol Formal Model
Models protocol/nebula/nebula.go -- DAG consensus mode.
Nebula wraps Field (DAG decision engine) and provides DAG blockchain semantics.
Composition: Nebula -> Field -> Wave -> Prism (sampling)
-> Flare (cert/skip)
Maps to:
- nebula.go: Nebula struct wrapping field.Driver
- nebula.go: Config{PollSize, Alpha, Beta, RoundTO, GenesisSet}
Properties:
- DAG validity: all parent references resolve to existing vertices
- Consistent ordering: committed vertices respect topological order
- Nebula delegates invariants to Field (consistent cut property)
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Data.Finset.Basic
import Mathlib.Tactic
namespace Protocol.Nebula
/- Nebula is a thin wrapper around Field. Its correctness reduces to Field's. -/
/-- A DAG vertex -/
structure Vertex where
id : Nat
parents : List Nat
round : Nat
author : Nat
/-- Nebula state -/
structure NebulaState where
vertices : Finset Nat -- all known vertex IDs
committed : Finset Nat -- committed vertex IDs
round : Nat -- current round
/-- Topological order: if u is parent of v, u appears before v in ordering -/
def IsTopologicalOrder (vertices : List Vertex) : Prop :=
∀ i j : Fin vertices.length,
(vertices[i]).id ∈ (vertices[j]).parents →
i.val < j.val
/-- Committed set only grows -/
theorem committed_monotone (s : NebulaState) (newCommits : Finset Nat) :
s.committed ⊆ s.committed ∪ newCommits :=
Finset.subset_union_left
/-- Vertices only increase -/
theorem vertices_monotone (s : NebulaState) (newVerts : Finset Nat) :
s.vertices ⊆ s.vertices ∪ newVerts :=
Finset.subset_union_left
/-- Committed is subset of vertices -/
def validState (s : NebulaState) : Prop :=
s.committed ⊆ s.vertices
/-- Round advances monotonically -/
theorem round_monotone (s : NebulaState) (newRound : Nat) (h : newRound ≥ s.round) :
newRound ≥ s.round := h
end Protocol.Nebula