{
  "name": "Algorithms",
  "version": "1.0.0",
  "area": {
    "name": "Algorithms",
    "slug": "algorithms",
    "group": "Computation",
    "kind": "algorithm",
    "summary": "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."
      }
    ],
    "methodology": [
      "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."
    ],
    "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.",
    "next_question": "Add stability certificates for tagged records or an unbounded inductive invariant.",
    "references": [
      "https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/"
    ]
  },
  "records": [
    {
      "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"
      ]
    },
    {
      "id": "KL-FCS-012",
      "version": "1.0.0",
      "domain": "Algorithms",
      "kind": "algorithm",
      "title": "Longer binary lists",
      "problem": "Sort every list of length at most 8 over [0, 1].",
      "specification": {
        "alphabet": [
          0,
          1
        ],
        "max_length": 8
      },
      "claim": {
        "correct_on_declared_domain": true
      },
      "witness": {
        "function": "insertion_sort"
      },
      "verification_scope": "Complete bounded enumeration · 511 inputs",
      "explanation": "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.",
      "limitations": "This finite acceptance result does not establish an unrestricted algorithm theorem.",
      "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 at most 8 over [0, 1].",
        "input_encoding": "Structured JSON; field meanings are stated in the specification.",
        "coverage": "Complete bounded enumeration · 511 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 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.",
        "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-001",
        "KL-FCS-013"
      ]
    },
    {
      "id": "KL-FCS-013",
      "version": "1.0.0",
      "domain": "Algorithms",
      "kind": "algorithm",
      "title": "Five-symbol sorting domain",
      "problem": "Sort every list of length at most 4 over [-2, -1, 0, 1, 2].",
      "specification": {
        "alphabet": [
          -2,
          -1,
          0,
          1,
          2
        ],
        "max_length": 4
      },
      "claim": {
        "correct_on_declared_domain": true
      },
      "witness": {
        "function": "insertion_sort"
      },
      "verification_scope": "Complete bounded enumeration · 781 inputs",
      "explanation": "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.",
      "limitations": "This finite acceptance result does not establish an unrestricted algorithm theorem.",
      "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 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."
      },
      "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 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.",
        "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-001",
        "KL-FCS-012"
      ]
    }
  ],
  "verification": [
    {
      "id": "KL-FCS-001",
      "status": "mechanically-checked",
      "check_units": 364,
      "scope": "Exhaustive bounded validation · 364 inputs",
      "review_status": "awaiting-independent-review"
    },
    {
      "id": "KL-FCS-012",
      "status": "mechanically-checked",
      "check_units": 511,
      "scope": "Complete bounded enumeration · 511 inputs",
      "review_status": "awaiting-independent-review"
    },
    {
      "id": "KL-FCS-013",
      "status": "mechanically-checked",
      "check_units": 781,
      "scope": "Complete bounded enumeration · 781 inputs",
      "review_status": "awaiting-independent-review"
    }
  ]
}
