
theorem Th38:
  for G being _Graph, W1, W2, W3 being Walk of G
  st W2 is_odd_substring_of W1, 0 &
    W2.first() = W3.first() & W2.last() = W3.last()
  holds
    W1.cut(1,W1.findFirstVertex(W2)).first() = W1.first() &
    W1.cut(1,W1.findFirstVertex(W2)).last() = W3.first() &
    W1.cut(1,W1.findFirstVertex(W2)).append(W3).first() =
      W1.first() &
    W1.cut(1,W1.findFirstVertex(W2)).append(W3).last() =
      W3.last() &
    W1.cut(W1.findLastVertex(W2), len W1).first() = W3.last() &
    W1.cut(W1.findLastVertex(W2), len W1).last() = W1.last()
proof
  let G be _Graph;
  let W1, W2, W3 be Walk of G;
  assume A1: W2 is_odd_substring_of W1, 0 &
    W2.first() = W3.first() & W2.last() = W3.last();
  reconsider n1 = 1 as odd Element of NAT by POLYFORM:4;
  set n2 = W1.findFirstVertex(W2);
  set n3 = W1.findLastVertex(W2);
  set n4 = len W1;
  set W1c = W1.cut(n1,n2);
  set W1ca = W1c.append(W3);
  set W1c2 = W1.cut(n3, n4);
  set W1caa = W1ca.append(W1c2);
  n1 <= n2 & n2 <= len W1 by A1, Th35;
  then A2: W1c.first() = W1.n1 & W1c.last() = W1.n2 by GLIB_001:37;
  then A3: W1c.first() = W1.first() by GLIB_001:def 6;
  A4: W1c.last() = W3.first() by A1, A2, Th34;
  then A5: W1ca.first() = W1.n1 & W1ca.last() = W3.last() by A2, GLIB_001:30;
  then A6: W1ca.first() = W1.first() by GLIB_001:def 6;
  A7: W1ca.last() = W3.last() by A5;
  n3 <= n4 & n4 <= len W1 by A1, Th35;
  then A8: W1c2.first() = W1.n3 & W1c2.last() = W1.n4 by GLIB_001:37;
  W1.n3 = W3.last() by A1, Th34;
  then A9: W1c2.first() = W3.last() by A8;
  A10: W1c2.last() = W1.last() by A8, GLIB_001:def 7;
  thus thesis by A3, A4, A6, A7, A9, A10;
end;
