
theorem Th23:
  for G being _finite nonnegative-weighted WGraph, s being Vertex
of G, n being Nat, G2 being inducedWSubgraph of G, dom (DIJK:CompSeq(s).n)`1, (
DIJK:CompSeq(s).n)`2 holds G2 is_mincost_DTree_rooted_at s & for v being Vertex
  of G st v in dom (DIJK:CompSeq(s).n)`1 holds G.min_DPath_cost(s,v) = (
  DIJK:CompSeq(s).n)`1.v
proof
  let G be _finite nonnegative-weighted WGraph, src be Vertex of G;
  set DCS = DIJK:CompSeq(src), D0 = DCS.0;
  defpred P[Nat] means for G2 being inducedWSubgraph of G,dom (DCS.$1)`1,(DCS.
$1)`2 holds G2 is_mincost_DTree_rooted_at src & for v being Vertex of G st v in
  dom (DCS.$1)`1 holds G.min_DPath_cost(src,v) = (DCS.$1)`1.v;
A1: D0 = DIJK:Init(src) by Def11;
  then
A2: D0`1 = src .--> 0;
  then
A3: dom D0`1 = {src};
  now
    let n be Nat;
    set Dn = DCS.n, Dn1 = DCS.(n+1);
    set BE = DIJK:NextBestEdges(Dn), e = the Element of BE;
    set source = (the_Source_of G).e, target = (the_Target_of G).e;
    set DnE = Dn`2 \/ {e};
    set pc = Dn`1.source;
    set ec = (the_Weight_of G).e;
    set DnW = the inducedWSubgraph of G,dom Dn`1,Dn`2;
A4: Dn1 = DIJK:Step(Dn) by Def11;
    assume
A5: P[n];
    then
A6: DnW is_mincost_DTree_rooted_at src;
    then
A7: DnW is Tree-like;
    let Dn1W be inducedWSubgraph of G,dom Dn1`1, Dn1`2;
A8: src in dom D0`1 & dom D0`1 c= dom Dn`1 by A3,Th18,TARSKI:def 1;
A9: Dn`2 c= G.edgesBetween(dom Dn`1) by Th22;
    then
A10: card Dn`2 = DnW.size() by A8,GLIB_000:def 37;
A11: Dn`2 c= G.edgesBetween(dom Dn`1) by Th22;
    then
A12: the_Vertices_of DnW = dom Dn`1 by A8,GLIB_000:def 37;
A13: the_Edges_of DnW = Dn`2 by A8,A11,GLIB_000:def 37;
A14: card dom Dn`1 = DnW.order() by A8,A9,GLIB_000:def 37;
    now
      per cases;
      suppose
        BE = {};
        then Dn1 = Dn by A4,Def8;
        hence Dn1W is_mincost_DTree_rooted_at src & for v being Vertex of G st
        v in dom Dn1`1 holds G.min_DPath_cost(src,v) = Dn1`1.v by A5;
      end;
      suppose
A15:    BE <> {};
        set mc = G.min_DPath_cost(src,target);
A16:    the_Weight_of Dn1W = (the_Weight_of G)| the_Edges_of Dn1W by
GLIB_003:def 10;
A17:    e DSJoins dom Dn`1, the_Vertices_of G \ dom Dn`1, G by A15,Def7;
        then
A18:    target in the_Vertices_of G\dom Dn`1;
        then
