
theorem Th27:
  for T being _Tree for a, b being Vertex of T for P1, P2 being
  Path of T st P1 is_Walk_from a, b & P2 is_Walk_from a, b holds P1 = P2
proof
  let T be _Tree;
  let a, b be Vertex of T;
  let P1, P2 be Path of T such that
A1: P1 is_Walk_from a, b and
A2: P2 is_Walk_from a, b;
  set di = len maxPrefix(P1,P2);
A3: P1.first() = a & P2.first() = a by A1,A2;
  then reconsider di as odd Element of NAT by Th22;
  defpred P[Nat] means $1 is odd & di < $1 & $1 <= len P2 & P2.$1 in P1
  .vertices();
  assume
A4: P1 <> P2;
A5: not P2 c= P1
  proof
    assume
A6: P2 c= P1;
    then len P2 <= len P1 by FINSEQ_1:63;
    then
A7: len P2 < len P1 by A4,A6,FINSEQ_2:129,XXREAL_0:1;
    1 <= len P2 by ABIAN:12;
    then len P2 in dom P2 by FINSEQ_3:25;
    then
A8: P2.len P2 = P1.len P2 by A6,GRFUNC_1:2;
A9: P1.len P1 = P1.last() .= b by A1;
    P2.len P2 = P2.last() .= b by A2;
    hence contradiction by A7,A8,A9,Th26;
  end;
A10: ex k being Nat st P[k]
  proof
    take k = len P2;
    thus k is odd;
    di +2 <= len P2 & di < di+2 by A3,A5,Th23,NAT_1:19;
    hence di < k by XXREAL_0:2;
    thus k <= len P2;
    P2.k = P2.last() .= b by A2
      .= P1.last() by A1;
    hence thesis by GLIB_001:88;
  end;
  consider ei being Nat such that
A11: P[ei] and
A12: for n being Nat st P[n] holds ei <= n from NAT_1:sch 5(A10);
  reconsider ei as odd Element of NAT by A11,ORDINAL1:def 12;
  set e = P2.ei;
  set fi = P1.find(e);
  set pde = P2.cut(di,ei), pdf = P1.cut(di,fi);
A13: fi <= len P1 by A11,GLIB_001:def 19;
  set rpdf = pdf.reverse();
A14: rpdf.vertices() = pdf.vertices() by GLIB_001:92;
  set C = pde.append(rpdf);
  set d = P1.di;
A15: P2.di = P1.di by Th7;
  then
A16: pde.first() = d by A11,GLIB_001:37;
A17: e = P1.fi by A11,GLIB_001:def 19;
  len P2 <> 1
  proof
    assume len P2 = 1;
    then di < 1 by A11,XXREAL_0:2;
    hence contradiction by ABIAN:12;
  end;
  then
A18: not P2 is trivial by GLIB_001:126;
A19: di < fi
  proof
    assume di >= fi;
    then P1.fi = P2.fi & ei > fi by A11,Th7,XXREAL_0:2;
    then P2.first() = e & P2.last() = e by A11,A17,GLIB_001:def 28;
    hence contradiction by A18,GLIB_001:def 24;
  end;
  then
A20: pdf is non trivial by A13,GLIB_001:131;
  then
A21: P1 is non trivial;
  fi <= len P1 by A11,GLIB_001:def 19;
  then
A22: rpdf.vertices() c= P1.vertices() by A19,A14,GLIB_001:94;
A23: pde.vertices() /\ rpdf.vertices() c= {e, d}
  proof
    assume not thesis;
    then consider g being object such that
A24: g in pde.vertices() /\ rpdf.vertices() and
A25: not g in {e, d};
    g in pde.vertices() by A24,XBOOLE_0:def 4;
    then consider gii being odd Element of NAT such that
A26: gii <= len pde and
A27: pde.gii = g by GLIB_001:87;
    consider gi being odd Nat such that
A28: P2.gi = pde.gii and
A29: gi = di+gii-1 and
A30: gi <= len P2 by A11,A26,Th12;
    reconsider gi as odd Element of NAT by ORDINAL1:def 12;
A31: gii >= 1 by ABIAN:12;
A32: gi < ei
    proof
A33:  len pde + di = ei+1 by A11,GLIB_001:36;
      assume
A34:  gi >= ei;
      per cases by A34,XXREAL_0:1;
      suppose
        gi = ei;
        then pde.gii = pde.last() by A29,A33
          .= e by A11,GLIB_001:37;
        hence contradiction by A25,A27,TARSKI:def 2;
      end;
      suppose
        gi > ei;
        then gi+1 > ei+1 by XREAL_1:6;
        hence contradiction by A26,A29,A33,XREAL_1:6;
      end;
    end;
    gii <> 1 by A16,A25,A27,TARSKI:def 2;
    then
