mirror of
https://github.com/zooai/proofs.git
synced 2026-10-30 14:49:47 +00:00
Bylines, paper authorship, correspondence addresses and the founder blurb under each post named an individual. They name the organisation that published the work instead: the brand on posts and pages, the research byline on papers, and research@ in place of a personal address. Both are what these repositories already used elsewhere — nothing new was coined. Co-authors are untouched. Where a paper named someone else alongside, they stay named; only the one byline changed. Bibliography entries, running heads, PDF metadata and affiliations move with it, so a citation still resolves to whoever the cited paper names. Sample and fixture data uses the placeholder name these tests already use elsewhere, so no assertion changed meaning. Co-authored-by: Hanzo Dev <[email protected]>
90 lines
2.9 KiB
Lean4
90 lines
2.9 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zoo Labs Foundation Research
|
|
|
|
Validator Economics and Slashing
|
|
|
|
Staking economics for Lux validators. Stake-weighted voting.
|
|
Slashing for provable misbehavior.
|
|
|
|
Maps to:
|
|
- lux/node/vms/platformvm: validator staking
|
|
- lux/consensus: stake-weighted BFT
|
|
- HIP-0024: Hanzo L1 validator requirements
|
|
|
|
Properties:
|
|
- Stake-weighted: voting power ∝ stake
|
|
- Slashing is loss-bounded: cannot lose more than stake
|
|
- Honest validators are never slashed (safety)
|
|
- Minimum stake enforced
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Data.List.Basic
|
|
import Mathlib.Tactic
|
|
|
|
namespace Consensus.Validator
|
|
|
|
/-- Validator with stake -/
|
|
structure Validator where
|
|
id : Nat
|
|
stake : Nat
|
|
isHonest : Bool
|
|
slashed : Nat -- amount already slashed
|
|
deriving DecidableEq, Repr
|
|
|
|
/-- Validator set -/
|
|
structure ValidatorSet where
|
|
validators : List Validator
|
|
minStake : Nat
|
|
totalStake : Nat
|
|
|
|
/-- Voting power: proportional to stake -/
|
|
def votingPower (v : Validator) (totalStake : Nat) : Nat :=
|
|
if totalStake = 0 then 0 else v.stake * 1000 / totalStake -- basis points
|
|
|
|
/-- Slash a validator for misbehavior -/
|
|
def slash (v : Validator) (penalty : Nat) : Validator :=
|
|
{ v with slashed := v.slashed + min penalty (v.stake - v.slashed) }
|
|
|
|
/-- SLASHING BOUNDED: Cannot lose more than stake.
|
|
Requires the structural invariant that prior slashing has not
|
|
already exceeded the stake (`v.slashed ≤ v.stake`). -/
|
|
theorem slash_bounded (v : Validator) (penalty : Nat) (hinv : v.slashed ≤ v.stake) :
|
|
(slash v penalty).slashed ≤ v.stake := by
|
|
simp only [slash]; omega
|
|
|
|
/-- SLASHING MONOTONE: Slashed amount only increases -/
|
|
theorem slash_monotone (v : Validator) (penalty : Nat) :
|
|
(slash v penalty).slashed ≥ v.slashed := by
|
|
simp [slash]
|
|
|
|
/-- HONEST NEVER SLASHED: Only provable misbehavior triggers slash.
|
|
This is a protocol property (axiomatized). -/
|
|
axiom honest_no_slash :
|
|
∀ (v : Validator), v.isHonest = true → v.slashed = 0
|
|
|
|
/-- MINIMUM STAKE: Below minimum cannot validate -/
|
|
def meetsMinimum (vs : ValidatorSet) (v : Validator) : Bool :=
|
|
v.stake ≥ vs.minStake
|
|
|
|
theorem below_minimum_rejected (vs : ValidatorSet) (v : Validator)
|
|
(h : v.stake < vs.minStake) :
|
|
meetsMinimum vs v = false := by
|
|
simp [meetsMinimum, Nat.not_le.mpr h]
|
|
|
|
/-- STAKE-WEIGHTED POWER: Higher stake → more voting power -/
|
|
theorem more_stake_more_power (v1 v2 : Validator) (total : Nat)
|
|
(h : v1.stake > v2.stake) (ht : total > 0) :
|
|
votingPower v1 total ≥ votingPower v2 total := by
|
|
have htne : total ≠ 0 := by omega
|
|
simp only [votingPower, htne, if_false]
|
|
exact Nat.div_le_div_right (Nat.mul_le_mul_right 1000 (le_of_lt h))
|
|
|
|
/-- TOTAL STAKE: Sum of all validator stakes -/
|
|
def computeTotalStake (vs : List Validator) : Nat :=
|
|
vs.foldl (fun acc v => acc + v.stake) 0
|
|
|
|
theorem empty_zero_stake : computeTotalStake [] = 0 := rfl
|
|
|
|
end Consensus.Validator
|