
theorem Th35:
  for G being _finite real-weighted WGraph, n being Nat holds
  PRIM:NextBestEdges(PRIM:CompSeq(G).n) = {} iff (PRIM:CompSeq(G).n)`1 = G
  .reachableFrom(the Element of the_Vertices_of G)
proof
  let G be _finite real-weighted WGraph, n be Nat;
  set src = the Element of the_Vertices_of G;
  set PCS = PRIM:CompSeq(G), RFS = G.reachableFrom(src);
  set Gn = PCS.n;
  set EG = the_Edges_of G;
  set Next = PRIM:NextBestEdges(Gn);
  set GnV = Gn`1, GnVg = the_Vertices_of G \ GnV;
  set e = the Element of Next;
  hereby
    assume
A1: Next = {};
    now
      defpred P1[set] means $1 SJoins GnV, GnVg, G;
      assume
A2:   GnV <> RFS;
      consider BE1 being Subset of EG such that
A3:   for x being set holds x in BE1 iff x in EG & P1[x] from SUBSET_1
      :sch 1;
      GnV c= RFS by Th33;
      then
A4:   GnV c< RFS by A2,XBOOLE_0:def 8;
      now
        src in {src} by TARSKI:def 1;
        then src in (PRIM:Init(G))`1;
        then
A5:     src in (PCS.0)`1 by Def17;
        assume
A6:     BE1 = {};
        consider v being object such that
A7:     v in RFS and
A8:     not v in Gn`1 by A4,XBOOLE_0:6;
        reconsider v as Vertex of G by A7;
        consider W being Walk of G such that
A9:     W is_Walk_from src, v by A7,GLIB_002:def 5;
        defpred P2[Nat] means $1 is odd & $1 <= len W & not W.$1 in GnV;
        W.(len W) = W.last() by GLIB_001:def 7
          .= v by A9,GLIB_001:def 23;
        then
A10:    ex k being Nat st P2[k] by A8;
        consider k being Nat such that
A11:    P2[k] & for m being Nat st P2[m] holds k <= m from NAT_1:sch
        5(A10 );
A12:    (PCS.0)`1 c= Gn`1 by Th34;
        now
          per cases;
          suppose
            k = 1;
            then W.k = W.first() by GLIB_001:def 6
              .= src by A9,GLIB_001:def 23;
            hence contradiction by A5,A12,A11;
          end;
          suppose
A13:        k <> 1;
            reconsider k9=k as odd Element of NAT by A11,ORDINAL1:def 12;
            1 <= k by A11,ABIAN:12;
            then 1 < k by A13,XXREAL_0:1;
            then 1+1 <= k by NAT_1:13;
            then reconsider k2a = k9-2*1 as odd Element of NAT by INT_1:5;
            set e = W.(k2a+1);
A14:        k - 2 < len W - 0 by A11,XREAL_1:15;
            then
A15:        e Joins W.k2a, W.(k2a+2),G by GLIB_001:def 3;
            then
A16:        e in EG;
            k2a < k - 0 by XREAL_1:15;
            then
A17:        W.k2a in GnV by A11,A14;
            W.k in the_Vertices_of G by A15,GLIB_000:13;
            then W.k in GnVg by A11,XBOOLE_0:def 5;
            then P1[e] by A17,A15,GLIB_000:17;
            hence contradiction by A3,A6,A16;
          end;
        end;
        hence contradiction;
      end;
      then reconsider BE1 as non empty finite set;
      deffunc F(Element of BE1) = (the_Weight_of G).$1;
      consider e1 being Element of BE1 such that
A18:  for e2 being Element of BE1 holds F(e1)<=F(e2) from PRE_CIRC:sch 5;
A19:  now
        let e2 be set;
        assume
A20:    e2 SJoins GnV, GnVg, G;
        reconsider e29 = e2 as Element of BE1 by A3,A20;
        (the_Weight_of G).e1 <= (the_Weight_of G).e29 by A18;
        hence (the_Weight_of G).e1 <= (the_Weight_of G).e2;
      end;
      e1 SJoins GnV, GnVg, G by A3;
      hence contradiction by A1,A19,Def13;
    end;
    hence GnV = RFS;
  end;
  assume
A21: GnV = RFS;
  now
    assume Next <> {};
    then
A22: e SJoins GnV, GnVg, G by Def13;
    then
A23: e in EG;
    now
      per cases by A22;
      suppose
A24:    (the_Source_of G).e in GnV & (the_Target_of G).e in GnVg;
A25:    e Joins (the_Source_of G).e, (the_Target_of G).e, G by A23;
        not (the_Target_of G).e in GnV by A24,XBOOLE_0:def 5;
        hence contradiction by A21,A24,A25,GLIB_002:10;
      end;
      suppose
A26:    (the_Source_of G).e in GnVg & (the_Target_of G).e in GnV;
A27:    e Joins (the_Target_of G).e, (the_Source_of G).e, G by A23;
        not (the_Source_of G).e in GnV by A26,XBOOLE_0:def 5;
        hence contradiction by A21,A26,A27,GLIB_002:10;
      end;
    end;
    hence contradiction;
  end;
  hence thesis;
end;
