reserve
  a for natural Number,
  k,l,m,n,k1,b,c,i for Nat,
  x,y,z,y1,y2 for object,
  X,Y for set,
  f,g for Function;
reserve p,q,r,s,t for FinSequence;
reserve D for set;

theorem
  rng p = rng q & p is one-to-one & q is one-to-one implies len p = len q
proof
  defpred P[FinSequence] means $1 is one-to-one implies
  for q st rng $1 = rng q & q is one-to-one holds len $1 = len q;
A1: P[{}] by RELAT_1:41;
  now
    let p,x;
    assume
A2: p is one-to-one implies
    for q st rng p = rng q & q is one-to-one holds len p = len q;
    assume
A3: p ^ <* x *> is one-to-one;
    let q;
    assume that
A4: rng(p ^ <* x *>) = rng q and
A5: q is one-to-one;
A6: rng(p ^ <* x *>) = rng p \/ rng<* x *> by Th31
      .= rng p \/ {x} by Th38;
    x in {x} by TARSKI:def 1;
    then x in rng q by A4,A6,XBOOLE_0:def 3;
    then consider y being object such that
A7: y in dom q and
A8: x = q.y by FUNCT_1:def 3;
A9: y in Seg(len q) by A7,Def3;
    reconsider y as Element of NAT by A7;
A10: 1 <= y by A9,Th1;
    then consider k be Nat such that
A11: 1 + k = y by NAT_1:10;
A12: y <= len q by A9,Th1;
    then consider n be Nat such that
A13: y + n = len q by NAT_1:10;
    reconsider k,n as Element of NAT by ORDINAL1:def 12;
    reconsider q1 = q | (Seg k) as FinSequence by Th15;
    defpred P[Nat,object] means $2 = q.(y + $1);
A14: for j being Nat st j in Seg n ex x st P[j,x];
    consider q2 being FinSequence such that
A15: dom q2 = Seg n and
A16: for j being Nat st j in Seg n holds P[j,q2.j] from SeqEx(A14);
A17: k <= y by A11,NAT_1:12;
    then
A18: k <= len q by A12,XXREAL_0:2;
    then
A19: len q1 = k by Th17;
    len(q1 ^ <* x *>) + len q2 = len q1 + len<* x *> + len q2 by Th22
      .= k + 1 + len q2 by A19,Th39
      .= len q by A11,A13,A15,Def3;
    then
A20: dom q = Seg(len(q1 ^ <* x *>) + len q2) by Def3;
A21: rng(q1 ^ q2) = rng q \ {x}
    proof
      thus rng(q1 ^ q2) c= rng q \ {x}
      proof
        let z be object;
        assume z in rng(q1 ^ q2);
        then
A22:    z in rng q1 \/ rng q2 by Th31;
A23:    now
          assume
A24:      z in rng q1;
          A25:      rng
 q1 = q .: (Seg k) & q .: (Seg k) c= rng q by RELAT_1:111,115;
          consider y1 being object such that
A26:      y1 in dom q1 and
A27:      q1.y1 = z by A24,FUNCT_1:def 3;
A28:      q1.y1 = q.y1 by A26,FUNCT_1:47;
A29:      y1 in Seg(len q1) by A26,Def3;
          reconsider y1 as Element of NAT by A26;
A30:      y1 <= k by A19,A29,Th1;
A31:      k < y by A11,XREAL_1:29;
          Seg k c= Seg(len q) by A17,Th5,A12,XXREAL_0:2;
          then dom q1 c= Seg(len q) by A18,Th17;
          then dom q1 c= dom q by Def3;
          then x <> z by A5,A7,A8,A26,A27,A28,A30,A31;
          then not z in {x} by TARSKI:def 1;
          hence thesis by A24,A25,XBOOLE_0:def 5;
        end;
        now
          assume z in rng q2;
          then consider y1 being object such that
A32:      y1 in dom q2 and
A33:      q2.y1 = z by FUNCT_1:def 3;
          reconsider y1 as Element of NAT by A32;
A34:      q2.y1 = q.(y + y1) by A15,A16,A32;
A35:      1 <= y + y1 by A10,NAT_1:12;
          y1 <= n by A15,A32,Th1;
          then y + y1 <= len q by A13,XREAL_1:7;
          then y + y1 in Seg(len q) by A35;
          then
A36:      y + y1 in dom q by Def3;
          then
A37:      z in rng q by A33,A34,FUNCT_1:def 3;
          y1 <> 0 by A15,A32,Th1;
          then y <> y + y1;
          then x <> z by A5,A7,A8,A33,A34,A36;
          then not z in {x} by TARSKI:def 1;
          hence thesis by A37,XBOOLE_0:def 5;
        end;
        hence thesis by A22,A23,XBOOLE_0:def 3;
      end;
      let z be object;
      assume
A38:  z in rng q \ {x};
      then consider y1 being object such that
