k_sorted
def
An array $A : \text{Fin } n \to \alpha$ is $k$-sorted if $A_i \le A_{i+k}$ whenever $i+k < n$.
Statement
def k_sorted {n : ℕ} (k : ℕ) {α : Type*} [Preorder α] (A : Fin n → α) : Prop
- Defined in
- arXiv:2611.27671 "Shellsort with O(n log n) Average-Case Complexity", Section 2.1
- Verified
- 23 Nov 2026
- Axioms
- none listed
- Used by 1
- k_sorted_of_monotoneIf an array $A : \text{Fin } n \to \alpha$ is monotone non-decreasing, then it is $k$-sorted for every $k$.
Read back from the Lean
Given an implicit natural number $n$, an explicit natural number $k$, an implicit type $\alpha$ equipped with a preorder, and a function $A : \text{Fin } n \to \alpha$, k_sorted k A is defined to hold if and only if for every index $i : \text{Fin } n$ and every proof $hi$ that $i.val + k < n$, $A(i) \le A(\langle i.val + k, hi \rangle)$.
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 array is k-sorted if elements at distance k are in non-decreasing order. -/ def k_sorted {n : ℕ} (k : ℕ) {α : Type*} [Preorder α] (A : Fin n → α) : Prop := ∀ (i : Fin n) (hi : i.val + k < n), A i ≤ A ⟨i.val + k, hi⟩