{
  "id": "KL-FCS-001",
  "version": "1.0.0",
  "domain": "Algorithms",
  "kind": "algorithm",
  "title": "Insertion sort over a finite domain",
  "problem": "Sort every list of length 0–5 over {−1, 0, 1}, preserving every occurrence.",
  "specification": {
    "alphabet": [
      -1,
      0,
      1
    ],
    "max_length": 5
  },
  "claim": {
    "correct_on_declared_domain": true
  },
  "witness": {
    "function": "insertion_sort"
  },
  "verification_scope": "Exhaustive bounded validation · 364 inputs",
  "explanation": "The candidate shifts larger values to the right before inserting the next value. A separate checker compares every declared input with Python’s reference ordering. Duplicates and the empty list are included.",
  "limitations": "This is not a general proof for arbitrary lists, a stability proof, or a complexity result.",
  "verification_status": "mechanically-checked",
  "review_status": "awaiting-independent-review",
  "provenance": {
    "origin": "Original Kenton Labs reference instance, authored with Codex assistance on 2026-10-11.",
    "external_dataset": null,
    "model_run": null
  },
  "references": [
    "https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/"
  ],
  "license_status": "not-yet-selected",
  "dataset": {
    "family": "algorithms",
    "task": "Sort every list of length 0–5 over {−1, 0, 1}, preserving every occurrence.",
    "input_encoding": "Structured JSON; field meanings are stated in the specification.",
    "coverage": "Exhaustive bounded validation · 364 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."
  },
  "lesson": {
    "motivation": "Separate a program’s behavior from its specification. Exhaustive finite domains expose ordering, multiplicity, empty-input, and duplicate-value errors.",
    "definitions": [
      {
        "term": "Input contract",
        "definition": "A precise set of admissible inputs, including sizes and value ranges."
      },
      {
        "term": "Postcondition",
        "definition": "The relation between the original input and the returned output."
      },
      {
        "term": "Oracle",
        "definition": "A separately implemented reference property used to accept or reject a candidate."
      }
    ],
    "reasoning": [
      "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."
    ],
    "worked_example": "The candidate shifts larger values to the right before inserting the next value. A separate checker compares every declared input with Python’s reference ordering. Duplicates and the empty list are included.",
    "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.",
    "common_error": "Sortedness alone does not prove that an output preserves the input multiset.",
    "further_work": "Add stability certificates for tagged records or an unbounded inductive invariant."
  },
  "related_ids": [
    "KL-FCS-012",
    "KL-FCS-013"
  ]
}