A35: gii > 1 by A31,XXREAL_0:1;
A36: di < gi
    proof
      assume di >= gi;
      then di+gii > gi+1 by A35,XREAL_1:8;
      hence contradiction by A29;
    end;
    g in rpdf.vertices() by A24,XBOOLE_0:def 4;
    hence contradiction by A12,A22,A27,A28,A30,A36,A32;
  end;
A37: pde.last() = e by A11,GLIB_001:37;
  pdf.first() = d by A13,A19,GLIB_001:37;
  then
A38: rpdf.last() = d by GLIB_001:22;
  pdf.last() = e by A13,A17,A19,GLIB_001:37;
  then
A39: rpdf.first() = e by GLIB_001:22;
  {e, d} c= pde.vertices() /\ rpdf.vertices()
  proof
    let x be object;
    assume
A40: x in {e, d};
    per cases by A40,TARSKI:def 2;
    suppose
      x = e;
      then x in pde.vertices() & x in rpdf.vertices() by A37,A39,GLIB_001:88;
      hence thesis by XBOOLE_0:def 4;
    end;
    suppose
      x = d;
      then x in pde.vertices() & x in rpdf.vertices() by A16,A38,GLIB_001:88;
      hence thesis by XBOOLE_0:def 4;
    end;
  end;
  then
A41: pde.vertices() /\ rpdf.vertices() = {e, d} by A23;
A42: pde is non trivial by A11,GLIB_001:131;
  then
A43: P2 is non trivial;
A44: not P1 c= P2
  proof
    assume
A45: P1 c= P2;
    then len P1 <= len P2 by FINSEQ_1:63;
    then
A46: len P1 < len P2 by A4,A45,FINSEQ_2:129,XXREAL_0:1;
    1 <= len P1 by ABIAN:12;
    then len P1 in dom P1 by FINSEQ_3:25;
    then
A47: P1.len P1 = P2.len P1 by A45,GRFUNC_1:2;
A48: P2.len P2 = P2.last() .= b by A2;
    P1.len P1 = P1.last() .= b by A1;
    hence contradiction by A46,A47,A48,Th26;
  end;
A49: pde.edges() misses rpdf.edges()
  proof
A50: pdf.vertices() = rpdf.vertices() by GLIB_001:92;
A51: pdf.edges() = rpdf.edges() by GLIB_001:107;
    assume pde.edges() /\ rpdf.edges() <> {};
    then consider x being object such that
A52: x in pde.edges() /\ rpdf.edges() by XBOOLE_0:def 1;
    x in rpdf.edges() by A52,XBOOLE_0:def 4;
    then consider
    u1, u2 being Vertex of T, m being odd Element of NAT such that
A53: m+2 <= len pdf and
A54: u1 = pdf.m and
    x = pdf.(m+1) and
A55: u2 = pdf.(m+2) and
A56: x Joins u1, u2, T by A51,GLIB_001:103;
    x in pde.edges() by A52,XBOOLE_0:def 4;
    then consider
    v1, v2 being Vertex of T, n being odd Element of NAT such that
A57: n+2 <= len pde and
A58: v1 = pde.n and
    x = pde.(n+1) and
A59: v2 = pde.(n+2) and
A60: x Joins v1, v2, T by GLIB_001:103;
A61: n+0 < n+2 by XREAL_1:8;
    per cases;
    suppose
A62:  v1 <> v2;
A63:  n+2 = n+1+1;
      then
A64:  n+1 < len pde by A57,NAT_1:13;
      then
A65:  pde.(n+2) = P2.(di+(n+1)) by A11,A63,GLIB_001:36;
      consider ni being Nat such that
A66:  n = ni+1 by NAT_1:6;
      reconsider ni as Element of NAT by ORDINAL1:def 12;
A67:  u2 in pdf.vertices() by A53,A55,GLIB_001:87;
      m+0 < m+2 by XREAL_1:8;
      then
A68:  m <= len pdf by A53,XXREAL_0:2;
      then u1 in pdf.vertices() by A54,GLIB_001:87;
      then
A69:  {u1, u2} c= rpdf.vertices() by A50,A67,ZFMISC_1:32;
A70:  m+2 = m+1+1;
      then
A71:  m+1 < len pdf by A53,NAT_1:13;
      then
A72:  pdf.(m+2) = P1.(di+(m+1)) by A13,A19,A70,GLIB_001:36;
      n <= len pde by A57,A61,XXREAL_0:2;
      then
A73:  v1 in pde.vertices() by A58,GLIB_001:87;
      v2 in pde.vertices() by A57,A59,GLIB_001:87;
      then
