# Five-symbol sorting domain

KL-FCS-013 · Algorithms · version 1.0.0

## Problem

Sort every list of length at most 4 over [-2, -1, 0, 1, 2].

## Context

Separate a program’s behavior from its specification. Exhaustive finite domains expose ordering, multiplicity, empty-input, and duplicate-value errors.

## Definitions

- **Input contract**: A precise set of admissible inputs, including sizes and value ranges.
- **Postcondition**: The relation between the original input and the returned output.
- **Oracle**: A separately implemented reference property used to accept or reject a candidate.

## Checked result

Correct over the stated input domain: yes.

The alphabet and bound jointly define the dataset. Every list is compared with a reference result; the declared domain includes duplicates, reversed lists, and empty input.

## Checker reasoning

1. Enumerate every list in the declared alphabet and length bound.
2. Run the candidate insertion-sort implementation without modifying the source input.
3. Compare each result with the reference ordering, including repeated elements.
4. Reject immediately with an input witness if ordering or multiplicity differs.

## Dataset construction

{
  "family": "algorithms",
  "task": "Sort every list of length at most 4 over [-2, -1, 0, 1, 2].",
  "input_encoding": "Structured JSON; field meanings are stated in the specification.",
  "coverage": "Complete bounded enumeration · 781 inputs",
  "acceptance": [
    "Enumerate every list in the declared alphabet and length bound.",
    "Run the candidate insertion-sort implementation without modifying the source input.",
    "Compare each result with the reference ordering, including repeated elements.",
    "Reject immediately with an input witness if ordering or multiplicity differs."
  ],
  "generation": "Deterministic finite fixture; full enumeration or witness replay as stated.",
  "split_policy": "Reference corpus for exposition and reproduction; no train/test evaluation split is claimed."
}

## Formal payload

```json
{
  "specification": {
    "alphabet": [
      -2,
      -1,
      0,
      1,
      2
    ],
    "max_length": 4
  },
  "claim": {
    "correct_on_declared_domain": true
  },
  "witness": {
    "function": "insertion_sort"
  }
}
```

## Complexity

For alphabet size k and maximum length n, this family checks Σ kⁱ inputs for i=0…n. Insertion sort performs O(n²) comparisons in its worst case.

## Limits

This finite acceptance result does not establish an unrestricted algorithm theorem.

## Common error and further work

Sortedness alone does not prove that an output preserves the input multiset.

Add stability certificates for tagged records or an unbounded inductive invariant.

## Verification

Complete bounded enumeration · 781 inputs. 781 checker units.
Replay with `python3 tools/verify.py`. Mechanical status: checked; human review
has not yet been recorded. Custom Python verification, not a proof-assistant
claim. Checker 1.0.0 and exact source hashes are in `verification.json`.

## Provenance and references

Original Kenton Labs reference instance, authored with Codex assistance on 2026-10-11.
No external dataset or model-generation experiment. Reuse-license selection
remains pending.

- [Conceptual reference](https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/)
