reserve c, c1, c2, d, d1, d2, e, y for Real,
  k, n, m, N, n1, N0, N1, N2, N3, M for Element of NAT,
  x for set;

theorem
  for f,g being Real_Sequence st (for n st n > 0 holds g.n = n*log(2,n))
  & (for n being Nat holds f.n = log(2,n!))
 ex s being eventually-nonnegative Real_Sequence st s = g & f in Big_Theta(s)
proof
  set h = seq_logn;
   let f,g be Real_Sequence such that
A1: for n st n > 0 holds g.n = n*log(2,n) and
A2: for n being Nat holds f.n = log(2,n!);
  g is eventually-positive
  proof
    take 2;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume
A4: n >= 2;
    then log(2,n) >= log(2,2) by PRE_FF:10;
    then log(2,n) >= 1 by POWER:52;
    then n*log(2,n) > n*0 by A4,XREAL_1:68;
    hence thesis by A1,A4,A3;
  end;
  then reconsider g as eventually-positive Real_Sequence;
A5: now
    let n;
    set n1 = [/n/2\];
    assume
A6: n >= 4;
    then
A7: (n/2)*log(2,n/2) = (n/2)*(log(2,n) - log(2,2)) by POWER:54
      .= (n/2)*(log(2,n) - 1) by POWER:52
      .= (n*log(2,n))/2 - (n/2);
    ex s being Real_Sequence st s.0 = 0 & for m st m > 0 holds s.m = (log
    (2,n/2))
    proof
      defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
      implies $2 = log(2,n/2));
A8:   for x being Element of NAT ex y being Element of REAL st P[x,y]
      proof
        let x be Element of NAT;
        per cases;
        suppose
          x = zz;
          hence thesis;
        end;
        suppose
A9:       x > 0;
           log(2,n/2) in REAL by XREAL_0:def 1;
          hence thesis by A9;
        end;
      end;
      consider h being sequence of REAL such that
A10:   for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(
      A8);
      take h;
      thus h.0 = 0 by A10;
      let n;
      thus thesis by A10;
    end;
    then consider p being Real_Sequence such that
A11: p.0 = 0 and
A12: for m st m > 0 holds p.m = log(2,n/2);
A13: [/n/2\] >= n/2 by INT_1:def 7;
    then reconsider n1 as Element of NAT by INT_1:3;
    set n2 = n1-1;
A14: n*2" > 0*2" by A6,XREAL_1:68;
A15: now
      assume n2 < 0;
      then n1-1 <= -1 by INT_1:8;
      then (n1-1)+1 <= -1+1 by XREAL_1:6;
      hence contradiction by A14,INT_1:def 7;
    end;
    (n*log(2,n))*4" >= (2*n)*4" by A6,Lm45,XREAL_1:64;
    then (n*log(2,n)) / 2 - (n*log(2,n)) / 4 >= n/2;
    then (n*log(2,n)) / 2 >= n/2 + (n*log(2,n)) / 4 by XREAL_1:19;
    then
A16: (n*log(2,n))/2 - (n/2) >= n*log(2,n) / 4 by XREAL_1:19;
    2*2 <= n by A6;
    then 2 <= n/2 by XREAL_1:77;
    then log(2,2) <= log(2,n/2) by PRE_FF:10;
    then
A17: 1 <= log(2,n/2) by POWER:52;
    reconsider n2 as Element of NAT by A15,INT_1:3;
A18: for k st n2+1 <= k & k <= n holds p.k <= h.k
    proof
      let k such that
A19:  n2+1 <= k and
      k <= n;
      n/2 <= k by A13,A19,XXREAL_0:2;
      then log(2,n/2) <= log(2,k) by A14,PRE_FF:10;
      then p.k <= log(2,k) by A12,A19;
      hence thesis by A19,Def2;
    end;
    n >= n1 by Lm17;
    then
A20: Sum(h, n, n2) >= Sum(p, n, n2) by A18,Lm16;
A21: now
      [/n/2\] < n/2 + 1 by INT_1:def 7;
      then n2 < n/2 by XREAL_1:19;
      then
A22:  n/2 + n2 < n/2 + n/2 by XREAL_1:6;
      assume n-n2 < n/2;
      hence contradiction by A22,XREAL_1:19;
    end;
    for k st k <= n2 holds h.k >= 0
    proof
      let k such that
      k <= n2;
      per cases;
      suppose
        k = 0;
        hence thesis by Def2;
      end;
      suppose
A23:    k > 0;
        then k >= 0+1 by NAT_1:13;
        then log(2,k) >= log(2,1) by PRE_FF:10;
        then log(2,k) >= 0 by POWER:51;
        hence thesis by A23,Def2;
      end;
    end;
    then Sum(h,n2) >= 0 by Lm12;
    then Sum(h, n) + Sum(h,n2) >= Sum(h, n) + 0 by XREAL_1:6;
    then Sum(h, n) >= Sum(h, n) - Sum(h,n2) by XREAL_1:20;
    then
A24: Sum(h, n) >= Sum(h, n, n2) by SERIES_1:def 6;
    Sum(p, n, n2) = (n - n2)*log(2,n/2) by A11,A12,Lm18;
    then
A25: Sum(p, n, n2) >= (n/2)*log(2,n/2) by A21,A17,XREAL_1:64;
    n*log(2,n) / 4 = g.n / 4 by A1,A6
      .= (1/4)*g.n;
    then Sum(p, n, n2) >= (1/4)*g.n by A25,A7,A16,XXREAL_0:2;
    then Sum(h, n, n2) >= (1/4)*g.n by A20,XXREAL_0:2;
    then Sum(h, n) >= (1/4)*g.n by A24,XXREAL_0:2;
    hence (1/4)*g.n <= f.n by A2,Lm44;
    ex s being Real_Sequence st s.0 = 0 & for m st m > 0 holds s.m = (log
    (2,n))
    proof
      defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
      implies $2 = log(2,n));
A26:  for x being Element of NAT ex y being Element of REAL st P[x,y]
      proof
        let x be Element of NAT;
        per cases;
        suppose
          x = zz;
          hence thesis;
        end;
        suppose
A27:        x > 0;
          log(2,n) in REAL by XREAL_0:def 1;
         hence thesis by A27;
        end;
      end;
      consider h being sequence of REAL such that
A28:  for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(
      A26);
      take h;
      thus h.0 = 0 by A28;
      let n;
      thus thesis by A28;
    end;
    then consider q being Real_Sequence such that
A29: q.0 = 0 and
A30: for m st m > 0 holds q.m = log(2,n);
A31: Sum(q, n) = n*log(2,n) by A29,A30,Lm14;
    for k st k <= n holds h.k <= q.k
    proof
      let k such that
A32:  k <= n;
      per cases;
      suppose
        k = 0;
        hence thesis by A29,Def2;
      end;
      suppose
A33:    k > 0;
        then log(2,k) <= log(2,n) by A32,PRE_FF:10;
        then h.k <= log(2,n) by A33,Def2;
        hence thesis by A30,A33;
      end;
    end;
    then
A34: Sum(h, n) <= Sum(q, n) by Lm13;
    log(2,n!) = f.n by A2
      .= Sum(h, n) by A2,Lm44;
    then log(2,n!) <= 1*g.n by A1,A6,A34,A31;
    hence f.n <= 1*g.n by A2;
  end;
  take g;
A35: f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  Big_Theta(g) = { s where s is Element of Funcs(NAT, REAL) : ex c,d,N st
c > 0 & d > 0 & for n st n >= N holds d*g.n <= s.n & s.n <= c*g.n } by
ASYMPT_0:27;
  hence thesis by A35,A5;
end;
