reserve
  X,x,y,z for set,
  k,n,m for Nat ,
  f for Function,
  p,q,r for FinSequence of NAT;
reserve p1,p2,p3 for FinSequence;
reserve T,T1 for Tree;
reserve fT,fT1 for finite Tree;
reserve t for Element of T;
reserve w for FinSequence;

theorem Th33:
  for p being FinSequence holds ProperPrefixes p,dom p are_equipotent
proof
  let p be FinSequence;
  defpred P[object,object] means ex w st $1 = w & $2 = (len w)+1;
A1: for x being object st x in ProperPrefixes p ex y being object st P[x,y]
  proof
    let x be object;
    assume x in ProperPrefixes p;
    then consider q being FinSequence such that
A2: x = q and q is_a_proper_prefix_of p by Def2;
    reconsider y = (len q)+1 as set;
    take y,q;
    thus thesis by A2;
  end;
  consider f such that
A3: dom f = ProperPrefixes p and
A4: for x being object st x in ProperPrefixes p holds P[x,f.x]
    from CLASSES1:sch 1(A1);
  take f;
  thus f is one-to-one
  proof
    let x,y be object;
    assume that
A5: x in dom f & y in dom f and
A6: f.x = f.y;
     (
ex q being FinSequence st x = q & f.x = (len q)+1 )& ex r being FinSequence
    st y = r & f.x = (len r)+1 by A3,A4,A5,A6;
    hence thesis by A3,A5,Th3,Th17;
  end;
  thus dom f = ProperPrefixes p by A3;
  thus rng f c= dom p
  proof
    let x be object;
    assume x in rng f;
    then consider y being object such that
A7: y in dom f and
A8: x = f.y by FUNCT_1:def 3;
    consider q being FinSequence such that
A9: y = q and
A10: x = (len q)+1 by A3,A4,A7,A8;
 len q < len p by A3,A7,A9,Th12;
then  0+1 <= (len q)+1 & (len q)+1 <= len p by NAT_1:13;
then  x in Seg len p by A10,FINSEQ_1:1;
    hence thesis by FINSEQ_1:def 3;
  end;
  let x be object;
  assume
A11: x in dom p;
then A12: x in Seg len p by FINSEQ_1:def 3;
  reconsider n = x as Nat by A11;
A13: 1 <= n by A12,FINSEQ_1:1;
A14: n <= len p by A12,FINSEQ_1:1;
  consider m be Nat such that
A15: n = 1+m by A13,NAT_1:10;
  reconsider m as Nat;
  reconsider q = p|Seg m as FinSequence by FINSEQ_1:15;
A16: m <= len p by A14,A15,NAT_1:13;
A17: m <> len p by A14,A15,NAT_1:13;
A18: len q = m by A16,FINSEQ_1:17;
A19: q is_a_prefix_of p;
   len q = m by A16,FINSEQ_1:17;
then  q is_a_proper_prefix_of p by A17,A19;
then A20: q in ProperPrefixes p by Th11;
then  ex r being FinSequence st q = r & f.q = (len r)+1 by A4;
  hence thesis by A3,A15,A18,A20,FUNCT_1:def 3;
end;