A19:    src <> target by A8,XBOOLE_0:def 5;
A20:    not target in dom Dn`1 by A18,XBOOLE_0:def 5;
        then
A21:    card (dom Dn`1 \/ {target}) = card dom Dn`1 + 1 by CARD_2:41;
A22:    source in dom Dn`1 by A17;
A23:    Dn1 = [Dn`1+*(target .--> (pc+ec)), DnE] by A4,A15,Def8;
        then Dn1`1 = Dn`1+*(target .--> (pc+ec));
        then
A24:    dom Dn1`1 = dom Dn`1 \/ {target} by Lm1;
A25:    Dn1`2 c= G.edgesBetween(dom Dn1`1) by Th22;
        then
A26:    the_Vertices_of Dn1W = dom Dn`1 \/ {target} by A24,GLIB_000:def 37;
        Dn1`2 = DnE by A23;
        then
A27:    the_Edges_of Dn1W =(Dn`2 \/ {e}) by A24,A25,GLIB_000:def 37;
A28:    now
          thus the_Vertices_of DnW c= the_Vertices_of Dn1W & the_Edges_of DnW
          c= the_Edges_of Dn1W by A12,A13,A26,A27,XBOOLE_1:7;
          let e be set;
          assume
A29:      e in the_Edges_of DnW;
          then
A30:      (the_Target_of DnW).e = (the_Target_of G).e by GLIB_000:def 32;
          e in the_Edges_of Dn1W & (the_Source_of DnW).e = (the_Source_of
          G).e by A13,A27,A29,GLIB_000:def 32,XBOOLE_0:def 3;
          hence
          (the_Source_of DnW).e = (the_Source_of Dn1W).e & (the_Target_of
          DnW).e = (the_Target_of Dn1W).e by A30,GLIB_000:def 32;
        end;
        then reconsider DnW9 = DnW as [Weighted] Subgraph of Dn1W by
GLIB_000:def 32;
        e in {e} by TARSKI:def 1;
        then
A31:    e in the_Edges_of Dn1W by A27,XBOOLE_0:def 3;
        e in BE by A15;
        then e DJoins source, target, G;
        then
A32:    e DJoins source, target, Dn1W by A31,GLIB_000:73;
        then
A33:    e Joins source, target, Dn1W;
A34:    the_Weight_of DnW9 = (the_Weight_of G)| the_Edges_of DnW by
GLIB_003:def 10;
A35:    now
          let y be object;
          assume y in dom the_Weight_of DnW9;
          then
A36:      y in the_Edges_of DnW;
          hence (the_Weight_of DnW9).y = (the_Weight_of G).y by A34,FUNCT_1:49
            .= (the_Weight_of Dn1W).y by A28,A16,A36,FUNCT_1:49;
        end;
        dom the_Weight_of Dn1W = the_Edges_of Dn1W by PARTFUN1:def 2;
        then dom (the_Weight_of Dn1W)/\the_Edges_of DnW = the_Edges_of DnW by
A28,XBOOLE_1:28;
        then dom the_Weight_of DnW9=dom (the_Weight_of Dn1W)/\ the_Edges_of
        DnW by PARTFUN1:def 2;
        then the_Weight_of DnW9 = (the_Weight_of Dn1W) | the_Edges_of DnW by
A35,FUNCT_1:46;
        then
A37:    DnW is WSubgraph of Dn1W by GLIB_003:def 10;
A38:    DnW is Subgraph of Dn1W by A28,GLIB_000:def 32;
        now
          let u,v be Vertex of Dn1W;
A39:      now
            let u,v be set;
            assume u in dom Dn`1 & v in dom Dn`1;
            then reconsider u9=u, v9=v as Vertex of DnW by A11,GLIB_000:def 37;
            consider W1 being Walk of DnW such that
A40:        W1 is_Walk_from u9,v9 by A7,GLIB_002:def 1;
            reconsider W2=W1 as Walk of Dn1W by A38,GLIB_001:167;
            W2 is_Walk_from u,v by A40,GLIB_001:19;
            hence ex W being Walk of Dn1W st W is_Walk_from u,v;
          end;
          now
            per cases by A26,XBOOLE_0:def 3;
            suppose
              u in dom Dn`1 & v in dom Dn`1;
              hence ex W being Walk of Dn1W st W is_Walk_from u,v by A39;
            end;
            suppose
A41:          u in dom Dn`1 & v in {target};
              then
A42:          v = target by TARSKI:def 1;
              consider W being Walk of Dn1W such that
A43:          W is_Walk_from u,source by A22,A39,A41;
              W.addEdge(e) is_Walk_from u,target by A33,A43,GLIB_001:66;
              hence ex W being Walk of Dn1W st W is_Walk_from u,v by A42;
            end;
            suppose
A44:          u in {target} & v in dom Dn`1;
              then consider W being Walk of Dn1W such that
A45:          W is_Walk_from v,source by A22,A39;
              W.addEdge(e) is_Walk_from v,target by A33,A45,GLIB_001:66;
              then W.addEdge(e) is_Walk_from v,u by A44,TARSKI:def 1;
              then W.addEdge(e).reverse() is_Walk_from u,v by GLIB_001:23;
              hence ex W being Walk of Dn1W st W is_Walk_from u,v;
            end;
            suppose
A46:          u in {target} & v in {target};
              take W = Dn1W.walkOf(u);
              u = target & v = target by A46,TARSKI:def 1;
              hence W is_Walk_from u,v by GLIB_001:13;
            end;
          end;
          hence ex W being Walk of Dn1W st W is_Walk_from u,v;
        end;
        then
A47:    Dn1W is connected by GLIB_002:def 1;
A48:    not e in Dn`2 by A9,A20,GLIB_000:31;
        then Dn1W.size() = DnW.size() + 1 by A10,A27,CARD_2:41;
        then Dn1W.order() = Dn1W.size() + 1 by A14,A7,A26,A21,GLIB_002:47;
        then
A49:    Dn1W is Tree-like by A47,GLIB_002:47;
        now
          consider WT being DPath of DnW such that
A50:      WT is_Walk_from src,source and
A51:      for W1 being DPath of G st W1 is_Walk_from src,source
          holds WT .cost() <= W1.cost() by A12,A6,A22;
          reconsider WT9=WT as DPath of Dn1W by A38,GLIB_001:175;
          set W2 = WT9.addEdge(e);
A52:      WT9 is_Walk_from src,source by A50,GLIB_001:19;
          then reconsider W2 as DWalk of Dn1W by A32,GLIB_001:123;
          now
            target in {target} by TARSKI:def 1;
            hence target is Vertex of Dn1W by A26,XBOOLE_0:def 3;
            thus e Joins WT9.last(),target,Dn1W by A33,A52,GLIB_001:def 23;
            ( not e in the_Edges_of DnW)& WT.edges() = WT9.edges() by A8,A9,A48
,GLIB_000:def 37,GLIB_001:110;
            hence not e in WT9.edges();
            thus WT9 is trivial or WT9 is open
            by GLIB_001:def 31,A49,GLIB_002:def 2;
            let n be odd Element of NAT;
            assume that
            1 < n and
A53:        n <= len WT9;
            WT9.vertices() = WT.vertices() by GLIB_001:98;
            then not target in WT9.vertices() by A12,A18,XBOOLE_0:def 5;
            hence WT9.n <> target by A53,GLIB_001:87;
          end;
          then reconsider W2 as DPath of Dn1W by GLIB_001:150;
          take W2;
          thus W2 is_Walk_from src,target by A33,A52,GLIB_001:66;
          now
            WT9.last() = source & (the_Source_of Dn1W).e = source by A32,A52,
GLIB_001:def 23;
            hence e in WT9.last().edgesInOut() by A31,GLIB_000:61;
            reconsider WTG = WT as DPath of G by GLIB_001:175;
A54:        WTG is_Walk_from src,source by A50,GLIB_001:19;
            (the_Weight_of Dn1W).e = ((the_Weight_of G) | the_Edges_of
            Dn1W).e by GLIB_003:def 10;
            hence ec = (the_Weight_of Dn1W).e by A31,FUNCT_1:49;
            pc = G.min_DPath_cost(src,source) by A5,A22;
            then consider WX being DPath of G such that
A55:        WX is_mincost_DPath_from src,source and
A56:        pc = WX.cost() by A54,Def3;
            WX is_Walk_from src,source by A55;
            then WT.cost() <= pc by A51,A56;
            then
A57:        WT9.cost() <= pc by A37,GLIB_003:27;
            pc <= WTG.cost() by A54,A55,A56;
            then pc <= WT9.cost() by GLIB_003:27;
            hence WT9.cost() = pc by A57,XXREAL_0:1;
          end;
          hence W2.cost() = pc + ec by GLIB_003:25;
        end;
        then consider W2 being DPath of Dn1W such that
A58:    W2 is_Walk_from src,target and
A59:    W2.cost() = pc+ec;
        reconsider W2G = W2 as DPath of G by GLIB_001:175;
A60:    W2G is_Walk_from src, target by A58,GLIB_001:19;
A61:    W2G.cost() = pc+ec by A59,GLIB_003:27;
        now
          consider WB being DPath of G such that
A62:      WB is_mincost_DPath_from src,target and
A63:      mc = WB.cost() by A60,Def3;
          thus mc <= pc+ec by A60,A61,A62,A63;
A64:      WB is_Walk_from src,target by A62;
          then reconsider target9=target as Vertex of G by GLIB_001:18;
          WB.first() = src & WB.last() = target by A64,GLIB_001:def 23;
          then consider lenWB2h being odd Element of NAT such that
A65:      lenWB2h = len WB - 2 and
A66:      WB.cut(1,lenWB2h).addEdge(WB.(lenWB2h+1)) = WB by A19,GLIB_001:127
,133;
A67:      lenWB2h < len WB - 0 by A65,XREAL_1:15;
          set sa = WB.lenWB2h, ea = WB.(lenWB2h+1);
          set WA = WB.cut(1,lenWB2h);
A68:      1 <= lenWB2h by ABIAN:12;
A69:      WB.1 = WB.first() by GLIB_001:def 6
            .= src by A64,GLIB_001:def 23;
          then WA is_Walk_from src,sa by A68,A67,GLIB_001:37,JORDAN12:2;
          then reconsider sa as Vertex of G by GLIB_001:18;
A70:      ea DJoins sa, WB.(lenWB2h+2), G by A67,GLIB_001:122;
          then
A71:      ea DJoins sa, WB.last(), G by A65,GLIB_001:def 7;
          then ea DJoins sa, target, G by A64,GLIB_001:def 23;
          then ea Joins sa,target9,G;
          then ea in sa.edgesInOut() by GLIB_000:62;
          then
A72:      ea in WA.last().edgesInOut() by A68,A67,GLIB_001:37,JORDAN12:2;
          then
A73:      mc = WA.cost() + (the_Weight_of G).ea by A63,A66,GLIB_003:25;
          reconsider WA as DPath of G;
A74:      WA.first() = src by A68,A67,A69,GLIB_001:37,JORDAN12:2;
A75:      WA.last() = sa by A68,A67,GLIB_001:37,JORDAN12:2;
          then
A76:      WA is_mincost_DPath_from src,sa by A62,A74,Th12;
A77:      ea DJoins sa, target, G by A64,A71,GLIB_001:def 23;
A78:      WA.cost() = G.min_DPath_cost(src,sa) by A62,A74,A75,Th12,Th14;
          now
            defpred P[Nat] means $1 is odd & $1 <= len WA & not WA.$1 in dom
            Dn`1;
A79:        (the_Source_of G).ea = sa by A70;
            assume
A80:        mc < pc+ec;
A81:        now
              assume
A82:          not sa in dom Dn`1;
              sa = WA.last() by A68,A67,GLIB_001:37,JORDAN12:2
                .= WA.(len WA) by GLIB_001:def 7;
              then
A83:          ex k being Nat st P[k] by A82;
              consider k being Nat such that
A84:          P[k] & for m being Nat st P[m] holds k <= m from NAT_1
              :sch 5(A83);
              reconsider k as odd Element of NAT by A84,ORDINAL1:def 12;
A85:          1 <= k by ABIAN:12;
              WA.1 = WA.first() by GLIB_001:def 6
                .= src by A68,A67,A69,GLIB_001:37,JORDAN12:2;
              then k <> 1 by A8,A84;
              then 1 < k by A85,XXREAL_0:1;
              then 1+1 < k+1 by XREAL_1:8;
              then 2 <= k by NAT_1:13;
              then reconsider k2a = k-2*1 as odd Element of NAT by INT_1:5;
              set sk = WA.k2a, ek = WA.(k2a+1), tk = WA.k;
A86:          k2a < len WA - 0 by A84,XREAL_1:15;
              set WKA = WA.cut(1,k), WKB = WA.cut(k,len WA);
              set WK1 = WA.cut(1,k2a);
              reconsider WK1, WKA, WKB as DPath of G;
A87:          1 <= k by ABIAN:12;
              then
A88:          WKA.append(WKB) = WA.cut(1,len WA) by A84,GLIB_001:38,JORDAN12:2
                .= WA by GLIB_001:39;
A89:          k2a < k - 0 by XREAL_1:15;
              then
A90:          sk in dom Dn`1 by A84,A86;
              then reconsider sk as Vertex of G;
A91:          1 <= k2a by ABIAN:12;
              then
A92:          WK1.last() = sk by A86,GLIB_001:37,JORDAN12:2;
              WK1.first() = WA.1 by A91,A86,GLIB_001:37,JORDAN12:2;
              then WK1 is_mincost_DPath_from WA.1, sk by A76,A92,Th12;
              then WK1 is_mincost_DPath_from WA.first(),sk by GLIB_001:def 6;
              then G.min_DPath_cost(src,sk) = WK1.cost() by A74,Th14;
              then
A93:          Dn`1.sk = WK1.cost() by A5,A84,A86,A89;
              reconsider tk as Vertex of G by A84,GLIB_001:7;
A94:          tk in the_Vertices_of G \ dom Dn`1 by A84,XBOOLE_0:def 5;
              tk = WA.(k2a+2);
              then
A95:          ek DJoins sk,tk,G by A86,GLIB_001:122;
              then
A96:          (the_Source_of G).ek = sk;
              WKB.first() = WA.k by A84,GLIB_001:37
                .= WKA.last() by A84,A87,GLIB_001:37,JORDAN12:2;
              then
A97:          WA.cost() = WKA.cost() + WKB.cost() by A88,GLIB_003:24;
              0 <= WKB.cost() by GLIB_003:29;
              then
A98:          0 qua Nat + WKA.cost() <= WA.cost() by A97,XREAL_1:7;
              ea in the_Edges_of G by A70;
              then
A99:         0 <= (the_Weight_of G).ea by GLIB_003:31;
              ek in the_Edges_of G & (the_Target_of G).ek = tk by A95;
              then ek DSJoins dom Dn`1,the_Vertices_of G \ dom Dn`1,G by A90
,A96,A94;
              then
A100:         pc+ec <= WK1.cost() + (the_Weight_of G).ek by A15,A96,A93,Def7;
              ek in the_Edges_of G & (the_Source_of G).ek = sk by A95;
              then
A101:         ek in sk.edgesInOut() by GLIB_000:61;
              k2a + 2 = k;
              then WK1.addEdge(ek) = WKA by A86,ABIAN:12,GLIB_001:41,JORDAN12:2
;
              then pc+ec <= WKA.cost() by A92,A100,A101,GLIB_003:25;
              then pc+ec <= WA.cost() by A98,XXREAL_0:2;
              then pc+ec+(0 qua Nat) <= WA.cost()+(the_Weight_of G).ea by A99,
XREAL_1:7;
              hence contradiction by A63,A66,A72,A80,GLIB_003:25;
            end;
            then
A102:       WA.cost() = Dn`1.sa by A5,A78;
            ea in the_Edges_of G & (the_Target_of G).ea=target by A77;
            then ea DSJoins dom Dn`1, the_Vertices_of G \ dom Dn`1,G by A18,A81
,A79;
            hence contradiction by A15,A73,A80,A102,A79,Def7;
          end;
          hence mc >= pc+ec;
        end;
        then
A103:   G.min_DPath_cost(src,target) = pc+ec by XXREAL_0:1;
        now
          let x be Vertex of Dn1W;
          now
            per cases by A26,XBOOLE_0:def 3;
            suppose
              x in dom Dn`1;
              then reconsider x9=x as Vertex of DnW by A11,GLIB_000:def 37;
              DnW is_mincost_DTree_rooted_at src by A5;
              then consider W2 being DPath of DnW such that
A104:         W2 is_Walk_from src,x9 and
A105:         for W1 being DPath of G st W1 is_Walk_from src,x9
              holds W2.cost() <= W1.cost();
              reconsider W29=W2 as DPath of Dn1W by A38,GLIB_001:175;
              take W29;
              thus W29 is_Walk_from src,x by A104,GLIB_001:19;
              let W1 be DPath of G;
              assume W1 is_Walk_from src,x;
              then W2.cost() <= W1.cost() by A105;
              hence W29.cost() <= W1.cost() by A37,GLIB_003:27;
            end;
            suppose
A106:         x in {target};
              take W2;
              thus W2 is_Walk_from src,x by A58,A106,TARSKI:def 1;
              let W1 be DPath of G;
              assume
A107:         W1 is_Walk_from src,x;
A108:         x = target by A106,TARSKI:def 1;
              ex WX being DPath of G st WX is_mincost_DPath_from src,
              target & WX.cost()=W2 .cost() by A59,A60,A103,Def3;
              hence W2.cost() <= W1.cost() by A108,A107;
            end;
          end;
          hence ex W2 being DPath of Dn1W st W2 is_Walk_from src,x & for W1
being DPath of G st W1 is_Walk_from src,x holds W2.cost() <= W1.cost();
        end;
        hence Dn1W is_mincost_DTree_rooted_at src by A49;
        let v be Vertex of G;
        assume
A109:   v in dom Dn1`1;
        now
          per cases by A24,A109,XBOOLE_0:def 3;
          suppose
A110:       v in dom Dn`1;
            then
A111:       G.min_DPath_cost(src,v) = Dn`1.v by A5;
A112:       Dn1`1 = Dn`1+*(target .-->(pc+ec)) by A23;
            not v in dom (target .-->(pc+ec)) by A20,A110,TARSKI:def 1;
            hence
            G.min_DPath_cost(src,v)=(Dn1`1).v by A24,A109,A111,A112,
