{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-connected-component-01",
  "mko_id": "mko-connected-component",
  "title": {
    "zh-Hant": "連通分量：以完整 BFS 求出有限簡單圖的全部分量",
    "en": "Connected components: finding every component of a finite simple graph by complete BFS"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-connected-component-01",
    "source": {
      "mko_id": "mko-connected-component",
      "commit": "b28a5edbd46279b1db2a3f3f48bb3f447e18899f",
      "sha256": "f921926c2c42fafc8d64364eb7bd06488901e081b0117ba17fc4265610e54eab",
      "english_sha256": "285fe3c5fee3788c2fe30437f7518390875655888e5723faf06e1126fca40995"
    },
    "mode": "algorithm_trace",
    "audience_prerequisites": [
      "graph_basics",
      "set_extensionality",
      "subset_def",
      "well_ordering",
      "nat_induction"
    ],
    "goal": {
      "zh-Hant": "設 G=(V,E)，V={0,1,2,3,4,5,6}，E 恰為 {0,1}、{0,2}、{1,2}、{3,4}、{4,5} 五條邊。先證明「有 path 相連」是 V 上的等價關係，再以完整 BFS 求出每個等價類，證明 BFS 回傳的集合恰為該類，並得出 Q(G)={{0,1,2},{3,4,5},{6}}，其中孤立頂點 6 自成單點分量。",
      "en": "Let G=(V,E) with V={0,1,2,3,4,5,6} and E consisting of exactly the five edges {0,1}, {0,2}, {1,2}, {3,4}, {4,5}. First prove that 'joined by a path' is an equivalence relation on V; then compute each equivalence class by complete BFS, prove that the set BFS returns is exactly that class, and conclude Q(G)={{0,1,2},{3,4,5},{6}}, where the isolated vertex 6 forms a singleton component."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "V={0,1,2,3,4,5,6}；E 恰為五條無向邊 {0,1}、{0,2}、{1,2}、{3,4}、{4,5}，沒有 loop 與重邊；這是完整邊集（MKO 假設 a1）。",
          "en": "V={0,1,2,3,4,5,6}; E consists of exactly the five undirected edges {0,1}, {0,2}, {1,2}, {3,4}, {4,5}, with no loops and no multiple edges; this is the complete edge set (MKO assumption a1)."
        }
      },
      {
        "id": "G2",
        "statement": {
          "zh-Hant": "walk：頂點序列 (x_i)_{i=0}^{k}，k≥0，且對每個 1≤i≤k 有 {x_{i−1},x_i}∈E；長度為 k。path：各 x_i 兩兩相異的 walk。k=0 時 (x_0) 是長度 0 的 path。",
          "en": "Walk: a vertex sequence (x_i)_{i=0}^{k} with k≥0 and {x_{i−1},x_i}∈E for every 1≤i≤k; its length is k. Path: a walk whose vertices x_i are pairwise distinct. For k=0, (x_0) is a path of length 0."
        }
      },
      {
        "id": "G3",
        "statement": {
          "zh-Hant": "u∼v 表示存在由 u 到 v 的 path（x_0=u、x_k=v）。v 的分量是 [v]={w∈V ∣ v∼w}；Q(G) 是所有 [v] 所成的集合（MKO 敘述）。",
          "en": "u∼v means there is a path from u to v (x_0=u, x_k=v). The component of v is [v]={w∈V ∣ v∼w}, and Q(G) is the set of all the [v] (MKO statement)."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1"
        ],
        "before_tex": "E=\\{\\{0,1\\},\\{0,2\\},\\{1,2\\},\\{3,4\\},\\{4,5\\}\\}",
        "after_tex": "N(0)=\\{1,2\\},\\ N(1)=\\{0,2\\},\\ N(2)=\\{0,1\\},\\ N(3)=\\{4\\},\\ N(4)=\\{3,5\\},\\ N(5)=\\{4\\},\\ N(6)=\\varnothing",
        "relation": "equivalent",
        "rule": "graph_basics",
        "conditions": [],
        "explanation": {
          "zh-Hant": "由完整邊集讀出每個頂點的鄰點：無向邊 {a,b} 同時把 b 放入 N(a)、把 a 放入 N(b)。頂點 6 不出現在任何邊中，所以 N(6)=∅。度數依序為 2、2、2、1、2、1、0，總和 10=2·5，與握手引理一致（N1）。",
          "en": "Read off each vertex's neighbours from the complete edge set: an undirected edge {a,b} puts b into N(a) and a into N(b). Vertex 6 occurs in no edge, so N(6)=∅. The degrees are 2, 2, 2, 1, 2, 1, 0 in order, summing to 10=2·5, in agreement with the handshake lemma (N1)."
        },
        "reverse_audit": {
          "kind": "inverse_equivalence",
          "required_ids": [
            "G1",
            "graph_basics"
          ],
          "explanation": {
            "zh-Hant": "反向：由鄰點表收回 E={{x,y} ∣ y∈N(x)}，恰得同樣五條邊，兩種表示互相決定。握手核對只是必要條件，不能單獨證明鄰點表無誤。",
            "en": "Backward: the lists give back E={{x,y} ∣ y∈N(x)}, exactly the same five edges, so the two descriptions determine each other. The handshake check is only a necessary condition and cannot by itself prove the lists correct."
          }
        },
        "leaf_basis": "graph_basics + set_builder + numeric_evaluation"
      },
      {
        "id": "S02",
        "uses": [
          "G2",
          "G3"
        ],
        "before_tex": "v\\in V",
        "after_tex": "v\\sim v",
        "relation": "implies",
        "rule": "def_unfold",
        "conditions": [],
        "explanation": {
          "zh-Hant": "對任何頂點 v，單點序列 (v) 是 k=0 的 walk（沒有需要核對的邊），唯一的頂點自然兩兩相異，所以它是由 v 到 v 的 path。因此 v∼v：反身性來自長度 0 的 path，不需要 loop（簡單圖本來就沒有 loop）。",
          "en": "For any vertex v, the one-term sequence (v) is a walk with k=0 (there is no edge to check), and its single vertex is trivially distinct from the others, so it is a path from v to v. Hence v∼v: reflexivity comes from the length-zero path and needs no loop (a simple graph has none anyway)."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G2",
            "G3"
          ],
          "explanation": {
            "zh-Hant": "只用到 G2 允許 k=0。若定義只接受長度至少 1 的 path，孤立頂點 6 就不與自身連通，反身性會失敗，6 也會從所有分量中消失。",
            "en": "It uses only that G2 allows k=0. If only paths of length at least 1 were accepted, the isolated vertex 6 would not be connected to itself, reflexivity would fail, and 6 would vanish from every component."
          }
        },
        "leaf_basis": "def_unfold + exists_intro"
      },
      {
        "id": "S03",
        "uses": [
          "G2",
          "G3"
        ],
        "before_tex": "u\\sim v",
        "after_tex": "v\\sim u",
        "relation": "implies",
        "rule": "def_unfold",
        "conditions": [],
        "explanation": {
          "zh-Hant": "取由 u 到 v 的 path (x_i)_{i=0}^{k}，令 y_i=x_{k−i}。則 y_0=v、y_k=u；每對相鄰頂點 {y_{i−1},y_i}={x_{k−i+1},x_{k−i}} 是原 path 的一條邊，因為無向邊滿足 {a,b}={b,a}；頂點只是換了順序，仍兩兩相異。所以 (y_i) 是由 v 到 u 的 path。",
          "en": "Take a path (x_i)_{i=0}^{k} from u to v and set y_i=x_{k−i}. Then y_0=v and y_k=u; each consecutive pair {y_{i−1},y_i}={x_{k−i+1},x_{k−i}} is an edge of the original path, because an undirected edge satisfies {a,b}={b,a}; the vertices are only reordered and stay pairwise distinct. So (y_i) is a path from v to u."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G2",
            "G3",
            "graph_basics"
          ],
          "explanation": {
            "zh-Hant": "關鍵前提是邊為無序對。在有向圖中把弧反轉不一定仍是弧，所以這一步只在無向圖成立。反方向 v∼u⇒u∼v 是同一論證交換名稱，不需另證。",
            "en": "The key premise is that edges are unordered pairs. In a directed graph a reversed arc need not be an arc, so this step holds only for undirected graphs. The other direction v∼u⇒u∼v is the same argument with the names exchanged."
          }
        },
        "leaf_basis": "def_unfold + graph_basics"
      },
      {
        "id": "S04",
        "uses": [
          "G2",
          "G3"
        ],
        "before_tex": "u\\sim v,\\ v\\sim w",
        "after_tex": "\\text{there is a walk from }u\\text{ to }w",
        "relation": "implies",
        "rule": "def_unfold",
        "conditions": [],
        "explanation": {
          "zh-Hant": "取由 u 到 v 的 path (x_i)_{i=0}^{k} 與由 v 到 w 的 path (z_j)_{j=0}^{l}，因 x_k=v=z_0，把兩者在 v 處接起來得序列 (x_0,x_1,直到 x_k=z_0,z_1,直到 z_l)，長度 k+l。每對相鄰頂點都是原來某條 path 的邊，所以這是由 u 到 w 的 walk。但它不一定是 path：兩段可能經過同一頂點。例：0,1,2 與 2,1 接成 0,1,2,1，頂點 1 重複。",
          "en": "Take a path (x_i)_{i=0}^{k} from u to v and a path (z_j)_{j=0}^{l} from v to w. Since x_k=v=z_0, joining them at v gives the sequence (x_0, x_1, up to x_k=z_0, z_1, up to z_l) of length k+l. Each consecutive pair is an edge of one of the two paths, so this is a walk from u to w. It need not be a path: the two pieces may share a vertex. Example: 0,1,2 and 2,1 join to 0,1,2,1, where vertex 1 repeats."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G2",
            "G3"
          ],
          "explanation": {
            "zh-Hant": "只用到兩段在 v 處首尾相接，以及 walk 的定義不要求頂點相異。本步不宣稱得到 path；那是 S05 的引理的工作。",
            "en": "It uses only that the two pieces meet end to start at v and that a walk need not have distinct vertices. This step does not claim a path; that is the job of the lemma in S05."
          }
        },
        "leaf_basis": "def_unfold + exists_elim"
      },
      {
        "id": "S05",
        "uses": [
          "S04"
        ],
        "before_tex": "\\text{walk from }u\\text{ to }w",
        "after_tex": "u\\sim w",
        "relation": "implies",
        "rule": "L_walk_path",
        "conditions": [],
        "explanation": {
          "zh-Hant": "依引理 L_walk_path（在 S05.1、S05.2 證明），S04 的 walk 可換成由 u 到 w 的 path，所以 u∼w。連同 S04，這證明了 ∼ 的傳遞性。",
          "en": "By Lemma L_walk_path (proved in S05.1 and S05.2), the walk of S04 can be replaced by a path from u to w, so u∼w. Together with S04 this proves that ∼ is transitive."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S04",
            "L_walk_path"
          ],
          "explanation": {
            "zh-Hant": "需要 S04 的 walk 與引理。此步「有 walk 推出有 path」的反向確實成立，因每條 path 都是 walk。另須區分：從 u∼w 本身，不能對任選中介 v 推出 u∼v 且 v∼w；這是否定把傳遞性的兩個前提倒推回來，不是否定 walk/path 存在性的等價。",
            "en": "The step needs the walk from S04 and the lemma. The converse of this step's walk-to-path existence implication does hold, since every path is a walk. Separately, u∼w alone does not imply u∼v and v∼w for an arbitrarily chosen intermediate v. That rejects reversing the two-premise transitivity claim, not equivalence of walk and path existence."
          }
        },
        "leaf_basis": "well_ordering + contradiction + def_unfold"
      },
      {
        "id": "S05.1",
        "uses": [
          "G2",
          "well_ordering"
        ],
        "before_tex": "\\text{some walk from }u\\text{ to }w",
        "after_tex": "\\text{a walk }(y_i)_{i=0}^{m}\\text{ from }u\\text{ to }w\\text{ of least length }m",
        "relation": "implies",
        "rule": "well_ordering",
        "conditions": [],
        "explanation": {
          "zh-Hant": "所有由 u 到 w 的 walk 的長度構成 ℕ 的子集，且因至少有一條 walk 而非空。依良序原理它有最小元素 m；取一條長度為 m 的 walk (y_i)_{i=0}^{m}。",
          "en": "The lengths of all walks from u to w form a subset of ℕ, nonempty because at least one walk exists. By the well-ordering principle it has a least element m; take a walk (y_i)_{i=0}^{m} of length m."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "well_ordering"
          ],
          "explanation": {
            "zh-Hant": "需要長度集合非空且在 ℕ 中；不宣稱最短 walk 唯一。",
            "en": "It needs the set of lengths to be nonempty and inside ℕ; it does not claim the shortest walk is unique."
          }
        },
        "leaf_basis": "well_ordering + exists_elim"
      },
      {
        "id": "S05.2",
        "uses": [
          "S05.1",
          "G2"
        ],
        "before_tex": "(y_i)_{i=0}^{m}\\ \\text{shortest}",
        "after_tex": "y_i\\neq y_j\\ (i<j),\\ \\text{so }(y_i)\\text{ is a path}",
        "relation": "implies",
        "rule": "contradiction",
        "conditions": [],
        "explanation": {
          "zh-Hant": "假設某 i<j 有 y_i=y_j。刪去 y_{i+1} 到 y_j，得序列 (y_0 到 y_i, y_{j+1} 到 y_m)。接點處 {y_i,y_{j+1}}={y_j,y_{j+1}}∈E（若 j=m 則無接點邊），所以它仍是由 u 到 w 的 walk，長度 m−(j−i)<m，與 m 最小矛盾。故頂點兩兩相異，(y_i) 是 path。例：0,1,2,1 中 y_1=y_3=1，刪去後得 (0,1)，長度 3−(3−1)=1（N4）。S05.1 與 S05.2 合起來證得引理 L_walk_path。",
          "en": "Suppose y_i=y_j for some i<j. Delete y_{i+1} through y_j to get the sequence (y_0 to y_i, then y_{j+1} to y_m). At the junction {y_i,y_{j+1}}={y_j,y_{j+1}}∈E (if j=m there is no junction edge), so it is still a walk from u to w, of length m−(j−i)<m, contradicting the minimality of m. Hence the vertices are pairwise distinct and (y_i) is a path. Example: in 0,1,2,1 we have y_1=y_3=1, and deleting gives (0,1) of length 3−(3−1)=1 (N4). S05.1 and S05.2 together prove Lemma L_walk_path."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S05.1",
            "contradiction"
          ],
          "explanation": {
            "zh-Hant": "矛盾只依賴 S05.1 的最小性與 j−i≥1；刪去後的端點仍是 u 與 w，因為 y_0 與 y_m 都被保留（i≥0、若 j=m 則 y_i=y_m=w）。",
            "en": "The contradiction relies only on the minimality from S05.1 and j−i≥1; the endpoints remain u and w, since y_0 and y_m are kept (i≥0, and if j=m then y_i=y_m=w)."
          }
        },
        "leaf_basis": "contradiction + order_basics + def_unfold"
      },
      {
        "id": "S06",
        "uses": [
          "S02",
          "S03",
          "S05"
        ],
        "before_tex": "\\sim\\ \\text{reflexive, symmetric, transitive}",
        "after_tex": "\\bigcup_{v\\in V}[v]=V,\\ \\ [u]=[v]\\ \\lor\\ [u]\\cap[v]=\\varnothing",
        "relation": "implies",
        "rule": "L_classes_partition",
        "conditions": [],
        "explanation": {
          "zh-Hant": "由 S02、S03、S05，∼ 是 V 上的等價關係。依引理 L_classes_partition（在 S06.1、S06.2 證明），它的類覆蓋 V，且任兩類相等或不交。這就是 MKO 所說的「互斥且覆蓋全部頂點」。",
          "en": "By S02, S03 and S05, ∼ is an equivalence relation on V. By Lemma L_classes_partition (proved in S06.1 and S06.2), its classes cover V and any two classes are equal or disjoint. This is what the MKO means by 'mutually disjoint and covering every vertex'."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S02",
            "S03",
            "S05",
            "equiv_rel_def",
            "L_classes_partition"
          ],
          "explanation": {
            "zh-Hant": "三個公理缺一不可：若缺傳遞性，所謂的類可能相交而不相等（見負面對照）。",
            "en": "All three axioms are needed: without transitivity the so-called classes could meet without being equal (see the negative controls)."
          }
        },
        "leaf_basis": "equiv_rel_def + set_extensionality"
      },
      {
        "id": "S06.1",
        "uses": [
          "S02",
          "G3"
        ],
        "before_tex": "v\\sim v",
        "after_tex": "v\\in[v]",
        "relation": "equivalent",
        "rule": "set_builder",
        "conditions": [],
        "explanation": {
          "zh-Hant": "依集合建構式，v∈[v] 當且僅當 v∈V 且 v∼v；由 S02 後者成立。所以每個頂點都在自己的類中，各類的聯集是 V。",
          "en": "By set-builder notation, v∈[v] exactly when v∈V and v∼v, and the latter holds by S02. So each vertex lies in its own class and the classes together cover V."
        },
        "reverse_audit": {
          "kind": "inverse_equivalence",
          "required_ids": [
            "set_builder"
          ],
          "explanation": {
            "zh-Hant": "集合建構式的成員條件是雙向的：v∈[v] 也推回 v∼v。",
            "en": "Membership in a set-builder set is two-way: v∈[v] also gives back v∼v."
          }
        },
        "leaf_basis": "set_builder"
      },
      {
        "id": "S06.2",
        "uses": [
          "S03",
          "S05",
          "G3"
        ],
        "before_tex": "x\\in[u]\\cap[v]",
        "after_tex": "[u]=[v]",
        "relation": "implies",
        "rule": "set_extensionality",
        "conditions": [],
        "explanation": {
          "zh-Hant": "x∈[u]∩[v] 表示 u∼x 且 v∼x。由對稱 x∼v，再由傳遞 u∼v。若 y∈[v]，則 u∼v、v∼y，所以 u∼y，y∈[u]，得 [v]⊆[u]。同理由 v∼u（對稱）與 u∼y 得 [u]⊆[v]。依集合相等，[u]=[v]。逆否：不相等的兩類必不交。S06.1 與 S06.2 合起來證得引理 L_classes_partition。",
          "en": "x∈[u]∩[v] means u∼x and v∼x. By symmetry x∼v, and by transitivity u∼v. If y∈[v], then u∼v and v∼y give u∼y, so y∈[u]; thus [v]⊆[u]. Likewise v∼u (symmetry) and u∼y give [u]⊆[v]. By set equality [u]=[v]. Contrapositive: two unequal classes are disjoint. S06.1 and S06.2 together prove Lemma L_classes_partition."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S03",
            "S05",
            "set_extensionality"
          ],
          "explanation": {
            "zh-Hant": "需要對稱（S03）與傳遞（S05）各一次以上；不宣稱反向，即 [u]=[v] 不需要先知道交集元素是哪一個。",
            "en": "It needs symmetry (S03) and transitivity (S05); no converse is claimed beyond the trivial one."
          }
        },
        "leaf_basis": "set_extensionality + subset_def + contrapositive"
      },
      {
        "id": "S07",
        "uses": [
          "S01",
          "bfs_procedure"
        ],
        "before_tex": "R=\\{0\\},\\ \\text{queue }(0)",
        "after_tex": "R=\\{0,1,2\\},\\ \\text{queue empty}",
        "relation": "implies",
        "rule": "bfs_procedure",
        "conditions": [],
        "explanation": {
          "zh-Hant": "從 s=0 執行 BFS。取出 0：N(0)={1,2}，1、2 都不在 R，依序加入，R={0,1,2}，佇列 (1,2)。取出 1：N(1)={0,2} 都已在 R。取出 2：N(2)={0,1} 都已在 R。佇列空，停止。共取出 3 次，每次都檢查了被取出頂點的全部鄰點。",
          "en": "Run BFS from s=0. Remove 0: N(0)={1,2}; neither 1 nor 2 is in R, so both are added, R={0,1,2}, queue (1,2). Remove 1: N(1)={0,2} is already inside R. Remove 2: N(2)={0,1} is already inside R. The queue is empty, so BFS stops. There were 3 removals, and each one checked every neighbour of the removed vertex."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S01",
            "bfs_procedure"
          ],
          "explanation": {
            "zh-Hant": "需要 S01 的完整鄰點表，且每次取出都要檢查全部鄰點；這個完整掃描協定保證 S08.2 的封閉性，但不能說略過任一鄰點都必然破壞它：略過已在 R 的冗餘鄰點可不影響結果；略過尚未發現且沒有其他涵蓋證明的鄰點則可能失去完整性保證。取出順序 0、1、2 只是副產品，不是分量的證書。",
            "en": "It needs the complete neighbour lists of S01 and a check of every neighbour at each removal; this complete-scan protocol guarantees the closure of S08.2, but not every skipped check must destroy closure. Skipping a redundant neighbour already in R may change nothing; skipping an undiscovered neighbour with no other coverage can lose the completeness guarantee. The removal order 0, 1, 2 is a by-product, not a certificate of the component."
          }
        },
        "leaf_basis": "bfs_procedure + set_operations_def"
      },
      {
        "id": "S08",
        "uses": [
          "S07",
          "G1"
        ],
        "before_tex": "R=\\{0,1,2\\}\\ \\text{(complete BFS from 0)}",
        "after_tex": "[0]=\\{0,1,2\\}",
        "relation": "theorem_application",
        "rule": "L_bfs_exact",
        "conditions": [
          "G\\ \\text{finite, loop-free, simple}",
          "\\text{BFS run until the queue is empty}"
        ],
        "explanation": {
          "zh-Hant": "依引理 L_bfs_exact（在 S08.1 到 S08.3 證明），s=0 的完整 BFS 回傳的集合就是 [0]。所以 [0]={0,1,2}。",
          "en": "By Lemma L_bfs_exact (proved in S08.1 to S08.3), the set returned by complete BFS from s=0 is exactly [0]. So [0]={0,1,2}."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S07",
            "G1",
            "L_bfs_exact"
          ],
          "explanation": {
            "zh-Hant": "引理要求圖有限、無 loop、簡單，且 BFS 執行到佇列空；G1 與 S07 都滿足。",
            "en": "The lemma needs a finite loop-free simple graph and a BFS run until the queue is empty; G1 and S07 provide both."
          }
        },
        "leaf_basis": "set_extensionality + nat_induction + bfs_procedure"
      },
      {
        "id": "S08.1",
        "uses": [
          "S02",
          "S05",
          "bfs_procedure",
          "nat_induction"
        ],
        "before_tex": "x\\in R\\ \\text{at any moment of the run}",
        "after_tex": "s\\sim x",
        "relation": "implies",
        "rule": "nat_induction",
        "conditions": [
          "\\{x,y\\}\\in E\\Rightarrow x\\neq y"
        ],
        "explanation": {
          "zh-Hant": "對加入 R 的次數歸納。開始時 R={s}，且 s∼s（S02）。設某時刻 R 的每個元素都 ∼s。下一個被加入的 y 是某個被取出的 x∈R 的鄰點：s∼x（歸納假設）；{x,y}∈E 且 x≠y（無 loop），所以 (x,y) 是長度 1 的 path，x∼y；由傳遞性（S05）s∼y。故不變量「R⊆[s]」在每次加入後仍成立。",
          "en": "Induct on the number of additions to R. At the start R={s} and s∼s (S02). Suppose at some moment every element of R is ∼s. The next vertex y added is a neighbour of some removed x∈R: s∼x by the induction hypothesis; {x,y}∈E with x≠y (no loops), so (x,y) is a path of length 1 and x∼y; transitivity (S05) gives s∼y. So the invariant 'R⊆[s]' survives every addition."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S02",
            "S05",
            "nat_induction"
          ],
          "explanation": {
            "zh-Hant": "用到無 loop（x≠y 才使 (x,y) 為 path）與 S05 的傳遞性。這一步只證 R⊆[s]，不宣稱反向。",
            "en": "It uses loop-freeness (x≠y makes (x,y) a path) and the transitivity of S05. This step proves only R⊆[s]; the reverse inclusion is not claimed here."
          }
        },
        "leaf_basis": "nat_induction + subset_def"
      },
      {
        "id": "S08.2",
        "uses": [
          "G1",
          "bfs_procedure"
        ],
        "before_tex": "\\text{BFS from }s",
        "after_tex": "\\text{BFS stops};\\ \\forall x\\in R:\\ N(x)\\subseteq R",
        "relation": "implies",
        "rule": "bfs_procedure",
        "conditions": [
          "|V|<\\infty"
        ],
        "explanation": {
          "zh-Hant": "頂點只在第一次被加入 R 時排入佇列；R 只增不減且 R⊆V，所以每個頂點至多入列一次，對任意有限 V，取出次數至多 |V|（本例為 7），迴圈必停止（終止）。停止時佇列為空，所以 R 中每個頂點都已被取出；取出 x 時 N(x) 的每個 y 不是已在 R 就是被加入 R。因此 R 對鄰接封閉：對每個 x∈R 有 N(x)⊆R。",
          "en": "A vertex is queued only when it is first added to R; R only grows and R⊆V, so each vertex is queued at most once and for any finite V there are at most |V| removals (7 in this example), so the loop stops (termination). When it stops the queue is empty, so every vertex of R has been removed, and at the removal of x each y in N(x) was either already in R or added to R. Hence R is closed under adjacency: N(x)⊆R for every x∈R."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "bfs_procedure"
          ],
          "explanation": {
            "zh-Hant": "完整協定在佇列空時保證封閉，但非必要條件：本例取出 0 後，R={0,1,2} 已封閉，佇列仍是 (1,2)。另一方面，中途停止（例如在 0 的鄰點尚未全部檢查前）得到的集合不保證封閉，例如 {0,1} 不封閉，因 2∈N(0)。",
            "en": "The complete protocol guarantees closure at an empty queue, but this is not necessary: here after removing 0, R={0,1,2} is already closed while the queue is still (1,2). On the other hand, a run stopped midway (for example before all neighbours of 0 are checked) need not be closed, e.g. {0,1} is not closed since 2∈N(0)."
          }
        },
        "leaf_basis": "bfs_procedure + finite_counting_basics + subset_def"
      },
      {
        "id": "S08.3",
        "uses": [
          "S08.2",
          "G2",
          "G3",
          "nat_induction"
        ],
        "before_tex": "s\\sim w",
        "after_tex": "w\\in R,\\ \\text{hence }[s]\\subseteq R\\ \\text{and}\\ R=[s]",
        "relation": "implies",
        "rule": "nat_induction",
        "conditions": [],
        "explanation": {
          "zh-Hant": "取由 s 到 w 的 path (x_i)_{i=0}^{k}，對 i 歸納證 x_i∈R：x_0=s∈R；若 x_i∈R，因 {x_i,x_{i+1}}∈E，x_{i+1}∈N(x_i)⊆R（S08.2）。所以 w=x_k∈R，即 [s]⊆R。結合 S08.1 的 R⊆[s]，依集合相等得 R=[s]。S08.1 到 S08.3 合起來證得引理 L_bfs_exact。",
          "en": "Take a path (x_i)_{i=0}^{k} from s to w and prove x_i∈R by induction on i: x_0=s∈R; if x_i∈R, then {x_i,x_{i+1}}∈E gives x_{i+1}∈N(x_i)⊆R (S08.2). So w=x_k∈R, that is [s]⊆R. With R⊆[s] from S08.1, set equality gives R=[s]. S08.1 to S08.3 together prove Lemma L_bfs_exact."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S08.1",
            "S08.2",
            "set_extensionality"
          ],
          "explanation": {
            "zh-Hant": "完備性需要 S08.2 的封閉性，等式還需要 S08.1 的另一個包含；只有其中一個包含不足以得出 R=[s]。",
            "en": "Completeness needs the closure of S08.2, and the equality also needs the other inclusion from S08.1; either inclusion alone does not give R=[s]."
          }
        },
        "leaf_basis": "nat_induction + set_extensionality + subset_def"
      },
      {
        "id": "S09",
        "uses": [
          "S01",
          "S08"
        ],
        "before_tex": "R=\\{3\\},\\ \\text{queue }(3)",
        "after_tex": "[3]=\\{3,4,5\\}",
        "relation": "theorem_application",
        "rule": "L_bfs_exact",
        "conditions": [],
        "explanation": {
          "zh-Hant": "3 是不在 [0] 中的最小頂點。取出 3：N(3)={4}，加入 4。取出 4：N(4)={3,5}，3 已在 R，加入 5。取出 5：N(5)={4} 已在 R。佇列空，R={3,4,5}；依 L_bfs_exact，[3]={3,4,5}。",
          "en": "3 is the smallest vertex not in [0]. Remove 3: N(3)={4}, add 4. Remove 4: N(4)={3,5}; 3 is in R, add 5. Remove 5: N(5)={4} is in R. The queue is empty and R={3,4,5}; by L_bfs_exact, [3]={3,4,5}."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S01",
            "L_bfs_exact"
          ],
          "explanation": {
            "zh-Hant": "同 S08 的前提；起點的選法（最小未覆蓋頂點）只決定計算順序，不影響所得的類。",
            "en": "The same premises as S08; the choice of start (the smallest uncovered vertex) only fixes the order of work and does not affect the class obtained."
          }
        },
        "leaf_basis": "bfs_procedure + set_extensionality"
      },
      {
        "id": "S10",
        "uses": [
          "S01",
          "S02",
          "G2",
          "G3"
        ],
        "before_tex": "N(6)=\\varnothing",
        "after_tex": "[6]=\\{6\\}",
        "relation": "implies",
        "rule": "L_bfs_exact",
        "conditions": [],
        "explanation": {
          "zh-Hant": "6 是不在 [0]∪[3] 中的唯一頂點。BFS 取出 6，N(6)=∅，沒有加入任何點，R={6}，所以 [6]={6}。直接核對：長度至少 1 的 path 的第一條邊必含 6，但 E 中沒有含 6 的邊；所以由 6 出發只有長度 0 的 path (6)。孤立頂點形成單點分量，不能因為它不出現在邊集中就遺漏。",
          "en": "6 is the only vertex outside [0]∪[3]. BFS removes 6, N(6)=∅, nothing is added, R={6}, so [6]={6}. Direct check: the first edge of a path of length at least 1 would contain 6, but no edge of E contains 6; so the only path from 6 is the length-zero path (6). An isolated vertex forms a singleton component and must not be dropped just because it is absent from the edge set."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S01",
            "S02",
            "L_bfs_exact"
          ],
          "explanation": {
            "zh-Hant": "需要 N(6)=∅（S01）與長度 0 path（S02）；兩種論證（BFS 與直接核對）得出同一結果。",
            "en": "It needs N(6)=∅ (S01) and the length-zero path (S02); both arguments (BFS and the direct check) give the same result."
          }
        },
        "leaf_basis": "bfs_procedure + def_unfold"
      },
      {
        "id": "S11",
        "uses": [
          "S06",
          "S08",
          "S09",
          "S10"
        ],
        "before_tex": "[0]=\\{0,1,2\\},\\ [3]=\\{3,4,5\\},\\ [6]=\\{6\\}",
        "after_tex": "Q(G)=\\{\\{0,1,2\\},\\{3,4,5\\},\\{6\\}\\}",
        "relation": "implies",
        "rule": "L_classes_partition",
        "conditions": [],
        "explanation": {
          "zh-Hant": "三個集合兩兩不交，聯集為 V，元素個數 3+3+1=7=|V|（N2）。任取一類 [v]：v 屬於三者之一 C，於是 v∈[v]∩C，依 L_classes_partition 得 [v]=C。所以 Q(G) 恰有這三個類，例如 [1]=[2]=[0]、[4]=[5]=[3]。",
          "en": "The three sets are pairwise disjoint and their union is V, with 3+3+1=7=|V| elements (N2). Take any class [v]: v lies in one of the three, say C, so v∈[v]∩C, and L_classes_partition gives [v]=C. So Q(G) consists of exactly these three classes; for example [1]=[2]=[0] and [4]=[5]=[3]."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S06",
            "S08",
            "S09",
            "S10",
            "L_classes_partition"
          ],
          "explanation": {
            "zh-Hant": "需要三次 BFS 的結果與分割引理；只數到 2 個分量會留下頂點 6 未被覆蓋（3+3≠7，N3）。",
            "en": "It needs the three BFS results and the partition lemma; counting only 2 components would leave vertex 6 uncovered (3+3≠7, N3)."
          }
        },
        "leaf_basis": "set_operations_def + finite_counting_basics + set_extensionality"
      },
      {
        "id": "S12",
        "uses": [
          "S03",
          "S05",
          "G3"
        ],
        "before_tex": "C=[v]",
        "after_tex": "C\\ \\text{connected};\\ C\\subseteq S,\\ S\\ \\text{connected}\\Rightarrow S=C",
        "relation": "implies",
        "rule": "mko_component_def",
        "conditions": [],
        "explanation": {
          "zh-Hant": "C 中任兩點 a、b 都滿足 v∼a、v∼b，由對稱與傳遞有 a 到 b 的 path。還要確認它在 C 內：對路徑上任一頂點 z，把 v 到 a 的 path 與 a 到 z 的前段接成 walk，再用 L_walk_path 得 v∼z，故 z∈C。因此誘導子圖 G[C] 連通，不只是各點在原圖中連通。若連通子集 S⊇C，對任一 s∈S，S 內的 v 到 s 的 path 也是原圖 path，所以 s∈[v]=C，故 S=C。一般子集不能省略內部路徑要求，例如 {3,5} 在原圖可經 4 相連，但其誘導子圖不連通。{0,1} 則內部連通而真包含於 {0,1,2}，所以不是分量。",
          "en": "For a,b∈C, the relations v∼a and v∼b give an a-to-b path by symmetry and transitivity. Its vertices must also lie in C: for each vertex z along that path, concatenate a v-to-a path with the a-to-z prefix, then apply L_walk_path to obtain v∼z and hence z∈C. Thus the induced graph G[C] is connected, not merely ambient-connected. If a connected subset S contains C, every s∈S has a v-to-s path within S, also a path of the original graph; hence s∈[v]=C and S=C. For arbitrary subsets the internal-path requirement matters: {3,5} is connected in the ambient graph through 4 but its induced graph is disconnected. The set {0,1} is internally connected but properly contained in {0,1,2}, so it is not a component."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "S03",
            "S05",
            "G3"
          ],
          "explanation": {
            "zh-Hant": "極大性只需要對稱、傳遞與類的定義；不宣稱一個連通集必是分量。",
            "en": "Maximality needs only symmetry, transitivity and the definition of a class; it is not claimed that every connected set is a component."
          }
        },
        "leaf_basis": "set_extensionality + subset_def + def_unfold"
      },
      {
        "id": "S13",
        "uses": [
          "S06",
          "S11",
          "S12"
        ],
        "before_tex": "\\text{S06, S11, S12}",
        "after_tex": "Q(G)=\\{\\{0,1,2\\},\\{3,4,5\\},\\{6\\}\\},\\ \\text{maximal, disjoint, covering }V",
        "relation": "implies",
        "rule": "mko_component_def",
        "conditions": [],
        "explanation": {
          "zh-Hant": "∼ 是等價關係（S06），其類恰為 {0,1,2}、{3,4,5}、{6}（S11），每一類都是極大連通集（S12）。所以 G 的連通分量就是這三個集合，互斥且覆蓋全部頂點，孤立頂點 6 為單點分量。",
          "en": "∼ is an equivalence relation (S06), its classes are exactly {0,1,2}, {3,4,5} and {6} (S11), and each class is a maximal connected set (S12). So the connected components of G are these three sets, mutually disjoint and covering every vertex, with the isolated vertex 6 as a singleton component."
        },
        "reverse_audit": {
          "kind": "sufficient_goal_reduction",
          "required_ids": [
            "S06",
            "S11",
            "S12",
            "mko_component_def"
          ],
          "explanation": {
            "zh-Hant": "目標 G：Q(G) 恰為這三個極大、互斥且覆蓋 V 的集合。足夠條件 H：∼ 為等價關係、三個 BFS 結果等於各類、各類極大；H⇒G 由 MKO 的定義。H 由 S02 到 S12 從 G1 到 G3 正向證成，沒有把 G 當作前提。",
            "en": "Goal G: Q(G) is exactly these three maximal, disjoint sets covering V. Sufficient condition H: ∼ is an equivalence relation, the three BFS results equal the classes, and each class is maximal; H⇒G by the MKO's definition. H is proved forwards from G1 to G3 in S02 to S12; G is never used as a premise."
          }
        },
        "leaf_basis": "and_intro_elim + def_unfold"
      }
    ],
    "result": {
      "zh-Hant": "「有 path 相連」是 V 上的等價關係（反身性來自長度 0 path，傳遞性需把 walk 化為 path）。完整 BFS 的回傳集合恰為起點的類，所以 G 的連通分量為 {0,1,2}、{3,4,5}、{6}：互斥、覆蓋全部 7 個頂點、各自極大，孤立頂點 6 自成單點分量。",
      "en": "'Joined by a path' is an equivalence relation on V (reflexivity comes from length-zero paths, and transitivity needs a walk to be reduced to a path). The set returned by complete BFS is exactly the class of the start vertex, so the connected components of G are {0,1,2}, {3,4,5} and {6}: mutually disjoint, covering all 7 vertices and each maximal, with the isolated vertex 6 forming a singleton component."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "G 只有 2 個連通分量，因為分量由邊決定",
          "en": "G has only 2 connected components, because components are determined by edges"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "孤立頂點 6 形成單點分量 {6}；兩個分量只覆蓋 6 個頂點，3+3≠7。",
          "en": "The isolated vertex 6 forms the singleton component {6}; two components cover only 6 vertices, 3+3≠7."
        }
      },
      {
        "claim": {
          "zh-Hant": "把 u 到 v 的 path 與 v 到 w 的 path 接起來一定是 path，所以傳遞性顯然",
          "en": "Joining a path from u to v with a path from v to w always gives a path, so transitivity is obvious"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "0,1,2 與 2,1 接成 0,1,2,1，頂點 1 重複；需要 L_walk_path 把 walk 縮成 path。",
          "en": "0,1,2 and 2,1 join to 0,1,2,1, which repeats vertex 1; Lemma L_walk_path is needed to shorten the walk to a path."
        }
      },
      {
        "claim": {
          "zh-Hant": "頂點只有在帶 loop 時才與自身連通",
          "en": "A vertex is connected to itself only if it carries a loop"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "長度 0 的 path (v) 已給出 v∼v；簡單圖本來就沒有 loop。",
          "en": "The length-zero path (v) already gives v∼v; a simple graph has no loops at all."
        }
      },
      {
        "claim": {
          "zh-Hant": "{0,1} 是連通分量，因為 0 與 1 相鄰",
          "en": "{0,1} is a connected component because 0 and 1 are adjacent"
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "分量必須極大：{0,1} 真包含於連通集 {0,1,2}（S12）。",
          "en": "A component must be maximal: {0,1} lies strictly inside the connected set {0,1,2} (S12)."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "graph_basics",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "（簡單無向）圖：G=(V,E)，E 中每條邊是 V 中兩個相異頂點的無序對；頂點度數是與它相連的邊數；握手引理 Σ_v deg(v)=2|E|。",
          "en": "(Simple undirected) graph: G=(V,E), where each edge is an unordered pair of distinct vertices; the degree of a vertex is the number of edges at it; handshake lemma Σ_v deg(v)=2|E|."
        }
      },
      {
        "id": "set_extensionality",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "集合相等：A=B 當且僅當 A⊆B 且 B⊆A，即兩者有相同元素。",
          "en": "Set equality: A=B if and only if A⊆B and B⊆A, i.e. they have the same elements."
        }
      },
      {
        "id": "subset_def",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "子集：A⊆B 表示 A 的每個元素都是 B 的元素，即 ∀x (x∈A⇒x∈B)。",
          "en": "Subset: A⊆B means every element of A is an element of B, i.e. ∀x (x∈A⇒x∈B)."
        }
      },
      {
        "id": "well_ordering",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "良序原理：ℕ 的每個非空子集都有最小元素。",
          "en": "Well-ordering principle: every nonempty subset of ℕ has a least element."
        }
      },
      {
        "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": "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": "numeric_evaluation",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "明確整數或有理數算式的精確求值；可以獨立重算。",
          "en": "Exact evaluation of an explicit integer or rational expression; independently recomputable."
        }
      },
      {
        "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": "exists_intro",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "∃引入：若找到 a∈D 使 P(a) 成立，則 ∃x∈D, P(x)。",
          "en": "∃-introduction: if some a∈D satisfies P(a), then ∃x∈D, P(x)."
        }
      },
      {
        "id": "exists_elim",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "∃消去：由 ∃x∈D, P(x)，可取一個新名字 a 表示某個滿足 P(a) 的元素；只要最後結論不含 a，就可用 a 推理。",
          "en": "∃-elimination: from ∃x∈D, P(x) we may name some element a with P(a) by a fresh name; reasoning with a is allowed as long as the final conclusion does not mention a."
        }
      },
      {
        "id": "contradiction",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "反證法：若假設 ¬P 推出矛盾（某命題與其否定同時成立），則 P 成立。",
          "en": "Proof by contradiction: if assuming ¬P leads to a contradiction (a statement and its negation both hold), then P holds."
        }
      },
      {
        "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": "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": "set_operations_def",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "集合運算：x∈A∪B ⇔ x∈A 或 x∈B；x∈A∩B ⇔ x∈A 且 x∈B；x∈A∖B ⇔ x∈A 且 x∉B；在全集 U 中 Aᶜ=U∖A。",
          "en": "Set operations: x∈A∪B ⇔ x∈A or x∈B; x∈A∩B ⇔ x∈A and x∈B; x∈A∖B ⇔ x∈A and x∉B; in a universe U, Aᶜ=U∖A."
        }
      },
      {
        "id": "finite_counting_basics",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "有限計數：互斥有限集合 A、B 有 |A∪B|=|A|+|B|；|A×B|=|A|·|B|；有限集之間存在雙射 ⇔ 元素個數相同。",
          "en": "Finite counting: for disjoint finite sets A, B, |A∪B|=|A|+|B|; |A×B|=|A|·|B|; there is a bijection between finite sets ⇔ they have the same number of elements."
        }
      },
      {
        "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": "mko_component_def",
        "kind": "cited",
        "source": {
          "mko_id": "mko-connected-component",
          "sha256": "f921926c2c42fafc8d64364eb7bd06488901e081b0117ba17fc4265610e54eab",
          "commit": "b28a5edbd46279b1db2a3f3f48bb3f447e18899f"
        },
        "statement": {
          "zh-Hant": "在有限無向無 loop 簡單圖中，u 與 v 連通若存在 u 到 v 的 path；長度 0 path 保證反身性。此關係的等價類為互斥且覆蓋全部頂點的最大連通分量；孤立頂點形成單點分量。",
          "en": "In a finite undirected loop-free simple graph, u and v are connected if a path joins them; length-zero paths ensure reflexivity. The equivalence classes are the maximal connected components, mutually disjoint and covering every vertex. Isolated vertices form singleton components."
        }
      },
      {
        "id": "equiv_rel_def",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "等價關係：集合上的關係若反身（v∼v）、對稱（u∼v⇒v∼u）且傳遞（u∼v 且 v∼w ⇒ u∼w），稱為等價關係。",
          "en": "Equivalence relation: a relation on a set that is reflexive (v∼v), symmetric (u∼v⇒v∼u) and transitive (u∼v and v∼w ⇒ u∼w)."
        }
      },
      {
        "id": "bfs_procedure",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "BFS（起點 s）：令 R={s}、佇列為 (s)。佇列非空時，取出最前面的 x，依遞增順序檢查 N(x) 的每個 y：若 y∉R，把 y 加入 R 並排到佇列尾端。佇列空時停止並回傳 R。",
          "en": "BFS (start s): set R={s} and the queue to (s). While the queue is nonempty, remove its front vertex x and check every y in N(x) in increasing order: if y∉R, add y to R and append y to the queue. When the queue is empty, stop and return R."
        }
      },
      {
        "id": "L_walk_path",
        "kind": "lemma",
        "proved_in": [
          "S05.1",
          "S05.2"
        ],
        "statement": {
          "zh-Hant": "若有由 u 到 w 的 walk，則有由 u 到 w 的 path。",
          "en": "If there is a walk from u to w, there is a path from u to w."
        }
      },
      {
        "id": "L_classes_partition",
        "kind": "lemma",
        "proved_in": [
          "S06.1",
          "S06.2"
        ],
        "statement": {
          "zh-Hant": "對 V 上的等價關係 ∼：每個 v 都滿足 v∈[v]；若 [u]∩[v]≠∅，則 [u]=[v]。因此各類覆蓋 V，任兩類相等或不交。",
          "en": "For an equivalence relation ∼ on V: every v satisfies v∈[v], and if [u]∩[v]≠∅ then [u]=[v]. Hence the classes cover V and any two classes are equal or disjoint."
        }
      },
      {
        "id": "L_bfs_exact",
        "kind": "lemma",
        "proved_in": [
          "S08.1",
          "S08.2",
          "S08.3"
        ],
        "statement": {
          "zh-Hant": "在有限無 loop 簡單圖中，從 s 開始的完整 BFS 必停止，且回傳的 R 恰等於 [s]。",
          "en": "In a finite loop-free simple graph, complete BFS from s stops, and the set R it returns equals [s]."
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": [
      {
        "id": "N1",
        "step": "S01",
        "lhs": "2+2+2+1+2+1+0",
        "rhs": "2*5"
      },
      {
        "id": "N2",
        "step": "S11",
        "lhs": "3+3+1",
        "rhs": "7"
      },
      {
        "id": "N3",
        "step": "S11",
        "lhs": "3+3",
        "relation": "!=",
        "rhs": "7"
      },
      {
        "id": "N4",
        "step": "S05.2",
        "lhs": "3-(3-1)",
        "rhs": "1"
      }
    ]
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "只處理 MKO 範圍內的有限無向無 loop 簡單圖，頂點標籤 0 到 6 與完整邊集明示（假設 a1），可達性以完整 BFS 核對（假設 a2）。證明連通是等價關係、BFS 的正確性（不變量、終止與封閉性）以及分量的極大性。不處理有向圖的弱連通或強連通、分量縮約與演算法複雜度；不改動 canonical MKO 或英文 edition。",
      "en": "Works only inside the MKO's scope: a finite undirected loop-free simple graph with explicit labels 0 to 6 and a complete edge set (assumption a1), with reachability checked by complete BFS (assumption a2). It proves that connectivity is an equivalence relation, that BFS is correct (invariant, termination and closure) and that components are maximal. It does not treat weak or strong connectivity of directed graphs, component contraction or algorithmic complexity, and does not change the canonical MKO or its English edition."
    },
    "md_symbols": [
      [
        "V,E",
        "頂點集與無向邊集",
        "the vertex set and the undirected edge set"
      ],
      [
        "N(x)",
        "x 的鄰點集合 {y ∣ {x,y}∈E}",
        "the neighbour set {y ∣ {x,y}∈E} of x"
      ],
      [
        "u\\sim v",
        "u 與 v 之間有 path",
        "there is a path between u and v"
      ],
      [
        "[v]",
        "v 的等價類 {w∈V ∣ v∼w}",
        "the class {w∈V ∣ v∼w} of v"
      ],
      [
        "R",
        "BFS 的已訪集合",
        "the set of vertices visited by BFS"
      ],
      [
        "Q(G)",
        "G 的全部連通分量所成的集合",
        "the set of all connected components of G"
      ]
    ],
    "md_error_controls": [
      {
        "title": "遺漏孤立頂點 / Forgetting the isolated vertex",
        "zh": "頂點 6 不出現在任何邊中。若只從邊集讀分量，會得到 {0,1,2} 與 {3,4,5} 兩個分量，但 3+3=6≠7，頂點沒有被覆蓋。MKO 的長度 0 path 使 6∼6，所以 [6]={6} 是分量（S02、S10）。",
        "en": "Vertex 6 occurs in no edge. Reading components off the edge set alone gives the two components {0,1,2} and {3,4,5}, but 3+3=6≠7, so the vertices are not covered. The MKO's length-zero path gives 6∼6, so [6]={6} is a component (S02, S10)."
      },
      {
        "title": "走訪順序不是證書 / A traversal order is not a certificate",
        "zh": "BFS 的取出順序 0、1、2 與 DFS 可能給出的 0、2、1 不同，但分量是集合，證書是 S08.1 的不變量（R⊆[s]）加上 S08.2 的封閉性與 S08.3 的完備性。中途停止的走訪，例如得到 {0,1}，不封閉（2∈N(0)），不能當分量。",
        "en": "The BFS removal order 0, 1, 2 differs from an order such as 0, 2, 1 that DFS may give, but a component is a set, and its certificate is the invariant of S08.1 (R⊆[s]) together with the closure of S08.2 and the completeness of S08.3. A traversal stopped midway, giving say {0,1}, is not closed (2∈N(0)) and is not a component."
      },
      {
        "title": "不混用有向連通 / Do not mix in directed connectivity",
        "zh": "S03 的對稱性依賴 {a,b}={b,a}。在只有一條弧 0→1 的有向圖中，0 能到 1 而 1 不能到 0：強連通分量是 {0}、{1}，弱連通分量是 {0,1}。本稿只處理無向圖，兩種有向概念都不在範圍內（MKO 假設 a2）。",
        "en": "The symmetry in S03 rests on {a,b}={b,a}. In a directed graph with the single arc 0→1, 0 reaches 1 but 1 does not reach 0: the strong components are {0} and {1}, the weak component is {0,1}. This guide treats undirected graphs only; both directed notions are out of scope (MKO assumption a2)."
      }
    ],
    "md_open_items": [
      {
        "zh-Hant": "BFS 正確性引理 L_bfs_exact 對任何有限無 loop 簡單圖與任何起點都已證明；但 S07、S09、S10 的追蹤只屬於本例的圖。演算法複雜度與分量縮約（MKO 的下一步）不在本稿範圍。",
        "en": "The BFS correctness lemma L_bfs_exact is proved for every finite loop-free simple graph and every start vertex, but the traces in S07, S09 and S10 belong to this graph only. Algorithmic complexity and component contraction (the MKO's next step) are outside this guide."
      }
    ]
  },
  "revision": {
    "id": "production-20261019-adopted-96",
    "source_commit": "b28a5edbd46279b1db2a3f3f48bb3f447e18899f",
    "adopted_source_sha256": "9e85095d87f3af0794978b9701c095e7c028d9221792ebf6948c93758faaf755",
    "original_source_sha256": "fdbf75b71f4debe2b4bee1584829d8fc145de60bee34e74180799fb687ed655c",
    "owner_adopted": true,
    "bilingual_sync": "complete_source_bound",
    "formal_Lean": "NOT_RUN",
    "independent_AI_concurrence": "NOT_MEASURED",
    "issue_ids": [
      "BR-M084",
      "BR-M085",
      "BR-M086",
      "BR-M087"
    ],
    "scope": "Owner-adopted natural-language teaching guide; not a formal proof, canonical MKO rewrite or evidence-status promotion."
  }
}
