
theorem Th37:
  for G being _finite real-weighted WGraph holds PRIM:CompSeq(G) is
  halting & PRIM:CompSeq(G).Lifespan() + 1
= card G.reachableFrom(the Element of
  the_Vertices_of G)
proof
  let G be _finite real-weighted WGraph;
  set PCS = PRIM:CompSeq(G);
  set src = the Element of the_Vertices_of G, RFS = G.reachableFrom(src);
  consider n being Nat such that
A1: n + 1 = card RFS by NAT_1:6;
  reconsider n as Element of NAT by ORDINAL1:def 12;
  set Gn = PCS.n, Gn1 = PCS.(n+1);
A2: card RFS <= card RFS + 1 by NAT_1:11;
A3: card Gn1`1 = min(card RFS + 1, card RFS) by A1,Th36
    .= card RFS by A2,XXREAL_0:def 9;
  set e = the Element of PRIM:NextBestEdges(Gn);
A4: card Gn`1 = min(card RFS, card RFS) by A1,Th36
    .= card RFS;
A5: Gn1 = PRIM:Step(Gn) by Def17;
  then
A6: Gn`1 c= Gn1`1 by Th29;
A7: now
    assume Gn`1 <> Gn1`1;
    then Gn`1 c< Gn1`1 by A6,XBOOLE_0:def 8;
    hence contradiction by A4,A3,CARD_2:48;
  end;
  now
    assume PRIM:NextBestEdges(Gn) <> {};
    then consider v being Vertex of G such that
A8: not v in Gn`1 and
A9: Gn1 = [Gn`1 \/ {v}, Gn`2 \/ {e}] by A5,Th28;
A10: v in {v} by TARSKI:def 1;
    Gn1`1 = Gn`1 \/ {v} by A9;
    hence contradiction by A7,A8,A10,XBOOLE_0:def 3;
  end;
  then
A11: Gn1 = Gn by A5,Def15;
  hence
A12: PCS is halting;
  now
    let m be Nat;
    set Gm = PCS.m;
    assume
A13: PCS.m = PCS.(m+1);
    now
      assume m < n;
      then
A14:  m+1 <= n by NAT_1:13;
      n+0 < card RFS by A1,XREAL_1:8;
      then
A15:  m+1 < card RFS by A14,XXREAL_0:2;
      then
A16:  m+1+1 <= card RFS by NAT_1:13;
A17:  card Gm`1 = min(m+1, card RFS) by Th36
        .= m+1 by A15,XXREAL_0:def 9;
      card Gm`1 = min(m+1+1,card RFS) by A13,Th36
        .= m+1+1 by A16,XXREAL_0:def 9;
      hence contradiction by A17;
    end;
    hence n <= m;
  end;
  hence thesis by A1,A11,A12,GLIB_000:def 56;
end;
