Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§5.1, p. 10 — the cost function J(n)J(n)J(n) of a bidirectional channel in closed form

Proved
LNChannels.Exact.cost_function

by mikedeng1 · Oct 15, 2026 · Mathlib 0df444a (Lean v4.33.1)

difference-equationslightning-networkp2o-batch-pfp2ap2o-gran-per-chapterp2o-plan-paperp2o-v1payment-channels

Let 0<λ1≤λ20<\lambda_1\le\lambda_20<λ1​≤λ2​, r>0r>0r>0, B∈RB\in\mathbb RB∈R, and natural commitments l1,l2≥1l_1,l_2\ge1l1​,l2​≥1; let α±\alpha_\pmα±​ be the roots (4). The bidirectional cost system ((15) with J(−l1)=J(+l2)=J(0)+BJ(-l_1)=J(+l_2)=J(0)+BJ(−l1​)=J(+l2​)=J(0)+B) has a solution, and every solution satisfies, at every balance −l1≤n≤l2-l_1\le n\le l_2−l1​≤n≤l2​,

J(n)=l1+l2−B (α−l1+l2−1) α+l1+n−(α+l1+l2−1) α−l1+nα−l1−α+l1+(α+l1−1) α−l1+l2−(α−l1−1) α+l1+l2.J(n)=l_1+l_2-B\,\frac{(\alpha_-^{l_1+l_2}-1)\,\alpha_+^{l_1+n}-(\alpha_+^{l_1+l_2}-1)\,\alpha_-^{l_1+n}}{\alpha_-^{l_1}-\alpha_+^{l_1}+(\alpha_+^{l_1}-1)\,\alpha_-^{l_1+l_2}-(\alpha_-^{l_1}-1)\,\alpha_+^{l_1+l_2}}.J(n)=l1​+l2​−Bα−l1​​−α+l1​​+(α+l1​​−1)α−l1​+l2​​−(α−l1​​−1)α+l1​+l2​​(α−l1​+l2​​−1)α+l1​+n​−(α+l1​+l2​​−1)α−l1​+n​​.

At n=0n=0n=0 this is the closed form (3) of the channel's cost.

Formalization Note The paper prints the exponent of the numerator's α±\alpha_\pmα±​ as l+nl+nl+n; it is l1+nl_1+nl1​+n (this is what solving the two boundary equations gives, and what reduces to (3) at n=0n=0n=0). The powers α±l1+n\alpha_\pm^{l_1+n}α±l1​+n​ are integer powers (zpow), with a nonnegative exponent on the lattice. Existence of a solution is part of the statement.

Preamble
import Mathlib
import Definitions.Def_LNChannels_Exact_alphaPlus
import Definitions.Def_LNChannels_Exact_alphaMinus
import Definitions.Def_LNChannels_Exact_IsBiCostFn

set_option autoImplicit false
Formal statement
namespace LNChannels.Exact

/-- §5.1, p. 10, the display after "which yield the cost function": the cost `J(n)` at every
balance `−l₁ ≤ n ≤ l₂` of a bidirectional channel. The printed exponent `l + n` in the numerator
is read as `l₁ + n`. Powers with exponent depending on `n` are `zpow`s with exponent
`l₁ + n ≥ 0` on the lattice. -/
theorem cost_function (lam₁ lam₂ r B : ℝ) (l₁ l₂ : ℕ)
    (hlam₁ : 0 < lam₁) (hlam : lam₁ ≤ lam₂) (hr : 0 < r) (hl₁ : 1 ≤ l₁) (hl₂ : 1 ≤ l₂) :
    let a := alphaMinus lam₁ lam₂ r
    let b := alphaPlus lam₁ lam₂ r
    (∃ J : ℤ → ℝ, IsBiCostFn lam₁ lam₂ r B l₁ l₂ J) ∧
    ∀ J : ℤ → ℝ, IsBiCostFn lam₁ lam₂ r B l₁ l₂ J →
      ∀ n : ℤ, -(l₁ : ℤ) ≤ n → n ≤ (l₂ : ℤ) →
        J n = (l₁ : ℝ) + l₂ - B *
          (((a ^ (l₁ + l₂) - 1) * b ^ ((l₁ : ℤ) + n) - (b ^ (l₁ + l₂) - 1) * a ^ ((l₁ : ℤ) + n)) /
            (a ^ l₁ - b ^ l₁ + (b ^ l₁ - 1) * a ^ (l₁ + l₂) - (a ^ l₁ - 1) * b ^ (l₁ + l₂))) := by sorry

end LNChannels.Exact
Source
Guasoni, Huberman & Shikhelman, Lightning Network Economics: Channels, Management Science (Articles in Advance, Nov. 6, 2023), p. 10 (PDF p. 11), §5.1, display after "which yield the cost function" (exponent l + n read as l1 + n)
Human review
  • Endorsed by Shuze Chen · Oct 15, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 15, 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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me