
theorem Th15:
  for G being _finite real-weighted WGraph, L be DIJK:Labeling of G
holds (card dom (DIJK:Step(L))`1 = card dom L`1 iff DIJK:NextBestEdges(L) = {})
& (card dom (DIJK:Step(L))`1 = card dom L`1 + 1 iff DIJK:NextBestEdges(L)<>{})
proof
  let G be _finite real-weighted WGraph, L be DIJK:Labeling of G;
  set BestEdges = DIJK:NextBestEdges(L), e = the Element of BestEdges;
  set nextEG = L`2 \/ {e}, nL = DIJK:Step(L);
  set src = (the_Source_of G).e, target = (the_Target_of G).e;
  set val = (L`1).src + (the_Weight_of G).e;
  hereby
    assume
A1: card dom nL`1 = card dom L`1;
    now
      assume
A2:   BestEdges <> {};
      then nL = [L`1+*(target .--> val), nextEG] by Def8;
      then nL`1 = L`1+*(target .--> val);
      then
A3:   dom nL`1 = dom L`1 \/ {target} by Lm1;
      e in BestEdges by A2;
      then reconsider target as Vertex of G by FUNCT_2:5;
      e DSJoins dom L`1,the_Vertices_of G \ dom L`1, G by A2,Def7;
      then target in the_Vertices_of G \ dom L`1;
      then not target in dom L`1 by XBOOLE_0:def 5;
      then card dom nL`1 = card dom L`1 + 1 by A3,CARD_2:41;
      hence contradiction by A1;
    end;
    hence BestEdges = {};
  end;
  thus BestEdges = {} implies card dom nL`1 = card dom L`1 by Def8;
  hereby
    assume
A4: card dom nL`1 = card dom L`1 + 1;
    now
      assume BestEdges = {};
      then 0 + card dom L`1 = card dom L`1 + 1 by A4,Def8;
      hence contradiction;
    end;
    hence BestEdges <> {};
  end;
  assume
A5: BestEdges <> {};
  then nL = [L`1+*(target .--> val), nextEG] by Def8;
  then nL`1 = L`1+*(target .--> val);
  then
A6: dom nL`1 = dom L`1 \/ {target} by Lm1;
  e in BestEdges by A5;
  then reconsider target as Vertex of G by FUNCT_2:5;
  e DSJoins dom L`1,the_Vertices_of G \ dom L`1, G by A5,Def7;
  then target in the_Vertices_of G \ dom L`1;
  then not target in dom L`1 by XBOOLE_0:def 5;
  hence thesis by A6,CARD_2:41;
end;
