is_k_rollercoaster
A 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 least k - 1 indices away from both ends, and any two turning points are separated by at least k - 1 indices.
Statement
def is_k_rollercoaster {α : Type*} [LinearOrder α] (k : ℕ) (L : List α) : Prop
- Defined in
- arXiv:2611.26297 Sec. 1
- Verified
- 22 Nov 2026
- Axioms
- none listed
- Built on 2
- TotalPreorderA total preorder: a preorder where
≤is total (complete). This is weaker thanLinearOrder— it does NOT require antisymmetry or… - LinearOrder.toTotalPreorderEvery
LinearOrderis aTotalPreorder.
- TotalPreorderA total preorder: a preorder where
- Used by 1
- is_valid_guaranteed_rollercoasterA 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…
Read back from the Lean
Given a linearly ordered type α, a natural number k, and a list L : List α, is_k_rollercoaster k L is defined as the conjunction of the following four conditions:
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 strict local extremum—that is, there exist hypotheses h0 : 0 < i and h1 : i + 1 < L.length such that either:
- L[i - 1] < L[i] and L[i + 1] < L[i] (a strict local maximum), or
- L[i] < L[i - 1] and L[i] < L[i + 1] (a strict local minimum)—
then k - 1 ≤ i and i + (k - 1) < L.length (i.e., i is at index at least k - 1 and at least k - 1 elements remain after index i).
4. For all natural numbers i and j, if i is a strict local extremum (in the same sense as above) and j is a strict local extremum, and i < j, then k - 1 ≤ j - i (i.e., any two distinct strict local extrema are separated by an index difference of at least k - 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
/-- A k-rollercoaster is a sequence of distinct elements whose maximal increasing and decreasing runs all have length at least k. -/ def is_k_rollercoaster {α : Type*} [LinearOrder α] (k : ℕ) (L : List α) : Prop := L.Nodup ∧ k ≤ L.length ∧ (∀ i, (∃ (h0 : 0 < i) (h1 : i + 1 < L.length), (L.get ⟨i - 1, by omega⟩ < L.get ⟨i, by omega⟩ ∧ L.get ⟨i + 1, h1⟩ < L.get ⟨i, by omega⟩) ∨ (L.get ⟨i, by omega⟩ < L.get ⟨i - 1, by omega⟩ ∧ L.get ⟨i, by omega⟩ < L.get ⟨i + 1, h1⟩)) → k - 1 ≤ i ∧ i + (k - 1) < L.length) ∧ (∀ i j, (∃ (h0 : 0 < i) (h1 : i + 1 < L.length), (L.get ⟨i - 1, by omega⟩ < L.get ⟨i, by omega⟩ ∧ L.get ⟨i + 1, h1⟩ < L.get ⟨i, by omega⟩) ∨ (L.get ⟨i, by omega⟩ < L.get ⟨i - 1, by omega⟩ ∧ L.get ⟨i, by omega⟩ < L.get ⟨i + 1, h1⟩)) → (∃ (h0 : 0 < j) (h1 : j + 1 < L.length), (L.get ⟨j - 1, by omega⟩ < L.get ⟨j, by omega⟩ ∧ L.get ⟨j + 1, h1⟩ < L.get ⟨j, by omega⟩) ∨ (L.get ⟨j, by omega⟩ < L.get ⟨j - 1, by omega⟩ ∧ L.get ⟨j, by omega⟩ < L.get ⟨j + 1, h1⟩)) → i < j → k - 1 ≤ j - i)