reserve n,m,i,j,k for Nat,
  x,y,e,X,V,U for set,
  W,f,g for Function;
reserve p,q for FinSequence;
reserve G for Graph,
  pe,qe for FinSequence of the carrier' of G;

theorem Th16:
  for p being Simple oriented Chain of G st p=pe^qe & len pe >=
1 & len qe >= 1 & (the Source of G).(p.1) <> (the Target of G).(p.len p) holds
not (the Source of G).(p.1) in vertices qe & not (the Target of G).(p.len p) in
  vertices pe
proof
  let p be Simple oriented Chain of G;
  set FT=the Target of G, FS=the Source of G;
  assume that
A1: p=pe^qe and
A2: len pe >= 1 and
A3: len qe >= 1 and
A4: FS.(p.1) <> FT.(p.len p);
  consider vs being FinSequence of the carrier of G such that
A5: vs is_oriented_vertex_seq_of p and
A6: for n,m st 1<=n & n<m & m<=len vs & vs.n=vs.m holds n=1 & m=len vs
  by GRAPH_4:def 7;
A7: len vs = len p + 1 by A5,GRAPH_4:def 5;
  then
A8: 1 <= len vs by NAT_1:12;
A9: len p = len pe + len qe by A1,FINSEQ_1:22;
  then
A10: len p >= 1 by A2,NAT_1:12;
  then p.1 orientedly_joins vs/.1, vs/.(1+1) by A5,GRAPH_4:def 5;
  then
A11: FS.(p.1)=vs/.1 by GRAPH_4:def 1
    .=vs.1 by A8,FINSEQ_4:15;
  p.len p orientedly_joins vs/.len p, vs/.(len p+1) by A5,A10,GRAPH_4:def 5;
  then
A12: FT.(p.len p)=vs/.(len p+1) by GRAPH_4:def 1
    .=vs.len vs by A7,A8,FINSEQ_4:15;
  hereby
    assume FS.(p.1) in vertices(qe);
    then consider x being Vertex of G such that
A13: FS.(p.1)=x and
A14: ex i st i in dom qe & x in vertices(qe/.i);
    consider i such that
A15: i in dom qe and
A16: x in vertices(qe/.i) by A14;
    set k=len pe + i;
A17: qe/.i=qe.i by A15,PARTFUN1:def 6
      .=p.k by A1,A15,FINSEQ_1:def 7;
    1 <= i by A15,FINSEQ_3:25;
    then
A18: 1 < i+1 by NAT_1:13;
    i <= len qe by A15,FINSEQ_3:25;
    then
A19: k <= len p by A9,XREAL_1:7;
    then
A20: k <= len vs by A7,NAT_1:13;
    1+i <= k by A2,XREAL_1:7;
    then
A21: 1 < k by A18,XXREAL_0:2;
    then
A22: p.k orientedly_joins vs/.k, vs/.(k+1) by A5,A19,GRAPH_4:def 5;
    per cases by A16,A17,TARSKI:def 2;
    suppose
A23:  x=FS.(p.k);
      FS.(p.k)=vs/.k by A22,GRAPH_4:def 1
        .=vs.k by A21,A20,FINSEQ_4:15;
      hence contradiction by A4,A6,A11,A12,A13,A21,A20,A23;
    end;
    suppose
A24:  x=FT.(p.k);
A25:  1 < k+1 by A21,NAT_1:13;
A26:  k+1 <= len vs by A7,A19,XREAL_1:7;
      FT.(p.k)=vs/.(k+1) by A22,GRAPH_4:def 1
        .=vs.(k+1) by A26,FINSEQ_4:15,NAT_1:12;
      hence contradiction by A4,A6,A11,A12,A13,A24,A26,A25;
    end;
  end;
  hereby
    assume FT.(p.len p) in vertices(pe);
    then consider x being Vertex of G such that
A27: FT.(p.len p)=x and
A28: ex i st i in dom pe & x in vertices(pe/.i);
    consider i such that
A29: i in dom pe and
A30: x in vertices(pe/.i) by A28;
A31: pe/.i=pe.i by A29,PARTFUN1:def 6
      .=p.i by A1,A29,FINSEQ_1:def 7;
A32: i <= len pe by A29,FINSEQ_3:25;
    then
A33: i <= len p by A9,NAT_1:12;
    then
A34: i < len vs by A7,NAT_1:13;
A35: 1 <= i by A29,FINSEQ_3:25;
    then
A36: p.i orientedly_joins vs/.i, vs/.(i+1) by A5,A33,GRAPH_4:def 5;
    per cases by A30,A31,TARSKI:def 2;
    suppose
A37:  x=FS.(p.i);
      FS.(p.i)=vs/.i by A36,GRAPH_4:def 1
        .=vs.i by A35,A34,FINSEQ_4:15;
      hence contradiction by A4,A6,A12,A27,A35,A34,A37;
    end;
    suppose
A38:  x=FT.(p.i);
A39:  i+1 <= len vs by A7,A33,XREAL_1:7;
      len pe+1 <= len pe + len qe & i+1 <= len pe+1 by A3,A32,XREAL_1:7;
      then i+1 <= len p by A9,XXREAL_0:2;
      then
A40:  1 <= i+1 & i+1 < len vs by A7,NAT_1:12,13;
      FT.(p.i)=vs/.(i+1) by A36,GRAPH_4:def 1
        .=vs.(i+1) by A39,FINSEQ_4:15,NAT_1:12;
      hence contradiction by A4,A6,A11,A12,A27,A38,A40;
    end;
  end;
end;
