
theorem Th33:
  for G being _Graph, P being Path of G st P is open & len P > 3
  for e being object st e Joins P.last(),P.first(),G holds
    P.addEdge(e) is Cycle-like
proof
  let G be _Graph, W be Path of G such that
A1: W is open and
A2: len W > 3;
  let e be object such that
A3: e Joins W.last(),W.first(),G;
A4: now
    assume e in W.edges();
    then consider
    v1,v2 being Vertex of G, n being odd Element of NAT such that
A5: n+2 <= len W and
A6: v1 = W.n and
    e = W.(n+1) and
A7: v2 = W.(n+2) and
A8: e Joins v1,v2,G by GLIB_001:103;
A9: n < len W by A5,XREAL_1:39;
    per cases by A3,A8;
    suppose
A10:  v1 = W.first() & v2 = W.last();
      now
        assume
A11:    1 <> n;
        1 <= n by Th2;
        then 2*0+1 < n by A11,XXREAL_0:1;
        hence contradiction by A1,A6,A9,A10,GLIB_001:147;
      end;
      hence contradiction by A1,A2,A7,A10,GLIB_001:147;
    end;
    suppose
      v1 = W.last() & v2 = W.first();
      hence contradiction by A1,A6,A9,GLIB_001:147;
    end;
  end;
  set P = W.addEdge(e);
A12: P.last() = W.first() by A3,GLIB_001:63;
A13: len P = len W + 2*1 by A3,GLIB_001:64;
A14: now
    let m,n be odd Element of NAT such that
A15: m < n and
A16: n <= len P;
    m < len W + 2*1 by A13,A15,A16,XXREAL_0:2;
    then
A17: m <= len W + 2 - 2 by Th3;
    assume
A18: P.m = P.n;
    1 <= m by Th2;
    then
A19: m in dom W by A17,FINSEQ_3:25;
    then
A20: W.m = P.m by A3,GLIB_001:65;
A21: now
      assume n < len P;
      then n < len W + 2*1 by A3,GLIB_001:64;
      then
A22:  n <= len W + 2 - 2 by Th3;
      1 <= n by Th2;
      then
A23:  n in dom W by A22,FINSEQ_3:25;
      W.n <> W.m by A1,A15,A22,GLIB_001:147;
      hence contradiction by A3,A18,A20,A23,GLIB_001:65;
    end;
    then
A24: P.n = W.1 by A12,A16,XXREAL_0:1;
    now
      assume
A25:  m <> 1;
      1 <= m by Th2;
      then 2*0+1 < m by A25,XXREAL_0:1;
      then W.1 <> W.m by A1,A17,GLIB_001:147;
      hence contradiction by A3,A18,A19,A24,GLIB_001:65;
    end;
    hence m = 1 & n = len P by A16,A21,XXREAL_0:1;
  end;
  e in W.last().edgesInOut() by A3,GLIB_000:62;
  then P is Trail-like by A4,GLIB_001:142;
  then
A26: P is Path-like by A14;
  P.first() = W.first() by A3,GLIB_001:63;
  then
A27: P is closed by A12;
  P is non trivial by A3,GLIB_001:132;
  hence thesis by A27,A26;
end;
