{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-regular-expression-01",
  "mko_id": "mko-regular-expression",
  "title": {
    "zh-Hant": "含epsilon的star閉包與完整長度切片",
    "en": "Star closure with epsilon and a complete length slice"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-regular-expression-01",
    "source": {
      "mko_id": "mko-regular-expression",
      "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
      "sha256": "0d4eaa52f48c71240a6e4166e4f1a4ddb3b607f21c102c49d944833b87583695",
      "english_sha256": "22c20144ec938506d8fa94ef6bff9ebea017c5799c2428a541f7b478c7e8182e"
    },
    "mode": "worked_example",
    "audience_prerequisites": [
      "work"
    ],
    "goal": {
      "zh-Hant": "typed AST遞迴語義、完整bounded枚舉與membership責任。",
      "en": "Give typed AST semantics, complete bounded enumeration and membership obligations."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "Σ={a,b}。R=concat(star(union(epsilon,symbol(a))),symbol(b))；empty-language記作∅，epsilon語言為{ε}。",
          "en": "Sigma={a,b}. R=concat(star(union(epsilon,symbol(a))),symbol(b)); empty-language is denoted emptyset and the epsilon language is{epsilon}."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1",
          "work"
        ],
        "before_tex": "R=\\operatorname{concat}(\\operatorname{star}(\\operatorname{union}(\\varepsilon,a)),b)",
        "after_tex": "\\text{union binary, concat binary, star unary; }a,b\\in\\Sigma",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "完整驗AST節點型別、arity與alphabet資格。",
          "en": "Validate all AST node types, arities and alphabet symbols."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "work"
          ],
          "explanation": {
            "zh-Hant": "star作用在子語言，不是shell任意字串wildcard。",
            "en": "Star applies to a sublanguage, not a shell arbitrary-string wildcard."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S02",
        "uses": [
          "G1",
          "S01",
          "work"
        ],
        "before_tex": "L(\\varepsilon)=\\{\\varepsilon\\},\\quad L(a)=\\{a\\}",
        "after_tex": "K=L(\\operatorname{union}(\\varepsilon,a))=\\{\\varepsilon,a\\}",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "union合併語言元素並去重。",
          "en": "Union combines language elements extensionally with deduplication."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "work"
          ],
          "explanation": {
            "zh-Hant": "empty-language與{epsilon}不同，前者沒有元素。",
            "en": "The empty language differs from{epsilon}; it contains no element."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S03",
        "uses": [
          "G1",
          "S02",
          "work"
        ],
        "before_tex": "S_0=\\{\\varepsilon\\},\\quad S_{j+1}=S_j\\cup\\{uv:u\\in S_j,v\\in K,|uv|\\le3\\}",
        "after_tex": "S_1=\\{\\varepsilon,a\\}",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "bounded star用set固定點closure，乘epsilon不新增元素。",
          "en": "Bounded star uses set fixed-point closure; multiplying by epsilon adds nothing new."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "work"
          ],
          "explanation": {
            "zh-Hant": "去重使epsilon cycle不產生無限重複。",
            "en": "Deduplication prevents infinite repetition from epsilon cycles."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S04",
        "uses": [
          "G1",
          "S03",
          "work"
        ],
        "before_tex": "S_1=\\{\\varepsilon,a\\}",
        "after_tex": "S_2=\\{\\varepsilon,a,aa\\},\\quad S_3=\\{\\varepsilon,a,aa,aaa\\},\\quad S_4=S_3",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "完整固定點在第四輪穩定，所有長度≤3的a串都列出。",
          "en": "The fourth round stabilizes, listing every a-string of length≤3."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S03",
            "work"
          ],
          "explanation": {
            "zh-Hant": "其他symbol不在K，故不會產生b或混合串。",
            "en": "No other symbol belongs to K, so no b or mixed string is generated."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S05",
        "uses": [
          "G1",
          "S04",
          "work"
        ],
        "before_tex": "L(R)=K^*\\{b\\}",
        "after_tex": "L(R)\\cap\\Sigma^{\\le3}=\\{b,ab,aab\\}",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "ordered concat在右附b，僅保留總長度≤3。",
          "en": "Ordered concatenation appends b on the right, retaining total length≤3."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S04",
            "work"
          ],
          "explanation": {
            "zh-Hant": "aaab長度4，不在此slice但可在完整language。",
            "en": "aaab has length4 and lies outside this slice but may belong to the full language."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S06",
        "uses": [
          "G1",
          "S05",
          "work"
        ],
        "before_tex": "K^*=\\{a^m:m\\in\\mathbb N_0\\}",
        "after_tex": "L(R)=\\{a^mb:m\\in\\mathbb N_0\\}",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "任意K因子不是epsilon就是a，故concat只計a個數；反向可用m個a因子。",
          "en": "Every K factor is epsilon or a, so concatenation counts a's only; conversely use m a-factors."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S05",
            "work"
          ],
          "explanation": {
            "zh-Hant": "這是雙向全m語義證明，不由bounded清單推無限語言。",
            "en": "This is a two-way all-m semantic proof, not inference from the bounded list."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S07",
        "uses": [
          "G1",
          "S06",
          "work"
        ],
        "before_tex": "w=aaab,\\quad |w|=4",
        "after_tex": "w=a^3b\\in L(R),\\quad w\\notin\\{b,ab,aab\\}",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "完整membership由語義判true，長度3清單缺席不能判false。",
          "en": "Full semantics decides membership true; absence from the length3 list cannot imply false."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S06",
            "work"
          ],
          "explanation": {
            "zh-Hant": "若用bounded membership，至少用完整長度4 slice。",
            "en": "A bounded membership procedure needs at least a complete length4 slice."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S08",
        "uses": [
          "G1",
          "S07",
          "work"
        ],
        "before_tex": "\\operatorname{concat}(b,\\operatorname{star}(a))",
        "after_tex": "b\\{a^m:m\\ge0\\}\\ne\\{a^mb:m\\ge0\\}\\quad(ab\\text{ witnesses})",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "concat不可交換：ab在R但不在ba*。",
          "en": "Concatenation is not commutative: ab lies in R but not in ba*."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S07",
            "work"
          ],
          "explanation": {
            "zh-Hant": "union可按排列及idempotence canonicalize，但concat須保序。",
            "en": "Union admits permutation and idempotence canonicalization, but concatenation preserves order."
          }
        },
        "leaf_basis": "work"
      }
    ],
    "result": {
      "zh-Hant": "完整語言為{a^m b:m≥0}；長度≤3切片為{b,ab,aab}，aaab仍是member。",
      "en": "The full language is{a^m b:m≥0}; its length≤3 slice is{b,ab,aab}, while aaab is still a member."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "∅與{ε}相同。",
          "en": "The empty language equals{epsilon}."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "後者有一元素空word，前者無元素。",
          "en": "The latter contains one empty word; the former contains none."
        }
      },
      {
        "claim": {
          "zh-Hant": "aaab沒在長度3清單故非member。",
          "en": "aaab is a nonmember because absent from the length3 list."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "aaab=a³b，符合完整語義且長度4超出slice。",
          "en": "aaab=a³b satisfies full semantics and has length4 outside the slice."
        }
      },
      {
        "claim": {
          "zh-Hant": "concat可交換左右。",
          "en": "Concatenation may swap operands."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "ab在a*b但不在ba*。",
          "en": "ab belongs to a*b but not ba*."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "mko_definition",
        "kind": "cited",
        "statement": {
          "zh-Hant": "typed AST只允許empty-language、epsilon、alphabet symbol、union、ordered concatenation與star；每個symbol須屬明示alphabet。語義遞迴定義language，star的bounded enumeration以fixed-point closure處理epsilon cycle並extensional dedup。word membership必須完整決定，不因某個不足的bound沒列出就判false。Union canonicalize permutation/idempotence，concatenation保留次序。empty language與{epsilon}、regex與shell wildcard分開；長度≤N語言相同不證全語言等價。",
          "en": "The typed AST permits only empty-language, epsilon, alphabet symbols, union, ordered concatenation and star; every symbol belongs to the explicit alphabet. Its language is defined recursively. Bounded star enumeration uses fixed-point closure with extensional deduplication to terminate epsilon cycles. Word membership must be decided with a sufficient complete length slice, not by absence from an insufficient bound. Unions are canonicalized under permutation and idempotence, while concatenation order is retained. The empty language differs from the language containing the empty word, a shell wildcard is not this core regex AST, and equality through length N does not imply equality of the full languages."
        },
        "source": {
          "mko_id": "mko-regular-expression",
          "sha256": "0d4eaa52f48c71240a6e4166e4f1a4ddb3b607f21c102c49d944833b87583695",
          "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f"
        }
      },
      {
        "id": "work",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "core regex遞迴語義：empty無word，epsilon含空word，union為聯集，concat為ordered word乘積，star為全部有限次concat；bounded closure以set去重。",
          "en": "Core regex semantics: empty has no words, epsilon contains the empty word, union is set union, concatenation is ordered word product, and star takes all finite concatenations; bounded closure deduplicates sets."
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": [
      {
        "id": "N01",
        "lhs": "3+1",
        "rhs": "4"
      },
      {
        "id": "N02",
        "lhs": "3",
        "rhs": "3"
      }
    ]
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "Σ={a,b}；只把長度≤3的清單標成切片。",
      "en": "Sigma={a,b}; the length≤3 list is explicitly only a slice."
    },
    "md_symbols": [
      [
        "K",
        "star的子語言",
        "sublanguage under star"
      ],
      [
        "S_j",
        "bounded closure迭代",
        "bounded closure iterate"
      ]
    ],
    "md_error_controls": [
      {
        "title": "epsilon去重 / Epsilon deduplication",
        "zh": "closure用集合，epsilon乘積不新增副本。",
        "en": "Use sets so epsilon products add no duplicate copies."
      },
      {
        "title": "slice標記 / Slice label",
        "zh": "每個bounded結果標長度上限，不推完整等價。",
        "en": "Label every bounded result with its length limit, without inferring full equivalence."
      }
    ],
    "md_open_items": []
  },
  "revision": {
    "id": "ocme-new142-reader-adoption-20261021",
    "collection": "coverage-20261021",
    "source_commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
    "adopted_source_sha256": "477a3a7c717c0ddf0f6208cbbf27ebde9d4743b8722ed272a842db0e6b108780",
    "original_source_sha256": "477a3a7c717c0ddf0f6208cbbf27ebde9d4743b8722ed272a842db0e6b108780",
    "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."
  }
}
