reserve x,y,X for set,
  i,j,k,m,n for Nat,
  p for FinSequence of X,
  ii for Integer;
reserve G for Graph,
  pe,qe for FinSequence of the carrier' of G,
  p,q for oriented Chain of G,
  W for Function,
  U,V,e,ee for set,
  v1,v2,v3,v4 for Vertex of G;
reserve G for finite Graph,
  P,Q for oriented Chain of G,
  v1,v2,v3 for Vertex of G;
reserve G for finite oriented Graph,
  P,Q for oriented Chain of G,
  W for Function of (the carrier' of G), Real>=0,
  v1,v2,v3,v4 for Vertex of G;

theorem Th14:
  e in the carrier' of G & P=<*e*> & e orientedly_joins v1,v2
  implies P is_shortestpath_of v1,v2,{v1},W
proof
  assume that
A1: e in the carrier' of G and
A2: P=<*e*> and
A3: e orientedly_joins v1,v2;
A4: len P = 1 by A2,FINSEQ_1:40;
  then
A5: vertices(P)=vertices(P/.1) by GRAPH_5:25;
  set FS=the Source of G, FT=the Target of G, Eg=the carrier' of G;
A6: FS.e = v1 & FT.e = v2 by A3,GRAPH_4:def 1;
A7: now
    let S be oriented Chain of G;
    assume
A8: S is_orientedpath_of v1,v2,{v1};
    W is_weight>=0of G by GRAPH_5:def 13;
    then consider s being Simple oriented Chain of G such that
A9: s is_shortestpath_of v1,v2,{v1},W by A8,GRAPH_5:62;
    set Vs=vertices s;
A10: s is_orientedpath_of v1,v2,{v1} by A9,GRAPH_5:def 18;
    then
A11: s is_orientedpath_of v1,v2 by GRAPH_5:def 4;
    then s <> {} by GRAPH_5:def 3;
    then
 len s >=1 by FINSEQ_1:20;
    then consider i being Nat such that
A12: len s = 1+i by NAT_1:10;
A13: FT.(s.len s)=v2 by A11,GRAPH_5:def 3;
A14: FS.(s.1)=v1 by A11,GRAPH_5:def 3;
    consider s1,s2 being FinSequence such that
A15: len s1 = i and
A16: len s2 = 1 and
A17: s = s1^s2 by A12,FINSEQ_2:22;
    reconsider s1,s2 as Simple oriented Chain of G by A17,GRAPH_5:14;
    Vs \ {v2} c= {v1} by A10,GRAPH_5:def 4;
    then Vs c= {v2} \/ {v1} by XBOOLE_1:44;
    then
A18: Vs c= {v1,v2} by ENUMSET1:1;
    now
      reconsider vx=FS.(s2.1) as Vertex of G by A16,Lm3;
A19:  len s1 < len s by A12,A15,NAT_1:13;
A20:  vx in vertices(s2) by A16,Lm4;
      vertices(s2) c= vertices(s1^s2) by GRAPH_5:26;
      then
A21:  vertices(s2) c= {v1,v2} by A18,A17;
      assume s1 <> {};
      then
A22:  len s1 >=1 by FINSEQ_1:20;
      then
A23:  FS.(s.1) <> FS.(s2.1) by A16,A17,Th6;
      len s2 =1 by A16;
      then
A24:  FT.(s.len s) <> FT.(s1.len s1) by A17,A22,Th6;
      FS.(s2.1)=FS.(s.(len s1+1)) by A16,A17,Lm2
        .=FT.(s.len s1) by A22,A19,GRAPH_1:def 15
        .=FT.(s1.len s1) by A17,A22,Lm1;
      hence contradiction by A14,A13,A24,A23,A21,A20,TARSKI:def 2;
    end;
    then
A25: len s= 0+1 by A12,A15;
    s/.1 in Eg by A1;
    then s.1 in Eg by A25,FINSEQ_4:15;
    then e = s.1 by A1,A6,A14,A13,A25,GRAPH_1:def 7;
    then s = P by A2,A25,FINSEQ_1:40;
    hence cost(P,W) <= cost(S,W) by A8,A9,GRAPH_5:def 18;
  end;
A26: P.1=e by A2;
  then P/.1=e by A4,FINSEQ_4:15;
  then vertices(P)={v1,v2} by A6,A5,GRAPH_5:def 1;
  then
A27: vertices(P) \ {v2} = ({v1} \/ {v2}) \{v2} by ENUMSET1:1
    .={v1} \ {v2} by XBOOLE_1:40;
  P is_orientedpath_of v1,v2 by A2,A6,A4,A26,GRAPH_5:def 3;
  then P is_orientedpath_of v1,v2,{v1} by A27,GRAPH_5:def 4;
  hence thesis by A7,GRAPH_5:def 18;
end;
