Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

DARE pruning model — masks, rescaling, and coefficient statistics

Definition
DAREx_Model

by Minghui · Sep 29, 2026 · Mathlib c5ea003 (Lean v4.30.0)

delta-parameter-pruningmachine-learningprobability

Fix a natural number nnn and deterministic real coefficients cjc_jcj​, indexed by j∈{1,…,n}j\in\{1,\ldots,n\}j∈{1,…,n}. A Boolean mask ω\omegaω records dropped coordinates. For 0≤p≤10\le p\le10≤p≤1, it has mass wp(ω)=∏j[p if ωj=1;  1−p otherwise]w_p(\omega)=\prod_j[p\text{ if }\omega_j=1;\;1-p\text{ otherwise}]wp​(ω)=∏j​[p if ωj​=1;1−p otherwise], so the drops are independent Bernoulli variables of parameter ppp. The bundle defines expectation and event probability as the finite weighted sums and proves nonnegative masses and total mass one.

Write S=∑jcjS=\sum_jc_jS=∑j​cj​, Q=∑jcj2Q=\sum_jc_j^2Q=∑j​cj2​, cˉ=S/n\bar c=S/ncˉ=S/n, and σ2=n−1∑j(cj−cˉ)2\sigma^2=n^{-1}\sum_j(c_j-\bar c)^2σ2=n−1∑j​(cj​−cˉ)2. The statistical identities using these last two quantities require n>0n>0n>0. For a positive rescaling denominator qqq, set Hq(ω)=∑jcj(1−(1−ωj)/q)H_q(\omega)=\sum_jc_j(1-(1-\omega_j)/q)Hq​(ω)=∑j​cj​(1−(1−ωj​)/q) and bq=(1−(1−p)/q)Sb_q=(1-(1-p)/q)Sbq​=(1−(1−p)/q)S. DARE uses H=H1−pH=H_{1-p}H=H1−p​ for 0<p<10<p<10<p<1. Define Φ(1/2)=1/2\Phi(1/2)=1/2Φ(1/2)=1/2 and Φ(p)=(1−2p)/log⁡((1−p)/p)\Phi(p)=(1-2p)/\log((1-p)/p)Φ(p)=(1−2p)/log((1−p)/p) otherwise; concentration theorems restrict ppp to (0,1)(0,1)(0,1).

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.

Definition code
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
Source
Deng et al., DARE the Extreme: Revisiting Delta-Parameter Pruning For Fine-Tuned Models, ICLR 2025, arXiv:2410.09344v2, https://arxiv.org/pdf/2410.09344v2, Section 3.2, PDF p. 5, equation (2); Appendix E.1, PDF pp. 29–31, equations (7)–(8).
Read-back

What the Lean code literally says, in plain math · inherited model (exact model identifier unavailable)

For every natural number nnn, let In={0,…,n−1}I_n=\{0,\ldots,n-1\}In​={0,…,n−1} and let Ωn={false,true}In\Omega_n=\{\mathsf{false},\mathsf{true}\}^{I_n}Ωn​={false,true}In​ be the set of all Boolean masks, with no assumption that n>0n>0n>0. For every real number ppp and mask ω∈Ωn\omega\in\Omega_nω∈Ωn​, the defined mask weight is wp(ω)=∏j∈Inap(ωj)w_p(\omega)=\prod_{j\in I_n}a_p(\omega_j)wp​(ω)=∏j∈In​​ap​(ωj​), where ap(true)=pa_p(\mathsf{true})=pap​(true)=p and ap(false)=1−pa_p(\mathsf{false})=1-pap​(false)=1−p. For every function f:Ωn→Rf:\Omega_n\to\mathbb Rf:Ωn​→R, its defined mean is Mp(f)=∑ω∈Ωnwp(ω)f(ω)\mathcal M_p(f)=\sum_{\omega\in\Omega_n}w_p(\omega)f(\omega)Mp​(f)=∑ω∈Ωn​​wp​(ω)f(ω); for every predicate AAA on Ωn\Omega_nΩn​, its defined probability is Pp(A)=∑ω∈Ωn, A(ω)wp(ω)\mathcal P_p(A)=\sum_{\omega\in\Omega_n,\ A(\omega)}w_p(\omega)Pp​(A)=∑ω∈Ωn​, A(ω)​wp​(ω). These are finite real sums, with no measurability assumption or supplied decision procedure for AAA. The definitions themselves permit every real ppp, so the weights can be signed outside [0,1][0,1][0,1]; the names “mean” and “probability” do not impose a probability-measure hypothesis there. The two model lemmas, which have explicit proof bodies, assert that wp(ω)≥0w_p(\omega)\ge0wp​(ω)≥0 for every natural nnn, every real ppp with 0≤p≤10\le p\le10≤p≤1, and every mask ω\omegaω, and that ∑ω∈Ωnwp(ω)=1\sum_{\omega\in\Omega_n}w_p(\omega)=1∑ω∈Ωn​​wp​(ω)=1 for every natural nnn and every real ppp, including values outside [0,1][0,1][0,1]. For 0≤p≤10\le p\le10≤p≤1, these weights give the finite product distribution in which the Boolean coordinates are independent and each is true with probability ppp; at p=0p=0p=0 all weight is on the all-false mask, and at p=1p=1p=1 all weight is on the all-true mask. For n=0n=0n=0 there is exactly one mask, the empty product is 111, Mp(f)\mathcal M_p(f)Mp​(f) is the value of fff on that mask, and Pp(A)\mathcal P_p(A)Pp​(A) is 111 or 000 according as AAA holds or fails there, for every real ppp.

