reserve p, q for FinSequence,
  e,X for set,
  i, j, k, m, n for Nat,
  G for Graph;
reserve x,y,v,v1,v2,v3,v4 for Element of G;
reserve vs, vs1, vs2 for FinSequence of the carrier of G,
  c, c1, c2 for oriented Chain of G;

theorem Th14:
  vs1 is_oriented_vertex_seq_of c1
  & vs2 is_oriented_vertex_seq_of c2 & vs1.len vs1 = vs2.1
  implies c1^c2 is oriented Chain of G
proof
  assume that
A1: vs1 is_oriented_vertex_seq_of c1 and
A2: vs2 is_oriented_vertex_seq_of c2 and
A3: vs1.len vs1 = vs2.1;
A4: vs1 is_vertex_seq_of c1 by A1,Th4;
A5: vs2 is_vertex_seq_of c2 by A2,Th4;
A6: len vs1 = len c1 + 1 by A1;
A7: len vs2 = len c2 + 1 by A2;
  set q=c1^c2;
  set p=vs1^'vs2;
  thus c1^c2 is oriented Chain of G
  proof
    reconsider cc=c1^c2 as Chain of G by A3,A4,A5,GRAPH_2:43;
    for n st 1 <= n & n < len q holds
    (the Source of G).(q.(n+1)) = (the Target of G).(q.n)
    proof
      let n;
      assume that
A8:   1 <= n and
A9:   n < len q;
A10:  n in dom q by A8,A9,FINSEQ_3:25;
A11:  n+1<=len q by A9,NAT_1:13;
A12:  1<n+1 by A8,NAT_1:13;
      now per cases by A10,FINSEQ_1:25;
        case
A13:      n in dom c1;
          then
A14:      q.n = c1.n by FINSEQ_1:def 7;
          set v1=vs1/.n;
          set v2=vs1/.(n+1);
A15:      1<=n by A13,FINSEQ_3:25;
A16:      n<=len c1 by A13,FINSEQ_3:25;
          then
A17:      c1.n orientedly_joins v1, v2 by A1,A15;
A18:      n<=len vs1 by A6,A16,NAT_1:12;
          n+1<=len c1+1 by A16,XREAL_1:6;
          then
A19:      n+1<=len vs1 by A1;
A20:      vs1/.n=vs1.n by A15,A18,FINSEQ_4:15;
A21:      vs1/.(n+1)=vs1.(n+1) by A19,FINSEQ_4:15,NAT_1:12;
A22:      p.n = vs1.n by A15,A18,FINSEQ_6:140;
          p.(n+1) = vs1.(n+1) by A19,FINSEQ_6:140,NAT_1:12;
          hence ex v1, v2 being Element of G st
          v1 = p.n & v2 = p.(n+1) & q.n orientedly_joins v1, v2 by A14,A17,A20
,A21,A22;
        end;
        case ex k being Nat st k in dom c2 & n=len c1 + k;
          then consider k being Nat such that
A23:      k in dom c2 and
A24:      n = len c1 + k;
          reconsider k as Element of NAT by ORDINAL1:def 12;
A25:      q.n = c2.k by A23,A24,FINSEQ_1:def 7;
A26:      1<=k by A23,FINSEQ_3:25;
A27:      k<=len c2 by A23,FINSEQ_3:25;
A28:      1<=k+1 by NAT_1:12;
A29:      k<=len vs2 by A7,A27,NAT_1:12;
          set v1 = vs2/.k;
          set v2 = vs2/.(k+1);
A30:      vs2/.k=vs2.k by A26,A29,FINSEQ_4:15;
A31:      vs2/.(k+1)=vs2.(k+1) by A7,A27,A28,FINSEQ_4:15,XREAL_1:7;
A32:      c2.k orientedly_joins v1, v2 by A2,A26,A27;
A33:      k<=len vs2 by A7,A27,NAT_1:12;
          0+1<=k by A23,FINSEQ_3:25;
          then consider j such that
          0<=j and
A34:      j<len vs2 and
A35:      k=j+1 by A33,FINSEQ_6:127;
A36:      p.n = vs2.k proof per cases by A26,XXREAL_0:1;
            suppose
A37:          1=k;
A38:          0+1<=len vs1 by A6,NAT_1:13;
              thus p.n = p.(len vs1) by A1,A24,A37
                .= vs2.k by A3,A37,A38,FINSEQ_6:140;
            end;
            suppose 1<k;
              then
A39:          1<=j by A35,NAT_1:13;
              thus p.n = p.(len c1 +1+j) by A24,A35
                .= p.(len vs1 +j) by A1
                .= vs2.k by A34,A35,A39,FINSEQ_6:141;
            end;
          end;