FUNCT_4:def 1;
          end;
          suppose
A114:       v in {target};
            Dn1`1 = Dn`1+*(target .-->(pc+ec)) & dom (target .--> (pc+ec
            )) = {target} by A23;
            then
A115:       (Dn1`1).v = (target .--> (pc+ec)).v by A114,FUNCT_4:13;
            v = target by A114,TARSKI:def 1;
            hence G.min_DPath_cost(src,v) = (Dn1`1).v by A103,A115,FUNCOP_1:72;
          end;
        end;
        hence G.min_DPath_cost(src,v) = (Dn1`1).v;
      end;
    end;
    hence
    Dn1W is_mincost_DTree_rooted_at src & for v being Vertex of G st v in
    dom Dn1`1 holds G.min_DPath_cost(src,v) = (Dn1`1).v;
  end;
  then
A116: for k being Nat st P[k] holds P[k+1];
A117: D0`2 = {} by A1;
  now
    let D0W be inducedWSubgraph of G,dom D0`1,D0`2;
A118: {} c= G.edgesBetween(dom D0`1);
    then
A119: the_Vertices_of D0W = {src} by A3,A117,GLIB_000:def 37;
    then card (the_Vertices_of D0W) = 1 by CARD_1:30;
    then
A120: D0W is _trivial;
A121: now
      let x be Vertex of D0W;
      set W2 = D0W.walkOf(x);
      take W2;
      x = src by A119,TARSKI:def 1;
      hence W2 is_Walk_from src,x by GLIB_001:13;
      let W1 be DPath of G;
      assume W1 is_Walk_from src,x;
      0 <= W1.cost() by GLIB_003:29;
      hence W2.cost() <= W1.cost() by GLIB_003:21;
    end;
    the_Edges_of D0W = {} by A2,A117,A118,GLIB_000:def 37;
    then D0W.order() = D0W.size() + 1 by A119,CARD_1:30;
    then D0W is Tree-like by A120,GLIB_002:47;
    hence D0W is_mincost_DTree_rooted_at src by A121;
    let v be Vertex of G;
    assume
A122: v in dom D0`1;
    then
A123: v = src by A3,TARSKI:def 1;
A124: now
      set W1 = G.walkOf(v);
A125: W1 is_Walk_from src,v by A123,GLIB_001:13;
      then consider W being DPath of G such that
A126: W is_mincost_DPath_from src,v and
A127: G.min_DPath_cost(src,v) = W.cost() by Def3;
      W1.cost() = 0 by GLIB_003:21;
      then W.cost() <= 0 by A125,A126;
      hence G.min_DPath_cost(src,v) = 0 by A127,GLIB_003:29;
    end;
    D0`1.src = 0 by A2;
    hence G.min_DPath_cost(src,v) = D0`1.v by A3,A122,A124,TARSKI:def 1;
  end;
  then
A128: P[ 0 ];
  for n being Nat holds P[n] from NAT_1:sch 2(A128,A116);
  hence thesis;
end;
