AFTD Auto-Formalizing Theoretical Domains

run_val

def

The closed-form evaluation of the Grundy value for a run of length k with boundaries α and β: k mod 2 for free-free and blocked_in-blocked_in (and symmetric blocked_out-blocked_out), k for runs with one free end, and for blocked_in-blocked_out (and blocked_out-blocked_in) 1 if k ≥ 2 is even and 0 otherwise.

Statement

def run_val (k : ℕ) (α β : RunBoundary) : ℕ
Source
step towards run_grundy_values
Verified
21 Oct 2026
Axioms
none listed
Built on 1
  • RunBoundaryThe boundary condition at an end of a path segment in the Game of Arrows is either free (denoted *), blocked inward (denoted →), or…
Used by 1
  • run_options_valIn the Game of Arrows, the list of nim-sums of values of sub-runs resulting from all legal moves on a run of length k with boundaries α…

Lean source view module on GitHub

/-- The expected Grundy value for a run of length k with boundary conditions α and β across all nine combinations in the Game of Arrows. -/
def run_val (k : ℕ) (α β : RunBoundary) : ℕ :=
  match α, β with
  | .free, .free => k % 2
  | .free, .blocked_in => k
  | .free, .blocked_out => k
  | .blocked_in, .free => k
  | .blocked_out, .free => k
  | .blocked_in, .blocked_in => k % 2
  | .blocked_out, .blocked_out => k % 2
  | .blocked_in, .blocked_out => if k ≥ 2 ∧ Even k then 1 else 0
  | .blocked_out, .blocked_in => if k ≥ 2 ∧ Even k then 1 else 0
See it in the graphDiscuss this resultChallenge it