For every natural nnn and real coefficient family c:In→Rc:I_n\to\mathbb Rc:In​→R, define the coefficient sum C(c)=∑j∈IncjC(c)=\sum_{j\in I_n}c_jC(c)=∑j∈In​​cj​, energy V(c)=∑j∈Incj2V(c)=\sum_{j\in I_n}c_j^2V(c)=∑j∈In​​cj2​, empirical mean cˉ=C(c)/n\bar c=C(c)/ncˉ=C(c)/n, and empirical variance sc2=(∑j∈In(cj−cˉ)2)/ns_c^2=\bigl(\sum_{j\in I_n}(c_j-\bar c)^2\bigr)/nsc2​=(∑j∈In​​(cj​−cˉ)2)/n, where nnn in a real expression denotes its image in R\mathbb RR. The variance uses denominator nnn, with no correction by n−1n-1n−1. These definitions impose no positivity, nonzero, or sign hypothesis on nnn or the coefficients, and real division is total with x/0=0x/0=0x/0=0. In particular, for n=0n=0n=0, the coefficient sum, energy, empirical mean, and empirical variance all equal 000; for n=1n=1n=1, the empirical mean is the sole coefficient and the empirical variance is 000.

For every natural nnn, real qqq, real coefficient family c:In→Rc:I_n\to\mathbb Rc:In​→R, and mask ω∈Ωn\omega\in\Omega_nω∈Ωn​, define the output error Eq,c(ω)=∑j∈In(cj−hq,c,j(ωj))E_{q,c}(\omega)=\sum_{j\in I_n}\bigl(c_j-h_{q,c,j}(\omega_j)\bigr)Eq,c​(ω)=∑j∈In​​(cj​−hq,c,j​(ωj​)), where hq,c,j(true)=0h_{q,c,j}(\mathsf{true})=0hq,c,j​(true)=0 and hq,c,j(false)=cj/qh_{q,c,j}(\mathsf{false})=c_j/qhq,c,j​(false)=cj​/q. Thus a true coordinate contributes cjc_jcj​ to the error and a false coordinate contributes cj−cj/qc_j-c_j/qcj​−cj​/q. For every additional real ppp, the DARE error is defined as Dp,c(ω)=E1−p,c(ω)D_{p,c}(\omega)=E_{1-p,c}(\omega)Dp,c​(ω)=E1−p,c​(ω), and the output bias is defined as the scalar bp,q,c=(1−(1−p)/q)C(c)b_{p,q,c}=\bigl(1-(1-p)/q\bigr)C(c)bp,q,c​=(1−(1−p)/q)C(c). Neither definition imposes p∈[0,1]p\in[0,1]p∈[0,1], q>0q>0q>0, or a relation between ppp and qqq; “output bias” is the name of this formula and is not itself an assertion that it equals a mean. With the total convention x/0=0x/0=0x/0=0, E0,c(ω)=C(c)E_{0,c}(\omega)=C(c)E0,c​(ω)=C(c) and bp,0,c=C(c)b_{p,0,c}=C(c)bp,0,c​=C(c) for every mask and every ppp, and D1,c(ω)=C(c)D_{1,c}(\omega)=C(c)D1,c​(ω)=C(c). For n=0n=0n=0, all these error and bias quantities are 000.

For every real ppp, define ϕ(p)=12\phi(p)=\tfrac12ϕ(p)=21​ if p=12p=\tfrac12p=21​, and otherwise define ϕ(p)=(1−2p)/log⁡((1−p)/p)\phi(p)=(1-2p)/\log((1-p)/p)ϕ(p)=(1−2p)/log((1−p)/p). There is no restriction on ppp in this definition and no separate assertion here that ϕ\phiϕ is positive or bounded. The logarithm is Lean's total real logarithm: it has value 000 at 000 and takes the logarithm of the absolute value at a negative input; all quotients use total real division with x/0=0x/0=0x/0=0. Consequently the formula is defined also at p=0p=0p=0 and p=1p=1p=1, where it gives ϕ(0)=ϕ(1)=0\phi(0)=\phi(1)=0ϕ(0)=ϕ(1)=0, while the explicitly selected midpoint value is ϕ(12)=12\phi(\tfrac12)=\tfrac12ϕ(21​)=21​.

Human review
  • Endorsed by Shuze Chen · Sep 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Minghui · Sep 29, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me