mirror of
https://github.com/luxfi/proofs.git
synced 2026-10-30 15:21:05 +00:00
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]>
90 lines
2.7 KiB
Lean4
90 lines
2.7 KiB
Lean4
/-
|
|
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 [Min.min, Authority.meet, List.mem_filter, List.contains_eq_any_beq,
|
|
List.any_eq_true] at hc
|
|
exact hc.2
|
|
|
|
/-- 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 [Min.min, Authority.meet, List.mem_filter, List.contains_eq_any_beq,
|
|
List.any_eq_true]
|
|
exact ⟨hca cap hcap, hcb cap hcap⟩
|
|
|
|
/-- 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
|