{
  "$schema": "../../../schemas/mko-v0.4.schema.json",
  "schema_version": "mko-v0.4",
  "id": "mko-euclidean-algorithm",
  "semantic_family_id": "sf-euclidean-algorithm",
  "type": "algorithm",
  "version": "0.10.0",
  "language": "zh-Hant",
  "titles": {
    "zh-Hant": "Euclidean演算法"
  },
  "summary": {
    "zh-Hant": "Euclidean演算法以精確帶餘除法、gcd invariant與嚴格餘數下降求最大公因數。"
  },
  "statement": {
    "zh-Hant": "逐步驗a=bq+r與0<=r<|b|，把gcd invariant、嚴格下降終止及最終非負gcd分開。extended版本回代並重驗ax+by=gcd；零輸入採gcd(0,0)=0且不執行除以零。"
  },
  "formula": {
    "tex": "a=b(q)+r",
    "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>a</mi><mo>=</mo><mrow><mrow><mi>b</mi><mo>(</mo><mi>q</mi><mo>)</mo></mrow><mo>+</mo><mi>r</mi></mrow></mrow></math>",
    "semantic_ast": {
      "type": "equation",
      "lhs": {
        "type": "symbol",
        "name": "a",
        "glyph": "a"
      },
      "rhs": {
        "type": "addition",
        "operands": [
          {
            "type": "function_call",
            "callee": {
              "type": "symbol",
              "name": "b",
              "glyph": "b"
            },
            "arguments": [
              {
                "type": "symbol",
                "name": "q",
                "glyph": "q"
              }
            ]
          },
          {
            "type": "symbol",
            "name": "r",
            "glyph": "r"
          }
        ]
      }
    },
    "compiler": {
      "id": "ocme-formula-core",
      "version": "0.4.0",
      "source_sha256": "89fa80047ecebf4d9b7ced4914ca22ce3279c20507794ddeb1a1cd420f1752ab"
    }
  },
  "assumptions": [
    {
      "id": "a1",
      "zh-Hant": "輸入為安全範圍內整數，主鏈對絕對值執行。"
    },
    {
      "id": "a2",
      "zh-Hant": "Bezout係數依原輸入符號回代並精確驗式。"
    }
  ],
  "symbols": [
    {
      "token": "q",
      "role": "euclidean_quotient",
      "role_zh": "商",
      "scope": "representative_formula"
    },
    {
      "token": "r",
      "role": "euclidean_remainder",
      "role_zh": "餘數",
      "scope": "representative_formula"
    }
  ],
  "dependencies": [
    {
      "id": "mko-gcd-coprime",
      "title_zh": "最大公因數與互質",
      "reason_zh": "目標gcd與互質判準。"
    },
    {
      "id": "mko-natural-divisibility",
      "title_zh": "自然數整除",
      "reason_zh": "帶餘除法與整除。"
    },
    {
      "id": "mko-algorithm-correctness",
      "title_zh": "算法正確性",
      "reason_zh": "invariant與終止分離。"
    }
  ],
  "explanation": {
    "paragraphs_zh": [
      "每一步保留gcd並嚴格降低非負餘數。",
      "最後非零餘數給非負gcd。",
      "Bezout係數需要extended回代證書，不能只由gcd值猜測。"
    ],
    "common_misconception_zh": "只算出一個數便聲稱演算法正確，或在零除數上繼續做帶餘除法。"
  },
  "proofs": [],
  "computational_companions": [],
  "verification": {
    "computational_status": "not_evaluated_no_computational_claim",
    "warning_zh": "只處理exact整數演算法；不宣稱位元複雜度最佳性。",
    "evidence_refs": [],
    "producers": [
      {
        "id": "lean-mathlib",
        "adapter": "formal_system",
        "config_path": "formal/lean/lakefile.toml",
        "status": "configured"
      }
    ]
  },
  "formalization": {
    "status": "not_formalized",
    "target_systems": [
      "Lean 4",
      "Mathlib"
    ],
    "next_obligation_zh": "加入binary gcd與模反元素構造。"
  },
  "provenance": {
    "origin": "ocme_local_ai_materialization_candidate",
    "note_zh": "依 research/atlas-euclidean-algorithm.md 整理；2026-10-14 脈衝 R03（使用者手動接續 2026-11-05 工作序列；實際日期仍為 2026-10-14），英文及 Lean 依使用者指示延後。",
    "content_license": "CC-BY-SA-4.0",
    "code_license": "MIT",
    "created_at": "2026-10-14"
  }
}
