{
  "$schema": "../../../schemas/mko-v0.4.schema.json",
  "schema_version": "mko-v0.4",
  "id": "mko-topological-ordering-dag",
  "semantic_family_id": "sf-topological-ordering-dag",
  "type": "theorem",
  "version": "0.10.0",
  "language": "zh-Hant",
  "titles": {
    "zh-Hant": "有向無環圖的拓撲排序"
  },
  "summary": {
    "zh-Hant": "有限有向圖存在topological ordering恰當其無directed cycle。"
  },
  "statement": {
    "zh-Hant": "candidate ordering須是全部vertices的permutation，逐edge驗pos(u)<pos(v)。小型graph完整枚舉所有valid orders；Kahn程序每步選lexicographically first zero-indegree source、刪除並記錄invariant。若無source但尚有vertices，輸出explicit directed cycle witness。multiple orders與empty-edge保留；invalid candidate不等於graph有cycle，亦不與topological-space混同。"
  },
  "formula": {
    "tex": "O(G,p)=b",
    "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mrow><mi>O</mi><mo>(</mo><mi>G</mi><mo>,</mo><mi>p</mi><mo>)</mo></mrow><mo>=</mo><mi>b</mi></mrow></math>",
    "semantic_ast": {
      "type": "equation",
      "lhs": {
        "type": "function_call",
        "callee": {
          "type": "symbol",
          "name": "O",
          "glyph": "O"
        },
        "arguments": [
          {
            "type": "symbol",
            "name": "G",
            "glyph": "G"
          },
          {
            "type": "symbol",
            "name": "p",
            "glyph": "p"
          }
        ]
      },
      "rhs": {
        "type": "symbol",
        "name": "b",
        "glyph": "b"
      }
    },
    "compiler": {
      "id": "ocme-formula-core",
      "version": "0.4.0",
      "source_sha256": "66bd94676946926c5adbb14f7ceec6bb48ad921907d3aa7b4c777d8f39cd9d98"
    }
  },
  "assumptions": [
    {
      "id": "a1",
      "zh-Hant": "finite unique vertices與loop-free duplicate-free directed edges。"
    },
    {
      "id": "a2",
      "zh-Hant": "完整permutation/cycle enumeration限bounded graph。"
    }
  ],
  "symbols": [
    {
      "token": "O",
      "role": "candidate_topological_order_predicate",
      "role_zh": "候選拓撲次序有效性判定",
      "scope": "representative_formula"
    },
    {
      "token": "G",
      "role": "finite_directed_graph",
      "role_zh": "有限有向圖",
      "scope": "representative_formula"
    },
    {
      "token": "p",
      "role": "vertex_permutation",
      "role_zh": "頂點排列",
      "scope": "representative_formula"
    },
    {
      "token": "b",
      "role": "candidate_order_validity_boolean",
      "role_zh": "候選次序有效性的布林值",
      "scope": "representative_formula"
    }
  ],
  "dependencies": [
    {
      "id": "mko-finite-directed-graph",
      "title_zh": "有限有向圖",
      "reason_zh": "graph model。"
    },
    {
      "id": "mko-order-relation",
      "title_zh": "偏序與全序",
      "reason_zh": "ordering。"
    },
    {
      "id": "mko-algorithm-correctness",
      "title_zh": "演算法正確性",
      "reason_zh": "Kahn invariant。"
    },
    {
      "id": "mko-mathematical-induction",
      "title_zh": "數學歸納法",
      "reason_zh": "iterative source removal一般證明。"
    }
  ],
  "explanation": {
    "paragraphs_zh": [
      "candidate permutation與all-edge audit。",
      "完整列舉與Kahn trace互相交叉核對。",
      "cycle witness保護iff反向。",
      "記號對齊候選：b 判定指定排列 p 是否尊重 G 的每一條有向邊，不直接表示 G 無圈。有限圖無圈等價於存在某個有效拓撲排列，是另外含存在量詞的圖性質；無效候選不代表圖有圈。"
    ],
    "common_misconception_zh": "一個invalid order就判graph cyclic，或默認topological order唯一。"
  },
  "proofs": [],
  "computational_companions": [],
  "verification": {
    "computational_status": "not_evaluated_no_computational_claim",
    "warning_zh": "finite enumeration只證指定graph；一般iff需induction。",
    "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": "加入partial-order linear extensions。"
  },
  "provenance": {
    "origin": "ocme_local_ai_materialization_candidate",
    "note_zh": "依 research/atlas-topological-ordering-dag.md 整理；2026-10-15 脈衝 R06（使用者手動接續 2026-11-16 工作序列；實際日期仍為 2026-10-15），英文及 Lean 依使用者指示延後。",
    "content_license": "CC-BY-SA-4.0",
    "code_license": "MIT",
    "created_at": "2026-10-15"
  }
}
