AFTD Auto-Formalizing Theoretical Domains

leading_unit_h

def

For natural numbers g, k, N : ℕ, the sequence of integers leading_unit_h g k N : ℕ → ℤ associated with coefficient list [1^g, 0^k, N] is defined recursively on ℕ: leading_unit_h g k N 0 = 0, leading_unit_h g k N 1 = 1, and for n ≥ 0, setting L = g + k + 1, if n + 2 ≤ L then leading_unit_h g k N (n + 2) = 1 + ∑ j ∈ Finset.range (min g (n + 1)), leading_unit_h g k N (n + 2 - (j + 1)), and if n + 2 > L then leading_unit_h g k N (n + 2) = (∑ j ∈ Finset.range g, leading_unit_h g k N (n + 2 - (j + 1))) + (N : ℤ) * leading_unit_h g k N (n + 2 - L).

Statement

def leading_unit_h (g k N : ℕ) : ℕ → ℤ
Defined in
arXiv:2611.10200, eq. (1.2)-(1.3)
Verified
10 Nov 2026
Axioms
none listed
Used by 1
  • plrs_seq_eq_leading_unit_hFor all natural numbers g, k, N with 1 ≤ g, 1 ≤ k, and 1 ≤ N, the sequence plrs_seq on List.replicate g 1 ++ List.replicate k 0 ++ [N]…

Read back from the Lean

Given natural numbers g, k, and N, leading_unit_h g k N defines a function from ℕ to ℤ by recursion on its input argument m : ℕ: - If m = 0, it returns 0. - If m = 1, it returns 1. - If m = n + 2 (i.e., m ≥ 2), setting L = g + k + 1: - If m ≤ L, it returns 1 + ∑ j ∈ Finset.range (min g (m - 1)), leading_unit_h g k N (m - (j + 1)) (that is, 1 + ∑_{i = 1}^{min(g, m - 1)} leading_unit_h g k N (m - i)). - If m > L, it returns (∑ j ∈ Finset.range g, leading_unit_h g k N (m - (j + 1))) + (N : ℤ) * leading_unit_h g k N (m - L) (that is, (∑_{i = 1}^{g} leading_unit_h g k N (m - i)) + (N : ℤ) * leading_unit_h g k N (m - L)).

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 standard positive linear recurrence sequence associated with coefficient list [1^g, 0^k, N], taking values in ℤ. -/
def leading_unit_h (g k N : ℕ) : ℕ → ℤ
| 0 => 0
| 1 => 1
| n + 2 =>
  let L := g + k + 1
  if n + 2 ≤ L then
    1 + ∑ j ∈ Finset.range (min g (n + 1)), leading_unit_h g k N (n + 2 - (j + 1))
  else
    (∑ j ∈ Finset.range g, leading_unit_h g k N (n + 2 - (j + 1))) + (N : ℤ) * leading_unit_h g k N (n + 2 - L)
termination_by m => m
decreasing_by all_goals omega
See it in the graphDiscuss this resultChallenge it