{
  "$schema": "../../../schemas/mko-v0.4.schema.json",
  "schema_version": "mko-v0.4",
  "id": "mko-algorithm-correctness",
  "semantic_family_id": "sf-algorithm-correctness",
  "type": "concept",
  "version": "0.10.0",
  "language": "zh-Hant",
  "titles": {
    "zh-Hant": "算法正確性"
  },
  "summary": {
    "zh-Hant": "算法正確性分開部分正確性與終止性；總正確性需要兩者同時成立。"
  },
  "statement": {
    "zh-Hant": "相對初始條件與後置條件，部分正確性表示每個從合法初始狀態到達的停止狀態都滿足後置條件；終止性表示每個合法執行最終到達停止狀態；總正確性是兩者的合取。"
  },
  "formula": {
    "tex": "P\\land T",
    "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>P</mi><mo>∧</mo><mi>T</mi></mrow></math>",
    "semantic_ast": {
      "type": "logical_and",
      "left": {
        "type": "symbol",
        "name": "P",
        "glyph": "P"
      },
      "right": {
        "type": "symbol",
        "name": "T",
        "glyph": "T"
      }
    },
    "compiler": {
      "id": "ocme-formula-core",
      "version": "0.4.0",
      "source_sha256": "0a6fb93bc914339b274880dfebc9d476c1751081039f4ef7bf4c39e987f9c17f"
    }
  },
  "assumptions": [
    {
      "id": "a1",
      "zh-Hant": "使用前一條目的有限狀態模型，Halt 狀態視為執行終點。"
    },
    {
      "id": "a2",
      "zh-Hant": "nondeterministic 模型要求所有可能執行滿足責任；一條成功路徑不足以證明。"
    }
  ],
  "symbols": [
    {
      "token": "P",
      "role": "partial_correctness",
      "role_zh": "部分正確性命題",
      "scope": "representative_formula"
    },
    {
      "token": "T",
      "role": "termination",
      "role_zh": "終止性命題",
      "scope": "representative_formula"
    }
  ],
  "dependencies": [
    {
      "id": "mko-computational-model",
      "title_zh": "抽象計算模型",
      "reason_zh": "正確性相對明示狀態與步驟語義。"
    },
    {
      "id": "mko-proposition",
      "title_zh": "命題",
      "reason_zh": "前置、後置、不變量與責任都是命題。"
    },
    {
      "id": "mko-proof",
      "title_zh": "證明",
      "reason_zh": "不變量與終止性需要分離的證明義務。"
    }
  ],
  "explanation": {
    "paragraphs_zh": [
      "不變量需在初始狀態成立，且每一步保持；只在幾個 sample state 成立不夠。",
      "部分正確性允許沒有執行終止；因此 vacuous partial correctness 不能冒充總正確。",
      "有限狀態模型的全部可達圖可以核對錯誤 halt、stuck 與非停止 cycle；一般程式仍需要適合的 proof method。"
    ],
    "common_misconception_zh": "把輸出正確但可能不停止，或一條成功 trace，當成總正確性。"
  },
  "proofs": [],
  "computational_companions": [],
  "verification": {
    "computational_status": "not_evaluated_no_computational_claim",
    "warning_zh": "有限模型完整枚舉只證該模型；不等於來源程式、編譯器或無界輸入已驗證。",
    "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": "建立 Hoare-style 規格、ranking function、nondeterministic fairness 與實際程式語義橋。"
  },
  "provenance": {
    "origin": "ocme_local_ai_materialization_candidate",
    "note_zh": "依 research/atlas-algorithm-correctness.md 整理；2026-10-13 脈衝 R05（使用者手動接續 2026-10-19 工作序列；實際日期仍為 2026-10-13），英文及 Lean 依使用者指示延後。",
    "content_license": "CC-BY-SA-4.0",
    "code_license": "MIT",
    "created_at": "2026-10-13"
  }
}
