{
  "id": "KL-FCS-055",
  "version": "1.0.0",
  "domain": "Information theory",
  "kind": "coding",
  "title": "A probability-shaped prefix code",
  "problem": "Check binary prefix-freeness and compute exact mean codeword length.",
  "specification": {
    "probabilities": {
      "A": "1/2",
      "B": "1/4",
      "C": "1/8",
      "D": "1/8"
    }
  },
  "claim": {
    "prefix_free": true,
    "expected_bits": "7/4"
  },
  "witness": {
    "codes": {
      "A": "0",
      "B": "10",
      "C": "110",
      "D": "111"
    }
  },
  "verification_scope": "Complete codeword-pair check + exact rational average",
  "explanation": "The pairwise check reveals every possible prefix collision. Expected length is an exact fraction, avoiding rounding in the acceptance artifact.",
  "limitations": "No entropy estimate or code optimality claim is made. A rejected prefix code is retained as an instructive checked negative 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-441-information-theory-spring-2010/"
  ],
  "license_status": "not-yet-selected",
  "dataset": {
    "family": "information-theory",
    "task": "Check binary prefix-freeness and compute exact mean codeword length.",
    "input_encoding": "Structured JSON; field meanings are stated in the specification.",
    "coverage": "Complete codeword-pair check + exact rational average",
    "acceptance": [
      "Require one binary codeword for every declared symbol.",
      "Check every ordered pair for the prefix relation.",
      "Verify symbol probabilities form an exact rational distribution.",
      "Compute the average code length using rational arithmetic."
    ],
    "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": "Make code structure and exact expected length visible. Prefix validity and optimality are different questions.",
    "definitions": [
      {
        "term": "Prefix-free code",
        "definition": "No symbol’s codeword is a prefix of another symbol’s codeword."
      },
      {
        "term": "Expected length",
        "definition": "The probability-weighted sum of codeword lengths."
      },
      {
        "term": "Instantaneous decoding",
        "definition": "A prefix-free stream can identify a codeword without waiting for the next symbol."
      }
    ],
    "reasoning": [
      "Require one binary codeword for every declared symbol.",
      "Check every ordered pair for the prefix relation.",
      "Verify symbol probabilities form an exact rational distribution.",
      "Compute the average code length using rational arithmetic."
    ],
    "worked_example": "The pairwise check reveals every possible prefix collision. Expected length is an exact fraction, avoiding rounding in the acceptance artifact.",
    "complexity": "With n symbols and maximum code length L, naive pairwise prefix checking is O(n²L).",
    "common_error": "Short-looking codewords can be ambiguous; a prefix check does not establish minimum expected length.",
    "further_work": "Add Huffman construction traces, lossless round trips, and exact small-tree optimality certificates."
  },
  "related_ids": [
    "KL-FCS-056",
    "KL-FCS-057"
  ]
}
