reserve x,y for set;
reserve G for Graph;
reserve vs,vs9 for FinSequence of the carrier of G;
reserve IT for oriented Chain of G;
reserve N for Nat;
reserve n,m,k,i,j for Nat;
reserve r,r1,r2 for Real;
reserve X for non empty set;

theorem Th18:
  for f being FinSequence of X holds PairF(f) is Simple & f.1<>f.
  len f implies f is one-to-one & len f<>1
proof
  let f be FinSequence of X;
  thus PairF(f) is Simple & f.1<>f.len f implies f is one-to-one & len f<>1
  proof
    reconsider f1=f as FinSequence of the carrier of PGraph(X);
    assume that
A1: PairF(f) is Simple and
A2: f.1<>f.len f;
    consider vs being FinSequence of the carrier of PGraph(X) such that
A3: vs is_oriented_vertex_seq_of PairF(f) and
A4: for n,m being Nat
   st 1<=n & n<m & m<=len vs & vs.n=vs.m holds n=1 & m=len vs
    by A1,GRAPH_4:def 7;
    now
      per cases;
      case
A5:     len f>=1;
        now
          per cases by A5,XXREAL_0:1;
          case
A6:         len f>1;
A7:         f1 is_oriented_vertex_seq_of PairF(f) by A5,Th7;
            then len f1=len PairF(f)+1 by GRAPH_4:def 5;
            then 1-1<len PairF(f)+1-1 by A6,XREAL_1:9;
            then PairF(f) <> {};
            then
A8:         vs = f1 by A3,A7,GRAPH_4:10;
         for x,y being object st x in dom f & y in dom f & f.x=f.y holds x=y
            proof
              let x,y be object;
              assume that
A9:           x in dom f and
A10:          y in dom f and
A11:          f.x=f.y;
              reconsider i=x,j=y as Element of NAT by A9,A10;
A12:          dom f=Seg len f by FINSEQ_1:def 3;
              then
A13:          i<=len f by A9,FINSEQ_1:1;
A14:          j<=len f by A10,A12,FINSEQ_1:1;
A15:          1<=j by A10,A12,FINSEQ_1:1;
A16:          1<=i by A9,A12,FINSEQ_1:1;
              now
                assume
A17:            i<>j;
                now
                  per cases by A17,XXREAL_0:1;
                  case
A18:                i<j;
                    then i=1 by A4,A8,A11,A16,A14;
                    hence contradiction by A2,A4,A8,A11,A14,A18;
                  end;
                  case
A19:                j<i;
                    then j=1 by A4,A8,A11,A13,A15;
                    hence contradiction by A2,A4,A8,A11,A13,A19;
                  end;
                end;
                hence contradiction;
              end;
              hence thesis;
            end;
            hence f is one-to-one;
          end;
          case
            len f=1;
            hence f is one-to-one by A2;
          end;
        end;
        hence f is one-to-one;
      end;
      case
        len f<1;
        then len f+1<=1 by NAT_1:13;
        then len f+1-1<=1-1 by XREAL_1:9;
        then len f=0;
        then Seg len f={};
        then for x,y being object st x in dom f & y in dom f & f.x=f.y
holds x=y by
FINSEQ_1:def 3;
        hence f is one-to-one;
      end;
    end;
    hence thesis by A2;
  end;
end;
