
theorem Th12:
  for G being _finite nonnegative-weighted WGraph, W being DPath of
G, x,y being set, m,n being Element of NAT st W is_mincost_DPath_from x,y holds
  W.cut(m,n) is_mincost_DPath_from W.cut(m,n).first(),W.cut(m,n).last()
proof
  let G be _finite nonnegative-weighted WGraph, W be DPath of G, x,y be set,
  m,n be Element of NAT;
  set WC = W.cut(m,n);
A1: WC is_Walk_from WC.first(),WC.last() by GLIB_001:def 23;
  assume
A2: W is_mincost_DPath_from x,y;
  then
A3: W is_Walk_from x,y;
  then
A4: W.1 = x & W.(len W) = y by GLIB_001:17;
  now
    per cases;
    suppose
A5:   m is odd & n is odd & m <= n & n <= len W;
      set W1 = W.cut(1,m), W3 = W.cut(n,len W);
A6:   1 <= n by A5,ABIAN:12;
      then
A7:   W.cut(1,n).append(W3) = W.cut(1,len W) by A5,GLIB_001:38,JORDAN12:2
        .= W by GLIB_001:39;
      W.cut(1,n).last() = W.n by A5,A6,GLIB_001:37,JORDAN12:2
        .= W3.first() by A5,GLIB_001:37;
      then
A8:   W.cost() = W.cut(1,n).cost() + W3.cost() by A7,GLIB_003:24;
A9:   1 <= m by A5,ABIAN:12;
      then
A10:  W1.append(WC) = W.cut(1,n) by A5,GLIB_001:38,JORDAN12:2;
A11:  m <= len W by A5,XXREAL_0:2;
      then W1.last() = W.m by A5,A9,GLIB_001:37,JORDAN12:2
        .= WC.first() by A5,GLIB_001:37;
      then W.cut(1,n).cost() = W1.cost() + WC.cost() by A10,GLIB_003:24;
      then
A12:  W.cost() = WC.cost() + (W1.cost() + W3.cost()) by A8;
A13:  W3 is_Walk_from W.n, W.(len W) by A5,GLIB_001:37;
A14:  W1 is_Walk_from W.1, W.m by A5,A9,A11,GLIB_001:37,JORDAN12:2;
      now
        assume not WC is_mincost_DPath_from WC.first(),WC.last();
        then consider W2 being DPath of G such that
A15:    W2 is_Walk_from WC.first(), WC.last() and
A16:    W2.cost() < WC.cost() by A1;
        set WA = W1.append(W2), WB = WA.append(W3);
        set WB2 = the DPath of WB;
A17:    WC.last() = W.n by A5,GLIB_001:37;
A18:    WC.first() = W.m by A5,GLIB_001:37;
        then WA is_Walk_from W.1, W.n by A14,A15,A17,GLIB_001:31;
        then WB is_Walk_from x,y by A4,A13,GLIB_001:31;
        then
A19:    WB2 is_Walk_from x,y by GLIB_001:160;
        W2.first() = W.m by A15,A18,GLIB_001:def 23;
        then
A20:    W1.last() = W2.first() by A5,A9,A11,GLIB_001:37,JORDAN12:2;
        then
A21:    WA.cost() = W1.cost() + W2.cost() by GLIB_003:24;
        W2.last() = W.n by A15,A17,GLIB_001:def 23;
        then W3.first() = W2.last() by A5,GLIB_001:37
          .= WA.last() by A20,GLIB_001:30;
        then WB.cost() = W1.cost() + W2.cost() + W3.cost() by A21,GLIB_003:24
          .= W2.cost() + (W1.cost() + W3.cost());
        then
A22:    WB.cost() < W.cost() by A12,A16,XREAL_1:8;
        WB2.cost() <= WB.cost() by GLIB_003:30;
        then WB2.cost() < W.cost() by A22,XXREAL_0:2;
        hence contradiction by A2,A19;
      end;
      hence thesis;
    end;
    suppose
      not (m is odd & n is odd & m <= n & n <= len W);
      then
A23:  WC = W by GLIB_001:def 11;
      then WC.first() = x by A3,GLIB_001:def 23;
      hence thesis by A2,A23,GLIB_001:def 23;
    end;
  end;
  hence thesis;
end;
