AFTD Auto-Formalizing Theoretical Domains

session_runs

def

Given a horizon T : ℕ and an increment vector a : Fin (T - 1) → NNReal, the number of runs session_runs T a : ℕ is 0 if T ≤ 1, and 1 plus the cardinality of the finset of indices i : Fin (T - 2) such that a ⟨i.val, _⟩ ≠ a ⟨i.val + 1, _⟩ otherwise.

Statement

noncomputable def session_runs (T : ℕ) (a : Fin (T - 1) → NNReal) : ℕ
Defined in
arXiv:2611.06955, Definition 2
Verified
08 Nov 2026
Axioms
none listed

Read back from the Lean

A definition of a function session_runs taking a natural number T and a sequence a : Fin (T - 1) → NNReal (a function from indices 0 to T - 2 to non-negative real numbers), returning a natural number: - If T ≤ 1, it returns 0. - Otherwise (if T ≥ 2), it returns 1 plus the cardinality of the set of indices i : Fin (T - 2) such that a(i) ≠ a(i + 1). (Equivalently, for T ≥ 2, it counts the number of contiguous constant runs in the sequence a of length T - 1.)

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 number of runs of a session of horizon T with increments a. -/
noncomputable def session_runs (T : ℕ) (a : Fin (T - 1) → NNReal) : ℕ := if T ≤ 1 then 0
  else
    1 + ((Finset.univ.filter (fun i : Fin (T - 2) =>
      a ⟨i.val, by omega⟩ ≠ a ⟨i.val + 1, by omega⟩)).card)
See it in the graphDiscuss this resultChallenge it