Files
zooqueenandHanzo Dev ac9676a47a proofs: drive formal/lean library to 0 errors
The formal/lean library (53 files — a separate formalization from lean/) had
~110 type-check errors across 38 files and had never had its Mathlib oleans
built. It now verifies at 0 errors under the project's strict setting:
`lake env lean -D autoImplicit=false`, all 53 files.

Fixed the same families as the sibling lean/ tree (the content is diverged, so
each was repaired directly):
- Crypto (BLS/FROST/Corona/Hybrid/threshold/FHE/Verkle): omega needs in-scope
  structure invariants; Nat-division bounds; noncomputable over opaque verifiers;
  Fin n index → Nat; deriving Inhabited.
- DeFi (AMM/staking/fees/flashloan/HFT/router): constant-product invariant and
  fee bounds via Nat.div_mul_le_self / Nat.div_le_of_le_mul; dead tactics.
- Protocol/Consensus/Warp/Bridge: BFT quorum theorems tightened to n=3f+1;
  pipe-projection parse fixes; split-after-simp; dead tactics; built the
  Consensus/Safety + ThresholdProof dependency oleans from clean source.
- Network/Compute/Trust/Build: record-projection opacity (unfold+split),
  foldl-min monotonicity, BEq parse parens.
- autoImplicit=false: declared previously auto-bound variables (explicit binders
  / variable blocks); the lakefile sets autoImplicit:=false.

Integrity: no sorry/admit/native_decide; no proof-by-assumption axiom cheats.
Statement changes only tightened false/trivial draft theorems to true
invariants. Remaining axioms are trusted-base only (opaque crypto primitives,
protocol modeling / honesty-static, build determinism).

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-02 09:31:40 -07:00

80 lines
2.7 KiB
Lean4

/-
Revocation Model
Revocations cancel vouches. A revocation must be cryptographically
signed by the revoker — otherwise anyone could DoS the trust graph.
Maps to:
- hanzo/iam: token revocation lists
- lux/node: validator key rotation and revocation
Properties:
- Revocations are signature-verified
- Revocation is monotone (adding revocations only removes trust paths)
- Revoked vouches have no authority
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Basic
import Mathlib.Tactic
namespace Trust.Revocation
/-- A revocation record -/
structure Revocation where
revoker : Nat -- who is revoking
revoked : Nat -- whose vouch is being revoked
timestamp : Nat -- when
sigValid : Bool -- has the signature been verified?
/-- A vouch reference (simplified) -/
structure VouchRef where
voucher : Nat
vouchee : Nat
/-- Check if a vouch is revoked -/
def isRevoked (revocations : List Revocation) (v : VouchRef) : Bool :=
revocations.any fun r =>
r.sigValid && r.revoker == v.voucher && r.revoked == v.vouchee
/-- Unsigned revocations are ignored -/
theorem unsigned_revocation_ignored (r : Revocation) (v : VouchRef)
(h : r.sigValid = false) :
¬(r.sigValid && r.revoker == v.voucher && r.revoked == v.vouchee) = true := by
simp [h]
/-- Adding a revocation can only increase the revoked set (monotone) -/
theorem revocation_monotone (revocations : List Revocation) (r : Revocation) (v : VouchRef)
(h : isRevoked revocations v = true) :
isRevoked (r :: revocations) v = true := by
simp [isRevoked, List.any_cons] at *
exact Or.inr h
/-- Empty revocation list revokes nothing -/
theorem empty_revokes_nothing (v : VouchRef) :
isRevoked [] v = false := rfl
/-- A valid revocation for the exact vouch works -/
theorem valid_revocation_works (revoker revoked ts : Nat) (v : VouchRef)
(h_revoker : (revoker == v.voucher) = true)
(h_revoked : (revoked == v.vouchee) = true) :
isRevoked [⟨revoker, revoked, ts, true⟩] v = true := by
simp [isRevoked, List.any_cons, List.any_nil, h_revoker, h_revoked]
/-- Filter: only valid (signed) revocations matter -/
def validRevocations (revocations : List Revocation) : List Revocation :=
revocations.filter (·.sigValid)
/-- Filtering preserves revocation status -/
theorem valid_filter_preserves (revocations : List Revocation) (v : VouchRef)
(h : isRevoked revocations v = true) :
isRevoked (validRevocations revocations) v = true := by
simp only [isRevoked, validRevocations, List.any_eq_true, List.mem_filter] at *
obtain ⟨r, hr_mem, hr_match⟩ := h
have hsig : r.sigValid = true := by
rw [Bool.and_eq_true, Bool.and_eq_true] at hr_match
exact hr_match.1.1
exact ⟨r, ⟨hr_mem, hsig⟩, hr_match⟩
end Trust.Revocation