{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-regular-language-01",
  "mko_id": "mko-regular-language",
  "title": {
    "zh-Hant": "任意字長的parity invariant",
    "en": "A parity invariant for arbitrary word length"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-regular-language-01",
    "source": {
      "mko_id": "mko-regular-language",
      "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
      "sha256": "5b76e4da673cf35d7a7014ce76f103fa504f5f9986498711ed877c15dc35e57a",
      "english_sha256": "b6bfb3d62bc7ec660a984b86c35cabf78b5826bddd2394009ea358db21f4038a"
    },
    "mode": "theorem_proof",
    "audience_prerequisites": [
      "calc"
    ],
    "goal": {
      "zh-Hant": "Σ={0,1}上含偶數個1的全部word構成正規語言。",
      "en": "All words over {0,1} with an even number of 1s form a regular language."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "Q={E,O}，Σ={0,1}，start E，finals{E}；轉移E0→E,E1→O,O0→O,O1→E；L={w:1出現偶數次}。",
          "en": "Q={E,O}, alphabet={0,1}, start E, finals {E}; transitions E0 to E,E1 to O,O0 to O,O1 to E; L consists of words with an even number of 1s."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1"
        ],
        "before_tex": "Q\\times\\Sigma\\text{ has four pairs}",
        "after_tex": "\\begin{array}{c|cc}\\delta&0&1\\\\\\hline E&E&O\\\\O&O&E\\end{array}",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "完整四格每格一個合法輸出，所以此DFA可讀任意有限word。",
          "en": "All four cells have one valid output, so the DFA can read every finite word."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1"
          ],
          "explanation": {
            "zh-Hant": "此資格只保證模型有效，還需不變量才能認證指定L。",
            "en": "Model qualification alone is not recognition of the specified L; an invariant is still required."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S02",
        "uses": [
          "G1",
          "S01"
        ],
        "before_tex": "c(w)=\\#\\{i:w_i=1\\}",
        "after_tex": "I(w):\\ \\delta^*(E,w)=E\\iff c(w)\\equiv0\\pmod2",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "明示全稱目標不變量：狀態記錄prefix中1數的奇偶。",
          "en": "State the universal target invariant: the state records parity of the count of 1s in the prefix."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01"
          ],
          "explanation": {
            "zh-Hant": "只說E代表even是命名，必用下面歸納證。",
            "en": "Naming E 'even' is not proof; induction below is required."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S03",
        "uses": [
          "G1",
          "S02"
        ],
        "before_tex": "w=\\varepsilon",
        "after_tex": "c(\\varepsilon)=0,\\quad\\delta^*(E,\\varepsilon)=E\\Rightarrow I(\\varepsilon)",
        "relation": "induction_base",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "歸納基礎：零個1為偶數且未讀字留E。",
          "en": "Base case: the empty word contains zero 1s, an even count, and with no input consumed the automaton remains in state E."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02"
          ],
          "explanation": {
            "zh-Hant": "ε不是字元，所以不計一個1或0。",
            "en": "Epsilon is not a character and contributes no symbol count."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S04",
        "uses": [
          "G1",
          "S01",
          "S02"
        ],
        "before_tex": "I(w),\\quad w'=w0",
        "after_tex": "c(w0)=c(w),\\quad\\delta(E,0)=E,\\ \\delta(O,0)=O\\Rightarrow I(w0)",
        "relation": "induction_step",
        "rule": "calc",
        "conditions": [
          "the induction hypothesis I(w) holds"
        ],
        "explanation": {
          "zh-Hant": "加0保持計數與狀態，所以兩種原奇偶均保留不變量。",
          "en": "Appending 0 preserves both count and state, covering either prior parity."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "S02"
          ],
          "explanation": {
            "zh-Hant": "E與O的0轉移都核到，不能只核even分支。",
            "en": "Both E and O zero-transitions are checked, not only the even case."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S05",
        "uses": [
          "G1",
          "S01",
          "S02"
        ],
        "before_tex": "I(w),\\quad w'=w1",
        "after_tex": "c(w1)=c(w)+1,\\quad E\\xrightarrow{1}O,\\ O\\xrightarrow{1}E\\Rightarrow I(w1)",
        "relation": "induction_step",
        "rule": "calc",
        "conditions": [
          "the induction hypothesis I(w) holds"
        ],
        "explanation": {
          "zh-Hant": "加1同時翻轉奇偶與狀態，兩種分支均匹配。",
          "en": "Appending 1 flips both parity and state, matching both cases."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "S02"
          ],
          "explanation": {
            "zh-Hant": "轉移O1→E確保奇數再加1變偶數，不漏反方向。",
            "en": "O1 to E ensures odd plus one becomes even, covering the reverse direction too."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S06",
        "uses": [
          "G1",
          "S03",
          "S04",
          "S05"
        ],
        "before_tex": "I(\\varepsilon),\\quad I(w)\\Rightarrow I(w0),I(w1)",
        "after_tex": "\\forall w\\in\\{0,1\\}^*:\\ I(w)",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "每個有限word由空字逐次加0或1形成，字長歸納完成全語言不變量。",
          "en": "Every finite word is formed from epsilon by appending 0 or 1, so induction proves the whole-language invariant."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S03",
            "S04",
            "S05"
          ],
          "explanation": {
            "zh-Hant": "任意字長由歸納覆蓋，不依測試長度上限。",
            "en": "Induction covers arbitrary length without a test cutoff."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S07",
        "uses": [
          "G1",
          "S01",
          "S06"
        ],
        "before_tex": "F=\\{E\\},\\quad\\forall w:\\ I(w)",
        "after_tex": "w\\text{ accepted}\\iff w\\in L\\Rightarrow L\\text{ regular}",
        "relation": "implies",
        "rule": "mko_definition",
        "conditions": [],
        "explanation": {
          "zh-Hant": "完整DFA接受恰當偶數1，所以它是L的全稱recognition證書。",
          "en": "The complete DFA accepts exactly words with even 1-count, a universal recognition certificate for L."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "S06"
          ],
          "explanation": {
            "zh-Hant": "兩方向都來自I(w)，不僅L包含在接受language。",
            "en": "Both directions follow from I(w), not merely inclusion of L in the accepted language."
          }
        },
        "leaf_basis": "mko_definition"
      },
      {
        "id": "S08",
        "uses": [
          "G1",
          "S06",
          "S07"
        ],
        "before_tex": "w=1011,\\quad v=1010",
        "after_tex": "c(w)=3\\Rightarrow w\\notin L;\\quad c(v)=2\\Rightarrow v\\in L",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "兩個例子說明既證不變量，並不代替證明。",
          "en": "Two examples illustrate the proven invariant without replacing the proof."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S06",
            "S07"
          ],
          "explanation": {
            "zh-Hant": "有限樣本可由很多不同language共享，因此不能單靠樣本宣稱equivalence。",
            "en": "Many different languages share finite samples, so samples alone cannot certify equivalence."
          }
        },
        "leaf_basis": "calc"
      }
    ],
    "result": {
      "zh-Hant": "Σ={0,1}上含偶數個1的全部word構成正規語言。",
      "en": "All words over {0,1} with an even number of 1s form a regular language."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "測完長度≤4便證L正規。",
          "en": "Testing lengths at most 4 proves L regular."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "需任意字長的完整DFA不變量，有限樣本不決定整個language。",
          "en": "A complete DFA invariant for arbitrary length is required; finite samples do not determine a language."
        }
      },
      {
        "claim": {
          "zh-Hant": "含奇數個1也在L。",
          "en": "Words with an odd number of 1s lie in L."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "不變量送到非final O，例如word1。",
          "en": "The invariant ends at nonfinal O, for example word 1."
        }
      },
      {
        "claim": {
          "zh-Hant": "此證書自動證兩個任意DFA等價。",
          "en": "This certificate proves any two DFAs equivalent."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "只認證這一台DFA與明示L。",
          "en": "It certifies this DFA and the specified L only."
        }
      }
    ],
    "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": "DFA certificate須涵蓋宣告alphabet上的任意有限word。mod-count/parity語言以state invariant對任意字長證明；有限語言可用prefix-trie DFA構造。有限測試字不足以證regularity或language equivalence。",
          "en": "The DFA certificate must cover every finite word over the declared alphabet. Mod-count and parity languages use a state invariant valid for arbitrary word length; a finite language can use a prefix-trie DFA construction. Finitely many tested words do not prove regularity or language equivalence."
        },
        "source": {
          "mko_id": "mko-regular-language",
          "sha256": "5b76e4da673cf35d7a7014ce76f103fa504f5f9986498711ed877c15dc35e57a",
          "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f"
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": []
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "完整DFA與對任意prefix的歸納不變量；不引入regex或NFA。",
      "en": "A complete DFA and an invariant for every prefix; no regex or NFA machinery."
    },
    "md_symbols": [
      [
        "c(w)",
        "word中1的數量",
        "number of 1s in the word"
      ],
      [
        "I(w)",
        "prefix parity不變量",
        "prefix-parity invariant"
      ]
    ],
    "md_error_controls": [
      {
        "title": "全稱不變量 / Universal invariant",
        "zh": "以字長歸納，不以有限測試清單證L。",
        "en": "Use induction on length, not a finite test list for L."
      },
      {
        "title": "兩方向 / Both directions",
        "zh": "末態E iff even，須含接受與不接受兩邊。",
        "en": "Final state E iff even must cover both acceptance and nonacceptance."
      }
    ],
    "md_open_items": []
  },
  "revision": {
    "id": "ocme-new142-reader-adoption-20261021",
    "collection": "coverage-20261021",
    "source_commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
    "adopted_source_sha256": "8b3f94b7386f3cfa6772b2ab39314f3cdfe8dbb931e9468ee42f746ee7293ecb",
    "original_source_sha256": "1805ff983292495019f5c1345bf8dfe377b3ed25ba222aa28cd86de46fed3f90",
    "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": [
      "BR142-P016"
    ],
    "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."
  }
}
