reserve n,m,k for Nat,
  x,y for set,
  r for Real;
reserve C,D for non empty finite set,
  a for FinSequence of bool D;

theorem Th22:
  for F be PartFunc of D,REAL, A be RearrangmentGen of C st F is
  total & card C = card D holds rng Rlor(F,A) = rng FinS(F,D)
proof
  let F be PartFunc of D,REAL, B be RearrangmentGen of C;
  assume that
A1: F is total and
A2: card C = card D;
  set fd = FinS(F,D), p = Rlor(F,B), mf = MIM(fd), b = Co_Gen B, h = CHI(b,C);
A3: len mf = len h by A1,A2,Th11;
  dom F is finite;
  then reconsider F9 = F as finite Function by FINSET_1:10;
A4: dom fd = Seg len fd by FINSEQ_1:def 3;
A5: dom p = C by A1,A2,Th20;
A6: dom b = Seg len b by FINSEQ_1:def 3;
  reconsider dfd = dom fd, dF = dom F9 as finite set;
A7: len h = len b & len mf = len fd by RFINSEQ:def 2,RFUNCT_3:def 6;
A8: dom F = D by A1,PARTFUN1:def 2;
  then F|D = F by RELAT_1:68;
  then fd, F are_fiberwise_equipotent by A8,RFUNCT_3:def 13;
  then card dfd = card dF by CLASSES1:81;
  then len fd <> 0 by A8,A4;
  then
A9: 0+1<=len fd by NAT_1:13;
  then
A10: 1 in dom fd by FINSEQ_3:25;
  thus rng p c= rng fd
  proof
    let x be object;
    assume x in rng p;
    then consider c be Element of C such that
    c in dom p and
A11: p.c = x by PARTFUN1:3;
    defpred P[set] means $1 in dom b & c in b.$1;
A12: ex n be Nat st P[n]
    proof
      take n = len b;
      b.n = C by Th3;
      hence thesis by A3,A7,A9,FINSEQ_3:25;
    end;
    consider mi be Nat such that
A13: P[mi] & for n be Nat st P[n] holds mi<=n from NAT_1:sch 5(A12);
A14: 1<=mi by A13,FINSEQ_3:25;
    then max(0,mi-1)=mi-1 by FINSEQ_2:4;
    then reconsider m1 = mi -1 as Element of NAT by FINSEQ_2:5;
A15: mi<=len b by A13,FINSEQ_3:25;
    now
      per cases;
      case
        mi = 1;
        then p.c = fd.1 by A1,A2,A13,Th21;
        hence thesis by A10,A11,FUNCT_1:def 3;
      end;
      case
        mi <> 1;
        then 1<mi by A14,XXREAL_0:1;
        then 1+1<=mi by NAT_1:13;
        then
A16:    1<=m1 by XREAL_1:19;
A17:    m1<mi by XREAL_1:44;
        then m1<=len b by A15,XXREAL_0:2;
        then m1 in dom b by A16,FINSEQ_3:25;
        then not c in b.m1 by A13,XREAL_1:44;
        then
A18:    c in b.(m1+1) \ b.m1 by A13,XBOOLE_0:def 5;
        m1<len b by A15,A17,XXREAL_0:2;
        then p.c = fd.(m1+1) by A1,A2,A16,A18,Th21;
        hence thesis by A3,A7,A4,A6,A11,A13,FUNCT_1:def 3;
      end;
    end;
    hence thesis;
  end;
  let x be object;
  defpred P[Nat] means $1 in dom fd & fd.$1 = x;
  assume x in rng fd;
  then
A19: ex n be Nat st P[n] by FINSEQ_2:10;
  consider mi be Nat such that
A20: P[mi] & for n be Nat st P[n] holds mi<=n from NAT_1:sch 5(A19);
A21: 1<=mi by A20,FINSEQ_3:25;
  then max(0,mi-1)=mi-1 by FINSEQ_2:4;
  then reconsider m1 = mi -1 as Element of NAT by FINSEQ_2:5;
A22: mi<=len fd by A20,FINSEQ_3:25;
  now
    per cases;
    case
A23:  mi=1;
      set y = the Element of b.1;
A24:  b.1 <> {} by A3,A7,A4,A6,A10,Th7;
      b.1 c= C by A3,A7,A4,A6,A10,Lm5;
      then reconsider y as Element of C by A24;
      p.y = fd.1 by A1,A2,A24,Th21;
      hence thesis by A5,A20,A23,FUNCT_1:def 3;
    end;
    case
A25:  mi<>1;
      set y = the Element of b.(m1+1) \ b.m1;
      1<mi by A21,A25,XXREAL_0:1;
      then 1+1<=mi by NAT_1:13;
      then
A26:  1<=m1 by XREAL_1:19;
      m1+1<=len fd by A20,FINSEQ_3:25;
      then m1<=len fd -1 by XREAL_1:19;
      then
A27:  b.(m1+1) \ b.m1 <> {} by A3,A7,A26,Th8;
      then
A28:  y in b.(m1+1) by XBOOLE_0:def 5;
      b.mi c= C by A3,A7,A4,A6,A20,Lm5;
      then reconsider y as Element of C by A28;
      m1<mi by XREAL_1:44;
      then m1<len fd by A22,XXREAL_0:2;
      then p.y=fd.(m1+1) by A1,A2,A3,A7,A26,A27,Th21;
      hence thesis by A5,A20,FUNCT_1:def 3;
    end;
  end;
  hence thesis;
end;
