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]>
108 lines
3.7 KiB
Lean4
108 lines
3.7 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zach Kelling
|
|
|
|
Vouch-Based Trust Model
|
|
|
|
No CA. No global root. Trust flows through attestation chains.
|
|
Each vouch bounds the scope of delegated authority.
|
|
|
|
Maps to:
|
|
- hanzo/iam: attestation chains
|
|
- lux/node: validator vouch graph
|
|
- zoo/contracts: role endorsements
|
|
|
|
Properties:
|
|
- Chain authority is monotonically decreasing
|
|
- Unrecognized keys have no authority
|
|
- Vouch signatures bind ALL security-relevant fields
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Data.List.Basic
|
|
import Mathlib.Tactic
|
|
|
|
namespace Trust.Vouch
|
|
|
|
/-- Recognition level: how much we trust this key -/
|
|
inductive RecognitionLevel where
|
|
| unrecognized -- No trust path
|
|
| vouched -- Vouched by someone trusted
|
|
| direct -- Directly trusted (root)
|
|
deriving DecidableEq, Repr
|
|
|
|
def RecognitionLevel.rank : RecognitionLevel → Nat
|
|
| .unrecognized => 0
|
|
| .vouched => 1
|
|
| .direct => 2
|
|
|
|
/-- Unrecognized is minimum recognition -/
|
|
theorem unrecognized_min (r : RecognitionLevel) :
|
|
RecognitionLevel.rank .unrecognized ≤ RecognitionLevel.rank r := by
|
|
cases r <;> simp [RecognitionLevel.rank]
|
|
|
|
/-- A vouch: one key vouches for another with bounded scope.
|
|
The signature MUST bind all fields to prevent replay attacks. -/
|
|
structure Vouch where
|
|
voucher : Nat -- voucher's public key (abstract)
|
|
vouchee : Nat -- who is being vouched for
|
|
scope : Nat -- authority bound (abstract)
|
|
expires : Nat -- expiry timestamp
|
|
|
|
/-- Vouch chain authority: foldl min over scope values.
|
|
Authority can only NARROW through delegation. -/
|
|
def chainAuthority (chain : List Vouch) (top : Nat) : Nat :=
|
|
chain.foldl (fun acc v => min acc v.scope) top
|
|
|
|
/-- foldl-min over scopes is monotone in the starting accumulator -/
|
|
theorem foldl_min_mono (chain : List Vouch) (a b : Nat) (h : a ≤ b) :
|
|
chain.foldl (fun acc v => min acc v.scope) a
|
|
≤ chain.foldl (fun acc v => min acc v.scope) b := by
|
|
induction chain generalizing a b with
|
|
| nil => simpa using h
|
|
| cons hd tl ih =>
|
|
simp only [List.foldl_cons]
|
|
exact ih (min a hd.scope) (min b hd.scope) (by omega)
|
|
|
|
/-- Adding a vouch can only reduce authority -/
|
|
theorem chain_authority_monotone (chain : List Vouch) (v : Vouch) (top : Nat) :
|
|
chainAuthority (v :: chain) top ≤ chainAuthority chain top := by
|
|
simp only [chainAuthority, List.foldl_cons]
|
|
exact foldl_min_mono chain (min top v.scope) top (Nat.min_le_left top v.scope)
|
|
|
|
/-- Empty chain gives full authority -/
|
|
theorem empty_chain_full (top : Nat) :
|
|
chainAuthority [] top = top := by
|
|
simp [chainAuthority]
|
|
|
|
/-- Chain authority is bounded by top -/
|
|
theorem chain_bounded (chain : List Vouch) (top : Nat) :
|
|
chainAuthority chain top ≤ top := by
|
|
induction chain generalizing top with
|
|
| nil => simp [chainAuthority]
|
|
| cons hd tl ih =>
|
|
simp [chainAuthority, List.foldl_cons]
|
|
calc chainAuthority tl (min top hd.scope)
|
|
≤ min top hd.scope := ih (min top hd.scope)
|
|
_ ≤ top := Nat.min_le_left top hd.scope
|
|
|
|
/-- Chain authority is bounded by every vouch's scope -/
|
|
theorem chain_bounded_by_scope (chain : List Vouch) (top : Nat) (v : Vouch)
|
|
(hv : v ∈ chain) :
|
|
chainAuthority chain top ≤ v.scope := by
|
|
induction chain generalizing top with
|
|
| nil => exact absurd hv (List.not_mem_nil _)
|
|
| cons hd tl ih =>
|
|
rw [List.mem_cons] at hv
|
|
cases hv with
|
|
| inl h =>
|
|
subst h
|
|
simp only [chainAuthority, List.foldl_cons]
|
|
calc chainAuthority tl (min top v.scope)
|
|
≤ min top v.scope := chain_bounded tl _
|
|
_ ≤ v.scope := Nat.min_le_right top v.scope
|
|
| inr h =>
|
|
simp only [chainAuthority, List.foldl_cons]
|
|
exact ih (min top hd.scope) h
|
|
|
|
end Trust.Vouch
|