Trimmed-extremes midpoint operator for approximate Byzantine agreement #
This module defines the computable trimmed-extremes midpoint operator midTrim over any linearly
ordered field K and proves the convex-hull validity and factor-1/2 contraction properties used
by the unit-interval, fixed-horizon synchronous (n > 3t) and single-hop asynchronous (n > 5t)
protocols in CslibFrontier.Computability.Distributed.ApproxAgreement.Protocol (milestone steps
toward #7116 and #3261, after Section 2 of
Dolev, Lynch, Pinter, Stark and Weihl):
- Convex-hull validity (
midTrim_mem_Icc): given a listxsof lengthm > 2tin which at leastm - tentries lie in[lo, hi](so at mosttentries come from Byzantine processes outside[lo, hi]), sortingxsand dropping itstsmallest andtlargest entries (trimmed t xs, corresponding toreduce^tin Section 2.1, Lemmas 3–4 of [DLP+86]) leaves only values in[lo, hi], and their extreme-value midpointmidTrim t xsalso lies in[lo, hi]. - Factor-
1/2contraction (abs_midTrim_sub_le): given two listsxsandys(not necessarily of equal length) each having at mosttentries outside[lo, hi]and sharing strictly more than2tentries with multiplicity (2 * t < (xs ∩ ys).cardas multisets),|midTrim t xs - midTrim t ys| ≤ (hi - lo) / 2.
Both regimes of CslibFrontier.Computability.Distributed.ApproxAgreement.Protocol instantiate the
same Finset-indexed multiset corollaries (multisetMidTrim_map_mem_Icc and
abs_multisetMidTrim_map_sub_le):
- Synchronous (
m = n,3 * t < n): two recipients collect values fromS₁ = S₂ = Finset.univand share alln - |F| ≥ n - t > 2thonest entries. - Single-hop asynchronous (
m ≥ n - t,5 * t < n): two recipients collect values from sender setsS₁, S₂of size at leastn - t, whose intersection contains at leastn - 2tsenders and therefore at leastn - 3t > 2tshared honest entries.
Comparison with multi-step representative averaging #
Section 2.2 (p. 503, Lemma 5) of [DLP+86] defines the parameterized family
of approximation functions f_{k, t}(V) = mean(select_k(reduce^t(V))) that sort the received
multiset, discard t extremes on each end (reduce^t), select every k-th surviving point
(select_k), and take the arithmetic mean of those c(m - 2t, k) = ⌊(m - 2t - 1) / k⌋ + 1
representatives, achieving per-round contraction 1 / c(m - 2t, k) (with k = t synchronously and
k = 2t asynchronously). Taking the midpoint (min + max) / 2 of the trimmed multiset (midTrim)
averages just the two extreme surviving points: it agrees with f_{t, t} at n = 3t + 1 and with
f_{2t, t} at n = 5t + 1 (where c = 2), while trading sharper 1 / c contraction at larger
n / t for one uniform formula across both 3t < n and 5t < n with no variable-arity division
and a uniform contraction factor of 1 / 2 per round.
To ensure kernel reduction (decide +kernel) works inside module clients (where Lean's
well-founded List.mergeSort and Mathlib's unexposed List.insertionSort do not unfold), sorting
is implemented structurally by sortLE (@[expose]) and equated to List.mergeSort (· ≤ ·) in
sortLE_eq_mergeSort.
Main definitions #
Cslib.Distributed.ApproxAgreement.trimmed: sort a list in nondecreasing order and drop thetsmallest andtlargest entries.Cslib.Distributed.ApproxAgreement.midTrim: midpoint(head + last) / 2oftrimmed t xs.Cslib.Distributed.ApproxAgreement.multisetMidTrim: permutation-invariant lift ofmidTrimtoMultiset K, preserving kernel computability viaQuot.liftOn.
Main results #
Cslib.Distributed.ApproxAgreement.mem_Icc_of_mem_trimmed: every surviving entry oftrimmed t xslies in[lo, hi]when at leastxs.length - tentries ofxslie in[lo, hi].Cslib.Distributed.ApproxAgreement.midTrim_mem_Icc: convex-hull validity ofmidTrim.Cslib.Distributed.ApproxAgreement.abs_midTrim_sub_le: factor-1/2contraction ofmidTrimwhenever two lists share strictly more than2tmultiset entries.Cslib.Distributed.ApproxAgreement.multisetMidTrim_map_mem_Icc,Cslib.Distributed.ApproxAgreement.abs_multisetMidTrim_map_sub_le: unifiedFinset-indexed validity and contraction for synchronous (3t < n) and asynchronous (5t < n) rounds.
References #
Kernel-reducible sorting and trimming #
Insert a into a sorted list l in nondecreasing order. Marked @[expose] so kernel
evaluation (decide +kernel) unfolds trimmed and midTrim in downstream module clients.
Structural insertion sort on List K, equal to List.mergeSort (· ≤ ·) (sortLE_eq_mergeSort)
and marked @[expose] for kernel reduction.
Sort xs in nondecreasing order and discard the t smallest and t largest entries.
Trimmed-range validity: if at least xs.length - t entries of xs lie in [lo, hi], then
every entry of trimmed t xs lies in [lo, hi].
The trimmed-extremes midpoint operator: sort xs, discard the t smallest and t largest
entries (trimmed t xs), and return (head + last) / 2 (or 0 when xs.length ≤ 2 * t).
Permutation-invariant lift of midTrim t to Multiset K. Because Quot.liftOn reduces
directly on quotient constructors, decide +kernel evaluates multisetMidTrim on concrete
multisets and Finset.val.map images in module clients.
Convex-hull validity (midTrim_mem_Icc): if 2 * t < xs.length and at least
xs.length - t entries of xs lie in [lo, hi], then midTrim t xs ∈ [lo, hi].
Trimmed-midpoint contraction (abs_midTrim_sub_le): extreme-endpoint specialization after
Section 2.2, Lemma 5 of Dolev, Lynch, Pinter, Stark and Weihl
(using (min + max) / 2 in place of f_{k, t}'s c-point select_k mean): if xs and ys
each have at most t entries outside [lo, hi] and share strictly more than 2 * t multiset
entries, then |midTrim t xs - midTrim t ys| ≤ (hi - lo) / 2.
Sender-multiset validity: if 2 * t < S.card, F.card ≤ t, and every correct sender
p ∈ S \ F reports a value f p ∈ [lo, hi], then multisetMidTrim t (S.val.map f) ∈ [lo, hi].
Sender-multiset contraction: suppose F.card ≤ t, two recipients collect values f₁, f₂
from sender sets S₁, S₂ with Fintype.card P + 3 * t < S₁.card + S₂.card (which holds both
synchronously when S₁ = S₂ = univ and 3 * t < |P|, and asynchronously when
|S₁|, |S₂| ≥ |P| - t and 5 * t < |P|), and every correct sender p ∉ F sends a common value
val p ∈ [lo, hi] to whichever recipient hears from it. Then
|multisetMidTrim t (S₁.val.map f₁) - multisetMidTrim t (S₂.val.map f₂)| ≤ (hi - lo) / 2.