DARE pruning model — masks, rescaling, and coefficient statistics
DefinitionDAREx_ModelFix a natural number and deterministic real coefficients , indexed by . A Boolean mask records dropped coordinates. For , it has mass , so the drops are independent Bernoulli variables of parameter . The bundle defines expectation and event probability as the finite weighted sums and proves nonnegative masses and total mass one.
Write , , , and . The statistical identities using these last two quantities require . For a positive rescaling denominator , set and . DARE uses for . Define and otherwise; concentration theorems restrict to .
Formalization note. Finite-sum encoding of the paper's Bernoulli probability model: true means dropped, the complement of its retention variable. Definitions are total Lean functions; no probability or analytic claim is made outside the stated domains. The model is not an assumption of any concentration conclusion. Primary reference: Deng et al., Section 3.2, PDF p. 5, equation (2); Appendix E.1, PDF pp. 29–31, equations (7)–(8); Appendix E.2, PDF p. 31, initial unnumbered identity. See the linked source.
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.Real
noncomputable section
open scoped BigOperators
namespace DAREx
/-- A true bit denotes a dropped coordinate. -/
abbrev Mask (n : ℕ) := Fin n → Bool
/-- Product law of independent Bernoulli drop indicators. -/
def maskMass {n : ℕ} (p : ℝ) (ω : Mask n) : ℝ :=
∏ j, if ω j then p else 1 - p
def mean {n : ℕ} (p : ℝ) (f : Mask n → ℝ) : ℝ :=
∑ ω, maskMass p ω * f ω
def probability {n : ℕ} (p : ℝ) (event : Mask n → Prop) : ℝ := by
classical
exact ∑ ω, if event ω then maskMass p ω else 0
def coefficientSum {n : ℕ} (c : Fin n → ℝ) : ℝ := ∑ j, c j
def energy {n : ℕ} (c : Fin n → ℝ) : ℝ := ∑ j, c j ^ 2
def empiricalMean {n : ℕ} (c : Fin n → ℝ) : ℝ := coefficientSum c / n
def empiricalVariance {n : ℕ} (c : Fin n → ℝ) : ℝ :=
(∑ j, (c j - empiricalMean c) ^ 2) / n
/-- Original output minus pruned output, with surviving weights rescaled by `1/q`. -/
def outputError {n : ℕ} (q : ℝ) (c : Fin n → ℝ) (ω : Mask n) : ℝ :=
∑ j, (c j - (if ω j then 0 else c j / q))
def dareError {n : ℕ} (p : ℝ) (c : Fin n → ℝ) : Mask n → ℝ :=
outputError (1 - p) c
def outputBias {n : ℕ} (p q : ℝ) (c : Fin n → ℝ) : ℝ :=
(1 - (1 - p) / q) * coefficientSum c
/-- Continuous value at one half; analytic claims use `0 < p < 1`. -/
def phi (p : ℝ) : ℝ :=
if p = 1 / 2 then 1 / 2 else (1 - 2 * p) / Real.log ((1 - p) / p)
lemma maskMass_nonneg {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp' : p ≤ 1) (ω : Mask n) :
0 ≤ maskMass p ω := by
apply Finset.prod_nonneg
intro j _
split
· exact hp
· exact sub_nonneg.mpr hp'
lemma maskMass_sum {n : ℕ} (p : ℝ) : ∑ ω : Mask n, maskMass p ω = 1 := by
unfold maskMass
simpa using (Fintype.prod_sum (fun (_ : Fin n) (b : Bool) ↦
if b then p else 1 - p)).symm
end DAREx
Read-back
What the Lean code literally says, in plain math · inherited model (exact model identifier unavailable)
For every natural number , let and let be the set of all Boolean masks, with no assumption that . For every real number and mask , the defined mask weight is , where and . For every function , its defined mean is ; for every predicate on , its defined probability is . These are finite real sums, with no measurability assumption or supplied decision procedure for . The definitions themselves permit every real , so the weights can be signed outside ; the names “mean” and “probability” do not impose a probability-measure hypothesis there. The two model lemmas, which have explicit proof bodies, assert that for every natural , every real with , and every mask , and that for every natural and every real , including values outside . For , these weights give the finite product distribution in which the Boolean coordinates are independent and each is true with probability ; at all weight is on the all-false mask, and at all weight is on the all-true mask. For there is exactly one mask, the empty product is , is the value of on that mask, and is or according as holds or fails there, for every real .
For every natural and real coefficient family , define the coefficient sum , energy , empirical mean , and empirical variance , where in a real expression denotes its image in . The variance uses denominator , with no correction by . These definitions impose no positivity, nonzero, or sign hypothesis on or the coefficients, and real division is total with . In particular, for , the coefficient sum, energy, empirical mean, and empirical variance all equal ; for , the empirical mean is the sole coefficient and the empirical variance is .
For every natural , real , real coefficient family , and mask , define the output error , where and . Thus a true coordinate contributes to the error and a false coordinate contributes . For every additional real , the DARE error is defined as , and the output bias is defined as the scalar . Neither definition imposes , , or a relation between and ; “output bias” is the name of this formula and is not itself an assertion that it equals a mean. With the total convention , and for every mask and every , and . For , all these error and bias quantities are .
For every real , define if , and otherwise define . There is no restriction on in this definition and no separate assertion here that is positive or bounded. The logarithm is Lean's total real logarithm: it has value at and takes the logarithm of the absolute value at a negative input; all quotients use total real division with . Consequently the formula is defined also at and , where it gives , while the explicitly selected midpoint value is .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.