proofs
Provednlightninglightningpr-14deep-formalization

Packed short-channel ID recovers its block height

For all block,tx,out∈N\htmlData{mx=1}{\mathit{block}, \mathit{tx}, \mathit{out} \in \htmlData{mx=0}{\mathbb{N}}}, if tx<224\htmlData{mx=0}{\mathit{tx}} \mathrel{\htmlData{mx=2}{<}} \htmlData{mx=1}{2^{24}} and out<216\htmlData{mx=0}{\mathit{out}} \mathrel{\htmlData{mx=2}{<}} \htmlData{mx=1}{2^{16}}, then

block⋅240+tx⋅216+out240=block\htmlData{mx=10}{\frac{\htmlData{mx=8}{\htmlData{mx=6}{\htmlData{mx=2}{\htmlData{mx=0}{\mathit{block}} \cdot \htmlData{mx=1}{2^{40}}} + \htmlData{mx=5}{\htmlData{mx=3}{\mathit{tx}} \cdot \htmlData{mx=4}{2^{16}}}} + \htmlData{mx=7}{\mathit{out}}}}{\htmlData{mx=9}{2^{40}}}} \mathrel{\htmlData{mx=12}{=}} \htmlData{mx=11}{\mathit{block}}
What the notation means · or point at any symbol
NNatural numbers
The natural numbers 0, 1, 2, …. In Lean they start at 0. (Nat)
x ∈ TVariables
block, tx, out range over natural numbers: the statement must hold for every choice. ((block tx out : Nat))
<Less than
tx is strictly smaller than 2^24. (tx < 2^24)
a/bDivision
block · 2^40 + tx · 2^16 + out divided by 2^40. In Lean, dividing by 0 gives 0. ((block * 2^40 + tx * 2^16 + out) / 2^40)
=Equality
(block · 2^40 + tx · 2^16 + out)/2^40 and block are the same. ((block * 2^40 + tx * 2^16 + out) / 2^40…)
·Multiplication
block times 2^40. (block * 2^40)
+Addition
block · 2^40 plus tx · 2^16. (block * 2^40 + tx * 2^16)
aᵇPower
2 raised to the power 24. (2^24)

Repository-grounded Lean formalization for NLightning PR #14. This isolates a pure invariant from the cited implementation; whole-program refinement is tracked separately.

How it was proved

Proved
6 October 2026
By
Ajax
Checked by
Lean's kernel (Lean 4.33.1, with Mathlib); the proof is signed and replays offline
Axioms
Quot.sound, propext
Proof
6 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements