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 Th9:
  ex vs st vs is_oriented_vertex_seq_of c
proof
  now per cases;
    case
A1:   c <>{};
      defpred P[Nat,object] means
      (($1=len c+1 implies $2=(the Target of G).(c.len c)) &
      ($1<>len c+1 implies $2=(the Source of G).(c.$1)));
A2:   for k be Nat st k in Seg (len c+1) ex x being object st P[k,x]
      proof
        let k be Nat;
        assume k in Seg (len c+1);
        now per cases;
          case k=len c+1;
            hence thesis;
          end;
          case k<>len c+1;
            hence thesis;
          end;
        end;
        hence thesis;
      end;
      ex p st dom p = Seg (len c+1) & for k be Nat st k in Seg (len c+1) holds
      P[k,p.k] from FINSEQ_1:sch 1(A2);
      then consider p such that
A3:   dom p = Seg (len c+1) and
A4:   for k be Nat st k in Seg (len c+1) holds (k=len c+1 implies p.k=(
the Target of G).(c.len c)) & (k<>len c+1 implies p.k=(the Source of G).(c.k));
A5:   len p=len c+1 by A3,FINSEQ_1:def 3;
      rng p c= (the carrier of G)
      proof
        let y be object;
        assume y in rng p;
        then consider x being object such that
A6:     x in dom p and
A7:     y=p.x by FUNCT_1:def 3;
        reconsider k=x as Element of NAT by A6;
A8:     1<=k by A3,A6,FINSEQ_1:1;
A9:     k<=len c+1 by A3,A6,FINSEQ_1:1;
        now per cases;
          case k=len c+1;
            then
A10:        y=(the Target of G).(c.len c) by A3,A4,A6,A7;
            len c>=0+1 by A1,NAT_1:13;
            then len c in Seg len c by FINSEQ_1:1;
            then len c in dom c by FINSEQ_1:def 3;
            then
A11:        c.len c in rng c by FUNCT_1:def 3;
            rng c c= the carrier' of G by FINSEQ_1:def 4;
            hence thesis by A10,A11,FUNCT_2:5;
          end;
          case
A12:        k<>len c+1;
            then
A13:        y=(the Source of G).(c.k) by A3,A4,A6,A7;
            k<len c+1 by A9,A12,XXREAL_0:1;
            then k<=len c by NAT_1:13;
            then k in Seg len c by A8,FINSEQ_1:1;
            then k in dom c by FINSEQ_1:def 3;
            then
A14:        c.k in rng c by FUNCT_1:def 3;
            rng c c= the carrier' of G by FINSEQ_1:def 4;
            hence thesis by A13,A14,FUNCT_2:5;
          end;
        end;
        hence thesis;
      end;
then reconsider vs=p as FinSequence of (the carrier of G) by FINSEQ_1:def 4;
      for n st 1<=n & n<=len c holds c.n orientedly_joins vs/.n, vs/.(n+1)
      proof
        let n;
        assume that
A15:    1<=n and
A16:    n<=len c;
        per cases;
        suppose
A17:      n=len c;
          then
A18:      n<len c+1 by NAT_1:13;
          then n in Seg (len c +1) by A15,FINSEQ_1:1;
          then
A19:      p.n=(the Source of G).(c.n) by A4,A18;
          1<n+1 by A15,NAT_1:13;
          then n+1 in Seg (len c +1) by A17,FINSEQ_1:1;
          then
A20:      p.(n+1)=(the Target of G).(c.len c) by A4,A17;
A21:      (the Source of G).(c.n) = vs/.n by A5,A15,A18,A19,FINSEQ_4:15;
          1<n+1 by A15,NAT_1:13;
          then (the Target of G).(c.n) = vs/.(n+1) by A5,A17,A20,FINSEQ_4:15;
          hence thesis by A21;
        end;
        suppose n<>len c;
          then
A22:      n<len c by A16,XXREAL_0:1;
          then n+1<=len c by NAT_1:13;
          then
A23:      n+1<len c+1 by NAT_1:13;
A24:      n<len c+1 by A16,NAT_1:13;
          then n in Seg (len c +1) by A15,FINSEQ_1:1;
          then
A25:      p.n=(the Source of G).(c.n) by A4,A24;
          1<n+1 by A15,NAT_1:13;
          then n+1 in Seg (len c +1) by A23,FINSEQ_1:1;
          then
A26:      p.(n+1)=(the Source of G).(c.(n+1)) by A4,A23;
A27:      (the Source of G).(c.n) = vs/.n by A5,A15,A24,A25,FINSEQ_4:15;
          1<n+1 by A15,NAT_1:13;
          then vs/.(n+1)=p.(n+1) by A5,A23,FINSEQ_4:15;
then (the Target of G).(c.n) = vs/.(n+1) by A15,A22,A26,GRAPH_1:def 15;
          hence thesis by A27;
        end;
      end;
      then vs is_oriented_vertex_seq_of c by A5;
      hence thesis;
    end;
    case
A28:  c ={};
      set x = the Element of G;
      set vs=<*x*>;
      len c =0 by A28;
      then
A29:  len vs = len c + 1 by FINSEQ_1:40;
      for n st 1<=n & n<=len c holds c.n orientedly_joins vs/.n, vs/.(n+1)
      by A28;
      then vs is_oriented_vertex_seq_of c by A29;
      hence thesis;
    end;
  end;
  hence thesis;
end;