A40:      k<len vs2 by A7,A27,NAT_1:13;
          p.(n+1) = p.(len c1 +1+k) by A24
            .= p.(len vs1+k) by A1
            .= vs2.(k+1) by A26,A40,FINSEQ_6:141;
          hence ex v1, v2 being Element of G st v1 = p.n & v2 = p.(n+1)
          & q.n orientedly_joins v1, v2 by A25,A30,A31,A32,A36;
        end;
      end;
      then consider v1,v2 being Element of G such that
      v1=p.n and
A41:  v2=p.(n+1) and
A42:  q.n orientedly_joins v1,v2;
A43:  n+1 in dom q by A11,A12,FINSEQ_3:25;
A44:  now per cases by A43,FINSEQ_1:25;
        case
A45:      n+1 in dom c1;
          then
A46:      q.(n+1) = c1.(n+1) by FINSEQ_1:def 7;
          set v29=vs1/.(n+1),v3=vs1/.(n+1+1);
A47:      1<=n+1 by A45,FINSEQ_3:25;
A48:      n+1<=len c1 by A45,FINSEQ_3:25;
          then
A49:      c1.(n+1) orientedly_joins v29, v3 by A1,A47;
A50:      n+1<=len vs1 by A6,A48,NAT_1:12;
          n+1+1<=len c1+1 by A48,XREAL_1:6;
          then
A51:      n+1+1<=len vs1 by A1;
A52:      vs1/.(n+1)=vs1.(n+1) by A47,A50,FINSEQ_4:15;
A53:      vs1/.(n+1+1)=vs1.(n+1+1) by A51,FINSEQ_4:15,NAT_1:12;
A54:      p.(n+1) = vs1.(n+1) by A47,A50,FINSEQ_6:140;
          p.(n+1+1) = vs1.(n+1+1) by A51,FINSEQ_6:140,NAT_1:12;
          hence ex v299,v39 being Element of G st
          v299 = p.(n+1) & v39 = p.(n+1+1)
          & q.(n+1) orientedly_joins v299, v39 by A46,A49,A52,A53,A54;
        end;
        case ex k being Nat st k in dom c2 & (n+1)=len c1 + k;
          then consider k being Nat such that
A55:      k in dom c2 and
A56:      (n+1) = len c1 + k;
          reconsider k as Element of NAT by ORDINAL1:def 12;
A57:      q.(n+1) = c2.k by A55,A56,FINSEQ_1:def 7;
A58:      1<=k by A55,FINSEQ_3:25;
A59:      k<=len c2 by A55,FINSEQ_3:25;
A60:      1<=k+1 by NAT_1:12;
A61:      k<=len vs2 by A7,A59,NAT_1:12;
          set v29=vs2/.k, v3 = vs2/.(k+1);
A62:      vs2/.k=vs2.k by A58,A61,FINSEQ_4:15;
A63:      vs2/.(k+1)=vs2.(k+1) by A7,A59,A60,FINSEQ_4:15,XREAL_1:7;
A64:      c2.k orientedly_joins v29, v3 by A2,A58,A59;
A65:      k<=len vs2 by A7,A59,NAT_1:12;
          0+1<=k by A55,FINSEQ_3:25;
          then consider j such that
          0<=j and
A66:      j<len vs2 and
A67:      k=j+1 by A65,FINSEQ_6:127;
A68:      p.(n+1) = vs2.k proof per cases by A58,XXREAL_0:1;
            suppose
A69:          1=k;
A70:          0+1<=len vs1 by A6,NAT_1:13;
              thus p.(n+1) = p.(len vs1) by A1,A56,A69
                .= vs2.k by A3,A69,A70,FINSEQ_6:140;
            end;
            suppose 1<k;
              then
A71:          1<=j by A67,NAT_1:13;
              thus p.(n+1) = p.(len c1 +1+j) by A56,A67
                .= p.(len vs1 +j) by A1
                .= vs2.k by A66,A67,A71,FINSEQ_6:141;
            end;
          end;
A72:      k<len vs2 by A7,A59,NAT_1:13;
          p.((n+1)+1) = p.(len c1 +1+k) by A56
            .= p.(len vs1+k) by A1
            .= vs2.(k+1) by A58,A72,FINSEQ_6:141;
          hence ex v299,v39 being Element of G st
          v299 = p.(n+1) & v39 = p.((n+1)+1)
          & q.(n+1) orientedly_joins v299, v39 by A57,A62,A63,A64,A68;
        end;
      end;
      (the Target of G).(q.n) = v2 by A42;
      hence thesis by A41,A44;
    end;
    then cc is oriented by GRAPH_1:def 15;
    hence thesis;
  end;
end;
