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

theorem
  sc is Path of G iff len sc = 0 or len sc = 1 or sc.1<>sc.2
proof
  hereby
    assume
A1: sc is Path of G;
    assume
A2: not len sc = 0;
    assume not len sc = 1;
    then len sc >1 by A2,NAT_1:25;
    then
A3: 1+1<=len sc by NAT_1:13;
    assume sc.1 = sc.2;
    hence contradiction by A1,A3,GRAPH_1:def 16;
  end;
  assume
A4: len sc = 0 or len sc = 1 or sc.1<>sc.2;
  per cases by A4;
  suppose
    len sc = 0;
    then for n, m st 1<=n & n<m & m<=len sc holds sc.n<>sc.m;
    hence thesis by GRAPH_1:def 16;
  end;
  suppose
    len sc = 1;
    then for n,m st 1<=n & n<m & m<=len sc holds sc.n<>sc.m by XXREAL_0:2;
    hence thesis by GRAPH_1:def 16;
  end;
  suppose
A5: sc.1<>sc.2;
    now
      let n, m;
      assume that
A6:   1<=n and
A7:   n<m and
A8:   m<=len sc;
      thus sc.n<>sc.m
      proof
        consider vs such that
A9:     vs is_vertex_seq_of sc and
A10:    for n,m st 1<=n & n<m & m<=len vs & vs.n=vs.m holds n=1 & m=
        len vs by Def9;
        set vm1 = vs/.(m+1);
A11:    len vs = len sc +1 by A9;
        then
A12:    m+1<=len vs by A8,XREAL_1:6;
        then
A13:    vm1=vs.(m+1) by FINSEQ_4:15,NAT_1:12;
        set vn1 = vs/.(n+1);
        set vn = vs/.n;
A14:    n<=len sc by A7,A8,XXREAL_0:2;
        then
A15:    sc.n joins vn, vn1 by A6,A9;
        n+1<=len vs by A11,A14,XREAL_1:6;
        then
A16:    vn1=vs.(n+1) by FINSEQ_4:15,NAT_1:12;
        n<=len vs by A11,A14,NAT_1:12;
        then
A17:    vn=vs.n by A6,FINSEQ_4:15;
        set vm = vs/.m;
A18:    1<=m by A6,A7,XXREAL_0:2;
        then
A19:    sc.m joins vm, vm1 by A8,A9;
A20:    m<=len vs by A8,A11,NAT_1:12;
        then
A21:    vm=vs.m by A18,FINSEQ_4:15;
        assume
A22:    not thesis;
        per cases by A22,A15,A19;
        suppose
A23:      vn=vm & vn1=vm1;
A24:      n+1<m+1 by A7,XREAL_1:6;
          n=1 by A6,A7,A10,A20,A17,A21,A23;
          hence contradiction by A10,A12,A16,A13,A23,A24;
        end;
        suppose
A25:      vn=vm1 & vn1=vm;
          thus contradiction
          proof
A26:        n+1<=m by A7,NAT_1:13;
A27:        n+0<m+1 by A7,XREAL_1:8;
            per cases by A26,XXREAL_0:1;
            suppose
A28:          n+1=m;
              n=1 by A6,A10,A12,A17,A13,A25,A27;
              hence contradiction by A5,A22,A28;
            end;
            suppose
A29:          n+1<m;
              n=1 by A6,A10,A12,A17,A13,A25,A27;
              hence contradiction by A10,A20,A16,A21,A25,A29;
            end;
          end;
        end;
      end;
    end;
    hence thesis by GRAPH_1:def 16;
  end;
end;
