AFTD Auto-Formalizing Theoretical Domains

shellsort_h_pass_example

theoremverified

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`.

  1. 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.

    line 3

      decide

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

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
See it in the graphDiscuss this resultChallenge it