Goal and scope
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.
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.
Main derivation
S01 · equivalent
Before
E=\{\{0,1\},\{0,2\},\{1,2\},\{3,4\},\{4,5\}\}After
N(0)=\{1,2\},\ N(1)=\{0,2\},\ N(2)=\{0,1\},\ N(3)=\{4\},\ N(4)=\{3,5\},\ N(5)=\{4\},\ N(6)=\varnothingConditions: none
Rule: graph_basics · Uses: G1
Leaf basis: graph_basics + set_builder + numeric_evaluation
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).
S02 · implies
Before
v\in V
After
v\sim v
Conditions: none
Rule: def_unfold · Uses: G2, G3
Leaf basis: def_unfold + exists_intro
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).
S03 · implies
Before
u\sim v
After
v\sim u
Conditions: none
Rule: def_unfold · Uses: G2, G3
Leaf basis: def_unfold + graph_basics
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.
S04 · implies
Before
u\sim v,\ v\sim w
After
\text{there is a walk from }u\text{ to }wConditions: none
Rule: def_unfold · Uses: G2, G3
Leaf basis: def_unfold + exists_elim
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.
S05 · implies
Before
\text{walk from }u\text{ to }wAfter
u\sim w
Conditions: none
Rule: L_walk_path · Uses: S04
Leaf basis: well_ordering + contradiction + def_unfold
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.
S06 · implies
Before
\sim\ \text{reflexive, symmetric, transitive}After
\bigcup_{v\in V}[v]=V,\ \ [u]=[v]\ \lor\ [u]\cap[v]=\varnothingConditions: none
Rule: L_classes_partition · Uses: S02, S03, S05
Leaf basis: equiv_rel_def + set_extensionality
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'.
S07 · implies
Before
R=\{0\},\ \text{queue }(0)After
R=\{0,1,2\},\ \text{queue empty}Conditions: none
Rule: bfs_procedure · Uses: S01, bfs_procedure
Leaf basis: bfs_procedure + set_operations_def
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.
S08 · theorem_application
Before
R=\{0,1,2\}\ \text{(complete BFS from 0)}After
[0]=\{0,1,2\}Conditions: G\ \text{finite, loop-free, simple}; \text{BFS run until the queue is empty}
Rule: L_bfs_exact · Uses: S07, G1
Leaf basis: set_extensionality + nat_induction + bfs_procedure
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}.
S09 · theorem_application
Before
R=\{3\},\ \text{queue }(3)After
[3]=\{3,4,5\}Conditions: none
Rule: L_bfs_exact · Uses: S01, S08
Leaf basis: bfs_procedure + set_extensionality
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}.
S10 · implies
Before
N(6)=\varnothing
After
[6]=\{6\}Conditions: none
Rule: L_bfs_exact · Uses: S01, S02, G2, G3
Leaf basis: bfs_procedure + def_unfold
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.
S11 · implies
Before
[0]=\{0,1,2\},\ [3]=\{3,4,5\},\ [6]=\{6\}After
Q(G)=\{\{0,1,2\},\{3,4,5\},\{6\}\}Conditions: none
Rule: L_classes_partition · Uses: S06, S08, S09, S10
Leaf basis: set_operations_def + finite_counting_basics + set_extensionality
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].
S12 · implies
Before
C=[v]
After
C\ \text{connected};\ C\subseteq S,\ S\ \text{connected}\Rightarrow S=CConditions: none
Rule: mko_component_def · Uses: S03, S05, G3
Leaf basis: set_extensionality + subset_def + def_unfold
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.
S13 · implies
Before
\text{S06, S11, S12}After
Q(G)=\{\{0,1,2\},\{3,4,5\},\{6\}\},\ \text{maximal, disjoint, covering }VConditions: none
Rule: mko_component_def · Uses: S06, S11, S12
Leaf basis: and_intro_elim + def_unfold
∼ 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.
Substeps and lemmas
S05.1 · implies
Before
\text{some walk from }u\text{ to }wAfter
\text{a walk }(y_i)_{i=0}^{m}\text{ from }u\text{ to }w\text{ of least length }mConditions: none
Rule: well_ordering · Uses: G2, well_ordering
Leaf basis: well_ordering + exists_elim
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.
S05.2 · implies
Before
(y_i)_{i=0}^{m}\ \text{shortest}After
y_i\neq y_j\ (i<j),\ \text{so }(y_i)\text{ is a path}Conditions: none
Rule: contradiction · Uses: S05.1, G2
Leaf basis: contradiction + order_basics + def_unfold
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.
S06.1 · equivalent
Before
v\sim v
After
v\in[v]
Conditions: none
Rule: set_builder · Uses: S02, G3
Leaf basis: set_builder
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.
S06.2 · implies
Before
x\in[u]\cap[v]
After
[u]=[v]
Conditions: none
Rule: set_extensionality · Uses: S03, S05, G3
Leaf basis: set_extensionality + subset_def + contrapositive
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.
S08.1 · implies
Before
x\in R\ \text{at any moment of the run}After
s\sim x
Conditions: \{x,y\}\in E\Rightarrow x\neq y
Rule: nat_induction · Uses: S02, S05, bfs_procedure, nat_induction
Leaf basis: nat_induction + subset_def
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.
S08.2 · implies
Before
\text{BFS from }sAfter
\text{BFS stops};\ \forall x\in R:\ N(x)\subseteq RConditions: |V|<\infty
Rule: bfs_procedure · Uses: G1, bfs_procedure
Leaf basis: bfs_procedure + finite_counting_basics + subset_def
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.
S08.3 · implies
Before
s\sim w
After
w\in R,\ \text{hence }[s]\subseteq R\ \text{and}\ R=[s]Conditions: none
Rule: nat_induction · Uses: S08.2, G2, G3, nat_induction
Leaf basis: nat_induction + set_extensionality + subset_def
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.
Error controls and negative controls
Forgetting the isolated vertex
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).
A traversal order is not a certificate
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.
Do not mix in directed connectivity
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).
- G has only 2 connected components, because components are determined by edges →
reject — The isolated vertex 6 forms the singleton component {6}; two components cover only 6 vertices, 3+3≠7. - Joining a path from u to v with a path from v to w always gives a path, so transitivity is obvious →
reject — 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. - A vertex is connected to itself only if it carries a loop →
reject — The length-zero path (v) already gives v∼v; a simple graph has no loops at all. - {0,1} is a connected component because 0 and 1 are adjacent →
reject — A component must be maximal: {0,1} lies strictly inside the connected set {0,1,2} (S12).