AFTD Auto-Formalizing Theoretical Domains

is_valid_guaranteed_rollercoaster

def

A strictly increasing list of indices ans is a valid guaranteed-length k-rollercoaster for a sequence v of length n if its length is at least the guaranteed bound f_k(n) = guaranteed_rollercoaster_length k n, and whenever f_k(n) > 0, the selected subsequence ans.map v is a k-rollercoaster.

Statement

def is_valid_guaranteed_rollercoaster {α : Type*} [LinearOrder α] (k n : ℕ)
    (v : Fin n → α) (ans : List (Fin n)) : Prop
Defined in
arXiv:2611.26297 Sec. 4
Verified
22 Nov 2026
Axioms
none listed
Built on 2
  • guaranteed_rollercoaster_lengthThe maximum guaranteed length f_k(n) of a k-rollercoaster subsequence in any permutation of length n: 0 for n ≤ (k-1)², 2(k-1) -…
  • is_k_rollercoasterA list L of distinct elements from a linearly ordered set is a k-rollercoaster if its length is at least k, every turning point is at…
Used by 1

Read back from the Lean

Given a linearly ordered type α, natural numbers k and n, a sequence v : Fin n → α, and a list of indices ans : List (Fin n), is_valid_guaranteed_rollercoaster k n v ans asserts that: 1. ans is strictly increasing (i.e., ans.Pairwise (· < ·)). 2. The length of ans is at least guaranteed_rollercoaster_length k n. 3. If 0 < guaranteed_rollercoaster_length k n, then the mapped list ans.map v is a k-rollercoaster according to is_k_rollercoaster k (ans.map v). Here, guaranteed_rollercoaster_length k n is defined with q := k - 1 as: - 0 if n ≤ q²; - 2 * q - Nat.sqrt (2 * q² - n) if q² < n < 2 * q²; - (n + q - 1) / q otherwise. And is_k_rollercoaster k L asserts for a list L : List α that: 1. L has no duplicate elements (L.Nodup). 2. The length of L is at least k (k ≤ L.length). 3. For every natural number i, if i is a local extremum of L (meaning 0 < i, i + 1 < L.length, and either L[i-1] < L[i] ∧ L[i+1] < L[i] or L[i] < L[i-1] ∧ L[i] < L[i+1]), then k - 1 ≤ i and i + (k - 1) < L.length. 4. For all natural numbers i < j, if both i and j are local extrema of L, then k - 1 ≤ j - i.

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

/-- An index subsequence is a valid guaranteed-length k-rollercoaster for sequence v. -/
def is_valid_guaranteed_rollercoaster {α : Type*} [LinearOrder α] (k n : ℕ)
    (v : Fin n → α) (ans : List (Fin n)) : Prop :=
  ans.Pairwise (· < ·) ∧
  guaranteed_rollercoaster_length k n ≤ ans.length ∧
  (0 < guaranteed_rollercoaster_length k n → is_k_rollercoaster k (ans.map v))
See it in the graphDiscuss this resultChallenge it