reserve x,y,z,a,b,c,X,X1,X2,Y,Z for set,
  W,W1,W2 for Tree,
  w,w9 for Element of W,
  f for Function,
  D,D9 for non empty set,
  i,k,k1,k2,l,m,n for Nat,
  v,v1,v2 for FinSequence,
  p,q,r,r1,r2 for FinSequence of NAT;
reserve C for Chain of W,
  B for Branch of W;
reserve T,T1,T2 for DecoratedTree;
reserve x1,x2 for set,
  w for FinSequence of NAT;

theorem
  for Z1,Z2 being Tree,p being FinSequence of NAT st p in Z1 holds
  for v being Element of Z1 with-replacement (p,Z2),w being Element of Z2
  st v = p^w holds succ v,succ w are_equipotent
proof
  let Z1,Z2 be Tree,p be FinSequence of NAT such that
A1: p in Z1;
  set T = Z1 with-replacement (p,Z2);
  let t be Element of Z1 with-replacement (p,Z2), t2 be Element of Z2;
  assume
A2: t = p^t2;
then A3: p is_a_prefix_of t by TREES_1:1;
A4: for n holds t^<*n*> in T iff t2^<*n*> in Z2
  proof
    let n;
A5: p is_a_proper_prefix_of t^<*n*> by A3,TREES_1:8;
    reconsider nn=n as Element of NAT by ORDINAL1:def 12;
A6: t^<*nn*> = p^(t2^<*nn*>) by A2,FINSEQ_1:32;
    thus t^<*n*> in T implies t2^<*n*> in Z2
    proof
      assume
A7:      t^<*n*> in T;
      reconsider n as Element of NAT by ORDINAL1:def 12;
      ex w st w in Z2 & t^<*n*> = p^w by A1,A5,TREES_1:def 9,A7;
      hence thesis by A6,FINSEQ_1:33;
    end;
    assume t2^<*n*> in Z2;
    hence thesis by A1,A6,TREES_1:def 9;
  end;
  defpred P[object,object] means for n st $1 = t^<*n*> holds $2 = t2^<*n*>;
A8: for x being object st x in succ t ex y being object st P[x,y]
  proof
    let x be object;
    assume x in succ t;
    then consider n such that
A9: x = t^<*n*> and t^<*n*> in T;
    take t2^<*n*>;
    let m;
    assume x = t^<*m*>;
    hence thesis by A9,FINSEQ_1:33;
  end;
  consider f being Function such that
A10: dom f = succ t & for x being object st x in
  succ t holds P[x,f.x] from CLASSES1:sch 1(A8);
 now
    let x be object;
    thus x in rng f implies x in succ t2
    proof
      assume x in rng f;
      then consider y being object such that
A11:  y in dom f and
A12:  x = f.y by FUNCT_1:def 3;
      consider n such that
A13:  y = t^<*n*> and
A14:  t^<*n*> in T by A10,A11;
A15:  x = t2^<*n*> by A10,A11,A12,A13;
  t2^<*n*> in Z2 by A4,A14;
      hence thesis by A15;
    end;
    assume x in succ t2;
    then consider n such that
A16: x = t2^<*n*> and
A17: t2^<*n*> in Z2;
 t^<*n*> in T by A4,A17;
then A18: t^<*n*> in dom f by A10;
then  f.(t^<*n*>) = x by A10,A16;
    hence x in rng f by A18,FUNCT_1:def 3;
  end;
then A19: rng f = succ t2 by TARSKI:2;
 f is one-to-one
  proof
    let x1,x2 be object;
    assume that
A20: x1 in dom f and
A21: x2 in dom f and
A22: f.x1 = f.x2;
    consider m such that
A23: x1 = t^<*m*> and t^<*m*> in T by A10,A20;
    consider k such that
A24: x2 = t^<*k*> and t^<*k*> in T by A10,A21;
 t2^<*m*> = f.x1 by A10,A20,A23
      .= t2^<*k*> by A10,A21,A22,A24;
    hence thesis by A23,A24,FINSEQ_1:33;
  end;
  hence thesis by A10,A19,WELLORD2:def 4;
end;
