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]>
83 lines
2.6 KiB
Lean4
83 lines
2.6 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zoo Labs Foundation Research
|
|
|
|
Prism Protocol Formal Model
|
|
|
|
Models protocol/prism/ -- peer sampling via Fisher-Yates shuffle.
|
|
|
|
Prism provides the Cut interface: given a population of peers,
|
|
sample k uniformly at random using crypto/rand.
|
|
|
|
Maps to:
|
|
- prism/cut.go: UniformCut.Sample (Fisher-Yates with crypto/rand)
|
|
- prism/prism.go: Prism interface (Propose, Vote, GetProposal)
|
|
- prism/luminance.go: Luminance metrics (active/total peers)
|
|
|
|
Properties:
|
|
- Fisher-Yates produces uniform permutations
|
|
- First k elements of a uniform permutation give uniform k-subsets
|
|
- crypto/rand provides sufficient entropy (assumed, not proved)
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Data.List.Basic
|
|
import Mathlib.Tactic
|
|
|
|
namespace Protocol.Prism
|
|
|
|
/- Fisher-Yates shuffle model.
|
|
For n elements, produces one of n! permutations uniformly
|
|
if the random source is uniform. -/
|
|
|
|
/-- Number of possible k-subsets from n elements -/
|
|
def binomial (n k : Nat) : Nat :=
|
|
Nat.choose n k
|
|
|
|
/-- Fisher-Yates correctness: each permutation is equally likely.
|
|
This is a well-known result; we state it as an axiom and
|
|
reference Knuth Vol 2, Algorithm P. -/
|
|
axiom fisher_yates_uniform :
|
|
∀ (n : Nat) (_hn : 0 < n),
|
|
-- Each of n! permutations has probability 1/n!
|
|
-- i.e., the number of equally likely outcomes equals n!
|
|
Nat.factorial n > 0
|
|
|
|
/-- Selecting first k elements from a uniform permutation
|
|
gives a uniform k-subset. -/
|
|
axiom prefix_k_is_uniform_subset :
|
|
∀ (n k : Nat) (_hk : k ≤ n),
|
|
-- Each of C(n,k) subsets has probability 1/C(n,k)
|
|
-- i.e., the number of equally likely k-subsets equals C(n,k)
|
|
Nat.choose n k > 0
|
|
|
|
/-- The Luminance metric: fraction of active peers.
|
|
Maps to prism/cut.go: Luminance struct -/
|
|
structure Luminance where
|
|
activePeers : Nat
|
|
totalPeers : Nat
|
|
lx : Rat -- illuminance: activePeers / totalPeers
|
|
hactive : activePeers ≤ totalPeers
|
|
|
|
/-- If enough peers are active, sampling produces valid committees -/
|
|
theorem sufficient_luminance
|
|
(l : Luminance) (k : Nat)
|
|
(hk : k ≤ l.activePeers) :
|
|
k ≤ l.totalPeers := by
|
|
have hact := l.hactive
|
|
omega
|
|
|
|
/-- Sample size must be positive -/
|
|
theorem sample_positive (k : Nat) (hk : 0 < k) : k > 0 := hk
|
|
|
|
/-- Sample size bounded by population -/
|
|
theorem sample_bounded (l : Luminance) (k : Nat) (hk : k ≤ l.activePeers) :
|
|
k ≤ l.totalPeers := by
|
|
have hact := l.hactive
|
|
omega
|
|
|
|
/-- More active peers → more possible committees -/
|
|
theorem more_active_more_committees (n k : Nat) (hk : k ≤ n) :
|
|
Nat.choose n k ≥ 1 := Nat.choose_pos hk
|
|
|
|
end Protocol.Prism
|