A39:  y1 in dom q and
A40:  z = q.y1 by FUNCT_1:def 3;
A41:  y1 in Seg(len q) by A39,Def3;
      reconsider y1 as Element of NAT by A39;
      not z in {x} by A38,XBOOLE_0:def 5;
      then
A42:  y <> y1 by A8,A40,TARSKI:def 1;
A43:  now
        assume
A44:    y < y1;
        then consider j being Nat such that
A45:    y1 = y + j by NAT_1:10;
A46:    1 <= j by A44,A45,NAT_1:19;
        j <= n by A13,A41,A45,Th1,XREAL_1:6;
        then
A47:    j in Seg n by A46;
        then z = q2.j by A16,A40,A45;
        hence z in rng q2 by A15,A47,FUNCT_1:def 3;
      end;
      now
        assume
A48:    y1 < y;
A49:    1 <= y1 by A41,Th1;
        y1 <= k by A11,A48,NAT_1:13;
        then y1 in Seg k by A49;
        then
A50:    y1 in dom q1 by A18,Th17;
        then q1.y1 = z by A40,FUNCT_1:47;
        hence z in rng q1 by A50,FUNCT_1:def 3;
      end;
      then z in rng q1 \/ rng q2 by A42,A43,XBOOLE_0:def 3,XXREAL_0:1;
      hence thesis by Th31;
    end;
A51: p = (p ^ <* x *>) | (dom p) by Th21;
A52: rng p = rng(p ^ <* x *>) \ {x}
    proof
      thus rng p c= rng(p ^ <* x *>) \ {x}
      proof
        let z be object;
        assume
A53:    z in rng p;
A54:    rng p c= rng(p ^ <* x *>) by A51,RELAT_1:70;
        consider y1 being object such that
A55:    y1 in dom p and
A56:    p.y1 = z by A53,FUNCT_1:def 3;
A57:    y1 in Seg(len p) by A55,Def3;
        reconsider y1 as Element of NAT by A55;
A58:    (p ^ <* x *>).(len p + 1) = x by Th42;
A59:    (p ^ <* x *>).y1 = p.y1 by A51,A55,FUNCT_1:47;
A60:    y1 <= len p by A57,Th1;
A61:    len p < len p +1 by XREAL_1:29;
A62:    1 <= y1 by A57,Th1;
        y1 <= len p + 1 by A60,A61,XXREAL_0:2;
        then
A63:    y1 in Seg(len p + 1) by A62;
A64:    len p + 1 in Seg(len p + 1) by Th3;
A65:    y1 in Seg(len p + len<* x *>) by A63,Th40;
A66:    len p + 1 in Seg(len p + len<* x *>) by A64,Th40;
A67:    y1 in dom(p ^ <* x *>) by A65,Def7;
        len p + 1 in dom(p ^ <* x *>) by A66,Def7;
        then x <> z by A3,A56,A58,A59,A60,A61,A67;
        then not z in {x} by TARSKI:def 1;
        hence thesis by A53,A54,XBOOLE_0:def 5;
      end;
      let z be object;
      assume
A68:  z in rng(p ^ <* x *>) \ {x};
      then
A69:  z in rng(p ^ <* x *>);
A70:  not z in {x} by A68,XBOOLE_0:def 5;
      z in rng p \/ rng<* x *> by A69,Th31;
      then z in rng p or z in rng<* x *> by XBOOLE_0:def 3;
      hence thesis by A70,Th38;
    end;
A71: q1 ^ q2 is one-to-one
    proof
      let y1,y2 be object;
      assume that
A72:  y1 in dom(q1 ^ q2) & y2 in dom(q1 ^ q2) and
A73:  (q1 ^ q2).y1 = (q1 ^ q2).y2;
      reconsider m1 = y1, m2 = y2 as Element of NAT by A72;
A74:  q1 is one-to-one by A5,FUNCT_1:52;
A75:  now
        assume
A76:    m1 in dom q1 & m2 in dom q1;
        then (q1 ^ q2).m1 = q1.m1 & (q1 ^ q2).m2 = q1.m2 by Def7;
        hence thesis by A73,A74,A76;
      end;
A77:  now
        assume
A78:    m1 in dom q1;
        given j being Nat such that
A79:    j in dom q2 and
A80:    m2 = len q1 + j;
A81:    (q1 ^ q2).m2 = q2.j by A79,A80,Def7;
        (q1 ^ q2).m1 = q1.m1 & q1.m1 = q.m1 by A78,Def7,FUNCT_1:47;
        then
A82:    q.m1 = q.(y + j) by A15,A16,A73,A79,A81;
        1 <= j by A15,A79,Th1;
        then
A83:    1 <= y + j by NAT_1:12;
        j <= n by A15,A79,Th1;
        then y + j <= len q by A13,XREAL_1:7;
        then y + j in Seg(len q) by A83;
        then
