subtraction_pass_grundy
The pass-available Sprague-Grundy sequence h_S : ℕ → ℕ of a subtraction game with move set S ⊆ ℕ is defined recursively by h_S(n) = mex ({h_S(n - s) : s ∈ S, 0 < s ≤ n} ∪ {g_S(n)}) when there is at least one legal move s ∈ S with 0 < s ≤ n, and h_S(n) = 0 otherwise.
Statement
noncomputable def subtraction_pass_grundy (S : Set ℕ) : ℕ → ℕ
- Defined in
- arXiv:2611.30147, Section 2, Eq. (2)
- Verified
- 26 Nov 2026
- Axioms
- none listed
- Built on 2
- subtraction_grundyThe ordinary Sprague-Grundy sequence g_S : ℕ → ℕ of a subtraction game with move set S ⊆ ℕ is defined recursively by g_S(n) = mex {g_S(n -…
- nat_mex_setThe minimum excluded natural number of a set s of natural numbers is the infimum of the set of natural numbers not in s.
Read back from the Lean
A definition of a function subtraction_pass_grundy : Set ℕ → ℕ → ℕ. For a given set of natural numbers S and a natural number n, the value subtraction_pass_grundy S n is defined by well-founded recursion on n (using the standard < order on ℕ):
- If there exists some s ∈ S such that 0 < s and s ≤ n, then subtraction_pass_grundy S n is the minimum excluded natural number (nat_mex_set) of the union of:
1. the set of values subtraction_pass_grundy S (n - s) for all s ∈ S with 0 < s and s ≤ n, and
2. the singleton set containing subtraction_grundy S n.
- Otherwise (if no s ∈ S satisfies 0 < s ∧ s ≤ n), subtraction_pass_grundy S n is 0.
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 pass-available Sprague-Grundy sequence of a subtraction game with move set S. -/ noncomputable def subtraction_pass_grundy (S : Set ℕ) : ℕ → ℕ := open Classical in WellFounded.fix (measure id).wf fun n ih => if ∃ s ∈ S, 0 < s ∧ s ≤ n then nat_mex_set ({k | ∃ s ∈ S, ∃ (_hs : 0 < s) (_hle : s ≤ n), k = ih (n - s) (Nat.sub_lt_self _hs _hle)} ∪ {subtraction_grundy S n}) else 0