
theorem Th36:
  for T being non empty TopStruct, S1,S2 being sequence of T st
  rng S2 c= rng S1 & S2 is one-to-one ex P being Permutation of NAT st S2*P is
  subsequence of S1
proof
  let T be non empty TopStruct, S1,S2 be sequence of T;
  assume that
A1: rng S2 c= rng S1 and
A2: S2 is one-to-one;
  defpred P[object,object] means S2.$1=S1.$2;
A3: for n being object st n in NAT ex u being object st u in NAT & P[n,u]
  proof
    let n be object;
    assume n in NAT;
    then n in dom S2 by NORMSP_1:12;
    then S2.n in rng S2 by FUNCT_1:def 3;
    then consider m being object such that
A4: m in dom S1 and
A5: S2.n = S1.m by A1,FUNCT_1:def 3;
    take m;
    thus m in NAT by A4;
    thus thesis by A5;
  end;
  consider f being Function such that
A6: dom f = NAT and
A7: rng f c= NAT and
A8: for n being object st n in NAT holds P[n,f.n] from FUNCT_1:sch 6(A3);
  reconsider A=rng f as non empty Subset of NAT by A6,A7,RELAT_1:42;
  defpred P[Nat,set,set] means for B being non empty Subset of NAT,
m being Element of NAT st m=$2 & B={k where k is Element of NAT:k in rng f & k>
  m} holds $3=min B;
A9: f is one-to-one
  proof
    let x1,x2 be object;
    assume that
A10: x1 in dom f and
A11: x2 in dom f and
A12: f.x1 = f.x2;
    S2.x2 = S1.(f.x2) by A6,A8,A11;
    then
A13: S2.x1 = S2.x2 by A6,A8,A10,A12;
    x1 in dom S2 & x2 in dom S2 by A6,A10,A11,NORMSP_1:12;
    hence thesis by A2,A13;
  end;
A14: for m being Element of NAT holds {k where k is Element of NAT : k in
  rng f & k>m} <> {}
  proof
    let m be Element of NAT;
    assume
A15: {k where k is Element of NAT : k in rng f & k>m} = {};
    rng f c= m + 1
    proof
      let x be object;
      assume
A16:  x in rng f;
      then reconsider x9=x as Element of NAT by A7;
      x9 < m + 1
      proof
        assume x9>= m + 1;
        then x9 > m by NAT_1:13;
        then x9 in {k where k is Element of NAT : k in rng f & k>m} by A16;
        hence contradiction by A15;
      end;
      then x9 in {x99 where x99 is Nat:x99< m+1};
      hence thesis by AXIOMS:4;
    end;
    then rng f is finite;
    hence contradiction by A6,A9,CARD_1:59;
  end;
A17: for m being Element of NAT holds {k where k is Element of NAT : k in
  rng f & k>m} c= NAT
  proof
    let m be Element of NAT;
    let z be object;
    assume z in {k where k is Element of NAT : k in rng f & k>m};
    then ex k being Element of NAT st k = z & k in rng f & k>m;
    hence thesis;
  end;
A18: for n being Nat for x being set ex y being set st P[n,x,y]
  proof
    let n be Nat, x be set;
    per cases;
    suppose
      x in NAT;
      then reconsider x9=x as Element of NAT;
      set B={k where k is Element of NAT:k in rng f & k>x9};
      reconsider B as Subset of NAT by A17;
      reconsider B as non empty Subset of NAT by A14;
      take min B;
      let B9 be non empty Subset of NAT, m be Element of NAT;
      assume m=x & B9={k where k is Element of NAT:k in rng f & k>m};
      hence thesis;
    end;
    suppose
A19:  not x in NAT;
      take 0;
      let B be non empty Subset of NAT, m be Element of NAT;
      assume that
A20:  m=x and
      B={k where k is Element of NAT:k in rng f & k>m};
      thus thesis by A19,A20;
    end;
  end;
  consider g being Function such that
A21: dom g = NAT and
A22: g.0 = min A and
A23: for n being Nat holds P[n,g.n,g.(n+1)] from RECDEF_1:sch 1(A18);
  defpred P[Nat] means g.$1 in NAT;
A24: for k being Nat st P[k] holds P[k+1]
  proof
    let k be Nat;
    assume g.k in NAT;
    then reconsider m=g.k as Element of NAT;
    set B={l where l is Element of NAT:l in rng f & l>m};
    reconsider B as Subset of NAT by A17;
    reconsider B as non empty Subset of NAT by A14;
    g.(k+1)= min B by A23;
    hence thesis;
  end;
A25: P[0] by A22;
A26: for k being Nat holds P[k] from NAT_1:sch 2(A25,A24);
  for n being Nat holds g.n is real
  proof
    let n be Nat;
    g.n in NAT by A26;
    then reconsider w = g.n as Element of REAL by XREAL_0:def 1;
    w is real;
    hence thesis;
  end;
  then reconsider g1=g as Real_Sequence by A21,SEQ_1:2;
A27: g1 is increasing
  proof
    let n be Nat;
    reconsider m=g.n as Element of NAT by A26;
    reconsider B={k where k is Element of NAT : k in rng f & k>m} as non empty
    Subset of NAT by A14,A17;
    g1.(n+1)=min B by A23;
    then g1.(n+1) in B by XXREAL_2:def 7;
    then ex k being Element of NAT st k = g1.(n+1) & k in rng f & k>m;
    hence thesis;
  end;
A28: rng g c= NAT
  proof
    let y be object;
    assume y in rng g;
    then consider x being object such that
