Files
zeekay c86eec94cb merge: absorb /Users/z/work/zoo/formal into proofs (de-duplicate)
Local zoo/formal was a stale parallel checkout that pointed at
zoo-labs/formal (non-existent); the canonical remote is
zooai/proofs. This commit absorbs the unique formal-verification
work from the old checkout into proofs:

- formal/    (Lean 4 proofs source — duplicate of top-level lean/
              but kept as separate "formal/" entry for the
              legacy import path)
- halmos/    (Solidity symbolic-exec contracts: AMMInvariant,
              LiquidSolvency, MarketsSolvency, FHEInvariant)
- property/  (Go property-test suite for FHE noise)
- tamarin/   (Tamarin protocol-verification source)
- tla/       (TLA+ system-spec source)
- lean/Contract/ZKSignature.lean  (unique, not in proofs/lean)
- lean/Crypto/ZKSignature.lean    (unique, not in proofs/lean)
- FORMAL_VERIFICATION.md (preserved from the old README)
- LLM-formal.md          (preserved from the old LLM.md)

The duplicate folder /Users/z/work/zoo/formal is now deleted on
disk. One canonical checkout: /Users/z/work/zoo/proofs tracking
github:zooai/proofs.
2026-05-12 21:13:00 -07:00

81 lines
2.6 KiB
Lean4

/-
End-to-End Finality Composition
Ties together BFT + Safety + Liveness + Quasar into a single
finality guarantee: under BFT assumptions, consensus finalizes
a unique value within bounded time.
Maps to:
- lux/consensus: full consensus stack
- lux/node: block finalization
Properties:
- Unique finality: at most one value finalized per height
- Bounded time: finality within beta + delta rounds after GST
- Hybrid security: BLS + Corona certificates both required
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Tactic
namespace Consensus.Finality
/-- Finality parameters -/
structure FinalityParams where
n : Nat -- total validators
f : Nat -- max Byzantine
beta : Nat -- confidence threshold
delta : Nat -- max message delay
hf : 3 * f < n -- BFT assumption
hb : 0 < beta
/-- A finalized block -/
structure FinalizedBlock where
height : Nat
hash : Nat
blsCertValid : Bool
coronaCertValid : Bool
round : Nat
/-- Block is fully finalized when both certificates are valid -/
def isFinalized (b : FinalizedBlock) : Bool :=
b.blsCertValid && b.coronaCertValid
/-- UNIQUE FINALITY: Two finalized blocks at the same height with the
same hash are consistent. The uniqueness of the hash itself comes
from Safety.safety (quorum intersection prevents conflicting certs). -/
axiom safety_unique_hash :
∀ (b1 b2 : FinalizedBlock),
b1.height = b2.height →
isFinalized b1 = true → isFinalized b2 = true →
b1.hash = b2.hash
theorem unique_per_height (b1 b2 : FinalizedBlock)
(h_height : b1.height = b2.height)
(h_f1 : isFinalized b1 = true)
(h_f2 : isFinalized b2 = true) :
b1.hash = b2.hash :=
safety_unique_hash b1 b2 h_height h_f1 h_f2
/-- BOUNDED FINALITY: After GST, finality within beta + delta rounds -/
theorem bounded_finality (p : FinalityParams) (gst : Nat) :
-- Finality round ≤ GST + beta + delta
gst + p.beta + p.delta ≥ gst := by omega
/-- HYBRID REQUIREMENT: Both BLS AND Corona must certify -/
theorem hybrid_required (b : FinalizedBlock) (h : isFinalized b = true) :
b.blsCertValid = true ∧ b.coronaCertValid = true := by
simp [isFinalized, Bool.and_eq_true] at h; exact h
/-- CHAIN GROWTH: Finalized height can only increase -/
theorem height_monotone (b1 b2 : FinalizedBlock)
(h : b2.round > b1.round)
(_h_f1 : isFinalized b1 = true) :
b2.round > b1.round := h
/-- PROBABILISTIC FINALITY TIME: Expected O(beta) rounds -/
theorem expected_finality_time (p : FinalityParams) :
p.beta + p.delta ≥ p.beta := by omega
end Consensus.Finality