A84:    y + j in dom q by Def3;
        m1 in Seg k by A18,A78,Th17;
        then
A85:    m1 <= k by Th1;
        k < y by A11,XREAL_1:29;
        then
A86:    m1 < y by A85,XXREAL_0:2;
        dom q1 c= dom q & y <= y + j by NAT_1:12,RELAT_1:60;
        hence thesis by A5,A78,A82,A84,A86;
      end;
A87:  now
        assume
A88:    m2 in dom q1;
        given j be Nat such that
A89:    j in dom q2 and
A90:    m1 = len q1 + j;
A91:    (q1 ^ q2).m1 = q2.j by A89,A90,Def7;
        (q1 ^ q2).m2 = q1.m2 & q1.m2 = q.m2 by A88,Def7,FUNCT_1:47;
        then
A92:    q.m2 = q.(y + j) by A15,A16,A73,A89,A91;
        1 <= j by A15,A89,Th1;
        then
A93:    1 <= y + j by NAT_1:12;
        j <= n by A15,A89,Th1;
        then y + j <= len q by A13,XREAL_1:7;
        then y + j in Seg(len q) by A93;
        then
A94:    y + j in dom q by Def3;
        m2 in Seg k by A18,A88,Th17;
        then
A95:    m2 <= k by Th1;
        k < y by A11,XREAL_1:29;
        then
A96:    m2 < y by A95,XXREAL_0:2;
        dom q1 c= dom q & y <= y + j by NAT_1:12,RELAT_1:60;
        hence thesis by A5,A88,A92,A94,A96;
      end;
      now
        given j1 being Nat such that
A97:    j1 in dom q2 and
A98:    m1 = len q1 + j1;
        given j2 being Nat such that
A99:    j2 in dom q2 and
A100:    m2 = len q1 + j2;
A101:   (q1 ^ q2).m1 = q2.j1 by A97,A98,Def7;
A102:   (q1 ^ q2).m2 = q2.j2 by A99,A100,Def7;
A103:   (q1 ^ q2).m1 = q.(y + j1) by A15,A16,A97,A101;
A104:   (q1 ^ q2).m2 = q.(y + j2) by A15,A16,A99,A102;
A105:   1 <= j1 by A15,A97,Th1;
A106:   1 <= j2 by A15,A99,Th1;
A107:   1 <= y + j1 by A105,NAT_1:12;
A108:   1 <= y + j2 by A106,NAT_1:12;
A109:   j1 <= n by A15,A97,Th1;
A110:   j2 <= n by A15,A99,Th1;
A111:   y + j1 <= len q by A13,A109,XREAL_1:7;
A112:   y + j2 <= len q by A13,A110,XREAL_1:7;
A113:   y + j1 in Seg(len q) by A107,A111;
A114:   y + j2 in Seg(len q) by A108,A112;
A115:   y + j1 in dom q by A113,Def3;
        y + j2 in dom q by A114,Def3;
        then y + j1 = y + j2 by A5,A73,A103,A104,A115;
        hence thesis by A98,A100;
      end;
      hence thesis by A72,A75,A77,A87,Th25;
    end;
A116: now
      let j be Nat;
      assume
A117: j in dom(q1 ^ <* x *>);
A118: now
        assume
A119:   j in dom q1;
        then (q1 ^ <* x *>).j = q1.j by Def7;
        hence q.j = (q1 ^ <* x *>).j by A119,FUNCT_1:47;
      end;
      now
        given i be Nat such that
A120:   i in dom<* x *> and
A121:   j = len q1 + i;
        i in {1} by A120,Th2,Th38;
        then i = 1 by TARSKI:def 1;
        hence q.j = (q1 ^ <* x *>).j by A8,A11,A19,A121,Th42;
      end;
      hence q.j = (q1 ^ <* x *>).j by A117,A118,Th25;
    end;
    now
      let j be Nat;
      assume j in dom q2;
      hence q2.j = q.(len q1 + 1 + j) by A11,A15,A16,A19
        .= q.(len q1 + len<* x *> + j) by Th39
        .= q.(len(q1 ^ <* x *>) + j) by Th22;
    end;
    then q1 ^ <* x *> ^ q2 = q by A20,A116,Def7;
    then
A122: len q = len(q1 ^ <* x *>) + len q2 by Th22
      .= len <* x *> + len q1 + len q2 by Th22
      .= 1 + len q1 + len q2 by Th40
      .= 1 + (len q1 + len q2)
      .= len(q1 ^ q2) + 1 by Th22;
    len(p ^ <* x *>) = len p + len<* x *> by Th22
      .= len p + 1 by Th40;
    hence len(p ^ <* x *>) = len q by A2,A3,A4,A21,A51,A52,A71,A122,FUNCT_1:52;
  end;
  then
A123: for p,x st P[p] holds P[p^<*x*>];
  for p holds P[p] from IndSeq(A1,A123);
  hence thesis;
end;
