
theorem Th36:
  for G being _finite real-weighted WGraph, n being Nat holds card
((PRIM:CompSeq(G).n)`1) = min(n+1,
  card(G.reachableFrom(the Element of the_Vertices_of
  G)))
proof
  let G be _finite real-weighted WGraph;
  set CS = PRIM:CompSeq(G), src = the Element of the_Vertices_of G;
  defpred P[Nat] means card (PRIM:CompSeq(G).$1)`1 = min($1+1, card(G
  .reachableFrom(src)));
  set G0 = CS.0;
  src in G.reachableFrom(src) by GLIB_002:9;
  then {src} c= G.reachableFrom(src) by ZFMISC_1:31;
  then card {src} <= card G.reachableFrom(src) by NAT_1:43;
  then
A1: 0+1 <= card G.reachableFrom(src) by CARD_1:30;
A2: now
    let n be Nat;
    assume
A3: P[n];
    set Gn = PRIM:CompSeq(G).n, Gn1 = PRIM:CompSeq(G).(n+1);
    set e = the Element of PRIM:NextBestEdges(Gn);
A4: Gn1 = PRIM:Step(Gn) by Def17;
    now
      per cases;
      suppose
A5:     PRIM:NextBestEdges(Gn) = {};
        then
A6:     card Gn`1 = card G.reachableFrom(src) by Th35;
        then card G.reachableFrom(src) <= n+1 by A3,XXREAL_0:def 9;
        then
A7:     card G.reachableFrom(src) <= n+1+1 by NAT_1:12;
        card Gn1`1 = min(n+1, card (G.reachableFrom(src)) ) by A3,A4,A5,Def15;
        hence P[n+1] by A3,A6,A7,XXREAL_0:def 9;
      end;
      suppose
A8:     PRIM:NextBestEdges(Gn) <> {};
A9:     Gn`1 c= G.reachableFrom(src) by Th33;
A10:    Gn`1 <> G.reachableFrom(src) by A8,Th35;
A11:    now
          assume
A12:      card Gn`1 = card G.reachableFrom(src);
          Gn`1 c< G.reachableFrom(src) by A10,A9,XBOOLE_0:def 8;
          hence contradiction by A12,CARD_2:48;
        end;
        then
A13:    card Gn`1 = n+1 by A3,XXREAL_0:15;
        consider v being Vertex of G such that
A14:    not v in Gn`1 and
A15:    Gn1 = [Gn`1 \/ {v}, Gn`2 \/ {e}] by A4,A8,Th28;
A16:    card Gn1`1 = card (Gn`1 \/ {v}) by A15
          .= card Gn`1 + 1 by A14,CARD_2:41;
        card Gn`1 <= card G.reachableFrom(src) by Th33,NAT_1:43;
        then n+1 < card G.reachableFrom(src) by A11,A13,XXREAL_0:1;
        then n+1+1 <= card G.reachableFrom(src) by NAT_1:13;
        hence P[n+1] by A16,A13,XXREAL_0:def 9;
      end;
    end;
    hence P[n+1];
  end;
  G0 = PRIM:Init(G) by Def17;
  then {src} = G0`1;
  then card G0`1 = 1 by CARD_1:30;
  then
A17: P[ 0 ] by A1,XXREAL_0:def 9;
  for n being Nat holds P[n] from NAT_1:sch 2(A17,A2);
  hence thesis;
end;
