Files
proofs/lean/Trust/Authority.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

93 lines
2.8 KiB
Lean4

/-
Authors: Antje Worring, Zach Kelling
Authority Meet-Semilattice
Models authority as a set of capabilities with meet (intersection).
Authority can only NARROW through delegation — never escalate.
Maps to:
- hanzo/iam: RBAC permission sets
- lux/node: validator capability scoping
- zoo/contracts: role-based access control
Properties:
- Meet is commutative, associative, idempotent
- Authority narrows through delegation (monotone)
- Meet is greatest lower bound
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Basic
import Mathlib.Tactic
namespace Trust.Authority
/-- A capability: what you're allowed to do -/
inductive Capability where
| shell (user : String)
| exec (command : String)
| build (target : String)
| attest (scope : String)
| sign (keyId : String)
| deploy (env : String)
deriving DecidableEq, Repr
/-- Authority: a set of capabilities (List for simplicity) -/
structure Authority where
capabilities : List Capability
deriving DecidableEq, Repr
/-- No authority -/
def Authority.none : Authority := ⟨[]⟩
/-- Full authority -/
def Authority.all : Authority := ⟨[
.shell "root", .exec "*", .build "*",
.attest "*", .sign "*", .deploy "*"
]⟩
/-- Meet (intersection): only capabilities in BOTH sets -/
def Authority.meet (a b : Authority) : Authority :=
⟨a.capabilities.filter (b.capabilities.contains ·)⟩
/-- Subset ordering -/
def Authority.subset (a b : Authority) : Prop :=
∀ c ∈ a.capabilities, c ∈ b.capabilities
instance : LE Authority where le := Authority.subset
instance : Min Authority where min := Authority.meet
/-- Meet is a lower bound (left): a ⊓ b ≤ a -/
theorem meet_le_left (a b : Authority) : min a b ≤ a := by
intro c hc
simp [Min.min, Authority.meet, List.mem_filter] at hc
exact hc.1
/-- Meet is a lower bound (right): a ⊓ b ≤ b -/
theorem meet_le_right (a b : Authority) : min a b ≤ b := by
intro c hc
simp only [Min.min, Authority.meet, List.mem_filter, List.contains_eq_any_beq,
List.any_eq_true, beq_iff_eq] at hc
obtain ⟨_, x, hxb, hcx⟩ := hc
rw [hcx]; exact hxb
/-- Meet is greatest lower bound -/
theorem meet_glb (a b c : Authority) (hca : c ≤ a) (hcb : c ≤ b) :
c ≤ min a b := by
intro cap hcap
simp only [Min.min, Authority.meet, List.mem_filter, List.contains_eq_any_beq,
List.any_eq_true, beq_iff_eq]
exact ⟨hca cap hcap, cap, hcb cap hcap, rfl⟩
/-- Authority.none is the bottom element -/
theorem none_is_bottom (a : Authority) : Authority.none ≤ a := by
intro c hc; simp [Authority.none] at hc
/-- DELEGATION NARROWING: delegating authority can only reduce it -/
theorem delegation_narrows (delegator_auth delegated_scope : Authority) :
min delegator_auth delegated_scope ≤ delegator_auth :=
meet_le_left delegator_auth delegated_scope
end Trust.Authority