shellsort_h_pass_example
Sanity check of the h-pass: the 2-pass of the array 5, 4, 3, 2, 1, 0 sorts the even positions (values 5, 3, 1) and the odd positions (4, 2, 0) separately, giving 1, 0, 3, 2, 5, 4.
Statement
theorem shellsort_h_pass_example :
(List.ofFn (shellsort_h_pass 2 (![5, 4, 3, 2, 1, 0] : Fin 6 → ℕ))) = [1, 0, 3, 2, 5, 4]- Source
- arXiv:2611.27671, Section 2 (definition of the h-pass); a computed instance.
- Verified
- 29 Nov 2026
- Axioms
propext- Built on 1
- shellsort_h_passThe h-pass of Shellsort on an array A : Fin n → α over a linear order: for each index i, form the h-chain of i, i.e. the list of the…
The proof, explained
This example is a concrete sanity check for `shellsort_h_pass`. The 2-pass partitions the input vector ⟨5, 4, 3, 2, 1, 0⟩ into two independent subarrays according to the index modulo 2: the even positions ⟨5, 3, 1⟩ and the odd positions ⟨4, 2, 0⟩. Each subarray is sorted separately into [1, 3, 5] and [0, 2, 4], producing the interleaved list [1, 0, 3, 2, 5, 4]. Because the entire operation is finite and computable, the equality is verified by Lean's computational evaluation via `decide`.
The result of applying a 2-pass of Shellsort to the vector ⟨5, 4, 3, 2, 1, 0⟩ is the list [1, 0, 3, 2, 5, 4]. automation
The input vector has finite length 6 and all operations involved in `shellsort_h_pass`—filtering the indices by their remainder modulo 2, sorting each sublist using insertion sort, and reading out the elements—are fully computable. The `decide` tactic evaluates the equality by direct finite computation and confirms that both sides match.
decide
- The proof relies entirely on computational evaluation by the `decide` tactic rather than symbolic reasoning.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem shellsort_h_pass_example : (List.ofFn (shellsort_h_pass 2 (![5, 4, 3, 2, 1, 0] : Fin 6 → ℕ))) = [1, 0, 3, 2, 5, 4] := by decide