A29: x in dom g and
A30: y = g.x by FUNCT_1:def 3;
    reconsider x as Element of NAT by A21,A29;
    g.x in NAT by A26;
    hence thesis by A30;
  end;
  then reconsider g1 as increasing sequence of NAT by A21,A27,RELSET_1:4;
A31: g1 is one-to-one
  proof
    let x1,x2 be object;
    assume that
A32: x1 in dom g1 and
A33: x2 in dom g1 and
A34: g1.x1 = g1.x2;
    reconsider n2=x2 as Element of NAT by A33;
    reconsider n1=x1 as Element of NAT by A32;
    assume
A35: x1 <> x2;
    per cases by A35,XXREAL_0:1;
    suppose
      n1 < n2;
      hence contradiction by A34,SEQM_3:1;
    end;
    suppose
      n2 < n1;
      hence contradiction by A34,SEQM_3:1;
    end;
  end;
  then
A36: rng(g") = NAT by A21,FUNCT_1:33;
A37: rng f = rng g
  proof
    thus for y being object holds y in rng f implies y in rng g
    proof
      let y be object;
      assume
A38:  y in rng f;
      then reconsider y9=y as Element of NAT by A7;
      defpred P[Nat] means g1.$1 < y9;
      assume
A39:  not y in rng g;
A40:  for n being Nat st P[n] holds P[n+1]
      proof
        let n be Nat;
        reconsider m = g.n as Element of NAT by A26;
        reconsider B={k where k is Element of NAT:k in rng f & k>m} as non
        empty Subset of NAT by A14,A17;
A41:    g.(n+1)=min B & g.(n+1) in rng g by A21,A23,FUNCT_1:def 3;
        assume g1.n < y9;
        then y9 in {k where k is Element of NAT:k in rng f & k>m} by A38;
        then
A42:    min B <= y9 by XXREAL_2:def 7;
        assume not g1.(n+1) < y9;
        hence contradiction by A39,A42,A41,XXREAL_0:1;
      end;
A43:  P[0]
      proof
        assume
A44:    not g1.0 < y9;
        min A <= y9 & g.0 in rng g by A21,A38,FUNCT_1:def 3,XXREAL_2:def 7;
        hence contradiction by A22,A39,A44,XXREAL_0:1;
      end;
A45:  for n being Nat holds P[n] from NAT_1:sch 2(A43,A40);
      rng g c= y9
      proof
        let y be object;
        assume y in rng g;
        then consider x being object such that
A46:    x in dom g and
A47:    y = g.x by FUNCT_1:def 3;
        reconsider x as Element of NAT by A21,A46;
        g1.x < y9 by A45;
        then g1.x in {i where i is Nat:i<y9};
        hence thesis by A47,AXIOMS:4;
      end;
      then rng g is finite;
      hence contradiction by A21,A31,CARD_1:59;
    end;
    let y be object;
    assume y in rng g;
    then consider x being object such that
A48: x in dom g and
A49: y = g.x by FUNCT_1:def 3;
    reconsider n=x as Element of NAT by A21,A48;
    per cases;
    suppose
      n=0;
      hence thesis by A22,A49,XXREAL_2:def 7;
    end;
    suppose
      n<>0;
      then n > 0 by NAT_1:3;
      then n + 1 > 0 + 1 by XREAL_1:6;
      then 1 <= n by NAT_1:13;
      then reconsider m=n-1 as Element of NAT by INT_1:5;
      reconsider l = g.m as Element of NAT by A26;
      reconsider B={k where k is Element of NAT:k in rng f & k>l} as non empty
      Subset of NAT by A14,A17;
      m+1 = n;
      then g.n = min B by A23;
      then y in B by A49,XXREAL_2:def 7;
      then ex k being Element of NAT st k = y & k in rng f & k>l;
      hence thesis;
    end;
  end;
  then
A50: rng f = dom(g") by A31,FUNCT_1:33;
  then dom(g"*f) = dom f & rng(g"*f) = rng(g") by RELAT_1:27,28;
  then reconsider P=g"*f as sequence of NAT by A6,A36,FUNCT_2:def 1
,RELSET_1:4;
  rng(g") = dom g by A31,FUNCT_1:33;
  then rng P = NAT by A21,A50,RELAT_1:28;
  then P is onto by FUNCT_2:def 3;
  then reconsider P as Permutation of NAT by A9,A31;
  take P";
  NAT = dom (S2*P") & NAT = dom (S1*g) & for x being object st x in NAT
  holds (S2*P").x = (S1*g).x
  proof
    thus NAT = dom (S2*(P")) by FUNCT_2:def 1;
    rng g c= dom S1 by A28,NORMSP_1:12;
    hence NAT = dom (S1*g) by A21,RELAT_1:27;
    let x be object;
    assume
A51: x in NAT;
    then
A52: g. x in rng g by A21,FUNCT_1:def 3;
    then
A53: f".(g.x) in dom f by A9,A37,FUNCT_1:32;
    dom (P") = NAT by FUNCT_2:def 1;
    hence (S2*(P")).x = S2.(((g"*f)").x) by A51,FUNCT_1:13
      .= S2.((f"*(g")").x) by A9,A31,FUNCT_1:44
      .= S2.((f"*g).x) by A31,FUNCT_1:43
      .= S2.(f".(g.x)) by A21,A51,FUNCT_1:13
      .= S1.(f.(f".(g.x))) by A6,A8,A53
      .= S1.(g.x) by A9,A37,A52,FUNCT_1:35
      .= (S1*g).x by A21,A51,FUNCT_1:13;
  end;
  then S2*(P")=S1*g1;
  hence thesis;
end;
