{
  "id": "KL-FCS-032",
  "version": "1.0.0",
  "domain": "Formal languages",
  "kind": "languages",
  "title": "Balanced words through length 6",
  "problem": "List every balanced parenthesis word of length at most 6, including the empty word.",
  "specification": {
    "max_length": 6,
    "alphabet": [
      "(",
      ")"
    ],
    "language": "Every prefix has nonnegative balance and the terminal balance is zero."
  },
  "claim": {
    "accepted_count": 9
  },
  "witness": {
    "words": [
      "",
      "()",
      "(())",
      "()()",
      "((()))",
      "(()())",
      "(())()",
      "()(())",
      "()()()"
    ]
  },
  "verification_scope": "Complete bounded membership · 127 candidates",
  "explanation": "A prefix can invalidate a word before its final symbol. The accepted list includes different nesting structures and concatenations, not only fully nested strings.",
  "limitations": "This enumerates a bounded language slice; it is not a grammar-equivalence 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/18-404j-theory-of-computation-fall-2020/download/"
  ],
  "license_status": "not-yet-selected",
  "dataset": {
    "family": "formal-languages",
    "task": "List every balanced parenthesis word of length at most 6, including the empty word.",
    "input_encoding": "Structured JSON; field meanings are stated in the specification.",
    "coverage": "Complete bounded membership · 127 candidates",
    "acceptance": [
      "Generate every parenthesis string up to the stated length.",
      "Scan each prefix and reject any negative balance.",
      "Accept only strings with terminal balance zero.",
      "Compare the complete accepted-word list and its cardinality."
    ],
    "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": "Characterize bounded membership in a recursively structured language while keeping the length bound visible.",
    "definitions": [
      {
        "term": "Dyck word",
        "definition": "A balanced parenthesis string whose prefix balance never goes negative."
      },
      {
        "term": "Prefix balance",
        "definition": "Opening parentheses minus closing parentheses in an input prefix."
      },
      {
        "term": "Membership",
        "definition": "Whether a particular word belongs to the specified language."
      }
    ],
    "reasoning": [
      "Generate every parenthesis string up to the stated length.",
      "Scan each prefix and reject any negative balance.",
      "Accept only strings with terminal balance zero.",
      "Compare the complete accepted-word list and its cardinality."
    ],
    "worked_example": "A prefix can invalidate a word before its final symbol. The accepted list includes different nesting structures and concatenations, not only fully nested strings.",
    "complexity": "A length bound n produces 2ⁿ⁺¹−1 candidate words; each membership scan takes O(n).",
    "common_error": "Equal numbers of opening and closing symbols do not guarantee proper nesting.",
    "further_work": "Add context-free grammar membership, CYK charts, and parse-tree certificates."
  },
  "related_ids": [
    "KL-FCS-031",
    "KL-FCS-033"
  ]
}
