{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-decision-problem-01",
  "mko_id": "mko-decision-problem",
  "title": {
    "zh-Hant": "決定問題：在明示有限輸入集上證明試除程序是 decider",
    "en": "Decision problem: proving that a trial-division procedure is a decider on an explicit finite input set"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-decision-problem-01",
    "source": {
      "mko_id": "mko-decision-problem",
      "commit": "b28a5edbd46279b1db2a3f3f48bb3f447e18899f",
      "sha256": "b63ff13299c4ce36349133c27ce4fdcc5554615d69e54610ae5c15fe80b3005c",
      "english_sha256": "ea9f55d1d06832146b0c1590a032bb035bede7246808b7b7cbccd14bd7dd4285"
    },
    "mode": "definition_walkthrough",
    "audience_prerequisites": [
      "set_builder",
      "divides_def",
      "order_basics",
      "numeric_evaluation",
      "prime_def",
      "while_semantics"
    ],
    "goal": {
      "zh-Hant": "取輸入集合 X={0,1,2,3,4,5,6,7,8,9}、規格 P(x)：「x 是質數」與 yes-instance 集合 Y={x∈X ∣ P(x)}。在明示的 while 程式計算模型 W 中，證明試除程序 D1 對每個 x∈X 都終止，且 D1(x)=true 當且僅當 x∈Y，因此 D1 是 (X,Y) 的 decider；再說明只在 yes-instance 上停止的 D2 與只看奇偶的 D3 都不是 decider。",
      "en": "Take the input set X={0,1,2,3,4,5,6,7,8,9}, the specification P(x): 'x is prime', and the yes-instance set Y={x∈X ∣ P(x)}. In the explicit while-program model W, prove that the trial-division procedure D1 terminates on every x∈X and that D1(x)=true exactly when x∈Y, so D1 is a decider for (X,Y); then show that D2, which halts only on yes-instances, and D3, which tests only parity, are not deciders."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "輸入集合 X={0,1,2,3,4,5,6,7,8,9} 是明示列出的有限集合；規格 P(x) 為「x 是質數」；yes-instance 集合 Y={x∈X ∣ P(x)}，所以 Y⊆X（MKO 假設 a1）。",
          "en": "The input set X={0,1,2,3,4,5,6,7,8,9} is an explicitly listed finite set; the specification P(x) is 'x is prime'; the yes-instance set is Y={x∈X ∣ P(x)}, so Y⊆X (MKO assumption a1)."
        }
      },
      {
        "id": "G2",
        "statement": {
          "zh-Hant": "計算模型 W：以自然數變數為狀態的確定性 while 程式。輸入 x 以自然數值給出（例如二進位數字串）。基本操作為兩數比較、加 1、d≥1 時求餘數 x mod d、賦值與 return v，各算一步。若程式在有限步內執行到 return，就稱它在 x 上終止，輸出是 return 的值；永遠不執行 return 的執行不終止（MKO 假設 a2）。",
          "en": "Computational model W: deterministic while-programs whose states are values of natural-number variables. The input x is given as a natural-number value (for example its binary numeral). The basic operations are comparing two numbers, adding 1, the remainder x mod d for d≥1, assignment and 'return v', each counted as one step. A program terminates on x if it executes a return after finitely many steps, and its output is the returned value; a run that never executes return does not terminate (MKO assumption a2)."
        }
      },
      {
        "id": "G3",
        "statement": {
          "zh-Hant": "候選程序。D1(x)：第 1 行 若 x<2 則 return false；第 2 行 d:=2；第 3 行 while d<x do（若 x mod d=0 則 return false；d:=d+1）；第 4 行 return true。D2(x)：照 D1 的程式文字執行；若 D1 會 return true 就 return true；若 D1 會 return false，改為執行 while true do skip（永不 return）。D3(x)：return（x mod 2=1）。",
          "en": "Candidate procedures. D1(x): line 1, if x<2 then return false; line 2, d:=2; line 3, while d<x do (if x mod d=0 then return false; d:=d+1); line 4, return true. D2(x): run the text of D1; if D1 would return true, return true; if D1 would return false, instead execute 'while true do skip' (never returns). D3(x): return (x mod 2=1)."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1"
        ],
        "before_tex": "P(x):\\ x\\ \\text{is prime},\\quad x\\in X",
        "after_tex": "Y=\\{x\\in X\\mid P(x)\\}",
        "relation": "definition",
        "rule": "set_builder",
        "conditions": [
          "X=\\{0,1,2,3,4,5,6,7,8,9\\}"
        ],
        "explanation": {
          "zh-Hant": "把問題寫成一對 (X,Y)：Y 由規格 P 以集合建構式定義，x∈Y 表示 x∈X 且 P(x)。Y 是正確答案的描述，與任何候選程序無關；D1、D2、D3 只是之後要拿來和 Y 比對的實作（MKO 第一段：規格與實作分開）。",
          "en": "Write the problem as a pair (X,Y): Y is defined from the specification P by set-builder notation, and x∈Y means x∈X and P(x). Y describes the correct answers and does not depend on any candidate program; D1, D2 and D3 are implementations to be compared with Y later (MKO paragraph 1: specification and implementation are separate)."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "set_builder",
            "mko_decision_problem_def"
          ],
          "explanation": {
            "zh-Hant": "此步只命名，不推出新事實。Y⊆X 直接來自集合建構式只收 X 的元素；不能反過來用某個程序的輸出來定義 Y。",
            "en": "This step only names and derives no new fact. Y⊆X holds because set-builder notation only collects elements of X; Y may not be defined backwards from the outputs of some program."
          }
        },
        "leaf_basis": "set_builder + def_intro"
      },
      {
        "id": "S02",
        "uses": [
          "S01",
          "G1"
        ],
        "before_tex": "Y=\\{x\\in X\\mid P(x)\\}",
        "after_tex": "Y=\\{2,3,5,7\\}",
        "relation": "implies",
        "rule": "prime_def",
        "conditions": [
          "X\\ \\text{finite and listed}"
        ],
        "explanation": {
          "zh-Hant": "對 X 的十個元素逐一判定 P(x)。X 是明示有限集合，所以逐一檢查全部元素就得到 Y 的完整列表；判定細節在 S02.1 到 S02.3。結果 Y={2,3,5,7}。",
          "en": "Decide P(x) for each of the ten elements of X. X is an explicitly listed finite set, so checking every element yields the complete list of Y; the details are in S02.1 to S02.3. The result is Y={2,3,5,7}."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S01",
            "prime_def",
            "finite_exhaustion"
          ],
          "explanation": {
            "zh-Hant": "需要質數的定義與 X 的完整列表。結論是兩個集合相等，靠的是十個元素都被檢查過；若漏掉任一元素就不能寫等號。",
            "en": "It needs the definition of prime and the complete list of X. The conclusion is an equality of sets, and it rests on all ten elements having been checked; leaving out any element would not justify the equality."
          }
        },
        "leaf_basis": "prime_def + divides_def + numeric_evaluation + finite_exhaustion"
      },
      {
        "id": "S02.1",
        "uses": [
          "S01"
        ],
        "before_tex": "x\\in\\{0,1\\}",
        "after_tex": "0\\notin Y,\\ 1\\notin Y",
        "relation": "implies",
        "rule": "prime_def",
        "conditions": [
          "x<2"
        ],
        "explanation": {
          "zh-Hant": "質數必須 ≥2；0 與 1 都小於 2，所以 P(0)、P(1) 為假，0、1 不在 Y。",
          "en": "A prime must be at least 2; 0 and 1 are less than 2, so P(0) and P(1) are false and 0, 1 are not in Y."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "prime_def"
          ],
          "explanation": {
            "zh-Hant": "只用到定義中的條件 p≥2。不宣稱反向：x≥2 不足以推出 x 是質數。",
            "en": "Only the clause p≥2 of the definition is used. No converse is claimed: x≥2 alone does not make x prime."
          }
        },
        "leaf_basis": "prime_def + order_basics"
      },
      {
        "id": "S02.2",
        "uses": [
          "S01"
        ],
        "before_tex": "x\\in\\{4,6,8,9\\}",
        "after_tex": "4=2\\cdot 2,\\ 6=2\\cdot 3,\\ 8=2\\cdot 4,\\ 9=3\\cdot 3\\ \\Rightarrow\\ 4,6,8,9\\notin Y",
        "relation": "implies",
        "rule": "divides_def",
        "conditions": [
          "2\\le d\\le x-1"
        ],
        "explanation": {
          "zh-Hant": "依整除定義，2∣4、2∣6、2∣8、3∣9，而且 2 與 3 都滿足 2≤d≤x−1。依 prime_def 的等價形式，這四個數不是質數，不在 Y。",
          "en": "By the definition of divisibility, 2∣4, 2∣6, 2∣8 and 3∣9, and in each case 2≤d≤x−1. By the equivalent form in prime_def these four numbers are not prime and are not in Y."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "divides_def",
            "prime_def"
          ],
          "explanation": {
            "zh-Hant": "每個數只需一個在 2 到 x−1 之間的因數見證（N1、N2 可重算）。見證必須在這個範圍內：d=1 或 d=x 永遠整除 x，不能當見證。",
            "en": "Each number needs only one divisor witness between 2 and x−1 (recomputable as N1, N2). The witness must lie in that range: d=1 and d=x always divide x and do not count."
          }
        },
        "leaf_basis": "divides_def + prime_def + numeric_evaluation"
      },
      {
        "id": "S02.3",
        "uses": [
          "S01"
        ],
        "before_tex": "x\\in\\{2,3,5,7\\}",
        "after_tex": "2,3,5,7\\in Y",
        "relation": "implies",
        "rule": "prime_def",
        "conditions": [
          "x\\ge 2",
          "x\\bmod d\\ne 0\\ \\text{for}\\ 2\\le d\\le x-1"
        ],
        "explanation": {
          "zh-Hant": "x=2 時 2≤d≤1 的範圍是空的；3 mod 2=1；5 除以 2、3、4 的餘數為 1、2、1；7 除以 2、3、4、5、6 的餘數為 1、1、3、2、1。這些數都 ≥2 且在 2 到 x−1 之間沒有因數，依 prime_def 都是質數。",
          "en": "For x=2 the range 2≤d≤1 is empty; 3 mod 2=1; the remainders of 5 by 2, 3, 4 are 1, 2, 1; the remainders of 7 by 2, 3, 4, 5, 6 are 1, 1, 3, 2, 1. Each of these numbers is at least 2 and has no divisor between 2 and x−1, so by prime_def each is prime."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "prime_def",
            "numeric_evaluation"
          ],
          "explanation": {
            "zh-Hant": "要證明「沒有」因數，必須檢查 2 到 x−1 的每一個 d，不能只試 2（N3、N4 是對這幾個 d 的完整有限核對）。",
            "en": "To show there is no divisor, every d from 2 to x−1 must be checked, not only d=2 (N3 and N4 are the complete finite checks over exactly these d)."
          }
        },
        "leaf_basis": "prime_def + divides_def + numeric_evaluation"
      },
      {
        "id": "S03",
        "uses": [
          "G2",
          "mko_decision_problem_def"
        ],
        "before_tex": "D\\ \\text{decides}\\ (X,Y)\\ \\text{in}\\ W",
        "after_tex": "(\\forall x\\in X,\\ D\\ \\text{terminates on}\\ x)\\ \\wedge\\ (\\forall x\\in X,\\ D(x)=\\mathrm{true}\\iff x\\in Y)",
        "relation": "equivalent",
        "rule": "def_unfold",
        "conditions": [
          "W\\ \\text{fixed (G2)}"
        ],
        "explanation": {
          "zh-Hant": "展開 MKO 的 decider 定義，得到兩個條款：(T) 對每個 x∈X 都終止；(C) 終止時輸出 true 恰好對應 x∈Y。兩個條款都量化在整個 X 上，而且都相對於固定的模型 W。之後分別為 D1 證明 (T) 與 (C)。",
          "en": "Unfold the MKO's definition of a decider into two clauses: (T) termination on every x∈X; (C) the output is true exactly when x∈Y. Both clauses quantify over all of X and both are relative to the fixed model W. (T) and (C) are then proved separately for D1."
        },
        "reverse_audit": {
          "kind": "inverse_equivalence",
          "required_ids": [
            "mko_decision_problem_def",
            "def_unfold"
          ],
          "explanation": {
            "zh-Hant": "展開與折回定義互為反向，所以兩邊等價。只滿足其中一個條款（例如只在 yes-instance 上終止）不是 decider。",
            "en": "Unfolding and folding a definition are inverse moves, so the two sides are equivalent. Satisfying only one clause (for example halting only on yes-instances) does not make a decider."
          }
        },
        "leaf_basis": "def_unfold + mko_decision_problem_def"
      },
      {
        "id": "S04",
        "uses": [
          "G3",
          "S02.1"
        ],
        "before_tex": "x\\in\\{0,1\\}",
        "after_tex": "D_1\\ \\text{terminates on}\\ x,\\ D_1(x)=\\mathrm{false},\\ x\\notin Y",
        "relation": "implies",
        "rule": "while_semantics",
        "conditions": [
          "x<2"
        ],
        "explanation": {
          "zh-Hant": "x=0 或 x=1 時，第 1 行的測試 x<2 為真，D1 立刻 return false，在有限步內終止。由 S02.1，這兩個輸入確實不在 Y，所以輸出與規格一致。",
          "en": "For x=0 or x=1 the test x<2 on line 1 is true, so D1 returns false immediately and terminates after finitely many steps. By S02.1 these two inputs are indeed not in Y, so the output agrees with the specification."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G3",
            "while_semantics",
            "S02.1"
          ],
          "explanation": {
            "zh-Hant": "需要程式文字與 if 的語義，以及 S02.1 的判定。這只處理 x<2 的情況；x≥2 的情況由 S05 到 S08 處理。",
            "en": "It needs the program text, the semantics of 'if', and the decision in S02.1. It handles only x<2; the case x≥2 is handled in S05 to S08."
          }
        },
        "leaf_basis": "while_semantics + prime_def"
      },
      {
        "id": "S05",
        "uses": [
          "G3",
          "G1"
        ],
        "before_tex": "x\\in X,\\ x\\ge 2",
        "after_tex": "D_1\\ \\text{terminates on}\\ x\\ \\text{after at most}\\ x-2\\le 7\\ \\text{loop passes}",
        "relation": "theorem_application",
        "rule": "L_loop_term",
        "conditions": [
          "x\\ge 2"
        ],
        "explanation": {
          "zh-Hant": "套用引理 L_loop_term：x≥2 時迴圈最多完成 x−2 輪，之後測試 d<x 失敗，執行第 4 行 return true，或在某輪中提早 return false。X 中最大的 x 是 9，所以最多 7 輪。與 S04 合起來，D1 對每個 x∈X 都終止，條款 (T) 成立。",
          "en": "Apply Lemma L_loop_term: for x≥2 the loop completes at most x−2 passes, after which the test d<x fails and line 4 returns true, unless some pass returns false earlier. The largest x in X is 9, so at most 7 passes. Together with S04, D1 terminates on every x∈X, so clause (T) holds."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "L_loop_term",
            "G3"
          ],
          "explanation": {
            "zh-Hant": "需要引理的前提 x≥2；引理在 S05.1、S05.2 證明。終止性來自 d 每輪加 1 且有上界，不是來自「試跑幾個輸入都停了」。",
            "en": "It needs the lemma's hypothesis x≥2; the lemma is proved in S05.1 and S05.2. Termination comes from d increasing by 1 per pass with an upper bound, not from having tried a few inputs that happened to stop."
          }
        },
        "leaf_basis": "while_semantics + nat_induction + order_basics"
      },
      {
        "id": "S05.1",
        "uses": [
          "G3",
          "while_semantics"
        ],
        "before_tex": "d=2\\ \\text{at the first test}",
        "after_tex": "\\text{each pass either returns or replaces}\\ d\\ \\text{by}\\ d+1",
        "relation": "implies",
        "rule": "while_semantics",
        "conditions": [],
        "explanation": {
          "zh-Hant": "第 2 行令 d=2。迴圈本體只有兩種結果：若 x mod d=0 則 return false，執行結束；否則執行 d:=d+1。本體中沒有其他改變 d 的敘述。",
          "en": "Line 2 sets d=2. The loop body has only two outcomes: if x mod d=0 it returns false and the run ends; otherwise it executes d:=d+1. No other statement in the body changes d."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G3",
            "while_semantics"
          ],
          "explanation": {
            "zh-Hant": "直接讀程式文字與語義；不宣稱每輪一定會 return，只說 d 的變化只有加 1 這一種。",
            "en": "Read directly from the program text and the semantics; it does not claim every pass returns, only that the sole change to d is adding 1."
          }
        },
        "leaf_basis": "while_semantics"
      },
      {
        "id": "S05.2",
        "uses": [
          "S05.1"
        ],
        "before_tex": "\\text{after}\\ k\\ \\text{completed passes without return:}\\ d=2+k",
        "after_tex": "\\text{a pass starts only if}\\ 2+k<x,\\ \\text{so at most}\\ x-2\\ \\text{passes complete}",
        "relation": "induction_step",
        "rule": "nat_induction",
        "conditions": [
          "x\\ge 2"
        ],
        "explanation": {
          "zh-Hant": "對 k 歸納：k=0 時 d=2；若完成 k 輪後 d=2+k，再完成一輪就是 d=2+(k+1)（S05.1）。第 k 輪開始前要先通過測試 d<x，即 2+k<x，也就是 k≤x−3，所以可能的輪次只有 k=0 到 x−3，共 x−2 輪。最後一輪完成後 d=x，測試失敗，第 4 行 return。因此執行在有限步內結束，引理 L_loop_term 得證。",
          "en": "Induct on k: for k=0, d=2; if d=2+k after k completed passes, one more completed pass gives d=2+(k+1) (S05.1). Pass number k can start only if the test d<x passes, that is 2+k<x, i.e. k≤x−3, so the possible passes are k=0 to x−3, which is x−2 passes. After the last one d=x, the test fails and line 4 returns. So the run ends after finitely many steps, proving Lemma L_loop_term."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S05.1",
            "nat_induction",
            "order_basics"
          ],
          "explanation": {
            "zh-Hant": "需要 S05.1 的「每輪加 1」與自然數歸納。上界 x−2 只是上界，不宣稱每個輸入都會跑滿；例如 x=9 在 d=3 就 return false。",
            "en": "It needs 'add 1 per pass' from S05.1 and natural induction. The bound x−2 is only an upper bound; it is not claimed that every input uses all passes; for example x=9 returns false at d=3."
          }
        },
        "leaf_basis": "nat_induction + order_basics + while_semantics"
      },
      {
        "id": "S06",
        "uses": [
          "G3"
        ],
        "before_tex": "x\\ge 2",
        "after_tex": "\\text{at every test of}\\ d<x:\\ 2\\le d\\le x\\ \\wedge\\ \\neg\\exists e\\,(2\\le e<d\\ \\wedge\\ e\\mid x)",
        "relation": "theorem_application",
        "rule": "L_loop_inv",
        "conditions": [
          "x\\ge 2"
        ],
        "explanation": {
          "zh-Hant": "套用迴圈不變量 L_loop_inv：每次測試 d<x 時，d 在 2 與 x 之間，且 2 到 d−1 之間沒有 x 的因數。不變量把「迴圈已經檢查過什麼」寫成一個命題，讓 S07、S08 能由程式的出口推出 x 是否為質數。",
          "en": "Apply the loop invariant L_loop_inv: whenever d<x is tested, d lies between 2 and x and x has no divisor between 2 and d−1. The invariant records as a proposition what the loop has already checked, so that S07 and S08 can infer from the exit point whether x is prime."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "L_loop_inv",
            "G3"
          ],
          "explanation": {
            "zh-Hant": "需要 x≥2（否則第 1 行已 return，迴圈不執行）；引理在 S06.1、S06.2 以初始成立與逐步保持證明，不是只在幾個樣本狀態檢查。",
            "en": "It needs x≥2 (otherwise line 1 has already returned and the loop never runs); the lemma is proved in S06.1 and S06.2 by establishment and preservation, not by checking a few sample states."
          }
        },
        "leaf_basis": "nat_induction + divides_def + while_semantics"
      },
      {
        "id": "S06.1",
        "uses": [
          "G3",
          "while_semantics"
        ],
        "before_tex": "\\text{first test},\\ d=2",
        "after_tex": "2\\le 2\\le x\\ \\wedge\\ \\{e:2\\le e<2\\}=\\varnothing",
        "relation": "induction_base",
        "rule": "nat_induction",
        "conditions": [
          "x\\ge 2"
        ],
        "explanation": {
          "zh-Hant": "第一次測試時 d=2。因為 x≥2，有 2≤d≤x；滿足 2≤e<2 的整數 e 不存在，所以「沒有這樣的 e 整除 x」空真成立。不變量在初始時成立。",
          "en": "At the first test d=2. Since x≥2 we have 2≤d≤x; no integer e satisfies 2≤e<2, so 'no such e divides x' holds vacuously. The invariant holds initially."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G3",
            "while_semantics",
            "order_basics"
          ],
          "explanation": {
            "zh-Hant": "需要 x≥2 與第 2 行的賦值；這是歸納的基底。",
            "en": "It needs x≥2 and the assignment on line 2; this is the base of the induction."
          }
        },
        "leaf_basis": "nat_induction + order_basics"
      },
      {
        "id": "S06.2",
        "uses": [
          "S06.1",
          "divides_def",
          "while_semantics"
        ],
        "before_tex": "2\\le d\\le x,\\ \\neg\\exists e\\,(2\\le e<d\\wedge e\\mid x),\\ d<x,\\ x\\bmod d\\ne 0",
        "after_tex": "d'=d+1:\\ 2\\le d'\\le x\\ \\wedge\\ \\neg\\exists e\\,(2\\le e<d'\\wedge e\\mid x)",
        "relation": "induction_step",
        "rule": "nat_induction",
        "conditions": [
          "d<x",
          "x\\bmod d\\ne 0"
        ],
        "explanation": {
          "zh-Hant": "設某次測試時不變量成立，測試 d<x 為真，且本輪沒有 return，也就是 x mod d≠0，故 d∤x。本輪後 d′=d+1。由 d<x 得 d′≤x，且 d′≥3≥2。滿足 2≤e<d′ 的 e 要嘛 e<d（依假設不整除 x），要嘛 e=d（剛驗證不整除 x）。所以下一次測試時不變量仍成立。S06.1 與 S06.2 合起來證得 L_loop_inv。",
          "en": "Suppose the invariant holds at a test, the test d<x is true, and the pass does not return, that is x mod d≠0, so d∤x. After the pass d′=d+1. From d<x we get d′≤x, and d′≥3≥2. Any e with 2≤e<d′ has either e<d (not a divisor by hypothesis) or e=d (just shown not to divide x). So the invariant holds at the next test. S06.1 and S06.2 together prove L_loop_inv."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S06.1",
            "divides_def",
            "while_semantics",
            "order_basics"
          ],
          "explanation": {
            "zh-Hant": "保持性需要本輪沒有 return 這個條件；若本輪 return，執行已結束，不再有下一次測試，所以不需要保持。對自然數 d<x 推 d+1≤x 用的是整數的次序。",
            "en": "Preservation needs the condition that the pass did not return; if it did, the run has ended and there is no next test to preserve the invariant for. Passing from d<x to d+1≤x uses the order of the integers."
          }
        },
        "leaf_basis": "nat_induction + divides_def + order_basics + while_semantics"
      },
      {
        "id": "S07",
        "uses": [
          "S04",
          "S06",
          "G3"
        ],
        "before_tex": "D_1(x)=\\mathrm{true}",
        "after_tex": "x\\in Y",
        "relation": "implies",
        "rule": "prime_def",
        "conditions": [],
        "explanation": {
          "zh-Hant": "D1 只在第 4 行輸出 true，而且由 S04，x<2 時不會到達第 4 行，所以 x≥2。到達第 4 行表示測試 d<x 失敗；不變量給 d≤x，依三分律得 d=x。不變量再給出：沒有 e 滿足 2≤e<x 且 e∣x，即 2 到 x−1 之間沒有因數。依 prime_def，x 是質數，x∈Y。",
          "en": "D1 outputs true only on line 4, and by S04 line 4 is not reached when x<2, so x≥2. Reaching line 4 means the test d<x failed; the invariant gives d≤x, so by trichotomy d=x. The invariant then says no e with 2≤e<x divides x, i.e. x has no divisor between 2 and x−1. By prime_def x is prime, so x∈Y."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S04",
            "S06",
            "prime_def",
            "order_basics"
          ],
          "explanation": {
            "zh-Hant": "需要不變量的兩部分（d≤x 與沒有小因數）以及第 4 行只能由迴圈出口到達。此步只證「輸出 true ⇒ x∈Y」，反向在 S09 另行處理。",
            "en": "It needs both parts of the invariant (d≤x and no small divisor) and that line 4 is reachable only through the loop exit. This step proves only 'output true ⇒ x∈Y'; the converse is handled separately in S09."
          }
        },
        "leaf_basis": "prime_def + order_basics + while_semantics"
      },
      {
        "id": "S08",
        "uses": [
          "S04",
          "S06",
          "G3"
        ],
        "before_tex": "D_1(x)=\\mathrm{false}",
        "after_tex": "x\\notin Y",
        "relation": "implies",
        "rule": "case_analysis",
        "conditions": [],
        "explanation": {
          "zh-Hant": "D1 只在兩處輸出 false。情況一：第 1 行，x<2，不是質數（S04）。情況二：迴圈中某次 x mod d=0；此時測試 d<x 剛通過，且不變量給 d≥2，所以 d 是滿足 2≤d≤x−1 的因數，x 不是質數。兩種情況涵蓋所有 return false 的位置，所以 x∉Y。",
          "en": "D1 outputs false in only two places. Case one: line 1, x<2, not prime (S04). Case two: in the loop with x mod d=0; the test d<x has just passed and the invariant gives d≥2, so d is a divisor with 2≤d≤x−1 and x is not prime. The two cases cover every 'return false' in the program, so x∉Y."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S04",
            "S06",
            "case_analysis",
            "prime_def",
            "divides_def"
          ],
          "explanation": {
            "zh-Hant": "分情況必須涵蓋程式中每個 return false，這由程式文字確認只有兩處。不宣稱反向；反向在 S09 處理。",
            "en": "The case split must cover every 'return false' in the program, and the program text confirms there are only two. No converse is claimed here; it is handled in S09."
          }
        },
        "leaf_basis": "case_analysis + prime_def + divides_def + while_semantics"
      },
      {
        "id": "S09",
        "uses": [
          "S04",
          "S05",
          "S07",
          "S08"
        ],
        "before_tex": "D_1(x)=\\mathrm{true}\\Rightarrow x\\in Y,\\quad D_1(x)=\\mathrm{false}\\Rightarrow x\\notin Y",
        "after_tex": "\\forall x\\in X,\\ D_1(x)=\\mathrm{true}\\iff x\\in Y",
        "relation": "implies",
        "rule": "iff_intro",
        "conditions": [
          "D_1\\ \\text{terminates on}\\ x"
        ],
        "explanation": {
          "zh-Hant": "取任意 x∈X。由 S04、S05，D1 在 x 上終止，輸出 true 或 false 其中之一。(⇒) 是 S07。(⇐) 若 x∈Y，輸出不可能是 false，否則由 S08 得 x∉Y，矛盾；所以輸出是 true。兩向合成 ⇔；x 是任意的，依全稱推廣對所有 x∈X 成立，條款 (C) 成立。",
          "en": "Take any x∈X. By S04 and S05, D1 terminates on x with output true or false. (⇒) is S07. (⇐) If x∈Y, the output cannot be false, for then S08 would give x∉Y, a contradiction; so the output is true. The two directions give ⇔; since x was arbitrary, generalization gives it for all x∈X, so clause (C) holds."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S05",
            "S07",
            "S08",
            "iff_intro",
            "contrapositive",
            "forall_intro"
          ],
          "explanation": {
            "zh-Hant": "本步為 D1 的一般論證使用已證終止性：只有在輸出確為 true 或 false 時，「不可能 false」才推出 true。D2 在每個 yes-instance 上確實回傳 true，沒有違反這個反向蘊含；它在 no-instance 上發散，違反的是獨立的全域終止條款 (T)（S12）。",
            "en": "The generic argument for D1 uses its proved termination: only when the result is known to be true or false does 'not false' imply true. D2 does return true on every yes-instance and does not violate that reverse implication; it diverges on no-instances and fails the separate total-termination clause (T) in S12."
          }
        },
        "leaf_basis": "iff_intro + contrapositive + forall_intro"
      },
      {
        "id": "S10",
        "uses": [
          "S03",
          "S04",
          "S05",
          "S09"
        ],
        "before_tex": "(\\forall x\\in X,\\ D_1\\ \\text{terminates})\\ \\wedge\\ (\\forall x\\in X,\\ D_1(x)=\\mathrm{true}\\iff x\\in Y)",
        "after_tex": "D_1\\ \\text{decides}\\ (X,Y)\\ \\text{in}\\ W",
        "relation": "implies",
        "rule": "and_intro_elim",
        "conditions": [],
        "explanation": {
          "zh-Hant": "條款 (T) 由 S04（x<2）與 S05（x≥2）合成，這兩種情況涵蓋 X 的每個元素；條款 (C) 是 S09。合取後依 S03 的等價折回定義：D1 是 (X,Y) 在 W 中的 decider。",
          "en": "Clause (T) combines S04 (x<2) and S05 (x≥2), and these two cases cover every element of X; clause (C) is S09. Their conjunction folds back through the equivalence of S03: D1 is a decider for (X,Y) in W."
        },
        "reverse_audit": {
          "kind": "sufficient_goal_reduction",
          "required_ids": [
            "S03",
            "S05",
            "S09",
            "and_intro_elim"
          ],
          "explanation": {
            "zh-Hant": "目標 G：D1 是 decider。足夠條件 H：(T)∧(C)，H⇔G 由 S03。H 由 S04 到 S09 從程式文字與定義正向證成，沒有把 G 當前提。",
            "en": "Goal G: D1 is a decider. Sufficient condition H: (T)∧(C), with H⇔G by S03. H is proved forwards in S04 to S09 from the program text and the definitions; G is never used as a premise."
          }
        },
        "leaf_basis": "and_intro_elim + def_unfold + case_analysis"
      },
      {
        "id": "S11",
        "uses": [
          "S02",
          "S10",
          "G3"
        ],
        "before_tex": "x=0,1,2,3,4,5,6,7,8,9",
        "after_tex": "D_1(x)=\\mathrm{F},\\mathrm{F},\\mathrm{T},\\mathrm{T},\\mathrm{F},\\mathrm{T},\\mathrm{F},\\mathrm{T},\\mathrm{F},\\mathrm{F}\\ =\\ [x\\in Y]",
        "relation": "implies",
        "rule": "finite_exhaustion",
        "conditions": [
          "X\\ \\text{finite and listed}"
        ],
        "explanation": {
          "zh-Hant": "交叉核對：手動執行 D1 於全部十個輸入。例如 x=9：d=2 時 9 mod 2=1，d=3 時 9 mod 3=0，return false；x=7：d=2 到 6 的餘數 1、1、3、2、1，之後 d=7 測試失敗，return true。完整表格與 Y={2,3,5,7} 的成員表逐項相同。因為 X 有限且已全部列出，這張表本身也是條款 (C) 在 X 上的完整核對；但它只涵蓋 X（MKO 假設 a2）。",
          "en": "Cross-check: run D1 by hand on all ten inputs. For example x=9: at d=2, 9 mod 2=1; at d=3, 9 mod 3=0, return false; x=7: the remainders for d=2 to 6 are 1, 1, 3, 2, 1, then the test fails at d=7 and it returns true. The full table agrees entry by entry with membership in Y={2,3,5,7}. Because X is finite and fully listed, this table is by itself a complete check of clause (C) on X; but it covers X only (MKO assumption a2)."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S02",
            "finite_exhaustion",
            "numeric_evaluation"
          ],
          "explanation": {
            "zh-Hant": "表格必須包含 X 的每個元素才算完整核對；若只列一部分就只是抽樣。這張表不能外推到 X 之外的輸入。",
            "en": "The table counts as a complete check only because it contains every element of X; a partial table would be a sample. It cannot be extrapolated to inputs outside X."
          }
        },
        "leaf_basis": "finite_exhaustion + numeric_evaluation + while_semantics"
      },
      {
        "id": "S12",
        "uses": [
          "S03",
          "S02.2",
          "G3"
        ],
        "before_tex": "x=4\\in X:\\ D_1\\ \\text{would return false}",
        "after_tex": "D_2\\ \\text{does not terminate on}\\ 4\\ \\Rightarrow\\ \\neg(\\forall x\\in X,\\ D_2\\ \\text{terminates})",
        "relation": "implies",
        "rule": "quantifier_negation",
        "conditions": [],
        "explanation": {
          "zh-Hant": "在 x=4 上，D1 的程式文字於 d=2 時得到 4 mod 2=0，會 return false；D2 此時改為執行 while true do skip，永不 return。所以存在 x∈X 使 D2 不終止，依量詞否定，條款 (T) 不成立，D2 不是 decider。D2 恰好在 Y 上以 true 停止，是 Y 的半決定程序；這正是 MKO 指出的誤解：只保證在 yes-instance 上接受，尚不足以保證總 decider；D2 真正違反的是對 no-instance 的終止性，而 D1 也只接受 yes-instance，卻會在其餘輸入拒絕並終止。",
          "en": "On x=4 the text of D1 finds 4 mod 2=0 at d=2 and would return false; D2 instead executes 'while true do skip' and never returns. So some x∈X makes D2 fail to terminate; by quantifier negation clause (T) fails and D2 is not a decider. D2 halts with true exactly on Y, so it is a semi-decision procedure for Y; this is the misconception the MKO names: accepting exactly the yes-instances alone does not ensure a total decider. D2 fails termination on no-instances, while D1 also accepts exactly the yes-instances but rejects and halts on the remaining inputs."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S03",
            "quantifier_negation",
            "G3"
          ],
          "explanation": {
            "zh-Hant": "一個不終止的輸入就足以否定全稱條款 (T)。這裡不需要也不宣稱 D2 在其他 no-instance 上的行為，雖然它在 0、1、6、8、9 上同樣不終止。",
            "en": "One non-terminating input suffices to refute the universal clause (T). Nothing else about D2 is needed, although it also fails to terminate on 0, 1, 6, 8 and 9."
          }
        },
        "leaf_basis": "quantifier_negation + while_semantics + divides_def"
      },
      {
        "id": "S13",
        "uses": [
          "S03",
          "S02",
          "G3"
        ],
        "before_tex": "D_3(x)=[x\\bmod 2=1]",
        "after_tex": "D_3(9)=\\mathrm{true},\\ 9\\notin Y\\ \\Rightarrow\\ \\neg(\\forall x\\in X,\\ D_3(x)=\\mathrm{true}\\iff x\\in Y)",
        "relation": "implies",
        "rule": "quantifier_negation",
        "conditions": [],
        "explanation": {
          "zh-Hant": "D3 在有限步內終止，所以 (T) 成立；但 9 mod 2=1，D3(9)=true，而 9∉Y（S02.2）；另外 D3(2)=false 而 2∈Y。存在反例，條款 (C) 不成立，D3 不是 decider。值得注意：在樣本 {3,4,5,6,7,8} 上 D3 與 Y 完全一致，所以抽樣一致不足以證明整個論域（MKO 第二段）。",
          "en": "D3 terminates after finitely many steps, so (T) holds; but 9 mod 2=1 gives D3(9)=true while 9∉Y (S02.2), and also D3(2)=false while 2∈Y. A counterexample exists, so clause (C) fails and D3 is not a decider. Note that on the sample {3,4,5,6,7,8} D3 agrees with Y completely, so agreement on a sample does not prove agreement on the whole domain (MKO paragraph 2)."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S02",
            "quantifier_negation",
            "numeric_evaluation"
          ],
          "explanation": {
            "zh-Hant": "一個反例就否定全稱的 (C)（N8、N9 可重算）。反過來，樣本一致不能證明 (C)，所以此處只用反例方向。",
            "en": "One counterexample refutes the universal clause (C) (recomputable as N8, N9). Conversely, agreement on a sample cannot prove (C), so only the counterexample direction is used."
          }
        },
        "leaf_basis": "quantifier_negation + numeric_evaluation"
      }
    ],
    "result": {
      "zh-Hant": "在模型 W 中，Y={2,3,5,7}，試除程序 D1 對每個 x∈X 終止且 D1(x)=true ⇔ x∈Y，所以 D1 是 (X,Y) 的 decider。D2 只在 yes-instance 上停止，是半決定程序而不是 decider；D3 總是終止但在 9 與 2 上答錯，也不是 decider。結論只涵蓋 X={0,1,2,3,4,5,6,7,8,9}。",
      "en": "In the model W, Y={2,3,5,7}, and the trial-division procedure D1 terminates on every x∈X with D1(x)=true ⇔ x∈Y, so D1 is a decider for (X,Y). D2 halts only on yes-instances and is a semi-decision procedure, not a decider; D3 always terminates but answers wrongly on 9 and 2, so it is not a decider either. The conclusion covers X={0,1,2,3,4,5,6,7,8,9} only."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "D2 對每個 x∈Y 都輸出 true，所以 D2 決定 (X,Y)",
          "en": "D2 outputs true on every x∈Y, so D2 decides (X,Y)"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "D2 在 x=4 上永不終止，違反「對每個 x∈X 終止」的條款；它只是半決定程序。",
          "en": "D2 never terminates on x=4, violating the clause 'terminates on every x∈X'; it is only a semi-decision procedure."
        }
      },
      {
        "claim": {
          "zh-Hant": "D3 在 3、4、5、6、7、8 上都與 Y 一致，所以 D3 是 X 上的 decider",
          "en": "D3 agrees with Y on 3, 4, 5, 6, 7 and 8, so D3 is a decider on X"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "D3(9)=true 但 9=3·3∉Y；D3(2)=false 但 2∈Y。",
          "en": "D3(9)=true but 9=3·3∉Y; D3(2)=false but 2∈Y."
        }
      },
      {
        "claim": {
          "zh-Hant": "D1 的表格在 X={0,1,2,3,4,5,6,7,8,9} 上與 Y 一致，所以這張表證明了整個自然數上的質數判定",
          "en": "D1's table agrees with Y on X={0,1,2,3,4,5,6,7,8,9}, so the table proves primality testing on all natural numbers"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "有限表格只證明該有限 X（MKO 假設 a2）；對整個自然數的宣稱是新的宣稱，需要對所有輸入的論證與固定的表示。",
          "en": "A finite table establishes only that finite X (MKO assumption a2); a claim over all natural numbers is a new claim needing an argument for every input and a fixed representation."
        }
      },
      {
        "claim": {
          "zh-Hant": "D1 不是 (X,Y) 的 decider，因為它沒有處理輸入 −3",
          "en": "D1 is not a decider for (X,Y) because it does not handle the input −3"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "−3∉X；域外輸入不參與目前問題（MKO 第二段），decider 只需在 X 上終止並正確。",
          "en": "−3∉X; inputs outside the domain are not part of the problem (MKO paragraph 2), and a decider only has to terminate correctly on X."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "set_builder",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "集合建構式：x∈{y∈A ∣ P(y)} 當且僅當 x∈A 且 P(x)。",
          "en": "Set-builder notation: x∈{y∈A ∣ P(y)} if and only if x∈A and P(x)."
        }
      },
      {
        "id": "divides_def",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "整除：對整數 a、b，a∣b 表示存在整數 k 使 b=ak。",
          "en": "Divisibility: for integers a, b, a∣b means there is an integer k with b=ak."
        }
      },
      {
        "id": "order_basics",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "實數的序：任兩數恰有 u<v、u=v、u>v 之一；u<v 且 v<w 推出 u<w；u<v 推出 u+w<v+w；u<v 且 w>0 推出 uw<vw；u<v 且 w<0 推出 uw>vw。",
          "en": "Order of the reals: exactly one of u<v, u=v, u>v holds; u<v and v<w give u<w; u<v gives u+w<v+w; u<v and w>0 give uw<vw; u<v and w<0 give uw>vw."
        }
      },
      {
        "id": "numeric_evaluation",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "明確整數或有理數算式的精確求值；可以獨立重算。",
          "en": "Exact evaluation of an explicit integer or rational expression; independently recomputable."
        }
      },
      {
        "id": "def_intro",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "引入定義：可為一個命題、式子或物件取名；之後名稱與被定義者可互相替換。",
          "en": "Introducing a definition: a statement, expression or object may be given a name, after which the name and what it stands for are interchangeable."
        }
      },
      {
        "id": "def_unfold",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "展開定義：把一個已定義的詞換成它的定義內容（或反向收回），命題的真假不變。",
          "en": "Unfolding a definition: replacing a defined term by its definition (or folding it back) does not change whether a statement is true."
        }
      },
      {
        "id": "nat_induction",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "數學歸納原理：對從 n₀ 起的命題族 P(n)，若 P(n₀) 成立，且對每個 n≥n₀ 都有 P(n)⇒P(n+1)，則所有 n≥n₀ 都有 P(n)。",
          "en": "Principle of induction: for a family P(n) starting at n₀, if P(n₀) holds and P(n)⇒P(n+1) for every n≥n₀, then P(n) holds for every n≥n₀."
        }
      },
      {
        "id": "case_analysis",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "分情況論證：若 P∨Q 成立，且 P⇒R、Q⇒R 都已證，則 R 成立。所有情況必須涵蓋全部可能。",
          "en": "Proof by cases: if P∨Q holds and both P⇒R and Q⇒R are proved, then R holds. The cases must cover every possibility."
        }
      },
      {
        "id": "iff_intro",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "雙條件：P⇒Q 與 Q⇒P 都成立時，P⇔Q 成立；反之亦然。",
          "en": "Biconditional: P⇔Q holds exactly when both P⇒Q and Q⇒P hold."
        }
      },
      {
        "id": "contrapositive",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "逆否命題：P⇒Q 與 ¬Q⇒¬P 等價。逆命題 Q⇒P 一般不與 P⇒Q 等價。",
          "en": "Contrapositive: P⇒Q is equivalent to ¬Q⇒¬P. The converse Q⇒P is in general not equivalent to P⇒Q."
        }
      },
      {
        "id": "forall_intro",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "∀引入（全稱推廣）：若某命題對一個「任意的」元素 x 證成，而證明沒有對 x 加任何額外假設，則它對論域中所有 x 成立。",
          "en": "∀-introduction (generalization): if a statement is proved for an arbitrary element x, with no extra assumption on x, it holds for every x in the domain."
        }
      },
      {
        "id": "and_intro_elim",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "合取：由 P 與 Q 得 P∧Q；由 P∧Q 可分別得 P 與 Q。",
          "en": "Conjunction: from P and Q infer P∧Q; from P∧Q infer P and infer Q."
        }
      },
      {
        "id": "quantifier_negation",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "量詞否定：¬(∀x, P(x)) 等價於 ∃x, ¬P(x)；¬(∃x, P(x)) 等價於 ∀x, ¬P(x)。",
          "en": "Negating quantifiers: ¬(∀x, P(x)) is equivalent to ∃x, ¬P(x), and ¬(∃x, P(x)) is equivalent to ∀x, ¬P(x)."
        }
      },
      {
        "id": "mko_decision_problem_def",
        "kind": "cited",
        "source": {
          "mko_id": "mko-decision-problem",
          "sha256": "b63ff13299c4ce36349133c27ce4fdcc5554615d69e54610ae5c15fe80b3005c",
          "commit": "b28a5edbd46279b1db2a3f3f48bb3f447e18899f"
        },
        "statement": {
          "zh-Hant": "決定問題可表示為輸入集合 X 與 yes-instance 集合 Y⊆X，等價於命題規格 P:X→Prop。相對一個明示計算模型，decider D 必須對每個 x∈X 終止，且 D(x)=true 當且僅當 x∈Y。",
          "en": "A decision problem is an input set X with a yes-instance set Y⊆X, equivalently a proposition-valued specification P:X→Prop. Relative to an explicit computational model, a decider D must terminate on every x∈X and satisfy D(x)=true exactly when x∈Y."
        }
      },
      {
        "id": "prime_def",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "自然數 p 是質數，當且僅當 p≥2 且其正因數只有 1 與 p。因為 p≥1 的正因數 d 滿足 d≤p（p=dk 且 k≥1），這等價於：p≥2 且沒有整數 d 滿足 2≤d≤p−1 且 d∣p。對自然數 x 與 d≥1，d∣x 當且僅當 x mod d=0。",
          "en": "A natural number p is prime exactly when p≥2 and its only positive divisors are 1 and p. Since a positive divisor d of p≥1 satisfies d≤p (p=dk with k≥1), this is equivalent to: p≥2 and no integer d with 2≤d≤p−1 divides p. For natural x and d≥1, d∣x exactly when x mod d=0."
        }
      },
      {
        "id": "while_semantics",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "W 的語義：敘述依序執行；if B then S 只在 B 為真時執行 S；while B do S 先測試 B，為真則執行 S 後再測試，為假則跳到迴圈之後；return v 以輸出 v 結束執行；while true do skip 永不結束。",
          "en": "Semantics of W: statements run in order; 'if B then S' runs S only when B is true; 'while B do S' tests B, runs S and tests again when B is true, and continues after the loop when B is false; 'return v' ends the run with output v; 'while true do skip' never ends."
        }
      },
      {
        "id": "finite_exhaustion",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "對明示列出的有限集合 D，∀x∈D, Q(x) 等價於 Q 對每個列出元素都成立的合取；逐一檢查全部元素即可證明它，只檢查部分元素則不行，而且結論只涵蓋 D。",
          "en": "For an explicitly listed finite set D, ∀x∈D, Q(x) is equivalent to the conjunction of Q(d) over the listed elements d; checking every element proves it, checking only some does not, and the conclusion covers D only."
        }
      },
      {
        "id": "L_loop_term",
        "kind": "lemma",
        "proved_in": [
          "S05.1",
          "S05.2"
        ],
        "statement": {
          "zh-Hant": "對每個自然數 x≥2，D1 在 x 上的 while 迴圈最多完成 x−2 輪，因此 D1 在 x 上終止。",
          "en": "For every natural number x≥2, the while loop of D1 on x completes at most x−2 passes, so D1 terminates on x."
        }
      },
      {
        "id": "L_loop_inv",
        "kind": "lemma",
        "proved_in": [
          "S06.1",
          "S06.2"
        ],
        "statement": {
          "zh-Hant": "對每個自然數 x≥2，D1 在 x 上每次測試 d<x 時，都有 2≤d≤x，且沒有整數 e 滿足 2≤e<d 且 e∣x。",
          "en": "For every natural number x≥2, whenever D1 on x tests d<x, we have 2≤d≤x and no integer e with 2≤e<d divides x."
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": [
      {
        "id": "N1",
        "step": "S02.2",
        "lhs": "9 % 3",
        "rhs": "0"
      },
      {
        "id": "N2",
        "step": "S02.2",
        "lhs": "4 % 2 + 6 % 2 + 8 % 2",
        "rhs": "0"
      },
      {
        "id": "N3",
        "step": "S02.3",
        "vars": [
          "d"
        ],
        "range": [
          2,
          6
        ],
        "lhs": "min(7 % d, 1)",
        "rhs": "1"
      },
      {
        "id": "N4",
        "step": "S02.3",
        "vars": [
          "d"
        ],
        "range": [
          2,
          4
        ],
        "lhs": "min(5 % d, 1)",
        "rhs": "1"
      },
      {
        "id": "N5",
        "step": "S02",
        "lhs": "isprime(2)+isprime(3)+isprime(5)+isprime(7)",
        "rhs": "4"
      },
      {
        "id": "N6",
        "step": "S02",
        "lhs": "isprime(0)+isprime(1)+isprime(4)+isprime(6)+isprime(8)+isprime(9)",
        "rhs": "0"
      },
      {
        "id": "N7",
        "step": "S05",
        "lhs": "9-2",
        "rhs": "7"
      },
      {
        "id": "N8",
        "step": "S13",
        "lhs": "9 % 2",
        "rhs": "1"
      },
      {
        "id": "N9",
        "step": "S13",
        "lhs": "2 % 2",
        "rhs": "0"
      }
    ]
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "在 MKO 範圍內工作：固定的有限輸入集 X 與 Y⊆X（假設 a1），以及明示的計算模型與輸入表示（假設 a2）。結論只涵蓋這個 X；不由此推論整個自然數上的可計算性或不可判定性，不處理一般半決定程序理論，不改動 canonical MKO 或英文 edition。",
      "en": "Works inside the MKO's scope: a fixed finite input set X with Y⊆X (assumption a1) and an explicit computational model and input representation (assumption a2). The conclusion covers this X only; it draws no conclusion about computability or undecidability over all natural numbers, does not treat the general theory of semi-decision procedures, and does not change the canonical MKO or its English edition."
    },
    "md_symbols": [
      [
        "X",
        "輸入集合 {0,1,2,3,4,5,6,7,8,9}",
        "the input set {0,1,2,3,4,5,6,7,8,9}"
      ],
      [
        "P(x)",
        "規格：x 是質數",
        "the specification: x is prime"
      ],
      [
        "Y",
        "yes-instance 集合 {x∈X ∣ P(x)}",
        "the yes-instance set {x∈X ∣ P(x)}"
      ],
      [
        "W",
        "明示的 while 程式計算模型",
        "the explicit while-program computational model"
      ],
      [
        "D_1,D_2,D_3",
        "三個候選程序",
        "the three candidate procedures"
      ],
      [
        "x \\bmod d",
        "x 除以 d 的餘數（d≥1）",
        "the remainder of x on division by d (d≥1)"
      ],
      [
        "d\\mid x",
        "d 整除 x",
        "d divides x"
      ]
    ],
    "md_error_controls": [
      {
        "title": "半決定程序不一定是 decider / A semidecision procedure need not be a decider",
        "zh": "MKO 指出的常見誤解是把只接受 yes-instance 的程序當成總 decider。D2 在每個 x∈Y 上都以 true 停止，看起來「答對了所有 yes」，但在 x=4 上永不停止，因此違反條款 (T)。decider 必須在每個輸入上都終止並給出答案；S09 的 (⇐) 方向正是靠終止性才成立。",
        "en": "The misconception identified in the MKO is treating a procedure that accepts only yes-instances as a total decider. D2 halts with true on every x∈Y and seems to 'get every yes right', but it never halts on x=4, violating clause (T). A decider must terminate with an answer on every input; the (⇐) direction of S09 holds only because of termination."
      },
      {
        "title": "抽樣一致與有限表格的界限 / The limits of sampling and of finite tables",
        "zh": "D3 在 {3,4,5,6,7,8} 上與 Y 完全一致，卻在 2 與 9 上出錯：抽樣一致不足以證明整個論域。另一方面，S11 的完整表格只因為 X 有限且全部列出才算證明，而且只涵蓋 X；不能由這張表推論整個自然數上的質數判定（MKO 假設 a2 與第三段）。",
        "en": "D3 agrees with Y on {3,4,5,6,7,8} but is wrong on 2 and 9: agreement on a sample does not prove the whole domain. On the other hand, the complete table in S11 counts as a proof only because X is finite and fully listed, and it covers X only; it does not establish primality testing on all natural numbers (MKO assumption a2 and paragraph 3)."
      },
      {
        "title": "規格先於實作 / The specification comes before the implementation",
        "zh": "Y 由規格 P 定義（S01、S02），不能用「D1 輸出 true 的輸入」來定義 Y，否則任何程序都會自動「正確」。正確性永遠是程序與獨立規格之間的比較。",
        "en": "Y is defined by the specification P (S01, S02); it must not be defined as 'the inputs on which D1 outputs true', or every program would be 'correct' automatically. Correctness is always a comparison between a program and an independent specification."
      }
    ],
    "md_open_items": [
      {
        "zh-Hant": "S05 到 S09 的論證除了輪數上界外沒有用到 x≤9；若要宣稱 D1 決定整個自然數上的質數性，需另外固定所有自然數在 W 中的表示並把該宣稱獨立陳述與審查，本稿不作此宣稱。",
        "en": "The argument in S05 to S09 uses x≤9 only for the pass bound; claiming that D1 decides primality on all natural numbers would require fixing the representation of every natural number in W and stating and reviewing that claim separately, which this guide does not do."
      },
      {
        "zh-Hant": "模型 W 以文字描述；與 Turing machine 等正式模型之間的語義橋（MKO formal next）未在此建立。",
        "en": "The model W is described in prose; the semantic bridge to a formal model such as Turing machines (MKO formal next) is not built here."
      }
    ]
  },
  "revision": {
    "id": "production-20261019-adopted-96",
    "source_commit": "b28a5edbd46279b1db2a3f3f48bb3f447e18899f",
    "adopted_source_sha256": "8c1298a85a7e15de57c25d5f9f4225a8395a15a17de10382e9374e299407f3f6",
    "original_source_sha256": "50e70577152ab8bc0e89748c30ba626dddea3df36bb2c9b31d40e16c3abd912b",
    "owner_adopted": true,
    "bilingual_sync": "complete_source_bound",
    "formal_Lean": "NOT_RUN",
    "independent_AI_concurrence": "NOT_MEASURED",
    "issue_ids": [
      "BR-M032",
      "BR-M033"
    ],
    "scope": "Owner-adopted natural-language teaching guide; not a formal proof, canonical MKO rewrite or evidence-status promotion.",
    "english_binding_revision": {
      "id": "edition-symbol-bindings-20261101",
      "path": "content/edition-symbol-bindings-20261101/revision.json",
      "sha256": "e9b4c69f2c4732074c37abb624c8ab8a70afc3645c12bf9df2268ef650ad7b6c"
    }
  }
}
