{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-euclidean-algorithm-01",
  "mko_id": "mko-euclidean-algorithm",
  "title": {
    "zh-Hant": "帶符號輸入的Euclid與回代",
    "en": "Euclid and back-substitution for signed inputs"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-euclidean-algorithm-01",
    "source": {
      "mko_id": "mko-euclidean-algorithm",
      "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
      "sha256": "eadc65605f926f582e90694e2b3cd2fad1b79c8f39d0f5ecca8962c1ef2e95bf",
      "english_sha256": "b75e7f75026cacf6d854568514b08487eb437112b1c0bc09062dbe1379b77f3c"
    },
    "mode": "worked_example",
    "audience_prerequisites": [
      "calc"
    ],
    "goal": {
      "zh-Hant": "gcd(−84,30)=6，且(−84)·1+30·3=6。",
      "en": "gcd(-84,30)=6, with (-84)*1+30*3=6."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "原輸入a=−84,b=30；主鏈使用|a|=84,|b|=30，gcd約定非負且gcd(0,0)=0。",
          "en": "Original a=-84,b=30; the main chain uses absolute values 84,30; gcd is nonnegative and gcd(0,0)=0."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1"
        ],
        "before_tex": "a=-84,\\quad b=30",
        "after_tex": "(|a|,|b|)=(84,30),\\quad\\gcd(a,b)=\\gcd(84,30)",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "整除不受輸入負號影響，先正規化主鏈。",
          "en": "Divisibility is unaffected by input signs, so normalize the main chain first."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1"
          ],
          "explanation": {
            "zh-Hant": "Bezout係數最後必恢復負號，不能直接沿正數係數。",
            "en": "Bezout coefficients must later restore the negative sign."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S02",
        "uses": [
          "G1",
          "S01"
        ],
        "before_tex": "84,30",
        "after_tex": "84=2\\cdot30+24,\\quad0\\le24<30",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "第一步商2餘24，符合帶餘除法界。",
          "en": "The first step has quotient 2 and remainder 24 within the division bounds."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01"
          ],
          "explanation": {
            "zh-Hant": "84−60=24且除數30非零。",
            "en": "84-60=24 and divisor 30 is nonzero."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S03",
        "uses": [
          "G1",
          "S02"
        ],
        "before_tex": "30,24",
        "after_tex": "30=1\\cdot24+6,\\quad0\\le6<24",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "第二步商1餘6，餘數繼續下降。",
          "en": "The next quotient is 1 and remainder 6, continuing descent."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02"
          ],
          "explanation": {
            "zh-Hant": "6是正餘數而非終止0，仍須下一步。",
            "en": "6 is a positive remainder rather than terminating zero, so another step is needed."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S04",
        "uses": [
          "G1",
          "S03"
        ],
        "before_tex": "24,6",
        "after_tex": "24=4\\cdot6+0,\\quad0\\le0<6",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "第三步餘數0，停止並保留最後非零值6。",
          "en": "The third remainder is zero; stop and retain last nonzero value 6."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S03"
          ],
          "explanation": {
            "zh-Hant": "不可把最後餘數0當gcd，或再做6/0。",
            "en": "Do not use final remainder 0 as the gcd or perform 6/0."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S05",
        "uses": [
          "G1",
          "S02",
          "S03",
          "S04"
        ],
        "before_tex": "u=qv+r,\\quad d>0",
        "after_tex": "d\\mid u,v\\iff d\\mid v,r",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "r=u−qv與u=qv+r證兩方向整除不變，所以整鏈的共因數相同。",
          "en": "r=u-qv and u=qv+r prove both directions of common-divisor invariance throughout the chain."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "S03",
            "S04"
          ],
          "explanation": {
            "zh-Hant": "不變量說明為何末對(6,0)仍代表原gcd，而不只給一串計算。",
            "en": "The invariant explains why final pair (6,0) has the original gcd, beyond a list of calculations."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S06",
        "uses": [
          "G1",
          "S04",
          "S05"
        ],
        "before_tex": "30>24>6>0",
        "after_tex": "\\gcd(84,30)=\\gcd(6,0)=6",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "正除數每步下降，非負整數不能無限嚴降，故終止；末gcd為6。",
          "en": "Positive divisors strictly decrease, so well-founded nonnegative integers force termination; the final gcd is 6."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S04",
            "S05"
          ],
          "explanation": {
            "zh-Hant": "終止責任與不變量不同，兩者加上末狀態才證演算法。",
            "en": "Termination differs from invariance; both plus the final state establish the algorithm."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S07",
        "uses": [
          "G1",
          "S01",
          "S02",
          "S03",
          "S06"
        ],
        "before_tex": "6=30-24,\\quad24=84-2\\cdot30",
        "after_tex": "6=3\\cdot30-84=(-84)\\cdot1+30\\cdot3",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "回代得到正規化係數−1、3，再恢復原a負號為1、3。",
          "en": "Back-substitution gives coefficients -1,3 for 84,30, restored to 1,3 for original -84,30."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "S02",
            "S03",
            "S06"
          ],
          "explanation": {
            "zh-Hant": "直接核−84+90=6；此符號不可從gcd值猜測。",
            "en": "Check -84+90=6 directly; signs are not guessed from the gcd value."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S08",
        "uses": [
          "G1",
          "S06"
        ],
        "before_tex": "(a,b)=(0,30)\\text{ or }(0,0)",
        "after_tex": "\\gcd(0,30)=30,\\quad\\gcd(0,0)=0",
        "relation": "implies",
        "rule": "mko_definition",
        "conditions": [],
        "explanation": {
          "zh-Hant": "單零輸入直接讀非零絕對值，雙零採明示慣例，均不執行零除法。",
          "en": "A single zero returns the other absolute value; double zero uses the stated convention, with no zero division."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S06"
          ],
          "explanation": {
            "zh-Hant": "(0,30)有Bezout0·0+30·1=30；(0,0)取係數0、0得0。",
            "en": "For (0,30), coefficients 0,1 give 30; for (0,0), coefficients 0,0 give 0."
          }
        },
        "leaf_basis": "mko_definition"
      }
    ],
    "result": {
      "zh-Hant": "gcd(−84,30)=6，且(−84)·1+30·3=6。",
      "en": "gcd(-84,30)=6, with (-84)*1+30*3=6."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "gcd(−84,30)=−6。",
          "en": "gcd(-84,30)=-6."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "本慣例gcd非負，正規化結果6。",
          "en": "The gcd is nonnegative under this convention, giving 6."
        }
      },
      {
        "claim": {
          "zh-Hant": "最後餘數0就是gcd。",
          "en": "The last remainder 0 is the gcd."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "最後非零除數6才是gcd。",
          "en": "The last nonzero divisor 6 is the gcd."
        }
      },
      {
        "claim": {
          "zh-Hant": "原Bezout係數可取−1、3。",
          "en": "Original Bezout coefficients are -1,3."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "(−84)(−1)+30·3=174，不是6。",
          "en": "(-84)(-1)+30*3=174, not 6."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "calc",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "假設精確整數算術、帶餘除法、整除與gcd的定義；同餘等式始終綁定明示模數。",
          "en": "Assume exact integer arithmetic, division with remainder, and definitions of divisibility and gcd; every congruence has an explicit modulus."
        }
      },
      {
        "id": "mko_definition",
        "kind": "cited",
        "statement": {
          "zh-Hant": "逐步驗a=bq+r與0<=r<|b|，把gcd invariant、嚴格下降終止及最終非負gcd分開。extended版本回代並重驗ax+by=gcd；零輸入採gcd(0,0)=0且不執行除以零。",
          "en": "At every nonzero-divisor step check a=bq+r and 0≤r<|b|, with quotient q and remainder r. Separate gcd invariance, descent/termination and the final nonnegative gcd. The extended version back-substitutes and rechecks ax+by=gcd; zero inputs use gcd(0,0)=0 without division by zero."
        },
        "source": {
          "mko_id": "mko-euclidean-algorithm",
          "sha256": "eadc65605f926f582e90694e2b3cd2fad1b79c8f39d0f5ecca8962c1ef2e95bf",
          "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f"
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": [
      {
        "id": "division1",
        "lhs": "2*30+24",
        "rhs": "84",
        "step": "S02"
      },
      {
        "id": "bezout",
        "lhs": "(-84)*1+30*3",
        "rhs": "6",
        "step": "S07"
      }
    ]
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "exact整數的除法鏈、不變量、下降終止與Bezout；不聲稱複雜度最佳。",
      "en": "Exact divisions, invariant, descent and Bezout; no optimal-complexity claim."
    },
    "md_symbols": [
      [
        "q,r",
        "帶餘除法商餘數",
        "division quotient and remainder"
      ],
      [
        "a,b",
        "原signed輸入",
        "original signed inputs"
      ]
    ],
    "md_error_controls": [
      {
        "title": "餘數界 / Remainder bounds",
        "zh": "每步核0≤r<非零除數，並於r=0停止。",
        "en": "Check 0≤r below the nonzero divisor, and stop at r=0."
      },
      {
        "title": "符號恢復 / Restore signs",
        "zh": "主鏈用絕對值，Bezout最後回原輸入。",
        "en": "The main chain uses absolute values; restore original signs for Bezout."
      }
    ],
    "md_open_items": []
  },
  "revision": {
    "id": "ocme-new142-reader-adoption-20261021",
    "collection": "coverage-20261021",
    "source_commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
    "adopted_source_sha256": "ab8873c7df2186d225549351554b2b4bea88decba7b0d72aeeb052a0d65fc9a4",
    "original_source_sha256": "ab8873c7df2186d225549351554b2b4bea88decba7b0d72aeeb052a0d65fc9a4",
    "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.",
    "english_binding_revision": {
      "id": "edition-symbol-bindings-20261101",
      "path": "content/edition-symbol-bindings-20261101/revision.json",
      "sha256": "e9b4c69f2c4732074c37abb624c8ab8a70afc3645c12bf9df2268ef650ad7b6c"
    },
    "source_quotation_revision": {
      "id": "edition-symbol-source-quotes-20261101",
      "path": "content/edition-symbol-bindings-20261101/guide-quote-revision.json",
      "sha256": "738a662b019680accb9f968b6b62a5bf284d9d213351faf5273715f932e427cb"
    }
  }
}