A74:  {v1, v2} c= pde.vertices() by A73,ZFMISC_1:32;
A75:  v1 = u1 & v2 = u2 or v1 = u2 & v2 = u1 by A60,A56,GLIB_000:15;
      then
A76:  v1 = e or v1 = d by A41,A74,A69,XBOOLE_1:19,ZFMISC_1:22;
      n+0 < n+2 by XREAL_1:8;
      then n <= len pde by A57,XXREAL_0:2;
      then
A77:  ni < len pde by A66,NAT_1:13;
      then
A78:  pde.n = P2.(di+ni) by A11,A66,GLIB_001:36;
A79:  P2.(di+2) = e
      proof
        per cases by A41,A62,A75,A74,A69,A76,XBOOLE_1:19,ZFMISC_1:22;
        suppose
A80:      v1 = e & v2 = d;
          di+(n+2) <= len pde +di by A57,XREAL_1:6;
          then di+n+1+1 <= ei+1 by A11,GLIB_001:36;
          then di+n+1 <= ei by XREAL_1:6;
          then
A81:      di+(n+1) <= len P2 by A11,XXREAL_0:2;
          di <= di+n by NAT_1:11;
          then di < di+n+1 by NAT_1:13;
          then P2.first() = d & P2.last() = d by A15,A59,A65,A80,A81,
GLIB_001:def 28;
          hence thesis by A43,GLIB_001:def 24;
        end;
        suppose
A82:      v1 = d & v2 = e;
          ni = 0
          proof
            di+ni < len pde +di by A77,XREAL_1:6;
            then di+ni < ei+1 by A11,GLIB_001:36;
            then di+ni <= ei by NAT_1:13;
            then
A83:        di+ni <= len P2 by A11,XXREAL_0:2;
            assume
A84:        ni <> 0;
            reconsider ni as even Element of NAT by A66;
            di+0 < di+ni by A84,XREAL_1:6;
            then P2.first() = d & P2.last() = d by A15,A58,A78,A82,A83,
GLIB_001:def 28;
            hence contradiction by A43,GLIB_001:def 24;
          end;
          hence thesis by A11,A59,A66,A64,A82,GLIB_001:36;
        end;
      end;
      consider im being Nat such that
A85:  m = im+1 by NAT_1:6;
A86:  v2 = e or v2 = d by A41,A75,A74,A69,XBOOLE_1:19,ZFMISC_1:22;
      reconsider im as Element of NAT by ORDINAL1:def 12;
A87:  im < len pdf by A68,A85,NAT_1:13;
      then
A88:  pdf.m = P1.(di+im) by A13,A19,A85,GLIB_001:36;
      P1.(di+2) = e
      proof
        per cases by A60,A56,A62,A76,A86,GLIB_000:15;
        suppose
A89:      u1 = e & u2 = d;
          di+(m+2) <= len pdf +di by A53,XREAL_1:6;
          then di+m+1+1 <= fi+1 by A13,A19,GLIB_001:36;
          then di+m+1 <= fi by XREAL_1:6;
          then
A90:      di+(m+1) <= len P1 by A13,XXREAL_0:2;
          di <= di+m by NAT_1:11;
          then di < di+m+1 by NAT_1:13;
          then P1.first() = d & P1.last() = d by A55,A72,A89,A90,
GLIB_001:def 28;
          hence thesis by A21,GLIB_001:def 24;
        end;
        suppose
A91:      u1 = d & u2 = e;
          im = 0
          proof
            di+im < len pdf +di by A87,XREAL_1:6;
            then di+im < fi+1 by A13,A19,GLIB_001:36;
            then di+im <= fi by NAT_1:13;
            then
A92:        di+im <= len P1 by A13,XXREAL_0:2;
            assume
A93:        im <> 0;
            reconsider im as even Element of NAT by A85;
            di+0 < di+im by A93,XREAL_1:6;
            then P1.first() = d & P1.last() = d by A54,A88,A91,A92,
GLIB_001:def 28;
            hence contradiction by A21,GLIB_001:def 24;
          end;
          hence thesis by A13,A19,A55,A85,A71,A91,GLIB_001:36;
        end;
      end;
      hence contradiction by A3,A44,A5,A79,Th24;
    end;
    suppose
      v1 = v2;
      then pde.first() = v1 & pde.last() = v1 by A57,A58,A59,A61,
GLIB_001:def 28;
      hence contradiction by A42,GLIB_001:def 24;
    end;
  end;
  rpdf is non trivial by A20,GLIB_001:129;
  then C is Cycle-like by A42,A16,A37,A39,A38,A41,A49,Th20;
  hence contradiction;
end;
