{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-context-free-grammar-01",
  "mko_id": "mko-context-free-grammar",
  "title": {
    "zh-Hant": "CFG的完整production與推導witness",
    "en": "A CFG production list and derivation witness"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-context-free-grammar-01",
    "source": {
      "mko_id": "mko-context-free-grammar",
      "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
      "sha256": "0cffcd9eae42c9318c21e6233a518469b8747f149bd785b0f4c94ecbe19ea685",
      "english_sha256": "a115d11c0e542ef86b3dc7c6f96803d1f34c21848831700815c78d4215ea10a4"
    },
    "mode": "worked_example",
    "audience_prerequisites": [
      "calc"
    ],
    "goal": {
      "zh-Hant": "grammar S→aSb或ε具有aaabbb與ε的有限推導witness。",
      "en": "The grammar S to aSb or epsilon has finite derivation witnesses for aaabbb and epsilon."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "N={S}，Σ={a,b}，start S；完整production P={S→aSb,S→ε}；ε為空rhs。",
          "en": "N={S}, terminals {a,b}, start S; all productions are S to aSb and S to epsilon; epsilon is the empty rhs."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1"
        ],
        "before_tex": "N=\\{S\\},\\quad\\Sigma=\\{a,b\\}",
        "after_tex": "N\\cap\\Sigma=\\varnothing,\\quad S\\in N",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "兩alphabet有限、元素互異且不交，start確為nonterminal。",
          "en": "Both alphabets are finite, internally distinct and disjoint, with a nonterminal start."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1"
          ],
          "explanation": {
            "zh-Hant": "S不是terminal，含S的中途字不是language member。",
            "en": "S is not terminal; a sentential form containing S is not a terminal word."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S02",
        "uses": [
          "G1",
          "S01"
        ],
        "before_tex": "P=\\{S\\to aSb,\\ S\\to\\varepsilon\\}",
        "after_tex": "\\text{each lhs is one nonterminal; every rhs symbol is legal}",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "兩條lhs皆單一S；aSb只用合法symbols，ε是長度0而非新字元。",
          "en": "Both left sides are the single nonterminal S; aSb uses legal symbols and epsilon is a length-zero string, not another character."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01"
          ],
          "explanation": {
            "zh-Hant": "grammar資格不等於任意word都可導出。",
            "en": "Grammar qualification does not imply every word is derivable."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S03",
        "uses": [
          "G1",
          "S02"
        ],
        "before_tex": "S",
        "after_tex": "aSb",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "對start套S→aSb，第一步保留一個S。",
          "en": "Apply S to aSb at the start, leaving one S."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02"
          ],
          "explanation": {
            "zh-Hant": "此時仍有nonterminal，尚非terminal-only結束。",
            "en": "A nonterminal remains, so this is not a terminal-only endpoint."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S04",
        "uses": [
          "G1",
          "S02",
          "S03"
        ],
        "before_tex": "aSb",
        "after_tex": "aaSbb",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "只替換中間S，以外的a、b保持順序。",
          "en": "Replace only the central S, preserving the surrounding terminals' order."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "S03"
          ],
          "explanation": {
            "zh-Hant": "不能同時把前面的terminal a改成S。",
            "en": "A previously produced terminal a cannot be rewritten as S."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S05",
        "uses": [
          "G1",
          "S02",
          "S04"
        ],
        "before_tex": "aaSbb",
        "after_tex": "aaaSbbb",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "再用同一production產生第三對a、b。",
          "en": "Use the same production again to create a third a,b pair."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "S04"
          ],
          "explanation": {
            "zh-Hant": "每步lhs是實際存在的單一S，沒有跳步換整個word。",
            "en": "Each step rewrites the actual single S rather than replacing an arbitrary whole word."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S06",
        "uses": [
          "G1",
          "S02",
          "S05"
        ],
        "before_tex": "aaaSbbb",
        "after_tex": "aaabbb",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "使用S→ε刪去唯一S，不消除或重排terminal。",
          "en": "Use S to epsilon to remove the sole S without deleting or reordering terminals."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "S05"
          ],
          "explanation": {
            "zh-Hant": "ε替換長度0，因此不輸出字母epsilon。",
            "en": "An epsilon replacement has length zero and does not output a letter called epsilon."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S07",
        "uses": [
          "G1",
          "S03",
          "S04",
          "S05",
          "S06"
        ],
        "before_tex": "S\\Rightarrow aSb\\Rightarrow aaSbb\\Rightarrow aaaSbbb\\Rightarrow aaabbb",
        "after_tex": "aaabbb\\in L(G)",
        "relation": "implies",
        "rule": "mko_definition",
        "conditions": [],
        "explanation": {
          "zh-Hant": "四步有限合法production序列結束於純terminal字，認證membership。",
          "en": "Four legal production steps end at a terminal-only word, certifying membership."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S03",
            "S04",
            "S05",
            "S06"
          ],
          "explanation": {
            "zh-Hant": "此witness只證這個word，未自動證grammar無歧義。",
            "en": "This witness certifies this word only, not unambiguity."
          }
        },
        "leaf_basis": "mko_definition"
      },
      {
        "id": "S08",
        "uses": [
          "G1",
          "S02",
          "S07"
        ],
        "before_tex": "S\\Rightarrow\\varepsilon",
        "after_tex": "\\varepsilon\\in L(G),\\quad L(G)\\ne\\varnothing",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "直接空production亦給有限witness；含空字的language不是空language。",
          "en": "The empty production gives another finite witness; a language containing epsilon is not empty."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "S07"
          ],
          "explanation": {
            "zh-Hant": "ε是集合的一個元素，∅則沒有元素。",
            "en": "Epsilon is an element of the language, whereas the empty language has no elements."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S09",
        "uses": [
          "G1",
          "S03",
          "S04",
          "S05",
          "S06",
          "S07"
        ],
        "before_tex": "\\text{search depth }2",
        "after_tex": "aaabbb\\text{ not found by depth 2, but has the depth-4 witness above}",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "深度不足的搜尋未命中不證非membership，這裡已有確切反例。",
          "en": "A too-shallow search does not prove nonmembership, as the exact depth-four witness shows."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S03",
            "S04",
            "S05",
            "S06",
            "S07"
          ],
          "explanation": {
            "zh-Hant": "只有本grammar的完整witness足以接受，不借CFG-PDA等價。",
            "en": "The grammar's explicit witness suffices without invoking CFG-PDA equivalence."
          }
        },
        "leaf_basis": "calc"
      }
    ],
    "result": {
      "zh-Hant": "grammar S→aSb或ε具有aaabbb與ε的有限推導witness。",
      "en": "The grammar S to aSb or epsilon has finite derivation witnesses for aaabbb and epsilon."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "aaSbb已是language中的terminal word。",
          "en": "aaSbb is already a terminal word in the language."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "它仍含nonterminal S。",
          "en": "It still contains nonterminal S."
        }
      },
      {
        "claim": {
          "zh-Hant": "因可導出ε，language是空集。",
          "en": "Deriving epsilon makes the language empty."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "ε本身已是一個元素，且aaabbb亦在內。",
          "en": "Epsilon is already an element, and aaabbb is another."
        }
      },
      {
        "claim": {
          "zh-Hant": "depth2未命中aaabbb證拒絕。",
          "en": "No hit at depth 2 rejects aaabbb."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "上面depth4完整推導認證membership。",
          "en": "The explicit depth-four derivation certifies membership."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "calc",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "假設有限集合、有限字串與索引、逐步函數更新及自然數歸納；ε表示長度0字串。",
          "en": "Assume finite sets, finite strings and indices, stepwise function updates and induction on natural numbers; epsilon denotes the length-zero word."
        }
      },
      {
        "id": "mko_definition",
        "kind": "cited",
        "statement": {
          "zh-Hant": "rhs為terminal/nonterminal finite strings並明示epsilon convention。derivation是finite production sequence；language只含start導出的terminal-only words。空語言不等於含epsilon。witness證membership，但bounded search failure不證nonmembership，亦不自動推unambiguous、regular或PDA equivalence。",
          "en": "Each right side is a finite string over terminal and nonterminal symbols, with the epsilon convention explicit. A derivation is a finite production sequence. The generated language contains only terminal-only words derivable from the start. The empty language is not a language containing epsilon. A derivation witness proves membership, but bounded-search failure does not prove nonmembership. Unambiguity, regularity and CFG-PDA equivalence do not follow automatically."
        },
        "source": {
          "mko_id": "mko-context-free-grammar",
          "sha256": "0cffcd9eae42c9318c21e6233a518469b8747f149bd785b0f4c94ecbe19ea685",
          "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f"
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": []
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "grammar合法性與指定word membership分開，不宣稱regularity或CFG-PDA等價。",
      "en": "Grammar qualification and specified-word membership are separate; no regularity or CFG-PDA equivalence claim."
    },
    "md_symbols": [
      [
        "N,\\Sigma",
        "nonterminal與terminal集合",
        "nonterminal and terminal sets"
      ],
      [
        "P",
        "完整production集合",
        "complete production set"
      ]
    ],
    "md_error_controls": [
      {
        "title": "終點純terminal / Terminal-only endpoint",
        "zh": "中途含S的sentential form不算接受word。",
        "en": "A sentential form containing S is not an accepted terminal word."
      },
      {
        "title": "production位置 / Production location",
        "zh": "每步只替換合法lhs出現處，保持其他symbols順序。",
        "en": "Rewrite only a valid lhs occurrence and preserve other symbols' order."
      }
    ],
    "md_open_items": []
  },
  "revision": {
    "id": "ocme-new142-reader-adoption-20261021",
    "collection": "coverage-20261021",
    "source_commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
    "adopted_source_sha256": "a8dca2b816c0c085ecbc6756e9970e00e0953a31ba8d0a4e35d497a9265aa220",
    "original_source_sha256": "a8dca2b816c0c085ecbc6756e9970e00e0953a31ba8d0a4e35d497a9265aa220",
    "owner_adopted": true,
    "bilingual_sync": "complete_source_bound",
    "formal_Lean": "NOT_RUN",
    "reader_review": "142_of_142_source_bound",
    "wording_review": "original_Lead_decisions_resolved",
    "glossary_reader_paraphrases": [],
    "independent_AI_concurrence": "SCOPED_LEAD_AND_BILINGUAL_CONTEXT_REVIEW",
    "issue_ids": [],
    "parent_manifest_sha256": "d29f4cae8229ebd24f60d496cb1d3cd4ad8c0a4dca9d44daab0c3245c544283a",
    "scope": "Owner-adopted reader revision. Lead and bilingual review concern the recorded text and premises; no new universal or Lean proof, canonical promotion or historical-label rewrite."
  }
}
