AFTD Auto-Formalizing Theoretical Domains

threshold_state

def

Given horizon T : ℕ, increments a : Fin (T - 1) → NNReal, and reset price K : ℝ, threshold_state T a K : Fin T → NNReal × NNReal is defined recursively: at index ⟨0, _⟩ it is (0, 0), and at index ⟨t + 1, _⟩, letting (h, acc) = threshold_state T a K ⟨t, _⟩, it is (a ⟨t, _⟩, 0) if K ≤ (acc : ℝ) + (h : ℝ), and (h + a ⟨t, _⟩, acc + h) otherwise.

Statement

noncomputable def threshold_state (T : ℕ) (a : Fin (T - 1) → NNReal) (K : ℝ) : Fin T → NNReal × NNReal
Defined in
arXiv:2611.06955, Definition 5
Verified
08 Nov 2026
Axioms
none listed
Used by 3
  • threshold_schedule_additive_boundFor every horizon T ≥ 2, nonnegative increments a : Fin (T - 1) → NNReal with P runs (P = rent_or_buy_num_runs T a), every positive reset…
  • not_threshold_schedule_competitive_ratio_twoThe statement threshold_schedule_competitive_ratio_two is false: The reset price K : ℝ is unrestricted, and for negative K the claim…
  • threshold_scheduleGiven horizon T : ℕ, increments a : Fin (T - 1) → NNReal, reset price K : ℝ, and call t : Fin T, threshold_schedule T a K t : Bool is…

Read back from the Lean

A recursive definition threshold_state taking: - a natural number T, - a function a : Fin (T - 1) → NNReal (a sequence of non-negative real numbers of length T - 1), - a real threshold K : ℝ, and producing a function Fin T → NNReal × NNReal (a sequence of pairs of non-negative real numbers of length T), defined by recursion on the index: - At index 0, it returns (0, 0). - At index t + 1 (where t + 1 < T, so t < T - 1): letting (h, acc) be the value at index t, - if K ≤ (acc : ℝ) + (h : ℝ), it returns (a t, 0); - otherwise, it returns (h + a t, acc + h).

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 state (history, accumulator) of the threshold rule before each call. -/
noncomputable def threshold_state (T : ℕ) (a : Fin (T - 1) → NNReal) (K : ℝ) : Fin T → NNReal × NNReal
  | ⟨0, _⟩ => (0, 0)
  | ⟨t + 1, ht⟩ =>
    let (h, acc) := threshold_state T a K ⟨t, by omega⟩
    have ht_lt : t < T - 1 := by omega
    if K ≤ (acc : ℝ) + (h : ℝ) then
      (a ⟨t, ht_lt⟩, 0)
    else
      (h + a ⟨t, ht_lt⟩, acc + h)
termination_by t => t.val
See it in the graphDiscuss this resultChallenge it