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]>
114 lines
3.8 KiB
Lean4
114 lines
3.8 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zach Kelling
|
|
|
|
SBOM+ Contribution Graph
|
|
|
|
Extends standard SBOM with role-aware attribution.
|
|
Tracks ALL value creation — not just code commits.
|
|
|
|
Content addressed via uor.foundation/{hash}/{name}
|
|
|
|
Maps to:
|
|
- hanzo/attest: attestation service
|
|
- lux/threshold: multi-sig compensation
|
|
- zoo/ZIPs: governance of contribution standards
|
|
- uor.foundation: content address scheme
|
|
|
|
Roles: Developer, Designer, Writer, Mathematician,
|
|
Researcher, DevOps, Security
|
|
|
|
Properties:
|
|
- Contributions are unforgeable (signature binds all fields)
|
|
- Compensation is additive (no double-counting)
|
|
- All roles are first-class (no code-only bias)
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Data.List.Basic
|
|
import Mathlib.Tactic
|
|
|
|
namespace Governance.Contribution
|
|
|
|
/-- Contributor roles — ALL are first-class -/
|
|
inductive Role where
|
|
| developer -- Code, tests, CI
|
|
| designer -- Figma, CSS, components, UX
|
|
| writer -- Docs, blog, i18n, copywriting
|
|
| mathematician -- Proofs, theorems, paper sections
|
|
| researcher -- Papers, proposals, experiments
|
|
| devops -- Infra, Docker, K8s, monitoring
|
|
| security -- Audits, CVE fixes, fuzzing
|
|
deriving DecidableEq, Repr
|
|
|
|
/-- A contribution record -/
|
|
structure Contribution where
|
|
contributor : Nat -- public key
|
|
role : Role
|
|
artifactHash : Nat -- SHA-256 of artifact
|
|
timestamp : Nat
|
|
ecosystem : String -- "hanzo" | "lux" | "zoo"
|
|
|
|
/-- Content address: uor.foundation/{hash}/{name} -/
|
|
def contentAddress (c : Contribution) (name : String) : String :=
|
|
s!"uor.foundation/{c.artifactHash}/{name}"
|
|
|
|
/-- Contribution signature message binds ALL fields -/
|
|
def signatureMessage (c : Contribution) : Nat :=
|
|
c.contributor + c.role.toCtorIdx + c.artifactHash + c.timestamp
|
|
|
|
/-- Signature verification primitive. Modeled as an opaque total function
|
|
(its concrete witness keeps it abstract to callers while introducing no
|
|
axiom — the kernel accepts it via the supplied default). -/
|
|
opaque verifySig : Nat → Nat → Nat → Bool := fun _ _ _ => true
|
|
|
|
/-- SBOM+ entry: contribution + compensation weight -/
|
|
structure SBOMEntry where
|
|
contribution : Contribution
|
|
weight : Nat -- compensation weight (basis points)
|
|
signature : Nat -- threshold signature
|
|
|
|
/-- An SBOM+ is a list of entries -/
|
|
abbrev SBOM := List SBOMEntry
|
|
|
|
/-- Total weight in an SBOM -/
|
|
def totalWeight (sbom : SBOM) : Nat :=
|
|
sbom.foldl (fun acc e => acc + e.weight) 0
|
|
|
|
/-- Helper: folding the weight sum from any start value extracts that start. -/
|
|
theorem foldl_start (sbom : SBOM) (s : Nat) :
|
|
sbom.foldl (fun acc e => acc + e.weight) s = s + totalWeight sbom := by
|
|
induction sbom generalizing s with
|
|
| nil => simp [totalWeight]
|
|
| cons hd tl ih =>
|
|
simp only [List.foldl_cons, totalWeight]
|
|
rw [ih (s + hd.weight), ih (0 + hd.weight)]
|
|
omega
|
|
|
|
/-- ADDITIVITY: Concatenating SBOMs adds their weights -/
|
|
theorem weight_additive_cons (e : SBOMEntry) (sbom : SBOM) :
|
|
totalWeight (e :: sbom) = e.weight + totalWeight sbom := by
|
|
show sbom.foldl (fun acc e => acc + e.weight) (0 + e.weight) = e.weight + totalWeight sbom
|
|
rw [foldl_start sbom (0 + e.weight)]
|
|
omega
|
|
|
|
/-- NO DOUBLE COUNTING: Each artifact hash appears at most once -/
|
|
def noDuplicates (sbom : SBOM) : Prop :=
|
|
∀ i j : Fin sbom.length,
|
|
sbom[i].contribution.artifactHash = sbom[j].contribution.artifactHash →
|
|
i = j
|
|
|
|
/-- Empty SBOM has no duplicates -/
|
|
theorem empty_no_duplicates : noDuplicates [] := by
|
|
intro i; exact Fin.elim0 i
|
|
|
|
/-- Empty SBOM has zero weight -/
|
|
theorem empty_zero_weight : totalWeight [] = 0 := rfl
|
|
|
|
/-- ALL ROLES FIRST-CLASS: role count (proves all 7 exist) -/
|
|
theorem seven_roles : (List.length
|
|
[Role.developer, Role.designer, Role.writer,
|
|
Role.mathematician, Role.researcher, Role.devops,
|
|
Role.security]) = 7 := rfl
|
|
|
|
end Governance.Contribution
|