
theorem Th16:
  for G being _finite natural-weighted WGraph, source,sink being
  Vertex of G, n being Nat st source <> sink holds FF:CompSeq(G,source,sink).n
  has_valid_flow_from source,sink
proof
  let G be _finite natural-weighted WGraph, source,sink be Vertex of G, n be
  Nat;
  set CS = FF:CompSeq(G,source,sink);
  defpred P[Nat] means (CS.$1) has_valid_flow_from source,sink;
  now
    set G0 = CS.0;
A1: G0 = the_Edges_of G --> 0 by Def20;
    hence for e being set st e in the_Edges_of G holds 0 <= G0.e & G0.e <= (
    the_Weight_of G).e by FUNCOP_1:7;
    let v be Vertex of G;
    set B1 = EmptyBag v.edgesIn(), B2 = EmptyBag v.edgesOut();
    set E1 = (G0|v.edgesIn()), E2 = (G0|v.edgesOut());
    now
      let e be set;
      assume
A2:   e in v.edgesOut();
      then E2.e = G0.e by FUNCT_1:49
        .= 0 by A1,A2,FUNCOP_1:7;
      hence B2.e = E2.e by PBOOLE:5;
    end;
    then
A3: Sum E2 = Sum B2 by GLIB_004:6
      .= 0 by UPROOTS:11;
    assume that
    v <> source and
    v <> sink;
    now
      let e be set;
      assume
A4:   e in v.edgesIn();
      then E1.e = G0.e by FUNCT_1:49
        .= 0 by A1,A4,FUNCOP_1:7;
      hence B1.e = E1.e by PBOOLE:5;
    end;
    then Sum E1 = Sum B1 by GLIB_004:6
      .= 0 by UPROOTS:11;
    hence Sum E1 = Sum E2 by A3;
  end;
  then
A5: P[ 0 ] by Def2;
  assume
A6: source <> sink;
  now
    let n be Nat;
    set Gn = CS.n, Gn1 = CS.(n+1);
    assume
A7: Gn has_valid_flow_from source,sink;
A8: Gn1 = FF:Step(Gn,source,sink) by Def20;
    now
      per cases;
      suppose
A9:     sink in dom AP:FindAugPath(Gn,source);
        set P = AP:GetAugPath(Gn,source,sink);
A10:    P is_Walk_from source,sink by A9,Def14;
A11:    P is_augmenting_wrt Gn by A9,Def14;
        Gn1 = FF:PushFlow(Gn, P) by A8,A9,Def18;
        hence P[n+1] by A6,A7,A10,A11,Th14;
      end;
      suppose
        not sink in dom AP:FindAugPath(Gn,source);
        hence P[n+1] by A7,A8,Def18;
      end;
    end;
    hence P[n+1];
  end;
  then
A12: for n being Nat st P[n] holds P[n+1];
  for n being Nat holds P[n] from NAT_1:sch 2(A5,A12);
  hence thesis;
end;
