switch_qk
def
The function switch_qk maps natural numbers k and d to a natural number, defined recursively by cases: if d ≤ k then d + 1; else if d < (3 * k + 1) / 2 + k then 2 * d + 1 - k; else if k = 0 then 0; else 2 * switch_qk k (d - k).
Statement
def switch_qk (k d : ℕ) : ℕ- Defined in
- arXiv:2611.28727 Fig. 9
- Verified
- 29 Nov 2026
- Axioms
- none listed
- Used by 2
- switch_vkFor natural numbers k and x, switch_vk k x is defined as Nat.findGreatest (fun d => switch_qk k d ≤ x) x, the greatest natural number d ≤…
- switch_vk_zeroFor every natural number k, switch_vk k 0 equals 0.
Read back from the Lean
switch_qk is a recursively defined function taking two natural numbers $k$ and $d$ and returning a natural number, defined by:
- If $d \le k$, the result is $d + 1$.
- Otherwise, if $d < \lfloor (3k + 1) / 2 \rfloor + k$, the result is $2d + 1 - k$.
- Otherwise, if $k = 0$, the result is $0$.
- Otherwise, the result is $2 \cdot \mathrm{switch\_qk}(k, d - k)$.
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- The piecewise threshold sequence Q_k(d) for switch budget k and depth d. -/ def switch_qk (k d : ℕ) : ℕ := if d ≤ k then d + 1 else if d < (3 * k + 1) / 2 + k then 2 * d + 1 - k else if k = 0 then 0 else 2 * switch_qk k (d - k) termination_by d decreasing_by omega