ASYMPT_1

index · ← EULER_2 · SERIES_3 →
:: Asymptotic notation. Part II: Examples and Problems
::  by Richard Krueger, Piotr Rudnicki and Paul Shelley
::
:: Received November 4, 1999
:: Copyright (c) 1999-2026 Association of Mizar Users
::           (Stowarzyszenie Uzytkownikow Mizara, Bialystok, Poland).
:: This code can be distributed under the GNU General Public Licence
:: version 3.0 or later, or the Creative Commons Attribution-ShareAlike
:: License version 3.0 or later, subject to the binding interpretation
:: detailed in file COPYING.interpretation.
:: See COPYING.GPL and COPYING.CC-BY-SA for the full text of these
:: licenses, or see http://www.gnu.org/licenses/gpl.html and
:: http://creativecommons.org/licenses/by-sa/3.0/.

environ

 vocabularies NUMBERS, REAL_1, SUBSET_1, NAT_1, XXREAL_0, POWER, ARYTM_3,
      RELAT_1, CARD_1, SQUARE_1, SEQ_1, FUNCT_1, ARYTM_1, ASYMPT_0, FUNCT_2,
      INT_1, VALUED_1, TARSKI, SEQ_2, ORDINAL2, COMPLEX1, CARD_3, SERIES_1,
      REALSET1, VALUED_0, NEWTON, FINSEQ_1, FINSEQ_2, ORDINAL4, XBOOLE_0,
      ASYMPT_1, FUNCT_7;
 notations TARSKI, XBOOLE_0, SUBSET_1, ORDINAL1, NUMBERS, XCMPLX_0, XXREAL_0,
      XREAL_0, COMPLEX1, REAL_1, FUNCT_1, FUNCT_2, FUNCT_7, SQUARE_1, INT_1,
      NAT_1, VALUED_1, SEQ_1, COMSEQ_2, SEQ_2, NEWTON, POWER, SERIES_1,
      FUNCOP_1, FINSEQ_1, FINSEQ_2, RVSUM_1, ASYMPT_0;
 constructors PARTFUN1, DOMAIN_1, REAL_1, SQUARE_1, NAT_1, NAT_D, SEQ_2,
      SEQM_3, RVSUM_1, NEWTON, PREPOWER, SERIES_1, ASYMPT_0, RELSET_1,
      FUNCOP_1, BINOP_2, COMSEQ_2, FUNCT_7, SEQ_1, NUMBERS;
 registrations XBOOLE_0, SUBSET_1, ORDINAL1, RELSET_1, NUMBERS, XXREAL_0,
      XREAL_0, NAT_1, INT_1, MEMBERED, ASYMPT_0, SQUARE_1, VALUED_0, VALUED_1,
      FUNCT_2, POWER, FINSEQ_1, FINSEQ_2;
 requirements REAL, NUMERALS, SUBSET, BOOLE, ARITHM;
 definitions ASYMPT_0;
 equalities ASYMPT_0, SQUARE_1, VALUED_1, XCMPLX_0, SEQ_1;
 expansions ASYMPT_0, VALUED_1;
 theorems TARSKI, FUNCT_2, INT_1, NAT_1, SEQ_1, SQUARE_1, SEQ_2, ABSVALUE,
      FUNCOP_1, POWER, NEWTON, EULER_2, SERIES_1, FINSEQ_1, PRE_FF, RVSUM_1,
      FINSEQ_2, ASYMPT_0, XREAL_0, XBOOLE_0, XCMPLX_0, XCMPLX_1, XREAL_1,
      XXREAL_0, ORDINAL1, NAT_D, VALUED_1;
 schemes FUNCT_2, SEQ_1, NAT_1;

begin :: Examples from the text

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;

Lm1: for n be Nat st n >= 2 holds 2 to_power n > n+1
proof
  defpred P[Nat] means 2 to_power $1 > $1+1;
A1: for k be Nat st k >= 2 & P[k] holds P[k+1]
  proof
    let k be Nat such that
    k >= 2 and
A2: 2 to_power k > k+1;
    2 to_power (k+1) = (2 to_power k)*(2 to_power 1) by POWER:27
      .= (2 to_power k)*2 by POWER:25
      .= (2 to_power k) + (2 to_power k);
    then
A3: 2 to_power (k+1) > (k+1) + (2 to_power k) by A2,XREAL_1:6;
    reconsider k as Element of NAT by ORDINAL1:def 12;
    2 to_power k >= 0 + 1 by INT_1:7,POWER:34;
    then (k+1) + (2 to_power k) >= (k+1) + 1 by XREAL_1:6;
    hence thesis by A3,XXREAL_0:2;
  end;
  2 to_power 2 = 2^2 by POWER:46
    .= 4;
  then
A4: P[2];
  for n be Nat st n >= 2 holds P[n] from NAT_1:sch 8(A4, A1);
  hence thesis;
end;

reconsider zz=0 as Element of REAL by XREAL_0:def 1;

theorem
  for t,t1 being Real_Sequence st t.0 = 0 & (for n st n > 0 holds t.n =
12*(n to_power 3)*log(2,n) - 5*n^2 + (log(2,n))^2 +36) & (for n st n > 0 holds
t1.n = (n to_power 3)*log(2,n)) ex s,s1 being eventually-positive Real_Sequence
  st s = t & s1 = t1 & s in Big_Oh(s1)
proof
  ex s being Real_Sequence st s.0 = 0 & for n st n > 0 holds s.n = (log(2
  ,n))^2 + 36
  proof
    defpred P[Element of NAT,Real]
    means ($1 = 0 implies $2 = 0) & ($1 > 0
    implies $2 = (log(2,$1))^2 + 36);
A1: for x being Element of NAT ex y being Element of REAL st P[x,y]
    proof
      let n;
      per cases;
      suppose n= zz;
      hence thesis;
      end;
      suppose
A2:      n > 0;
       (log(2,n))^2 + 36 in REAL by XREAL_0:def 1;
      hence thesis by A2;
      end;
     end;
    consider h being sequence of REAL such that
A3: for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(A1);
    take h;
    thus thesis by A3;
  end;
  then consider q being Real_Sequence such that
A4: q.0 = 0 and
A5: for n st n > 0 holds q.n = (log(2,n))^2 + 36;
  q is eventually-positive
  proof
    take 1;
    let n be Nat;
A6:  n in NAT by ORDINAL1:def 12;
A7: (log(2,n))^2 + 36 > 0+0 by XREAL_1:8,63;
    assume n >= 1;
    hence thesis by A5,A7,A6;
  end;
  then reconsider q as eventually-positive Real_Sequence;
  let f,g be Real_Sequence such that
A8: f.0 = 0 and
A9: for n st n > 0 holds f.n = 12*(n to_power 3)*log(2,n) - 5*n^2 + (
  log(2,n))^2 + 36 and
A10: for n st n > 0 holds g.n = (n to_power 3)*log(2,n);
A11: g is eventually-positive
  proof
    take 2;
    let n be Nat;
    assume
A12: n >= 2;
    then log(2,n) >= log(2,2) by PRE_FF:10;
    then
A13: log(2,n) >= 1 by POWER:52;
A14:  n in NAT by ORDINAL1:def 12;
    n to_power 3 > 0 by A12,POWER:34;
    then (n to_power 3)*log(2,n) > (n to_power 3)*0 by A13,XREAL_1:68;
    hence thesis by A10,A12,A14;
  end;
  4 = 2^2 .= 2 to_power 2 by POWER:46;
  then
A15: log(2,4) = 2*log(2,2) by POWER:55
    .= 2*1 by POWER:52
    .= 2;
A16: for n st n >= 4 holds 7*n^2 > q.n
  proof
    defpred P[Nat] means 7*$1^2 > q.$1;
A17: for k be Nat st k >= 4 & P[k] holds P[k+1]
    proof
      let k be Nat such that
A18:  k >= 4 and
A19:  7*k^2 > q.k;
A20:  q.(k+1) = (log(2,k+1))^2 + 36 by A5;
      k >= 2 by A18,XXREAL_0:2;
      then
A21:  2 to_power k > k + 1 by Lm1;
      k+1 > k+0 by XREAL_1:8;
      then 2 to_power k > k by A21,XXREAL_0:2;
      then log(2,2 to_power k) > log(2,k) by A18,POWER:57;
      then k*log(2,2) > log(2,k) by POWER:55;
      then
A22:  k*1 > log(2,k) by POWER:52;
      log(2,k) >= 2 by A15,A18,PRE_FF:10;
      then 14*k > 2*log(2,k) by A22,XREAL_1:98;
      then (7*2)*k + 7 > 2*log(2,k) + 1 by XREAL_1:8;
      then
A23:  (log(2,k))^2 + (2*log(2,k) + 1) < (log(2,k))^2 + (7*(2*k) + 7) by
XREAL_1:6;
      log(2,k+k) = log(2,2*k);
      then log(2,k+k) = log(2,k) + log(2,2) by A18,POWER:53;
      then (log(2,k+k))^2 = (log(2,k) + 1)^2 by POWER:52
        .= (log(2,k))^2 + 2*log(2,k) + 1;
      then
A24:  (log(2,k+k))^2 + 36 < ((log(2,k))^2 + (7*(2*k) + 7)) + 36 by A23,
XREAL_1:6;
      k >= 1 by A18,XXREAL_0:2;
      then k+k >= k+1 by XREAL_1:6;
      then
A25:  log(2,k+k) >= log(2,k+1) by PRE_FF:10;
      k+1 >= 4+0 by A18,XREAL_1:8;
      then log(2,k+1) >= 2 by A15,PRE_FF:10;
      then (log(2,k+k))^2 >= (log(2,k+1))^2 by A25,SQUARE_1:15;
      then
A26:  q.(k+1) <= (log(2,k+k))^2 + 36 by A20,XREAL_1:6;
      7*(k+1)^2 = 7*k^2 + (7*(2*k) + 7*1);
      then
A27:  7*(k+1)^2 > q.k + (7*(2*k) + 7*1) by A19,XREAL_1:6;
      k in NAT by ORDINAL1:def 12;
      then q.k = (log(2,k))^2 + 36 by A5,A18;
      then q.k + (7*(2*k) + 7*1) > q.(k+1) by A26,A24,XXREAL_0:2;
      hence thesis by A27,XXREAL_0:2;
    end;
    q.4 = 2^2 + 36 by A5,A15
      .= 40;
    then
A28: P[4];
    for n be Nat st n >= 4 holds P[n] from NAT_1:sch 8(A28, A17);
    hence thesis;
  end;
  reconsider g as eventually-positive Real_Sequence by A11;
  f is eventually-positive
  proof
    log(2,3) > log(2,2) by POWER:57;
    then
A29: log(2,3) > 1 by POWER:52;
    take 3;
    let n be Nat;
    assume
A30: n >= 3;
    then
A31: n to_power 2 > 0 by POWER:34;
    n > 1 by A30,XXREAL_0:2;
    then
A32: n to_power 3 > n to_power 2 by POWER:39;
A33:  n in NAT by ORDINAL1:def 12;
    log(2,n) >= log(2,3) by A30,PRE_FF:10;
    then log(2,n) > 1 by A29,XXREAL_0:2;
    then (n to_power 3)*log(2,n) > (n to_power 2)*1 by A32,A31,XREAL_1:98;
    then 12*((n to_power 3)*log(2,n)) > 5*(n to_power 2) by A31,XREAL_1:98;
    then 12*(n to_power 3)*log(2,n) > 5*n^2 + 0 by POWER:46;
    then 12*(n to_power 3)*log(2,n) - 5*n^2 > 0 by XREAL_1:20;
    then (12*(n to_power 3)*log(2,n)-5*n^2)+(log(2,n))^2>0+0 by XREAL_1:8,63;
    then (12*(n to_power 3)*log(2,n)-5*n^2)+(log(2,n))^2+36 > 0+0;
    hence thesis by A9,A30,A33;
  end;
  then reconsider f as eventually-positive Real_Sequence;
  take f, g;
  ex s being Real_Sequence st s.0 = 0 & for n st n > 0 holds s.n = 12*(n
  to_power 3)*log(2,n) - 5*n^2
  proof
    defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
    implies $2 = 12*($1 to_power 3)*log(2,$1) - 5*($1)^2);
A34: for x being Element of NAT ex y being Element of REAL st P[x,y]
    proof
      let n;
A35:    n = zz or n > 0;
       12*(n to_power 3)*log(2,n) - 5*n^2 in REAL by XREAL_0:def 1;
      hence thesis by A35;
    end;
    consider h being sequence of REAL such that
A36: for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(A34);
    take h;
    thus h.0 = 0 by A36;
    let n;
    thus thesis by A36;
  end;
  then consider p being Real_Sequence such that
A37: p.0 = 0 and
A38: for n st n > 0 holds p.n = 12*(n to_power 3)*log(2,n) - 5*n^2;
  p is eventually-positive
  proof
    log(2,3) > log(2,2) by POWER:57;
    then
A39: log(2,3) > 1 by POWER:52;
    take 3;
    let n be Nat;
    assume
A40: n >= 3;
    then
A41: n to_power 2 > 0 by POWER:34;
    n > 1 by A40,XXREAL_0:2;
    then
A42: n to_power 3 > n to_power 2 by POWER:39;
A43:  n in NAT by ORDINAL1:def 12;
    log(2,n) >= log(2,3) by A40,PRE_FF:10;
    then log(2,n) > 1 by A39,XXREAL_0:2;
    then (n to_power 3)*log(2,n) > (n to_power 2)*1 by A42,A41,XREAL_1:98;
    then 12*((n to_power 3)*log(2,n)) > 5*(n to_power 2) by A41,XREAL_1:98;
    then 12*(n to_power 3)*log(2,n) > 5*n^2 + 0 by POWER:46;
    then 12*(n to_power 3)*log(2,n) - 5*n^2 > 0 by XREAL_1:20;
    hence thesis by A38,A40,A43;
  end;
  then reconsider p as eventually-positive Real_Sequence;
  set t = max(p,q);
  consider N being Nat such that
A44: for n being Nat st n >= N holds t.n > 0 by ASYMPT_0:def 4;
A45: for n st n >= 4 holds p.n > 7*n^2
  proof
    let n;
    assume
A46: n >= 4;
    then n > 1 by XXREAL_0:2;
    then
A47: n to_power 3 > n to_power 2 by POWER:39;
    log(2,n) >= log(2,4) by A46,PRE_FF:10;
    then
A48: log(2,n) > 1 by A15,XXREAL_0:2;
    n to_power 2 > 0 by A46,POWER:34;
    then (n to_power 3)*log(2,n) > (n to_power 2)*1 by A47,A48,XREAL_1:98;
    then 12*((n to_power 3)*log(2,n)) > 12*(n to_power 2) by XREAL_1:68;
    then
A49: 12*(n to_power 3)*log(2,n) > 12*n^2 by POWER:46;
    p.n = 12*(n to_power 3)*log(2,n) - 5*n^2 by A38,A46;
    then p.n > 12*n^2 - 5*n^2 by A49,XREAL_1:9;
    hence thesis;
  end;
A50: for n st n >= 4 holds p.n > q.n
  proof
    let n;
    assume
A51: n >= 4;
    then
A52: 7*n^2 > q.n by A16;
    p.n > 7*n^2 by A45,A51;
    hence thesis by A52,XXREAL_0:2;
  end;
A53: for n st n >= 4 holds t.n = p.n
  proof
    let n;
    assume n >= 4;
    then
A54: p.n > q.n by A50;
    thus t.n = max( p.n, q.n ) by ASYMPT_0:def 7
      .= p.n by A54,XXREAL_0:def 10;
  end;
  reconsider mN = max(4,N) as Element of NAT by ORDINAL1:def 12;
A55: now
    let n;
    assume
A56: n >= mN;
A57: max(4,N) >= 4 by XXREAL_0:25;
    then t.n = p.n by A53,A56,XXREAL_0:2
      .= 12*(n to_power 3)*log(2,n) - 5*n^2 by A38,A56,A57;
    then t.n <= 12*(n to_power 3)*log(2,n) - 0 by XREAL_1:13;
    then t.n <= 12*((n to_power 3)*log(2,n));
    hence t.n <= 12*g.n by A10,A56,A57;
    max(4,N) >= N by XXREAL_0:25;
    then n >= N by A56,XXREAL_0:2;
    hence t.n >= 0 by A44;
  end;
  t is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  then
A58: t in Big_Oh(g) by A55;
  for n being Nat holds f.n = p.n + q.n
  proof
    let n be Nat;
A59:   n in NAT by ORDINAL1:def 12;
    thus f.n = p.n + q.n
    proof
      per cases;
      suppose
        n = 0;
        hence thesis by A8,A37,A4;
      end;
      suppose
A60:    n > 0;
        then p.n = 12*(n to_power 3)*log(2,n) - 5*n^2 by A38,A59;
        then
        p.n + q.n = (12*(n to_power 3)*log(2,n)-5*n^2)+((log(2,n))^2 +36)
        by A5,A60,A59
          .= 12*(n to_power 3)*log(2,n)-5*n^2+(log(2,n))^2 +36;
        hence thesis by A9,A60,A59;
      end;
    end;
  end;
  then
A61: Big_Oh(f) = Big_Oh(p+q) by SEQ_1:7
    .= Big_Oh(t) by ASYMPT_0:9;
  f in Big_Oh(f) by ASYMPT_0:10;
  hence thesis by A61,A58,ASYMPT_0:12;
end;

Lm2: for a being logbase Real, f being Real_Sequence st a > 1 & (for n st n >
0 holds f.n = log(a,n)) holds f is eventually-positive
proof
  let a be logbase Real, f be Real_Sequence such that
A1: a > 1 and
A2: for n st n > 0 holds f.n = log(a,n);
  set N = [/a\];
A3: [/a\] >= a by INT_1:def 7;
A4: a > 0 by ASYMPT_0:def 1;
  then
A5: N > 0;
  then reconsider N as Element of NAT by INT_1:3;
A6: a <> 1 by ASYMPT_0:def 1;
  now
A7: log(a,N) >= log(a,a) by A1,A3,PRE_FF:10;
    let n be Nat;
A8:  n in NAT by ORDINAL1:def 12;
    assume
A9: n >= N+1;
    N+1 > N+0 by XREAL_1:8;
    then n > N by A9,XXREAL_0:2;
    then log(a,n) > log(a,N) by A1,POWER:57;
    then log(a,n) > 0 by A4,A6,A7,POWER:52;
    hence f.n > 0 by A2,A9,A8;
  end;
  hence thesis;
end;

theorem
  for a,b being logbase Real, f,g being Real_Sequence st a > 1 & b > 1 &
  (for n st n > 0 holds f.n = log(a,n)) & (for n st n > 0 holds g.n = log(b,n))
  holds ex s,s1 being eventually-positive Real_Sequence st s = f & s1 = g &
  Big_Oh(s) = Big_Oh(s1)
proof
  let a,b be logbase Real, f,g be Real_Sequence such that
A1: a > 1 and
A2: b > 1 and
A3: for n st n > 0 holds f.n = log(a,n) and
A4: for n st n > 0 holds g.n = log(b,n);
  reconsider g as eventually-positive Real_Sequence by A2,A4,Lm2;
  reconsider f as eventually-positive Real_Sequence by A1,A3,Lm2;
  take f,g;
A5: a <> 1 by ASYMPT_0:def 1;
A6: b <> 1 by ASYMPT_0:def 1;
A7: b > 0 by ASYMPT_0:def 1;
A8: a > 0 by ASYMPT_0:def 1;
  now
    let x be object;
    hereby
      assume x in Big_Oh(f);
      then consider t being Element of Funcs(NAT, REAL) such that
A9:   x = t and
A10:  ex c,N st c > 0 & for n st n >= N holds t.n <= c*f.n & t.n >= 0;
      consider c,N such that
A11:  c > 0 and
A12:  for n st n >= N holds t.n <= c*f.n & t.n >= 0 by A10;
A13:  now
        take N1 = N+1;
        let n;
        assume
A14:    n >= N1;
        then
A15:    f.n = log(a,n) by A3
          .= log(a,b)*log(b,n) by A8,A5,A7,A6,A14,POWER:56;
        N+1 > N+0 by XREAL_1:8;
        then
A16:    n > N by A14,XXREAL_0:2;
        then t.n <= c*f.n by A12;
        then t.n <= (c*log(a,b))*log(b,n) by A15;
        hence t.n <= (c*log(a,b))*g.n by A4,A14;
        thus t.n >= 0 by A12,A16;
      end;
      log(a,b) > log(a,1) by A1,A2,POWER:57;
      then log(a,b) > 0 by A8,A5,POWER:51;
      then c*log(a,b) > c*0 by A11,XREAL_1:68;
      hence x in Big_Oh(g) by A9,A13;
    end;
    assume x in Big_Oh(g);
    then consider t being Element of Funcs(NAT, REAL) such that
A17: x = t and
A18: ex c,N st c > 0 & for n st n >= N holds t.n <= c*g.n & t.n >= 0;
    consider c,N such that
A19: c > 0 and
A20: for n st n >= N holds t.n <= c*g.n & t.n >= 0 by A18;
A21: now
      take N1 = N+1;
      let n;
      assume
A22:  n >= N1;
      then
A23:  g.n = log(b,n) by A4
        .= log(b,a)*log(a,n) by A8,A5,A7,A6,A22,POWER:56;
      N+1 > N+0 by XREAL_1:8;
      then
A24:  n > N by A22,XXREAL_0:2;
      then t.n <= c*g.n by A20;
      then t.n <= (c*log(b,a))*log(a,n) by A23;
      hence t.n <= (c*log(b,a))*f.n by A3,A22;
      thus t.n >= 0 by A20,A24;
    end;
    log(b,a) > log(b,1) by A1,A2,POWER:57;
    then log(b,a) > 0 by A7,A6,POWER:51;
    then c*log(b,a) > c*0 by A19,XREAL_1:68;
    hence x in Big_Oh(f) by A17,A21;
  end;
  hence thesis by TARSKI:2;
end;

definition
  let a,b,c be Real;
  func seq_a^(a,b,c) -> Real_Sequence means
  :Def1:
  it.n = a to_power (b*n+c);
  existence
  proof
    deffunc F(Element of NAT) = In(a to_power (b*$1+c),REAL);
    consider h being sequence of  REAL such that
A1: for n being Element of NAT holds h.n = F(n) from FUNCT_2:sch 4;
    take h;
    let n;
    thus h.n = In(a to_power (b*n+c),REAL) by A1
       .= In(a to_power (b*n+c),REAL)
       .= a to_power (b*n+c);
  end;
  uniqueness
  proof
    let j,k be Real_Sequence such that
A2: for n holds j.n = a to_power (b*n+c) and
A3: for n holds k.n = a to_power (b*n+c);
    now
      let n;
      thus j.n = a to_power (b*n+c) by A2
        .= k.n by A3;
    end;
    hence thesis by FUNCT_2:63;
  end;
end;

registration
  let a be positive Real, b,c be Real;
  cluster seq_a^(a,b,c) -> eventually-positive;
  coherence
  proof
    take 0;
    set f = seq_a^(a,b,c);
    let n be Nat;
A1:  n in NAT by ORDINAL1:def 12;
    assume n >= 0;
    f.n = a to_power (b*n+c) by Def1,A1;
    hence thesis by POWER:34;
  end;
end;

Lm3: for a,b,c being Real st a > 0 & c > 0 & c <> 1
  holds a to_power b = c to_power (b*log(c,a))
proof
  let a,b,c be Real;
  assume that
A1: a > 0 and
A2: c > 0 and
A3: c <> 1;
A4: a to_power b > 0 by A1,POWER:34;
  log(c, a to_power b) = b*log(c,a) by A1,A2,A3,POWER:55;
  hence thesis by A2,A3,A4,POWER:def 3;
end;

theorem
  for a,b being positive Real st a < b
   holds not seq_a^(b,1,0) in Big_Oh(seq_a^(a,1,0))
proof
  let a,b be positive Real such that
A1: a < b;
  set g = seq_a^(a,1,0);
  set f = seq_a^(b,1,0);
  hereby
    set d = (log(2,b) - log(2,a));
    assume f in Big_Oh(g);
    then consider s being Element of Funcs(NAT, REAL) such that
A2: s = f and
A3: ex c,N st c > 0 & for n st n >= N holds s.n <= c*g.n & s.n >= 0;
    consider c,N such that
A4: c > 0 and
A5: for n st n >= N holds s.n <= c*g.n & s.n >= 0 by A3;
    set N0 = [/log(2,c) / d\];
    set N1 = max( N, N0 );
A6: N1 >= N by XXREAL_0:25;
A7: N1 = N or N1 = N0 by XXREAL_0:16;
A8: N1 >= N0 by XXREAL_0:25;
    reconsider N1 as Element of NAT by A6,A7,INT_1:3;
    set n = N1 + 1;
    set e = (2 to_power (n*log(2,a)));
A9: e > 0 by POWER:34;
A10: N0 >= log(2,c) / d by INT_1:def 7;
    log(2,b) > log(2,a) + 0 by A1,POWER:57;
    then
A11: d > 0 by XREAL_1:20;
A12: N1 + 1 > N1 + 0 by XREAL_1:8;
    then n > N0 by A8,XXREAL_0:2;
    then n > log(2,c) / d by A10,XXREAL_0:2;
    then n*d > (log(2,c) / d)*d by A11,XREAL_1:68;
    then n*d > log(2,c) by A11,XCMPLX_1:87;
    then 2 to_power (n*d) > 2 to_power log(2,c) by POWER:39;
    then 2 to_power (n*log(2,b) - n*log(2,a)) > c by A4,POWER:def 3;
    then (2 to_power (n*log(2,b))) / e > c by POWER:29;
    then ((2 to_power (n*log(2,b)))/e)*e > c*e by A9,XREAL_1:68;
    then 2 to_power (n*log(2,b)) > c*e by A9,XCMPLX_1:87;
    then b to_power n > c*(2 to_power (n*log(2,a))) by Lm3;
    then
A13: b to_power n > c*(a to_power n) by Lm3;
    n > N by A6,A12,XXREAL_0:2;
    then f.n <= c*g.n by A2,A5;
    then b to_power (1*n + 0) <= c*g.n by Def1;
    hence contradiction by A13,Def1;
  end;
end;

:: Example p. 84

definition
  func seq_logn -> Real_Sequence means
  :Def2:
  it.0 = 0 & for n st n > 0 holds it.n = log(2,n);
  existence
  proof
    defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
    implies $2 = log(2,$1));
A1: for x being Element of NAT ex y being Element of REAL st P[x,y]
    proof
      let n;
      per cases;
      suppose
        n = zz;
        hence thesis;
      end;
      suppose
A2:      n > 0;
         log(2,n) in REAL by XREAL_0:def 1;
        hence thesis by A2;
      end;
    end;
    consider h being sequence of REAL such that
A3: for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(A1);
    take h;
    thus h.0 = 0 by A3;
    let n;
    thus thesis by A3;
  end;
  uniqueness
  proof
    let j,k be Real_Sequence such that
A4: j.0 = 0 and
A5: for n st n > 0 holds j.n = log(2,n) and
A6: k.0 = 0 and
A7: for n st n > 0 holds k.n = log(2,n);
    now
      let n;
      per cases;
      suppose
        n = 0;
        hence j.n = k.n by A4,A6;
      end;
      suppose
A8:     n > 0;
        then j.n = log(2,n) by A5;
        hence j.n = k.n by A7,A8;
      end;
    end;
    hence thesis by FUNCT_2:63;
  end;
end;

definition
  let a be Real;
  func seq_n^(a) -> Real_Sequence means
  :Def3:
  it.0 = 0 & for n st n > 0 holds it.n = n to_power a;
  existence
  proof
    defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
    implies $2 = $1 to_power a);
A1: for x being Element of NAT ex y being Element of REAL st P[x,y]
    proof
      let n;
      per cases;
      suppose
        n = zz;
        hence thesis;
      end;
      suppose
A2:      n > 0;
         n to_power a in REAL by XREAL_0:def 1;
        hence thesis by A2;
      end;
    end;
    consider h being sequence of REAL such that
A3: for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(A1);
    take h;
    thus h.0 = 0 by A3;
    let n;
    thus thesis by A3;
  end;
  uniqueness
  proof
    let j,k be Real_Sequence such that
A4: j.0 = 0 and
A5: for n st n > 0 holds j.n = n to_power a and
A6: k.0 = 0 and
A7: for n st n > 0 holds k.n = n to_power a;
    now
      let n;
      per cases;
      suppose
        n = 0;
        hence j.n = k.n by A4,A6;
      end;
      suppose
A8:     n > 0;
        then j.n = n to_power a by A5;
        hence j.n = k.n by A7,A8;
      end;
    end;
    hence thesis by FUNCT_2:63;
  end;
end;

registration
  cluster seq_logn -> eventually-positive;
  coherence
  proof
    take 2;
    set f = seq_logn;
    let n be Nat;
A1:  n in NAT by ORDINAL1:def 12;
    assume
A2: n >= 2;
    then
A3: log(2,n) >= log(2,2) by PRE_FF:10;
    f.n = log(2,n) by A2,Def2,A1;
    hence thesis by A3,POWER:52;
  end;
end;

registration
  let a be Real;
  cluster seq_n^(a) -> eventually-positive;
  coherence
  proof
    take 1;
    set f = seq_n^(a);
    let n be Nat;
A1:  n in NAT by ORDINAL1:def 12;
    assume
A2: n >= 1;
    then f.n = n to_power a by Def3,A1;
    hence thesis by A2,POWER:34;
  end;
end;

Lm4: for f,g being Real_Sequence, n being Nat holds (f/"g).n = f.n/
g.n
proof
  let f,g be Real_Sequence, n be Nat;
  thus (f/"g).n = f.n*g".n by SEQ_1:8
    .= f.n*(g.n)" by VALUED_1:10
    .= f.n/g.n;
end;

Lm5: for f,g being eventually-nonnegative Real_Sequence holds f in Big_Oh(g) &
g in Big_Oh(f) iff Big_Oh(f) = Big_Oh(g)
proof
  let f,g be eventually-nonnegative Real_Sequence;
  hereby
    assume that
A1: f in Big_Oh(g) and
A2: g in Big_Oh(f);
A3: Big_Oh(g) c= Big_Oh(f) by A2,ASYMPT_0:11;
    Big_Oh(f) c= Big_Oh(g) by A1,ASYMPT_0:11;
    hence Big_Oh(f) = Big_Oh(g) by A3,XBOOLE_0:def 10;
  end;
  thus thesis by ASYMPT_0:10;
end;

theorem Th4:
  for f,g being eventually-nonnegative Real_Sequence holds Big_Oh(f
  ) c= Big_Oh(g) & not Big_Oh(f) = Big_Oh(g) iff f in Big_Oh(g) & not f in
  Big_Omega(g)
proof
  let f,g be eventually-nonnegative Real_Sequence;
  hereby
    assume that
A1: Big_Oh(f) c= Big_Oh(g) and
A2: not Big_Oh(f) = Big_Oh(g);
A3: f in Big_Oh(f) by ASYMPT_0:10;
    now
      assume f in Big_Omega(g);
      then g in Big_Oh(f) by ASYMPT_0:19;
      hence contradiction by A1,A2,A3,Lm5;
    end;
    hence f in Big_Oh(g) & not f in Big_Omega(g) by A1,A3;
  end;
  assume that
A4: f in Big_Oh(g) and
A5: not f in Big_Omega(g);
  now
    let x be object;
    assume x in Big_Oh(f);
    then consider t being Element of Funcs(NAT, REAL) such that
A6: x = t and
A7: ex c,N st c > 0 & for n st n >= N holds t.n <= c*f.n & t.n >= 0;
    consider c,N such that
    c > 0 and
A8: for n st n >= N holds t.n <= c*f.n & t.n >= 0 by A7;
    now
       reconsider N as Nat;
      take N;
      let n be Nat;
A9:  n in NAT by ORDINAL1:def 12;
      assume n >= N;
      hence t.n >= 0 by A8,A9;
    end;
    then
A10: t is eventually-nonnegative;
    t in Big_Oh(f) by A7;
    hence x in Big_Oh(g) by A4,A6,A10,ASYMPT_0:12;
  end;
  hence Big_Oh(f) c= Big_Oh(g) by TARSKI:def 3;
  assume Big_Oh(f) = Big_Oh(g);
  then g in Big_Oh(f) by Lm5;
  hence contradiction by A5,ASYMPT_0:19;
end;

Lm6: for a, b, c being Real st 0 < a & a <= b & c >= 0 holds a to_power
c <= b to_power c
proof
  let a, b, c be Real;
  assume that
A1: 0 < a and
A2: a <= b and
A3: c >= 0;
  per cases by A3;
  suppose
A4: c = 0;
    then a to_power c = 1 by POWER:24;
    hence thesis by A4,POWER:24;
  end;
  suppose
A5: c > 0;
    per cases by A2,XXREAL_0:1;
    suppose
      a = b;
      hence thesis;
    end;
    suppose
      a < b;
      hence thesis by A1,A5,POWER:37;
    end;
  end;
end;

Lm7: for n be Nat st n >= 4 holds 2*n + 3 < 2 to_power n
proof
  defpred P[Nat] means 2*$1 + 3 < 2 to_power $1;
A1: for k be Nat st k >= 4 & P[k] holds P[k+1]
  proof
    let k be Nat such that
A2: k >= 4 and
A3: 2*k + 3 < 2 to_power k;
    k > 1 by A2,XXREAL_0:2;
    then 2 to_power k > 2 to_power 1 by POWER:39;
    then 2 to_power k > 2 by POWER:25;
    then
A4: (2 to_power k) + (2 to_power k) > 2 + (2 to_power k) by XREAL_1:6;
    2*(k+1) + 3 = 2 + (2*k + 3);
    then 2*(k+1) + 3 < 2 + (2 to_power k) by A3,XREAL_1:6;
    then 2*(k+1) + 3 < 2*(2 to_power k) by A4,XXREAL_0:2;
    then 2*(k+1) + 3 < (2 to_power 1)*(2 to_power k) by POWER:25;
    hence thesis by POWER:27;
  end;
A5: P[4] by POWER:62;
  for n be Nat st n >= 4 holds P[n] from NAT_1:sch 8(A5, A1);
  hence thesis;
end;

Lm8: for n st n >= 6 holds (n+1)^2 < 2 to_power n
proof
  defpred P[Nat] means ($1+1)^2 < 2 to_power $1;
A1: for k be Nat st k >= 6 & P[k] holds P[k+1]
  proof
    let k be Nat such that
A2: k >= 6 and
A3: (k+1)^2 < 2 to_power k;
    k >= 4 by A2,XXREAL_0:2;
    then 2*k + 3 < 2 to_power k by Lm7;
    then
A4: (k+1)^2 + (2*k + 3) < (k+1)^2 + (2 to_power k) by XREAL_1:6;
    (k+1)^2 + (2 to_power k) < (2 to_power k) + (2 to_power k) by A3,XREAL_1:6;
    then ((k+1)+1)^2 < 2*(2 to_power k) by A4,XXREAL_0:2;
    then ((k+1)+1)^2 < (2 to_power 1)*(2 to_power k) by POWER:25;
    hence thesis by POWER:27;
  end;
A5: P[6] by POWER:64;
  for n be Nat st n >= 6 holds P[n] from NAT_1:sch 8(A5, A1);
  hence thesis;
end;

Lm9: for c being Real st c > 6 holds c^2 < 2 to_power c
proof
A1: 5 = 6-1;
  let c be Real such that
A2: c > 6;
  set i0 = [\c/], i1 = [/c\];
  per cases;
  suppose
    i0 = i1;
    then c is Integer by INT_1:34;
    then reconsider c as Element of NAT by A2,INT_1:3;
    c+0 < c+1 by XREAL_1:8;
    then
A3: c^2 < (c+1)^2 by SQUARE_1:16;
    (c+1)^2 < 2 to_power c by A2,Lm8;
    hence thesis by A3,XXREAL_0:2;
  end;
  suppose
    not i0 = i1;
    then
A4: i0 + 1 = i1 by INT_1:41;
    then
A5: i0 = i1 - 1;
A6: i1 >= c by INT_1:def 7;
    reconsider i1 as Element of NAT by A2,INT_1:3;
    i1 > 6 by A2,A6,XXREAL_0:2;
    then
A7: i0 > 5 by A1,A5,XREAL_1:9;
    then reconsider i0 as Element of NAT by INT_1:3;
    i0 <= c by INT_1:def 6;
    then
A8: 2 to_power i0 <= 2 to_power c by PRE_FF:8;
    i1 >= c by INT_1:def 7;
    then
A9: i1^2 >= c^2 by A2,SQUARE_1:15;
    i0 >= 5 + 1 by A7,INT_1:7;
    then i1^2 < 2 to_power i0 by A4,Lm8;
    then c^2 < 2 to_power i0 by A9,XXREAL_0:2;
    hence thesis by A8,XXREAL_0:2;
  end;
end;

Lm10: for e being positive Real, f being Real_Sequence
  st (for n st n > 0
holds f.n = log(2,n to_power e)) holds (f /" seq_n^(e)) is convergent & lim (f
/" seq_n^(e)) = 0
proof
  let e be positive Real, f be Real_Sequence such that
A1: for n st n > 0 holds f.n = log(2,n to_power e);
  set g = seq_n^(e);
  set h = f/"g;
A2: now
    let p be Real;
    reconsider p1 = p as Real;
    set i0 = [/(7/p1) to_power (1/e)\];
    set i1 = [/(p1 to_power -(2/e)) + 1\];
    set N = max( max(i0, i1), 2 );
A3: N >= max(i0, i1) by XXREAL_0:25;
A4: N is Integer
    proof
      per cases by XXREAL_0:16;
      suppose
        N = max(i0, i1);
        hence thesis by XXREAL_0:16;
      end;
      suppose
        N = 2;
        hence thesis;
      end;
    end;
A5: (p to_power -(2/e)) + 1 > (p to_power -(2/e)) + 0 by XREAL_1:8;
    i1 >= (p to_power -(2/e)) + 1 by INT_1:def 7;
    then
A6: i1 > (p to_power -(2/e)) by A5,XXREAL_0:2;
    assume
A7: p > 0;
    then
A8: p1 to_power 2 > 0 by POWER:34;
    max(i0, i1) >= i1 by XXREAL_0:25;
    then
A9: N >= i1 by A3,XXREAL_0:2;
A10: i0 >= (7/p) to_power (1/e) by INT_1:def 7;
    max(i0, i1) >= i0 by XXREAL_0:25;
    then
A11: N >= i0 by A3,XXREAL_0:2;
A12: N >= 2 by XXREAL_0:25;
A13: p1 to_power -(2/e) > 0 by A7,POWER:34;
A14: 7*p" > 7*0 by A7,XREAL_1:68;
    then
A15: (7/p1) to_power (1/e) > 0 by POWER:34;
    N in NAT by A12,A4,INT_1:3;
    then reconsider N as Nat;
    take N;
    let n be Nat;
    set c = p1*(n to_power e);
    assume
A16: n >= N;
    then n >= i0 by A11,XXREAL_0:2;
    then n >= (7/p) to_power (1/e) by A10,XXREAL_0:2;
    then n to_power e >= (7/p) to_power (1/e) to_power e by A15,Lm6;
    then n to_power e >= (7/p1) to_power (e*(1/e)) by A14,POWER:33;
    then n to_power e >= (7/p) to_power 1 by XCMPLX_1:106;
    then n to_power e >= 7/p1 by POWER:25;
    then p*(n to_power e) >= (7/p)*p by A7,XREAL_1:64;
    then p*(n to_power e) >= 7 by A7,XCMPLX_1:87;
    then p*(n to_power e) > 6 by XXREAL_0:2;
    then
A17: (p1*(n to_power e))^2 < 2 to_power (p1*(n to_power e)) by Lm9;
    n >= i1 by A9,A16,XXREAL_0:2;
    then n > p to_power -(2/e) by A6,XXREAL_0:2;
    then n to_power e > p to_power (-(2/e)) to_power e by A13,POWER:37;
    then n to_power e > p1 to_power ((-(2/e))*e) by A7,POWER:33;
    then n to_power e > p to_power -((2/e)*e);
    then n to_power e > p to_power -2 by XCMPLX_1:87;
    then
    (p to_power 2)*(n to_power e) > (p to_power 2)*(p to_power -2) by A8,
XREAL_1:68;
    then (p1 to_power 2)*(n to_power e) > p1 to_power (2+-2) by A7,POWER:27;
    then (p1 to_power 2)*(n to_power e) > 1 by POWER:24;
    then p1^2*(n to_power e) > 1 by POWER:46;
    then
A18: 1/(p*c) < 1/1 by XREAL_1:88;
    2 to_power c > 0 by POWER:34;
    then
A19: (2 to_power c)/(c*p) < (2 to_power c)*1 by A18,XREAL_1:68;
A20: n to_power e > 0 by A12,A16,POWER:34;
    then p*(n to_power e) > p*0 by A7,XREAL_1:68;
    then c < (2 to_power c)/c by A17,XREAL_1:81;
    then n to_power e < ((2 to_power c)/c)/p by A7,XREAL_1:81;
    then n to_power e < (2 to_power c)/(c*p) by XCMPLX_1:78;
    then n to_power e < 2 to_power c by A19,XXREAL_0:2;
    then log(2,n to_power e) < log(2,2 to_power c) by A20,POWER:57;
    then log(2,n to_power e) < c*log(2,2) by POWER:55;
    then log(2,n to_power e) < c*1 by POWER:52;
    then
A21: log(2,n to_power e)/(n to_power e) < p by A12,A16,POWER:34,XREAL_1:83;
    n >= 2 by A12,A16,XXREAL_0:2;
    then n > 1 by XXREAL_0:2;
    then n to_power e > n to_power 0 by POWER:39;
    then n to_power e > 1 by POWER:24;
    then log(2,n to_power e) > log(2,1) by POWER:57;
    then
A22: log(2,n to_power e) > 0 by POWER:51;
    reconsider nn=n as Element of NAT by ORDINAL1:def 12;
    h.n = f.n/g.nn by Lm4
      .= log(2,nn to_power e)/g.n by A1,A12,A16
      .= log(2,nn to_power e)/(n to_power e) by A12,A16,Def3;
    hence |.h.n-0.| < p by A20,A21,A22,ABSVALUE:def 1;
  end;
  hence h is convergent by SEQ_2:def 6;
  hence thesis by A2,SEQ_2:def 7;
end;

Lm11: for e being Real st e > 0
  holds (seq_logn /" seq_n^(e)) is convergent &
lim(seq_logn /" seq_n^(e)) = 0
proof
  set f = seq_logn;
  let e be Real;
  assume e > 0;
  then reconsider e as positive Real;
  set g = seq_n^(e);
  set h = f/"g;
  ex s being Real_Sequence st s.0 = 0 & for n st n > 0 holds s.n = log(2,n
  to_power e)
  proof
    defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
    implies $2 = log(2,$1 to_power e));
A1: for x being Element of NAT ex y being Element of REAL st P[x,y]
    proof
      let n;
      per cases;
      suppose
        n = zz;
        hence thesis;
      end;
      suppose
A2:      n > 0;
        log(2,n to_power e) in REAL by XREAL_0:def 1;
        hence thesis by A2;
      end;
    end;
    consider h being sequence of REAL such that
A3: for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(A1);
    take h;
    thus h.0 = 0 by A3;
    let n;
    thus thesis by A3;
  end;
  then consider p being Real_Sequence such that
A4: p.0 = 0 and
A5: for n st n > 0 holds p.n = log(2,n to_power e);
  set q = p/"g;
A6: q is convergent by A5,Lm10;
A7: 1 = e/e by XCMPLX_1:60
    .= e*(1/e);
A8: for n being Nat holds h.n = (1/e)*q.n
  proof
    let n be Nat;
A9:  n in NAT by ORDINAL1:def 12;
A10: h.n = f.n / g.n by Lm4;
A11: q.n = p.n / g.n by Lm4;
    per cases;
    suppose
A12:  n = 0;
      then h.n = 0 / g.n by A10,Def2
        .= 0*(1/e);
      hence thesis by A4,A11,A12;
    end;
    suppose
A13:  n > 0;
      then
A14:  n to_power e > 0 by POWER:34;
      h.n = log(2,n) / g.n by A10,A13,Def2,A9
        .= log(2,n to_power (e*(1/e))) / g.n by A7,POWER:25
        .= log(2,n to_power e to_power (1/e)) / g.n by A13,POWER:33
        .= ((1/e)*log(2,n to_power e)) / g.n by A14,POWER:55
        .= ((1/e)*log(2,n to_power e)) * (g.n)"
        .= (1/e)*(log(2,n to_power e) * (g.n)")
        .= (1/e)*(log(2,n to_power e) / g.n);
      hence thesis by A5,A11,A13,A9;
    end;
  end;
  then
A15: h = (1/e)(#)q by SEQ_1:9;
A16: lim q = 0 by A5,Lm10;
  lim h = lim((1/e)(#)q) by A8,SEQ_1:9
    .= (1/e)*0 by A6,A16,SEQ_2:8;
  hence thesis by A6,A15,SEQ_2:7;
end;

theorem Th5:
  Big_Oh(seq_logn) c= Big_Oh(seq_n^(1/2)) &
  not Big_Oh(seq_logn) = Big_Oh(seq_n^(1/2))
proof
  set g = seq_n^(1/2);
  set f = seq_logn;
A1: lim (f/"g) = 0 by Lm11;
A2: f/"g is convergent by Lm11;
  then not g in Big_Oh(f) by A1,ASYMPT_0:16;
  then
A3: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A2,A1,ASYMPT_0:16;
  hence thesis by A3,Th4;
end;

:: Example p. 86

theorem
  seq_n^(1/2) in Big_Omega(seq_logn) & not seq_logn in Big_Omega(seq_n^( 1/2))
proof
  seq_logn in Big_Oh(seq_n^(1/2)) by Th4,Th5;
  hence thesis by Th4,Th5,ASYMPT_0:19;
end;

:: Example p. 88

Lm12: for f being Real_Sequence holds for N holds (for n st n <= N holds f.n
>= 0) implies Sum(f,N) >= 0
proof
  let f be Real_Sequence;
  defpred P[Nat] means
(for n st n <= $1 holds f.n >= 0) implies Sum(f,$1) >= 0;
A1: for N being Nat st P[N] holds P[N+1]
  proof
    let N be Nat;
    assume
A2: (for n st n <= N holds f.n >= 0) implies Sum(f,N) >= 0;
    assume
A3: for n st n <= (N+1) holds f.n >= 0;
A4: now
      let n;
      assume n <= N;
      then n+0 <= N+1 by XREAL_1:7;
      hence f.n >= 0 by A3;
    end;
    f.(N+1) >= 0 by A3;
    then Sum(f,N) + f.(N+1) >= 0 + 0 by A2,A4;
    then (Partial_Sums(f)).N + f.(N+1) >= 0 by SERIES_1:def 5;
    then (Partial_Sums(f)).(N+1) >= 0 by SERIES_1:def 1;
    hence thesis by SERIES_1:def 5;
  end;
A5: P[0]
  proof
    assume for n st n <= 0 holds f.n >= 0;
    then f.0 >= 0;
    then (Partial_Sums(f)).0 >= 0 by SERIES_1:def 1;
    hence thesis by SERIES_1:def 5;
  end;
  for N being Nat holds P[N] from NAT_1:sch 2(A5, A1);
  hence thesis;
end;

Lm13: for f,g being Real_Sequence holds for N holds (for n st n <= N holds f.n
<= g.n) implies Sum(f,N) <= Sum (g,N)
proof
  let f,g be Real_Sequence;
  defpred P[Nat] means
(for n st n <= $1 holds f.n <= g.n) implies
  Sum(f,$1) <= Sum(g,$1);
A1: for N being Nat st P[N] holds P[N+1]
  proof
    let N be Nat;
    assume
A2: (for n st n <= N holds f.n <= g.n) implies Sum(f,N) <= Sum(g,N);
    assume
A3: for n st n <= (N+1) holds f.n <= g.n;
A4: now
      let n;
      assume n <= N;
      then n+0 <= N+1 by XREAL_1:7;
      hence f.n <= g.n by A3;
    end;
    f.(N+1) <= g.(N+1) by A3;
    then Sum(f,N) + f.(N+1) <= Sum(g,N) + g.(N+1) by A2,A4,XREAL_1:7;
    then (Partial_Sums(f)).N + f.(N+1) <= Sum(g,N) + g.(N+1) by SERIES_1:def 5;
    then (Partial_Sums(f)).(N+1) <= Sum(g,N) + g.(N+1) by SERIES_1:def 1;
    then Sum(f,N+1) <= Sum(g,N) + g.(N+1) by SERIES_1:def 5;
    then Sum(f,N+1) <= (Partial_Sums(g)).N + g.(N+1) by SERIES_1:def 5;
    then Sum(f,N+1) <= (Partial_Sums(g)).(N+1) by SERIES_1:def 1;
    hence thesis by SERIES_1:def 5;
  end;
A5: P[0]
  proof
    assume for n st n <= 0 holds f.n <= g.n;
    then f.0 <= g.0;
    then Partial_Sums(f).0 <= g.0 by SERIES_1:def 1;
    then Partial_Sums(f).0 <= Partial_Sums(g).0 by SERIES_1:def 1;
    then Sum(f,0) <= Partial_Sums(g).0 by SERIES_1:def 5;
    hence thesis by SERIES_1:def 5;
  end;
  for N being Nat holds P[N] from NAT_1:sch 2(A5, A1);
  hence thesis;
end;

Lm14: for f being Real_Sequence, b being Real
  st f.0 = 0 & (for n st n > 0
holds f.n = b) holds for N being Element of NAT holds Sum(f,N) = b*N
proof
  let f be Real_Sequence, b be Real;
  defpred P[Nat] means Sum(f,$1) = b*$1;
  assume that
A1: f.0 = 0 and
A2: for n st n > 0 holds f.n = b;
A3: for N being Nat st P[N] holds P[N+1]
  proof
    let N be Nat;
    assume
A4: Sum(f, N) = b*N;
    Sum(f, N+1) = (Partial_Sums(f)).(N+1) by SERIES_1:def 5
      .= (Partial_Sums(f)).N + f.(N+1) by SERIES_1:def 1
      .= b*N + f.(N+1) by A4,SERIES_1:def 5
      .= b*N + b*1 by A2
      .= b*(N+1);
    hence thesis;
  end;
  (Partial_Sums(f)).0 = 0 by A1,SERIES_1:def 1;
  then
A5: P[0] by SERIES_1:def 5;
  for N being Nat holds P[N] from NAT_1:sch 2( A5, A3 );
  hence thesis;
end;

Lm15: for f being Real_Sequence, N,M being Nat holds Sum(f,N,M) + f.(N+1) =
Sum(f,N+1,M)
proof
  let f be Real_Sequence, N,M be Nat;
  Sum(f,N,M) + f.(N+1) = Sum(f,N) - Sum(f,M) + f.(N+1) by SERIES_1:def 6
    .= Sum(f,N) + f.(N+1) + -Sum(f,M)
    .= (Partial_Sums(f)).N + f.(N+1) + -Sum (f,M) by SERIES_1:def 5
    .= (Partial_Sums(f)).(N+1) + -Sum(f,M) by SERIES_1:def 1
    .= Sum(f,N+1) + -Sum(f,M) by SERIES_1:def 5
    .= Sum(f,N+1) - Sum(f,M)
    .= Sum(f,N+1,M) by SERIES_1:def 6;
  hence thesis;
end;

Lm16: for f,g being Real_Sequence, M being Element of NAT holds for N st N >=
M+1 holds (for n st M+1 <= n & n <= N holds f.n <= g.n) implies Sum(f,N,M) <=
Sum (g,N,M)
proof
  let f,g be Real_Sequence, M be Element of NAT;
  defpred P[Nat] means (for n st M+1 <= n & n <= $1 holds f.n <= g.n) implies
  Sum(f,$1,M) <= Sum(g,$1,M);
A1: for N1 be Nat st N1 >= M+1 & P[N1] holds P[N1+1]
  proof
    let N1 be Nat;
    assume that
A2: N1 >= M+1 and
A3: (for n st M+1 <= n & n <= N1 holds f.n <= g.n) implies Sum(f,N1,M)
    <= Sum(g,N1,M);
    assume
A4: for n st M+1 <= n & n <= N1+1 holds f.n <= g.n;
A5: now
      let n;
      assume that
A6:   M+1 <= n and
A7:   n <= N1;
      n + 0 <= N1 + 1 by A7,XREAL_1:7;
      hence f.n <= g.n by A4,A6;
    end;
    N1+1 >= M+1+0 by A2,XREAL_1:7;
    then f.(N1+1) <= g.(N1+1) by A4;
    then Sum(f,N1,M) + f.(N1+1) <= g.(N1+1) + Sum(g,N1,M) by A3,A5,XREAL_1:7;
    then Sum(f,N1+1,M) <= g.(N1+1) + Sum(g,N1,M) by Lm15;
    hence thesis by Lm15;
  end;
A8: P[M+1]
  proof
A9: Sum(g,M+1,M) = Sum(g,M+1) - Sum(g,M) by SERIES_1:def 6
      .= (Partial_Sums(g)).(M+1) - Sum(g,M) by SERIES_1:def 5
      .= g.(M+1) + (Partial_Sums(g)).M - Sum(g,M) by SERIES_1:def 1
      .= g.(M+1) + Sum(g,M) - Sum(g,M) by SERIES_1:def 5
      .= g.(M+1) + 0;
A10: Sum(f,M+1,M) = Sum(f,M+1) - Sum(f,M) by SERIES_1:def 6
      .= (Partial_Sums(f)).(M+1) - Sum(f,M) by SERIES_1:def 5
      .= f.(M+1) + (Partial_Sums(f)).M - Sum(f,M) by SERIES_1:def 1
      .= f.(M+1) + Sum(f,M) - Sum(f,M) by SERIES_1:def 5
      .= f.(M+1) + 0;
    assume for n st M+1 <= n & n <= M+1 holds f.n <= g.n;
    hence thesis by A10,A9;
  end;
  for N be Nat st N >= M+1 holds P[N] from NAT_1:sch 8(A8, A1);
  hence thesis;
end;

Lm17: for n being Nat holds [/n/2\] <= n
proof
  let n be Nat;
  per cases;
  suppose
    n = 0;
    hence thesis;
  end;
  suppose
    n > 0;
    then
A1: n >= 0+1 by NAT_1:13;
    per cases by A1,XXREAL_0:1;
    suppose
A2:   n = 1;
      now
        assume [/1/2\] > 1;
        then
A3:     [/1/2\] >= 1+1 by INT_1:7;
        [/1/2\] < 1/2 + 1 by INT_1:def 7;
        hence contradiction by A3,XXREAL_0:2;
      end;
      hence thesis by A2;
    end;
    suppose
      n > 1;
      then
A4:   n >= 1+1 by NAT_1:13;
A5:   now
        assume n/2 + 1 > n;
        then 2*(n/2 + 1) > 2*n by XREAL_1:68;
        then 2*(n/2) + 2*1 > 2*n;
        then 2 > 2*n - n by XREAL_1:19;
        hence contradiction by A4;
      end;
      [/n/2\] < n/2 + 1 by INT_1:def 7;
      hence thesis by A5,XXREAL_0:2;
    end;
  end;
end;

Lm18: for f being Real_Sequence,
   b being Real, N being Element of NAT st f.0 =
0 & (for n st n > 0 holds f.n = b) holds for M being Element of NAT holds Sum(f
, N, M) = b*(N-M)
proof
  let f be Real_Sequence, b be Real, N be Element of NAT such that
A1: f.0 = 0 and
A2: for n st n > 0 holds f.n = b;
  defpred P[Nat] means Sum(f, N, $1) = b*(N-$1);
A3: for M being Nat st P[M] holds P[M+1]
  proof
    let M be Nat;
    assume
A4: Sum(f, N, M) = b*(N-M);
    Sum(f, N, M+1) = Sum(f, N) - Sum(f, M+1) by SERIES_1:def 6
      .= Sum(f, N) - (Partial_Sums(f)).(M+1) by SERIES_1:def 5
      .= Sum (f, N) - ((Partial_Sums(f)).M + f.(M+1)) by SERIES_1:def 1
      .= (Sum (f, N) - (Partial_Sums(f)).M) + -f.(M+1)
      .= (Sum(f, N) - Sum(f, M)) + -f.(M+1) by SERIES_1:def 5
      .= b*(N-M) + -f.(M+1) by A4,SERIES_1:def 6
      .= b*(N-M) + -b by A2
      .= b*(N-(M+1));
    hence thesis;
  end;
  Sum(f, 0) = (Partial_Sums(f)).0 by SERIES_1:def 5
    .= 0 by A1,SERIES_1:def 1;
  then Sum(f, N, 0) = Sum(f, N) - 0 by SERIES_1:def 6
    .= b*(N-0) by A1,A2,Lm14;
  then
A5: P[0];
  for M being Nat holds P[M] from NAT_1:sch 2(A5, A3);
  hence thesis;
end;

theorem
  for f being Real_Sequence, k being Element of NAT st (for n holds f.n
  = Sum(seq_n^(k), n)) holds f in Big_Theta(seq_n^(k+1))
proof
  let f be Real_Sequence, k be Element of NAT such that
A1: for n holds f.n = Sum(seq_n^(k), n);
  set g = seq_n^(k+1);
A2: f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
A3: now
    set p = seq_n^(k);
    let n;
    set n1 = [/n/2\];
    ex s being Real_Sequence st s.0 = 0 & for m st m > 0 holds s.m = ((n/
    2) to_power k)
    proof
      defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
      implies $2 = ((n/2) to_power k));
A4:   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
A5:       x > 0;
           reconsider y = (n/2) to_power k as Element of REAL by XREAL_0:def 1;
          take y;
          thus thesis by A5;
        end;
      end;
      consider h being sequence of REAL such that
A6:   for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(
      A4);
      take h;
      thus h.0 = 0 by A6;
      let n;
      thus thesis by A6;
    end;
    then consider q being Real_Sequence such that
A7: q.0 = 0 and
A8: for m st m > 0 holds q.m = (n/2) to_power k;
A9: [/n/2\] >= n/2 by INT_1:def 7;
    reconsider n1 as Element of NAT by INT_1:3;
    set n2 = n1-1;
    assume
A10: n >= 1;
    then
A11: n*2" > 0*2" by XREAL_1:68;
    then
A12: ((n/2) to_power k) > 0 by POWER:34;
    now
      assume n2 < 0;
      then (n1-1)+1 <= -1+1;
      hence contradiction by A11;
    end;
    then reconsider n2 as Element of NAT by INT_1:3;
A13: now
      [/n/2\] < n/2 + 1 by INT_1:def 7;
      then n2 < n/2 by XREAL_1:19;
      then
A14:  n/2 + n2 < n/2 + n/2 by XREAL_1:6;
      assume n-n2 < n/2;
      hence contradiction by A14,XREAL_1:19;
    end;
    Sum(q,n,n2) = (n-n2)*((n/2) to_power k) by A7,A8,Lm18;
    then Sum(q,n,n2) >= (n/2) * ((n/2) to_power k) by A13,A12,XREAL_1:64;
    then Sum(q,n,n2) >= ((n/2) to_power 1) * ((n/2) to_power k) by POWER:25;
    then Sum(q,n,n2) >= ((n/2) to_power (k+1)) by A11,POWER:27;
    then
A15: Sum(q,n,n2) >= (n to_power (k+1))/(2 to_power (k+1)) by A10,POWER:31;
A16: f.n = Sum(p, n) by A1;
A17: now
      let m;
      assume m <= n;
      per cases;
      suppose
        m = 0;
        hence p.m >= 0 by Def3;
      end;
      suppose
        m > 0;
        then p.m = m to_power k by Def3;
        hence p.m >= 0;
      end;
    end;
    now
      let m;
      n1 <= n1+1 by NAT_1:11;
      then
A18:  n2 <= n1 by XREAL_1:20;
A19:  n1 <= n by Lm17;
      assume m <= n2;
      then m <= n1 by A18,XXREAL_0:2;
      then m <= n by A19,XXREAL_0:2;
      hence p.m >= 0 by A17;
    end;
    then Sum(p,n2) >= 0 by Lm12;
    then
A20: Sum(p,n) + Sum(p,n2) >= Sum(p,n) + 0 by XREAL_1:7;
A21: for N0 st n1 <= N0 & N0 <= n holds q.N0 <= p.N0
    proof
      let N0;
      assume that
A22:  n1 <= N0 and
      N0 <= n;
A23:  N0 >= n/2 by A9,A22,XXREAL_0:2;
A24:  p.N0 = N0 to_power k by A11,A9,A22,Def3;
      q.N0 = (n/2) to_power k by A8,A11,A9,A22;
      hence thesis by A11,A24,A23,Lm6;
    end;
    n >= n2 + 1 by Lm17;
    then Sum(p,n,n2) >= Sum(q,n,n2) by A21,Lm16;
    then
A25: Sum(p,n,n2) >= (n to_power (k+1))*(2 to_power (k+1))" by A15,XXREAL_0:2;
    Sum(p,n,n2) = Sum(p,n) - Sum(p,n2) by SERIES_1:def 6;
    then
A26: Sum(p,n) >= Sum(p,n,n2) by A20,XREAL_1:20;
    g.n = n to_power (k+1) by A10,Def3;
    hence (2 to_power (k+1))"*g.n <= f.n by A16,A26,A25,XXREAL_0:2;
    Sum(p,n) >= 0 by A17,Lm12;
    hence f.n >= 0 by A1;
  end;
  now
    set p = seq_n^(k);
    let n;
    assume
A27: n >= 1;
    ex s being Real_Sequence st s.0 = 0 & for m st m > 0 holds s.m = (n
    to_power k)
    proof
      defpred P[Element of NAT,Real] means ($1 = 0 implies $2 = 0) & ($1 > 0
      implies $2 = n to_power k);
A28:  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
A29:        x > 0;
           reconsider y = n to_power k as Element of REAL by XREAL_0:def 1;
          take y;

          thus thesis by A29;
        end;
      end;
      consider h being sequence of REAL such that
A30:  for x being Element of NAT holds P[x,h.x] from FUNCT_2:sch 3(
      A28
      );
      take h;
      thus h.0 = 0 by A30;
      let n;
      thus thesis by A30;
    end;
    then consider q being Real_Sequence such that
A31: q.0 = 0 and
A32: for m st m > 0 holds q.m = n to_power k;
    now
      let m;
      assume
A33:  m <= n;
      per cases;
      suppose
        m = 0;
        hence p.m <= q.m by A31,Def3;
      end;
      suppose
A34:    m > 0;
        then
A35:    q.m = n to_power k by A32;
        p.m = m to_power k by A34,Def3;
        hence p.m <= q.m by A33,A34,A35,Lm6;
      end;
    end;
    then
A36: Sum(p, n) <= Sum(q, n) by Lm13;
    Sum(q, n) = (n to_power k)*n by A31,A32,Lm14
      .= (n to_power k)*(n to_power 1) by POWER:25
      .= n to_power (k+1) by A27,POWER:27
      .= g.n by A27,Def3;
    hence f.n <= 1*g.n by A1,A36;
A37: now
      let m;
      assume m <= n;
      per cases;
      suppose
        m = 0;
        hence p.m >= 0 by Def3;
      end;
      suppose
        m > 0;
        then p.m = m to_power k by Def3;
        hence p.m >= 0;
      end;
    end;
    f.n = Sum(p, n) by A1;
    hence f.n >= 0 by A37,Lm12;
  end;
  then
A38: f in Big_Oh(g) by A2;
  2 to_power (k+1) > 0 by POWER:34;
  then f in Big_Omega(g) by A2,A3;
  hence thesis by A38,XBOOLE_0:def 4;
end;

:: Example p. 89

theorem
  for f being Real_Sequence st (for n st n > 0 holds f.n = (n to_power
log(2,n))) holds ex s being eventually-positive Real_Sequence st s = f & not s
  is smooth
proof
  let f be Real_Sequence such that
A1: for n st n > 0 holds f.n = (n to_power log(2,n));
A2: f is eventually-positive
  proof
    take 1;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume
A4: n >= 1;
    then f.n = n to_power log(2,n) by A1,A3;
    hence thesis by A4,POWER:34;
  end;
  set g = f taken_every 2;
  reconsider f as eventually-positive Real_Sequence by A2;
  take f;
  now
    assume f is smooth;
    then f is_smooth_wrt 2;
    then consider t being Element of Funcs(NAT, REAL) such that
A5: t = g and
A6: ex c,N st c > 0 & for n st n >= N holds t.n <= c*f.n & t.n >= 0;
    consider c,N such that
A7: c > 0 and
A8: for n st n >= N holds t.n <= c*f.n & t.n >= 0 by A6;
A9: sqrt c > 0 by A7,SQUARE_1:25;
    set N0 = [/sqrt c / sqrt 2\];
    reconsider N2=max(N, N0) as Integer by XXREAL_0:16;
    set N1 = max( N2, 2 );
A10: N1 >= N2 by XXREAL_0:25;
    N2 >= N0 by XXREAL_0:25;
    then
A11: N1 >= N0 by A10,XXREAL_0:2;
A12: N1 is Integer by XXREAL_0:16;
    N2 >= N by XXREAL_0:25;
    then
A13: N1 >= N by A10,XXREAL_0:2;
    N1 >= 2 by XXREAL_0:25;
    then reconsider N1 as Element of NAT by A12,INT_1:3;
    set n = N1 + 1;
A14: n to_power log(2,n) > 0 by POWER:34;
A15: 2*n > 2*0 by XREAL_1:68;
A16: sqrt 2 <> 0 by SQUARE_1:25;
A17: sqrt 2 > 0 by SQUARE_1:25;
A18: N0 >= sqrt c / sqrt 2 by INT_1:def 7;
A19: n > N1 + 0 by XREAL_1:8;
    then n > N0 by A11,XXREAL_0:2;
    then n > sqrt c / sqrt 2 by A18,XXREAL_0:2;
    then n*sqrt 2 > (sqrt c / sqrt 2) * sqrt 2 by A17,XREAL_1:68;
    then n*sqrt 2 > sqrt c by A16,XCMPLX_1:87;
    then (n*sqrt 2)^2 > (sqrt c)^2 by A9,SQUARE_1:16;
    then n^2*(sqrt 2)^2 > c by A7,SQUARE_1:def 2;
    then
A20: 2*n^2 > c by SQUARE_1:def 2;
    (2*n^2)*(n to_power log(2,n)) = ((2*n)*n)*(n to_power log(2,n))
      .= ((2*n)*(2 to_power (log(2,n))))*(n to_power log(2,n)) by POWER:def 3
      .= (2*n)*((2 to_power (log(2,n)))*(n to_power log(2,n)))
      .= (2*n)*((2*n) to_power log(2,n)) by POWER:30
      .= ((2*n) to_power 1)*((2*n) to_power log(2,n)) by POWER:25
      .= (2*n) to_power (1 + log(2,n)) by A15,POWER:27
      .= (2*n) to_power (log(2,2) + log(2,n)) by POWER:52
      .= (2*n) to_power log(2,2*n) by POWER:53;
    then (2*n) to_power log(2,2*n) > c*(n to_power log(2,n)) by A14,A20,
XREAL_1:68;
    then f.(2*n) > c*(n to_power log(2,n)) by A1,A15;
    then t.n > c*(n to_power log(2,n)) by A5,ASYMPT_0:def 15;
    then
A21: t.n > c*f.n by A1;
    n > N by A13,A19,XXREAL_0:2;
    hence contradiction by A8,A21;
  end;
  hence thesis;
end;

:: Example p. 92

definition
::$CD
end;

registration
  cluster seq_const(1) -> eventually-nonnegative;
  coherence
  proof
    take 0;
    let n be Nat;
    assume n >= 0;
    thus thesis;
  end;
end;

Lm19: for a,b,c being Real
  holds a>1 & b>=a & c>=1 implies log(a,c) >= log(b,c)
proof
  let a,b,c be Real;
  assume that
A1: a > 1 and
A2: b >= a and
A3: c >= 1;
  b > 1 by A1,A2,XXREAL_0:2;
  then log(b,c) >= log(b,1) by A3,PRE_FF:10;
  then
A4: log(b,c) >= 0 by A1,A2,POWER:51;
  log(a,b) >= log(a,a) by A1,A2,PRE_FF:10;
  then log(a,b) >= 1 by A1,POWER:52;
  then log(a,b)*log(b,c) >= 1*log(b,c) by A4,XREAL_1:64;
  hence thesis by A1,A2,A3,POWER:56;
end;

theorem Th9:
  for f being eventually-nonnegative Real_Sequence holds ex F being
  FUNCTION_DOMAIN of NAT,REAL st F = { seq_n^(1) } & (f in F to_power Big_Oh(
seq_const(1)) iff ex N,c,k st c>0 & for n st n >= N holds 1 <= f.n & f.n <= c*(
  seq_n^(k)).n)
proof
  set p = seq_const(1);
  set G = Big_Oh(seq_const(1));
  reconsider F = { seq_n^(1) } as FUNCTION_DOMAIN of NAT,REAL by FUNCT_2:121;
  let h be eventually-nonnegative Real_Sequence;
  take F;
  thus F = { seq_n^(1) };
  now
    hereby
      reconsider i = 1 as Element of NAT;
      assume h in F to_power Big_Oh(seq_const(1));
      then consider t being Element of Funcs(NAT,REAL) such that
A1:   h = t and
A2:   ex f,g being Element of Funcs(NAT,REAL), N being Element of NAT
      st f in F & g in G & for n being Element of NAT st n>=N holds t.n=(f.n)
      to_power (g.n);
      consider f,g being Element of Funcs(NAT,REAL), N0 being Element of NAT
      such that
A3:   f in F and
A4:   g in G and
A5:   for n being Element of NAT st n>=N0 holds t.n = (f.n) to_power (
      g.n) by A2;
      consider g9 being Element of Funcs(NAT, REAL) such that
A6:   g = g9 and
A7:   ex c,N st c > 0 & for n st n >= N holds g9.n <= c*p.n & g9.n >= 0 by A4;
      consider c,N1 such that
A8:   c > 0 and
A9:   for n st n >= N1 holds g9.n <= c*p.n & g9.n >= 0 by A7;
      set k = [/c\];
A10:  k > 0 by A8;
      set N = max(2,max(N0,N1));
A11:  N >= max(N0,N1) by XXREAL_0:25;
      max(N0,N1) >= N0 by XXREAL_0:25;
      then
A12:  N >= N0 by A11,XXREAL_0:2;
A13:  k >= c by INT_1:def 7;
      reconsider k as Element of NAT by A10,INT_1:3;
      take N,i,k;
      thus i > 0;
      let n;
      assume
A14:  n >= N;
A15:  N >= 2 by XXREAL_0:25;
      then n >= 2 by A14,XXREAL_0:2;
      then
A16:  n > 1 by XXREAL_0:2;
      then
A17:  n to_power c <= n to_power k by A13,PRE_FF:8;
      f = seq_n^(1) by A3,TARSKI:def 1;
      then f.n = n to_power 1 by A15,A14,Def3
        .= n by POWER:25;
      then
A18:  h.n = n to_power (g.n) by A1,A5,A12,A14,XXREAL_0:2;
      max(N0,N1) >= N1 by XXREAL_0:25;
      then N >= N1 by A11,XXREAL_0:2;
      then
A19:  n >= N1 by A14,XXREAL_0:2;
      then n to_power (g.n) >= n to_power 0 by A6,A16,PRE_FF:8,A9;
      hence 1 <= h.n by A18,POWER:24;
A20:  p.n = 1 by FUNCOP_1:7;
      g.n <= c*p.n by A6,A9,A19;
      then h.n <= n to_power (c*1) by A20,A16,A18,PRE_FF:8;
      then h.n <= n to_power k by A17,XXREAL_0:2;
      hence h.n <= i*(seq_n^(k)).n by A15,A14,Def3;
    end;
    reconsider f = seq_n^(1) as Element of Funcs(NAT,REAL) by FUNCT_2:8;
    reconsider t = h as Element of Funcs(NAT,REAL) by FUNCT_2:8;
    given N0,c,k such that
    c > 0 and
A21: for n st n >= N0 holds 1 <= h.n & h.n <= c*(seq_n^(k)).n;
    reconsider N = max(N0,2) as Element of REAL by XREAL_0:def 1;
    defpred Q[Element of NAT,Real] means ($1 < N implies $2 = 1) & ($1 >= N
    implies $2 = log($1,t.$1));
A22: N >= 2 by XXREAL_0:25;
    then
A23: N > 1 by XXREAL_0:2;
A24: for x being Element of NAT ex y being Element of REAL st Q[x,y]
    proof
      let n;
      per cases;
      suppose
A25:      n < N;
         1 in REAL by XREAL_0:def 1;
        hence thesis by A25;
      end;
      suppose
A26:      n >= N;
         reconsider y=log(n,t.n) as Element of REAL by XREAL_0:def 1;
        take y;
        thus thesis by A26;
      end;
    end;
    consider g being sequence of REAL such that
A27: for x being Element of NAT holds Q[x,g.x] from FUNCT_2:sch 3(A24);
A28: N >= N0 by XXREAL_0:25;
A29: now
      let n be Element of NAT;
      assume
A30:  n >= N;
      then n >= N0 by A28,XXREAL_0:2;
      then
A31:  t.n >= 1 by A21;
      thus (f.n) to_power (g.n) = (n to_power 1) to_power (g.n) by A22,A30,Def3
        .= n to_power (g.n) by POWER:25
        .= n to_power (1*log(n,t.n)) by A27,A30
        .= t.n by A23,A30,A31,POWER:def 3;
    end;
    set c1= max(c,2);
A32: N <> 1 by XXREAL_0:25;
    set a = log(N,c1);
    set b = k+a;
A33: c1 >= 2 by XXREAL_0:25;
    then
A34: c1 > 1 by XXREAL_0:2;
A35: f in F by TARSKI:def 1;
A36: g is Element of Funcs(NAT,REAL) by FUNCT_2:8;
A37: N > 0 by XXREAL_0:25;
    now
      log(N,1) = 0 by A37,A32,POWER:51;
      then a > 0 by A23,A34,POWER:57;
      hence b > 0;
      let n;
A38:  (seq_const(1)).n = 1 by FUNCOP_1:7;
      assume
A39:  n >= N;
      then
A40:  n <> 1 by A22,XXREAL_0:2;
A41:  (seq_n^(k)).n = n to_power k by A22,A39,Def3;
      then
A42:  c*(seq_n^(k)).n <= c1*(seq_n^(k)).n by XREAL_1:64,XXREAL_0:25;
      (seq_n^(k)).n > 0 by A22,A39,A41,POWER:34;
      then
A43:  log(n,c1*(seq_n^(k)).n) = log(n,c1) + log(n,n to_power k) by A22,A33,A39
,A40,A41,POWER:53
        .= log(n,c1) + k*log(n,n) by A22,A39,A40,POWER:55
        .= log(n,c1) + k*1 by A22,A39,A40,POWER:52;
      a >= log(n,c1) by A23,A34,A39,Lm19;
      then
A44:  log(n,c1) + k <= a + k by XREAL_1:6;
A45:  n >= N0 by A28,A39,XXREAL_0:2;
      then
A46:  1 <= t.n by A21;
      t.n = (f.n) to_power (g.n) by A29,A39
        .= (n to_power 1) to_power (g.n) by A22,A39,Def3
        .= n to_power (g.n) by POWER:25;
      then
A47:  log(n,t.n) = g.n*log(n,n) by A22,A39,A40,POWER:55
        .= g.n*1 by A22,A39,A40,POWER:52;
      n >= 2 by A22,A39,XXREAL_0:2;
      then
A48:  n > 1 by XXREAL_0:2;
      t.n <= c*(seq_n^(k)).n by A21,A45;
      then t.n <= c1*(seq_n^(k)).n by A42,XXREAL_0:2;
      then log(n,t.n) <= log(n,c1*(seq_n^(k)).n) by A48,A46,PRE_FF:10;
      hence g.n <= b*(seq_const(1)).n by A47,A43,A44,A38,XXREAL_0:2;
      g.n = log(n,t.n) by A27,A39;
      then g.n >= log(n,1) by A48,A46,PRE_FF:10;
      hence g.n >= 0 by A22,A39,A40,POWER:51;
    end;
    then g in G by A36;
    hence h in F to_power Big_Oh(seq_const(1)) by A36,A29,A35;
  end;
  hence thesis;
end;

begin :: Problem 3.1

theorem
  for f being Real_Sequence st (for n holds f.n = 3*(10 to_power 6) - 18
  *(10 to_power 3)*n + 27*n^2) holds f in Big_Oh(seq_n^(2))
proof
  set g = seq_n^(2);
  consider t1 being Element of NAT such that
A1: t1 = 10*10*10;
  consider t2 being Element of NAT such that
A2: t2 = t1*t1;
  t1 = 10*10^2 by A1;
  then t1 = 10*(10 to_power 2) by POWER:46;
  then t1 = (10 to_power 1)*(10 to_power 2) by POWER:25;
  then
A3: t1 = 10 to_power (1+2) by POWER:27;
  then
A4: t2 = 10 to_power (3+3) by A2,POWER:27
    .= 10 to_power 6;
A5: 10 to_power 3 = 10 to_power (2+1)
    .= (10 to_power 2)*(10 to_power 1) by POWER:27
    .= (10 to_power 2)*10 by POWER:25
    .= (10^2)*10 by POWER:46
    .= 1000;
A6: for n st n >= 400 holds 18*t1*n - 3*t2 < 27*n^2
  proof
    defpred P[Nat] means 18*t1*$1 - 3*t2 < 27*$1^2;
A7: for k be Nat st k >= 400 & P[k] holds P[k+1]
    proof
      let k be Nat such that
A8:   k >= 400 and
A9:   18*t1*k - 3*t2 < 27*k^2;
      54*400 <= 54*k by A8,XREAL_1:64;
      then
A10:  18*t1 < 54*k by A3,A5,XXREAL_0:2;
      54*k + 0 <= 54*k + 27 by XREAL_1:7;
      then 18*t1 < 54*k + 27 by A10,XXREAL_0:2;
      then
A11:  27*k^2 + 18*t1 < 27*k^2 + (54*k + 27) by XREAL_1:6;
      18*t1*(k+1) - 3*t2 = (18*t1*k - 3*t2) + 18*t1;
      then 18*t1*(k+1) - 3*t2 < 27*k^2 + 18*t1 by A9,XREAL_1:6;
      hence thesis by A11,XXREAL_0:2;
    end;
A12: P[400] by A2,A3,A5;
    for n be Nat st n >= 400 holds P[n]from NAT_1:sch 8(A12, A7);
    hence thesis;
  end;
  let f be Real_Sequence such that
A13: for n holds f.n = 3*(10 to_power 6) - 18*(10 to_power 3)*n + 27*n^2;
A14: for n st n >= 400 holds f.n <= 27*n^2
  proof
    let n such that
A15: n >= 400;
    now
      assume f.n > 27*n^2;
      then 3*t2 - 18*(10 to_power 3)*n + 27*n^2 > 27*n^2 by A13,A4;
      then 3*t2 + -18*t1*n > 27*n^2 - 27*n^2 by A3,XREAL_1:19;
      then 3*t2 - 18*t1*n > 0;
      then
A16:  3*t2 > 0 + 18*t1*n by XREAL_1:20;
      (18*t1)*n >= (18*t1)*400 by A15,XREAL_1:64;
      then 3*(10 to_power (3+3)) > t1*7200 by A4,A16,XXREAL_0:2;
      then 3*((10 to_power 3)*(10 to_power 3)) > t1*7200 by POWER:27;
      hence contradiction by A3,A5;
    end;
    hence thesis;
  end;
A17: now
    let n;
    assume
A18: n >= 400;
    then f.n <= 27*n^2 by A14;
    then f.n <= 27*(n to_power 2) by POWER:46;
    hence f.n <= 27*g.n by A18,Def3;
    0 + (18*t1*n - 3*t2) < 27*n^2 by A6,A18;
    then 0 < 27*n^2 - (18*t1*n - 3*t2) by XREAL_1:20;
    then 0 < 3*(10 to_power 6) - 18*t1*n + 27*n^2 by A4;
    hence f.n >= 0 by A13,A3;
  end;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  hence thesis by A17;
end;

:: Problem 3.2 -- omitted
:: Problem 3.3 -- omitted
:: Problem 3.4 -- omitted

begin :: Problem 3.5

theorem
  seq_n^(2) in Big_Oh(seq_n^(3))
proof
  set g = seq_n^(3);
  set f = seq_n^(2);
A1: now
    let n;
    assume
A2: n >= 2;
    then
A3: n > 1 by XXREAL_0:2;
A4: f.n = n to_power 2 by A2,Def3;
    g.n = n to_power 3 by A2,Def3;
    hence f.n <= 1*g.n by A3,A4,POWER:39;
    thus f.n >= 0 by A4;
  end;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  hence thesis by A1;
end;

theorem :: Part 2
  not seq_n^(2) in Big_Omega(seq_n^(3))
proof
  set g = seq_n^(3);
  set f = seq_n^(2);
  now
    assume seq_n^(2) in Big_Omega(seq_n^(3));
    then consider s being Element of Funcs(NAT, REAL) such that
A1: s = f and
A2: ex d,N st d > 0 & for n st n >= N holds d*g.n <= s.n & s.n >= 0;
    consider d,N such that
A3: d > 0 and
A4: for n st n >= N holds d*g.n <= s.n & s.n >= 0 by A2;
A5: N+2 > 1+0 by XREAL_1:8;
    ex n st n >= N & d*g.n > s.n
    proof
      take n = max( N, [/(N+2)/d\] );
A6:   n >= N by XXREAL_0:25;
A7:   n is Integer by XXREAL_0:16;
A8:   [/(N+2)/d\] >= (N+2)/d by INT_1:def 7;
      (N+2)*d" > 0*d" by A3,XREAL_1:68;
      then
A9:   n > 0 by XXREAL_0:25;
      reconsider n as Element of NAT by A6,A7,INT_1:3;
A10:  f.n*(n to_power -2) = (n to_power 2)*(n to_power -2) by A9,Def3
        .= (n to_power (2+(-2))) by A9,POWER:27
        .= 1 by POWER:24;
A11:  (n to_power -2) > 0 by A9,POWER:34;
A12:  d*n >= d*([/(N+2)/d\]) by A3,XREAL_1:64,XXREAL_0:25;
      d*([/(N+2)/d\]) >= d*((N+2)/d) by A3,A8,XREAL_1:64;
      then d*n >= ((N+2)/d)*d by A12,XXREAL_0:2;
      then
A13:  d*n >= N+2 by A3,XCMPLX_1:87;
      (d*g.n)*(n to_power -2) = d*(n to_power 3)*(n to_power -2) by A9,Def3
        .= d*((n to_power 3)*(n to_power -2))
        .= d*(n to_power (3+(-2))) by A9,POWER:27
        .= d*n by POWER:25;
      then (d*g.n)*(n to_power -2) > f.n*(n to_power -2) by A5,A10,A13,
XXREAL_0:2;
      hence thesis by A1,A11,XREAL_1:64,XXREAL_0:25;
    end;
    hence contradiction by A4;
  end;
  hence thesis;
end;

theorem :: Part 3
  ex s being eventually-positive Real_Sequence st s = seq_a^(2,1,1) &
  seq_a^(2,1,0) in Big_Theta(s)
proof
  reconsider g = seq_a^(2,1,1) as eventually-positive Real_Sequence;
  set f = seq_a^(2,1,0);
  take g;
  thus g = seq_a^(2,1,1);
A1: f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
A2: now
    let n;
    assume n >= 2;
A3: f.n = 2 to_power (1*n+0) by Def1;
A4: g.n = 2 to_power (1*n+1) by Def1;
    then (2 to_power -1)*g.n = 2 to_power ((-1)+(n+1)) by POWER:27
      .= f.n by A3;
    hence (2 to_power -1)*g.n <= f.n;
    n+0 <= n+1 by XREAL_1:7;
    hence f.n <= 1*g.n by A3,A4,PRE_FF:8;
  end;
A5: (2 to_power -1) > 0 by POWER:34;
  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 A1,A5,A2;
end;

definition
  let a be Element of NAT;
  func seq_n!(a) -> Real_Sequence means
  :Def4:
  it.n = (n+a)!;
  existence
  proof
    deffunc F(Element of NAT) = In(($1+a)!,REAL);
    consider h being sequence of  REAL such that
A1: for n being Element of NAT holds h.n = F(n) from FUNCT_2:sch 4;
    take h;
    let n;
      h.n = F(n) by A1;
    hence thesis;
  end;
  uniqueness
  proof
    let j,k be Real_Sequence such that
A2: for n holds j.n = (n+a)! and
A3: for n holds k.n = (n+a)!;
    now
      let n;
      thus j.n = (n+a)! by A2
        .= k.n by A3;
    end;
    hence thesis by FUNCT_2:63;
  end;
end;

registration
  let a be Element of NAT;
  cluster seq_n!(a) -> eventually-positive;
  coherence
  proof
    take 0;
    set f = seq_n!(a);
    let n be Nat;
A1: n in NAT by ORDINAL1:def 12;
    assume n >= 0;
    f.n = (n+a)! by Def4,A1;
    hence thesis by NEWTON:17;
  end;
end;

theorem :: Part 4
  not seq_n!(0) in Big_Theta(seq_n!(1))
proof
  set g = seq_n!(1);
  set f = seq_n!(0);
A1: 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;
  now
    assume f in Big_Theta(g);
    then consider s being Element of Funcs(NAT, REAL) such that
A2: s = f and
A3: 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 A1;
    consider c,d,N such that
    c > 0 and
A4: d > 0 and
A5: for n st n >= N holds d*g.n <= s.n & s.n <= c*g.n by A3;
    ex n st n >= N & d*g.n > f.n
    proof
      [/(N+1)/d\] >= (N+1)/d by INT_1:def 7;
      then [/(N+1)/d\] + 1 >= (N+1)/d + 1 by XREAL_1:6;
      then
A6:   d*([/(N+1)/d\] + 1) >= d*((N+1)/d + 1) by A4,XREAL_1:64;
A7:   N+1 >= 1+0 by XREAL_1:6;
      d*(((N+1)/d) + 1) = d*((N+1)/d) + d*1 .= (N+1) + d by A4,XCMPLX_1:87;
      then
A8:   d*(((N+1)/d) + 1) > 1 by A4,A7,XREAL_1:8;
      take n = max( N, [/(N+1)/d\] );
A9:   n >= N by XXREAL_0:25;
A10:  n >= [/(N+1)/d\] by XXREAL_0:25;
      n is Integer by XXREAL_0:16;
      then reconsider n as Element of NAT by A9,INT_1:3;
A11:  n! <> 0 by NEWTON:17;
      n+1 >= [/(N+1)/d\]+1 by A10,XREAL_1:6;
      then d*(n+1) >= d*([/(N+1)/d\]+1) by A4,XREAL_1:64;
      then
A12:  d*(n+1) >= d*(((N+1)/d) + 1) by A6,XXREAL_0:2;
A13:  f.n*(n!)" = (n+0)!*(n!)" by Def4
        .= 1 by A11,XCMPLX_0:def 7;
      (d*g.n)*(n!)" = (d*((n+1)!))*(n!)" by Def4
        .= (d*((n+1)*(n!)))*(n!)" by NEWTON:15
        .= (d*(n+1)*((n!)*(n!)"))
        .= (d*(n+1))*1 by A11,XCMPLX_0:def 7
        .= d*(n+1);
      then (d*g.n)*(n!)" > 1 by A12,A8,XXREAL_0:2;
      hence thesis by A13,XREAL_1:64,XXREAL_0:25;
    end;
    hence contradiction by A2,A5;
  end;
  hence thesis;
end;

begin :: Problem 3.6

Lm20: now
  let a,b,c,d be Real;
  assume that
A1: 0 <= b and
A2: a <= b and
A3: 0 <= c and
A4: c <= d;
A5: b*c <= b*d by A1,A4,XREAL_1:64;
  a*c <= b*c by A2,A3,XREAL_1:64;
  hence a*c <= b*d by A5,XXREAL_0:2;
end;

theorem
  for f being Real_Sequence st f in Big_Oh(seq_n^(1)) holds
    f(#)f in Big_Oh(seq_n^(2))
proof
  let f be Real_Sequence;
  set h = seq_n^(2);
  set g = seq_n^(1);
  assume f in Big_Oh(g);
  then consider t being Element of Funcs(NAT, REAL) such that
A1: t = f and
A2: ex c,N st c > 0 & for n st n >= N holds t.n <= c*g.n & t.n >= 0;
  consider c, N such that
A3: c > 0 and
A4: for n st n >= N holds t.n <= c*g.n & t.n >= 0 by A2;
  set d = max( c, c*c );
A5: 0 to_power 1 = 0 by POWER:def 2;
A6: now
    take N;
    let n;
    assume
A7: n >= N;
    then
A8: t.n >= 0 by A4;
    for n holds g.n <= h.n
    proof
      let n;
      per cases;
      suppose
A9:     n = 0;
        then g.n = 0 by Def3;
        hence thesis by A9,Def3;
      end;
      suppose
        n > 0;
        then
A10:    n >= 0+1 by NAT_1:13;
        thus g.n <= h.n
        proof
          per cases by A10,XXREAL_0:1;
          suppose
A11:        n = 1;
A12:        (1 to_power 2) = 1 by POWER:26;
            (1 to_power 1) = 1 by POWER:26;
            then g.n = (1 to_power 2) by A11,A12,Def3;
            hence thesis by A11,Def3;
          end;
          suppose
A13:        n > 1;
            then (n to_power 1) < (n to_power 2) by POWER:39;
            then g.n < (n to_power 2) by A13,Def3;
            hence thesis by A13,Def3;
          end;
        end;
      end;
    end;
    then
A14: h.n >= g.n;
    g.n >= 0
    proof
      per cases;
      suppose
        n = 0;
        hence thesis by Def3;
      end;
      suppose
        n > 0;
        then g.n = n to_power 1 by Def3
          .= n by POWER:25;
        hence thesis;
      end;
    end;
    then
A15: (c*c)*h.n <= d*h.n by A14,XREAL_1:64,XXREAL_0:25;
A16: (n to_power 1)*(n to_power 1) = (n to_power (1+1))
    proof
      per cases;
      suppose
        n = 0;
        hence thesis by A5,POWER:def 2;
      end;
      suppose
        n > 0;
        hence thesis by POWER:27;
      end;
    end;
A17: g.n*g.n = h.n
    proof
      per cases;
      suppose
A18:    n = 0;
        hence g.n*g.n = 0*g.n by Def3
          .= h.n by A18,Def3;
      end;
      suppose
A19:    n > 0;
        hence g.n*g.n = (n to_power 1)*g.n by Def3
          .= (n to_power (1+1)) by A16,A19,Def3
          .= h.n by A19,Def3;
      end;
    end;
    t.n <= c*g.n by A4,A7;
    then t.n*t.n <= (c*g.n)*(c*g.n) by A8,Lm20;
    then t.n*t.n <= d*h.n by A17,A15,XXREAL_0:2;
    hence (t(#)t).n <= d*h.n by SEQ_1:8;
    t.n*t.n >= t.n*0 by A8;
    hence (t(#)t).n >= 0 by SEQ_1:8;
  end;
A20: t(#)t is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  d > 0 by A3,XXREAL_0:25;
  hence thesis by A1,A20,A6;
end;

begin :: Problem 3.7

theorem
  ex s being eventually-positive Real_Sequence st s = seq_a^(2,1,0) & 2
  (#)seq_n^(1) in Big_Oh( seq_n^(1) ) & not seq_a^(2,2,0) in Big_Oh(s)
proof
  reconsider q = seq_a^(2,1,0) as eventually-positive Real_Sequence;
  set p = seq_a^(2,2,0);
  set g = seq_n^(1);
  set f = 2(#)seq_n^(1);
  take q;
  thus q = seq_a^(2,1,0);
A1: now
    let n;
    assume n >= 0;
    thus f.n <= 2*g.n by SEQ_1:9;
A2: g.n = n
    proof
      per cases;
      suppose
        n = 0;
        hence thesis by Def3;
      end;
      suppose
        n > 0;
        hence g.n = n to_power 1 by Def3
          .= n by POWER:25;
      end;
    end;
    2*n >= 2*0;
    hence f.n >= 0 by A2,SEQ_1:9;
  end;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  hence f in Big_Oh(g) by A1;
  now
    assume p in Big_Oh(q);
    then consider t being Element of Funcs(NAT, REAL) such that
A3: t = p and
A4: ex c,N st c > 0 & for n st n >= N holds t.n <= c*q.n & t.n >= 0;
    consider c,N such that
A5: c > 0 and
A6: for n st n >= N holds t.n <= c*q.n & t.n >= 0 by A4;
    ex n st n >= N & t.n > c*q.n
    proof
      take n = max( N, [/log(2,c)+1\] );
A7:   n >= N by XXREAL_0:25;
      n is Integer by XXREAL_0:16;
      then reconsider n as Element of NAT by A7,INT_1:3;
A8:   2 to_power n >= 2 to_power [/log(2,c)+1\] by PRE_FF:8,XXREAL_0:25;
A9:   2 to_power -n > 0 by POWER:34;
      [/log(2,c)+1\] >= log(2,c)+1 by INT_1:def 7;
      then
A10:  2 to_power [/log(2,c)+1\] >= 2 to_power (log(2,c)+1) by PRE_FF:8;
A11:  2 to_power (log(2,c)+1) = (2 to_power log(2,c))*(2 to_power 1) by
POWER:27
        .= c*(2 to_power 1) by A5,POWER:def 3
        .= c*2 by POWER:25;
      (c*q.n)*(2 to_power -n) = (c*(2 to_power (1*n+0)))*(2 to_power -n)
      by Def1
        .= c*((2 to_power n)*(2 to_power -n))
        .= c*(2 to_power (n+-n)) by POWER:27
        .= c*1 by POWER:24;
      then 2 to_power (log(2,c)+1) > (c*q.n)*(2 to_power -n) by A5,A11,
XREAL_1:68;
      then
A12:  2 to_power [/log(2,c)+1\] > (c*q.n)*(2 to_power -n) by A10,XXREAL_0:2;
      p.n*(2 to_power -n) = (2 to_power (2*n+0))*(2 to_power -n) by Def1
        .= (2 to_power (2*n+(-1)*n)) by POWER:27
        .= (2 to_power (1*n));
      then p.n*(2 to_power -n) > (c*q.n)*(2 to_power -n) by A8,A12,XXREAL_0:2;
      hence thesis by A3,A9,XREAL_1:64,XXREAL_0:25;
    end;
    hence contradiction by A6;
  end;
  hence thesis;
end;

begin :: Problem 3.8

theorem
  log(2,3) < 159/100 implies seq_n^(log(2,3)) in Big_Oh(seq_n^(159/100))
& not seq_n^(log(2,3)) in Big_Omega(seq_n^(159/100)) & not seq_n^(log(2,3)) in
  Big_Theta(seq_n^(159/100))
proof
  set c = 159/100 - log(2,3);
  set g = seq_n^(159/100);
  set f = seq_n^(log(2,3));
  set h = f/"g;
  assume
A1: log(2,3) < 159/100;
  then
A2: log(2,3) - log(2,3) < 159/100 - log(2,3) by XREAL_1:9;
A3: c/2 <> 0 by A1;
A4: now
A5: c*(1/2) < c*1 by A2,XREAL_1:68;
    let p be Real such that
A6: p > 0;
    reconsider p1 = p as Real;
A7: ((1/p1) to_power (1/(c/2))) > 0 by A6,POWER:34;
    set N1 = max([/((1/p1) to_power (1/(c/2)))\], 2);
A8: N1 >= [/((1/p) to_power (1/(c/2)))\] by XXREAL_0:25;
A9: N1 is Integer by XXREAL_0:16;
A10: N1 >= 2 by XXREAL_0:25;
    then
A11: N1 > 1 by XXREAL_0:2;
    N1 in NAT by A10,A9,INT_1:3;
    then reconsider N1 as Nat;
    take N1;
    let n be Nat;
A12:  n in NAT by ORDINAL1:def 12;
A13: h.n = f.n/g.n by Lm4;
    assume
A14: n >= N1;
    then f.n = (n to_power log(2,3)) by A10,Def3,A12;
    then
A15: h.n = (n to_power log(2,3)) / (n to_power (159/100))
               by A10,A14,A13,Def3,A12
      .= (n to_power (log(2,3) - (159/100))) by A10,A14,POWER:29
      .= (n to_power -c);
    [/((1/p) to_power (1/(c/2)))\]>= ((1/p) to_power (1/(c/2))) by INT_1:def 7;
    then N1 >= ((1/p) to_power (1/(c/2))) by A8,XXREAL_0:2;
    then n >= ((1/p) to_power (1/(c/2))) by A14,XXREAL_0:2;
    then n to_power (c/2) >= ((1/p) to_power (1/(c/2))) to_power (c/2) by A2,A7
,Lm6;
    then n to_power (c/2) >= (1/p1) to_power ((1/(c/2))*(c/2)) by A6,POWER:33;
    then n to_power (c/2) >= (1/p) to_power 1 by A3,XCMPLX_1:87;
    then n to_power (c/2) >= 1/p1 by POWER:25;
    then 1 / (n to_power (c/2)) <= 1 / (p") by A6,XREAL_1:85;
    then
A16: n to_power -(c/2) <= p by A10,A14,POWER:28;
    n > 1 by A11,A14,XXREAL_0:2;
    then
A17: n to_power (c/2) < n to_power c by A5,POWER:39;
    n to_power (c/2) > 0 by A10,A14,POWER:34;
    then 1 / (n to_power (c/2)) > 1 / (n to_power c) by A17,XREAL_1:88;
    then n to_power -(c/2) > 1 / (n to_power c) by A10,A14,POWER:28;
    then h.n < n to_power -(c/2) by A10,A14,A15,POWER:28;
    then
A18: h.n < p by A16,XXREAL_0:2;
    h.n > 0 by A10,A14,A15,POWER:34;
    hence |.h.n-0.| < p by A18,ABSVALUE:def 1;
  end;
  then
A19: h is convergent by SEQ_2:def 6;
  then
A20: lim h = 0 by A4,SEQ_2:def 7;
  hence f in Big_Oh(g) by A19,ASYMPT_0:16;
A21: not g in Big_Oh(f) by A19,A20,ASYMPT_0:16;
  hence not f in Big_Omega(g) by ASYMPT_0:19;
  not f in Big_Omega(g) by A21,ASYMPT_0:19;
  hence thesis by XBOOLE_0:def 4;
end;

:: Problem 3.9 --  Proven in theorem ASYMPT_0:10
:: Problem 3.10 --  Proven in theorem ASYMPT_0:12

begin :: Problem 3.11

theorem
  for f,g being Real_Sequence st
    (for n holds f.n = n mod 2) &
    (for n holds g.n = n+1 mod 2)
  ex s,s1 being eventually-nonnegative Real_Sequence
  st s = f & s1 = g & not s in Big_Oh(s1) & not s1 in Big_Oh(s)
proof
  let f,g be Real_Sequence such that
A1: for n holds f.n = n mod 2 and
A2: for n holds g.n = n+1 mod 2;
  g is eventually-nonnegative
  proof
    take 0;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume n >= 0;
A4: g.n = n+1 mod 2 by A2,A3;
    per cases by A4,NAT_D:12;
    suppose
      g.n = 0;
      hence thesis;
    end;
    suppose
      g.n = 1;
      hence thesis;
    end;
  end;
  then reconsider g as eventually-nonnegative Real_Sequence;
  f is eventually-nonnegative
  proof
    take 0;
    let n be Nat;
A5:  n in NAT by ORDINAL1:def 12;
    assume n >= 0;
A6: f.n = n mod 2 by A1,A5;
    per cases by A6,NAT_D:12;
    suppose
      f.n = 0;
      hence thesis;
    end;
    suppose
      f.n = 1;
      hence thesis;
    end;
  end;
  then reconsider f as eventually-nonnegative Real_Sequence;
A7: now
    assume g in Big_Oh(f);
    then consider t being Element of Funcs(NAT, REAL) such that
A8: t = g and
A9: ex c,N st c > 0 & for n st n >= N holds t.n <= c*f.n & t.n >= 0;
    consider c,N such that
    c > 0 and
A10: for n st n >= N holds t.n <= c*f.n & t.n >= 0 by A9;
    ex n st n >= N & t.n > c*f.n
    proof
      per cases by NAT_D:12;
      suppose
A11:     N mod 2 = 0;
        then f.N = 0 by A1;
        then
A12:    c*f.N = 0;
        t.N = (N+1) mod 2 by A2,A8
          .= (0+(1 mod 2)) mod 2 by A11,NAT_D:66
          .= (0+1) mod 2 by NAT_D:14
          .= 1 by NAT_D:14;
        hence thesis by A12;
      end;
      suppose
A13:    N mod 2 = 1;
        f.(N+1) = (N+1) mod 2 by A1
          .= (1+(1 mod 2)) mod 2 by A13,NAT_D:66
          .= (1+1) mod 2 by NAT_D:14
          .= 0 by NAT_D:25;
        then
A14:    c*f.(N+1) = 0;
A15:    N+1 >= N by NAT_1:13;
        t.(N+1) = ((N+1)+1) mod 2 by A2,A8
          .= (N+(1+1)) mod 2
          .= (1+(2 mod 2)) mod 2 by A13,NAT_D:66
          .= (1+0) mod 2 by NAT_D:25
          .= 1 by NAT_D:14;
        hence thesis by A15,A14;
      end;
    end;
    hence contradiction by A10;
  end;
  take f,g;
  now
    assume f in Big_Oh(g);
    then consider t being Element of Funcs(NAT, REAL) such that
A16: t = f and
A17: ex c,N st c > 0 & for n st n >= N holds t.n <= c*g.n & t.n >= 0;
    consider c,N such that
    c > 0 and
A18: for n st n >= N holds t.n <= c*g.n & t.n >= 0 by A17;
    ex n st n >= N & t.n > c*g.n
    proof
      per cases by NAT_D:12;
      suppose
A19:    N mod 2 = 0;
        g.(N+1) = ((N+1)+1) mod 2 by A2
          .= (N+(1+1)) mod 2
          .= (0+(2 mod 2)) mod 2 by A19,NAT_D:66
          .= (0+0) mod 2 by NAT_D:25
          .= 0 by NAT_D:26;
        then
A20:    c*g.(N+1) = 0;
A21:    N+1 >= N by NAT_1:13;
        t.(N+1) = (N+1) mod 2 by A1,A16
          .= (0+(1 mod 2)) mod 2 by A19,NAT_D:66
          .= (0+1) mod 2 by NAT_D:14
          .= 1 by NAT_D:14;
        hence thesis by A21,A20;
      end;
      suppose
A22:    N mod 2 = 1;
        g.N = (N+1) mod 2 by A2
          .= (1+(1 mod 2)) mod 2 by A22,NAT_D:66
          .= (1+1) mod 2 by NAT_D:14
          .= 0 by NAT_D:25;
        then
A23:    c*g.N = 0;
        t.N = 1 by A1,A16,A22;
        hence thesis by A23;
      end;
    end;
    hence contradiction by A18;
  end;
  hence thesis by A7;
end;

:: Problem 3.12 -- Proven in theorems ASYMPT_0:20, ASYMPT_0:21
:: Problem 3.13 -- omitted (uses a notation that we do not support)
:: Problem 3.14 -- omitted (cannot Mizar an incorrect proof)
:: Problem 3.15 -- omitted (cannot Mizar an incorrect proof)
:: Problem 3.16 -- omitted (maximum rule over multiple functions can be
::                          reduced to repeated applications of the binary
::                          maximum rule)
:: Problem 3.17 -- omitted (cannot Mizar an incorrect proof)
:: Problem 3.18 -- Proven in theorems ASYMPT_0:28, ASYMPT_0:29, ASYMPT_0:30

begin :: Problem 3.19

theorem
  for f,g being eventually-nonnegative Real_Sequence holds
    Big_Oh(f) = Big_Oh(g) iff f in Big_Theta(g)
proof
  let f,g be eventually-nonnegative Real_Sequence;
  hereby
    assume
A1: Big_Oh(f) = Big_Oh(g);
    then g in Big_Oh(f) by ASYMPT_0:10;
    then
A2: f in Big_Omega(g) by ASYMPT_0:19;
    f in Big_Oh(g) by A1,ASYMPT_0:10;
    hence f in Big_Theta(g) by A2,XBOOLE_0:def 4;
  end;
  assume
A3: f in Big_Theta(g);
  now
    let x be object;
    hereby
      assume x in Big_Oh(f);
      then consider t being Element of Funcs(NAT, REAL) such that
A4:   x = t and
A5:   ex c,N st c > 0 & for n st n >= N holds t.n <= c*f.n & t.n >= 0;
      consider c,N such that
      c > 0 and
A6:   for n st n >= N holds t.n <= c*f.n & t.n >= 0 by A5;
      now
         reconsider N as Nat;
        take N;
        let n be Nat;
A7:      n in NAT by ORDINAL1:def 12;
        assume n >= N;
        hence t.n >= 0 by A6,A7;
      end;
      then
A8:   t is eventually-nonnegative;
A9:   f in Big_Oh(g) by A3,XBOOLE_0:def 4;
      t in Big_Oh(f) by A5;
      hence x in Big_Oh(g) by A4,A8,A9,ASYMPT_0:12;
    end;
    assume x in Big_Oh(g);
    then consider t being Element of Funcs(NAT, REAL) such that
A10: x = t and
A11: ex c,N st c > 0 & for n st n >= N holds t.n <= c*g.n & t.n >= 0;
    consider c,N such that
    c > 0 and
A12: for n st n >= N holds t.n <= c*g.n & t.n >= 0 by A11;
    now
       reconsider N as Nat;
      take N;
      let n be Nat;
A13:      n in NAT by ORDINAL1:def 12;
      assume n >= N;
      hence t.n >= 0 by A12,A13;
    end;
    then
A14: t is eventually-nonnegative;
    f in Big_Omega(g) by A3,XBOOLE_0:def 4;
    then
A15: g in Big_Oh(f) by ASYMPT_0:19;
    t in Big_Oh(g) by A11;
    hence x in Big_Oh(f) by A10,A14,A15,ASYMPT_0:12;
  end;
  hence thesis by TARSKI:2;
end;

theorem :: Part 2
  for f,g being eventually-nonnegative Real_Sequence holds
    f in Big_Theta(g) iff Big_Theta(f) = Big_Theta(g)
proof
  let f,g be eventually-nonnegative Real_Sequence;
A1: 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;
  consider N2 being Nat such that
A2: for n being Nat st n >= N2 holds g.n >= 0 by ASYMPT_0:def 2;
  consider N1 being Nat such that
A3: for n being Nat st n >= N1 holds f.n >= 0 by ASYMPT_0:def 2;
A4: Big_Theta(f) = { 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*f.n <= s.n & s.n <= c*f.n } by
ASYMPT_0:27;
  hereby
    assume
A5: f in Big_Theta(g);
    now
      let x be object;
A6:   g in Big_Theta(f) by A5,ASYMPT_0:29;
      hereby
        assume x in Big_Theta(f);
        then consider s being Element of Funcs(NAT, REAL) such that
A7:     s = x and
A8:     ex c,d,N st c > 0 & d > 0 & for n st n >= N holds d*f.n <= s.n
        & s.n <= c*f.n by A4;
        consider c,d,N3 such that
        c > 0 and
A9:     d > 0 and
A10:    for n st n >= N3 holds d*f.n <= s.n & s.n <= c*f.n by A8;
        reconsider N = max( N1, N3 ) as Nat by TARSKI:1;
A11:    N >= N3 by XXREAL_0:25;
A12:    N >= N1 by XXREAL_0:25;
        now
          take N;
          let n be Nat;
A13:      n in NAT by ORDINAL1:def 12;
          assume
A14:      n >= N;
          then n >= N1 by A12,XXREAL_0:2;
          then f.n >= 0 by A3;
          then
A15:      d*f.n >= d*0 by A9;
          n >= N3 by A11,A14,XXREAL_0:2;
          hence s.n >= 0 by A10,A15,A13;
        end;
        then
A16:    s is eventually-nonnegative;
        s in Big_Theta(f) by A4,A8;
        hence x in Big_Theta(g) by A5,A7,A16,ASYMPT_0:30;
      end;
      assume x in Big_Theta(g);
      then consider s being Element of Funcs(NAT, REAL) such that
A17:  s = x and
A18:  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 A1;
      consider c,d,N3 such that
      c > 0 and
A19:  d > 0 and
A20:  for n st n >= N3 holds d*g.n <= s.n & s.n <= c*g.n by A18;
      reconsider N = max( N2, N3 ) as Nat by TARSKI:1;
A21:  N >= N3 by XXREAL_0:25;
A22:  N >= N2 by XXREAL_0:25;
      now
        take N;
        let n be Nat;
A23:      n in NAT by ORDINAL1:def 12;
        assume
A24:    n >= N;
        then n >= N2 by A22,XXREAL_0:2;
        then g.n >= 0 by A2;
        then
A25:    d*g.n >= d*0 by A19;
        n >= N3 by A21,A24,XXREAL_0:2;
        hence s.n >= 0 by A20,A25,A23;
      end;
      then
A26:  s is eventually-nonnegative;
      s in Big_Theta(g) by A1,A18;
      hence x in Big_Theta(f) by A17,A26,A6,ASYMPT_0:30;
    end;
    hence Big_Theta(f) = Big_Theta(g) by TARSKI:2;
  end;
  assume Big_Theta(f) = Big_Theta(g);
  hence thesis by ASYMPT_0:28;
end;

:: Problem 3.20 -- Proven above in theorem ASYMPT_1:?????

begin :: Problem 3.21

Lm21: for n holds (n^2 - n + 1) > 0
proof
  defpred P[Nat] means ($1^2 - $1 + 1) > 0;
A1: for k being Nat st P[k] holds P[k+1]
  proof
    let k be Nat;
    assume (k^2 - k + 1) > 0;
    then (k^2 - k + 1) + 2*k > 0+0;
    hence thesis;
  end;
A2: P[0];
  for n being Nat holds P[n] from NAT_1:sch 2(A2, A1);
  hence thesis;
end;

Lm22: for f,g being Real_Sequence, N being Element of NAT, c being Real st f
is convergent & lim f = c & for n st n >= N holds f.n = g.n holds g is
convergent & lim g = c
proof
  let f,g be Real_Sequence, N be Element of NAT, c be Real such that
A1: f is convergent and
A2: lim f = c and
A3: for n st n >= N holds f.n = g.n;
A4: now
    let p be Real;
    assume p > 0;
    then consider M being Nat such that
A5: for n being Nat st n >= M holds |.f.n-c.| < p by A1,A2,SEQ_2:def 7;
    reconsider N1 = max(N, M) as Nat by TARSKI:1;
A6: N1 >= N by XXREAL_0:25;
    take N1;
    let n be Nat;
A7: n in NAT by ORDINAL1:def 12;
    assume
A8: n >= N1;
    N1 >= M by XXREAL_0:25;
    then n >= M by A8,XXREAL_0:2;
    then |.f.n-c.| < p by A5;
    hence |.g.n-c.| < p by A3,A6,A8,XXREAL_0:2,A7;
  end;
  hence g is convergent by SEQ_2:def 6;
  hence thesis by A4,SEQ_2:def 7;
end;

Lm23: for n st n >= 1 holds (n^2 -n + 1) <= n^2
proof
  let n such that
A1: n >= 1;
  now
    assume (n^2 -n + 1) > n^2;
    then -n^2 + (n^2 + (-n + 1)) > n^2 + -n^2 by XREAL_1:6;
    then 1 > 0 -(-n) by XREAL_1:19;
    hence contradiction by A1;
  end;
  hence thesis;
end;

Lm24: for n st n >= 1 holds n^2 <= 2*(n^2 -n + 1)
proof
  defpred P[Nat] means $1^2 <= 2*($1^2 -$1 + 1);
A1: for k be Nat st k>=1 & P[k] holds P[k+1]
  proof
    let k be Nat such that
A2: k >= 1 and
A3: k^2 <= 2*(k^2 -k + 1);
A4: k^2 + (2*k + 1) <= 2*(k^2 -k + 1) + (2*k + 1) by A3,XREAL_1:6;
    2*k >= 2*1 by A2,XREAL_1:64;
    then 2*k + 2 >= 2 + 2 by XREAL_1:6;
    then
A5: 2*k^2 + 4 <= 2*k^2 + (2*k + 2) by XREAL_1:6;
    2*k^2 + 3 <= 2*k^2 + 4 by XREAL_1:6;
    then 2*(k^2 -k + 1) + (2*k + 1) <= 2*k^2 + (2*k + 2) by A5,XXREAL_0:2;
    hence thesis by A4,XXREAL_0:2;
  end;
A6: P[1];
  for n be Nat st n >= 1 holds P[n] from NAT_1:sch 8(A6, A1);
  hence thesis;
end;

Lm25: for e being Real st 0 < e & e < 1 holds ex N st for n st n >= N holds n*
log(2,1+e) - 8*log(2,n) > 8*log(2,n)
proof
  set f = seq_logn;
  let e be Real such that
A1: 0 < e and
A2: e < 1;
  set d = log(2,1+e);
  set g = seq_n^(e);
  set h = f/"g;
A3: h is convergent by A1,Lm11;
A4: lim h = 0 by A1,Lm11;
  0+1 < e+1 by A1,XREAL_1:6;
  then log(2,1) < log(2,e+1) by POWER:57;
  then
A5: d > 0 by POWER:51;
  then d*(1/16) > d*0 by XREAL_1:68;
  then consider N being Nat such that
A6: for n being Nat st n >= N holds |.h.n-0.| < d/16 by A3,A4,SEQ_2:def 7;
  ex N st for n st n >= N holds n*log(2,1+e) - 8*log(2,n) > 8*log(2,n)
  proof
    reconsider N1 = max(2, N) as Element of NAT by ORDINAL1:def 12;
A7: N1 >= 2 by XXREAL_0:25;
A8: N1 >= N by XXREAL_0:25;
    now
      take N1;
      let n;
      assume
A9:   n >= N1;
      then
A10:  n to_power e > 0 by A7,POWER:34;
A11:  n >= 2 by A7,A9,XXREAL_0:2;
      then log(2,2) <= log(2,n) by PRE_FF:10;
      then
A12:  1 <= log(2,n) by POWER:52;
A13:  h.n = f.n / g.n by Lm4
        .= log(2,n) / g.n by A7,A9,Def2
        .= log(2,n) / (n to_power e) by A7,A9,Def3;
      n > 1 by A11,XXREAL_0:2;
      then n to_power 1 > n to_power e by A2,POWER:39;
      then 1 / (n to_power 1) < 1 / (n to_power e) by A10,XREAL_1:88;
      then 1 / n < 1 / (n to_power e) by POWER:25;
      then
A14:  log(2,n) / n < log(2,n) * (1/(n to_power e)) by A12,XREAL_1:68;
      n >= N by A8,A9,XXREAL_0:2;
      then |.h.n-0.| < d/16 by A6;
      then h.n < d/16 by A12,A13,A10,ABSVALUE:def 1;
      then
A15:  log(2,n) / n < d / 16 by A13,A14,XXREAL_0:2;
      log(2,n)*n" > 0*n" by A7,A9,A12,XREAL_1:68;
      then 1 / (log(2,n) / n) > 1 / (d / 16) by A15,XREAL_1:88;
      then n / log(2,n) > 1 / (d / 16) by XCMPLX_1:57;
      then n / log(2,n) > 16 / d by XCMPLX_1:57;
      then d * (n / log(2,n)) > 16 / d * d by A5,XREAL_1:68;
      then d * (n / log(2,n)) > 16 by A5,XCMPLX_1:87;
      then d * (n / log(2,n)) * log(2,n) > 16*log(2,n) by A12,XREAL_1:68;
      then d * ((n / log(2,n)) * log(2,n)) > 16*log(2,n);
      then d*n > (8+8)*log(2,n) by A12,XCMPLX_1:87;
      then d*n - 8*log(2,n) > (8*log(2,n) + 8*log(2,n)) - 8*log(2,n) by
XREAL_1:9;
      hence n*d - 8*log(2,n) > 8*log(2,n);
    end;
    hence thesis;
  end;
  hence thesis;
end;

theorem :: (Part 1, O(nlogn) c O(n^(1+e))), slightly generalized
  for e being Real, f being Real_Sequence st 0 < e & (for n st n > 0
holds f.n = n*log(2,n)) holds ex s being eventually-positive Real_Sequence st s
  = f & Big_Oh(s) c= Big_Oh(seq_n^(1+e)) & not Big_Oh(s) = Big_Oh(seq_n^(1+e))
proof
  set seq = seq_logn;
  let e be Real, f be Real_Sequence such that
A1: 0 < e and
A2: for n st n > 0 holds f.n = n*log(2,n);
  set seq1 = seq_n^(e);
  set p = seq /" seq1;
A3: lim p = 0 by A1,Lm11;
  f is eventually-positive
  proof
    take 2;
    let n be Nat;
A4:  n in NAT by ORDINAL1:def 12;
    assume
A5: 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 A5,XREAL_1:68;
    hence thesis by A2,A5,A4;
  end;
  then reconsider f as eventually-positive Real_Sequence;
  set g = seq_n^(1+e);
  set h = f /" g;
A6: for n st n >= 1 holds h.n = p.n
  proof
    let n;
    assume
A7: n >= 1;
    h.n = f.n / g.n by Lm4
      .= n*log(2,n) / g.n by A2,A7
      .= n*log(2,n) / (n to_power (1+e)) by A7,Def3
      .= (n to_power 1)*log(2,n) / (n to_power (1+e)) by POWER:25
      .= (n to_power 1)*log(2,n) * (n to_power (1+e))"
      .= log(2,n)*((n to_power 1)*(n to_power (1+e))")
      .= log(2,n)*((n to_power 1)/(n to_power (1+e)))
      .= log(2,n)*(n to_power (1-(1+e))) by A7,POWER:29
      .= log(2,n)*(n to_power (1+(-1+-e)))
      .= log(2,n)*(1/(n to_power e)) by A7,POWER:28
      .= log(2,n)/(n to_power e)
      .= seq.n / (n to_power e) by A7,Def2
      .= seq.n / seq1.n by A7,Def3
      .= p.n by Lm4;
    hence thesis;
  end;
A8: p is convergent by A1,Lm11;
  then
A9: lim h = 0 by A3,A6,Lm22;
A10: h is convergent by A8,A3,A6,Lm22;
  then not g in Big_Oh(f) by A9,ASYMPT_0:16;
  then
A11: not f in Big_Omega(g) by ASYMPT_0:19;
  take f;
  f in Big_Oh(g) by A10,A9,ASYMPT_0:16;
  hence thesis by A11,Th4;
end;

theorem
  for e being Real, g being Real_Sequence st e < 1 & (for n st n > 1
  holds g.n = (n to_power 2)/log(2,n)) holds ex s being eventually-positive
Real_Sequence st s = g & Big_Oh(seq_n^(1+e)) c= Big_Oh(s) & not Big_Oh(seq_n^(1
  +e)) = Big_Oh(s)
proof
  set seq = seq_logn;
  let e be Real, g be Real_Sequence such that
A1: e < 1 and
A2: for n st n > 1 holds g.n = (n to_power 2)/log(2,n);
  set seq1 = seq_n^(1-e);
  set p = seq /" seq1;
  set f = seq_n^(1+e);
  set h = f /" g;
  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
A5: log(2,n) >= 1 by POWER:52;
    n > 1 by A4,XXREAL_0:2;
    then
A6: g.n = (n to_power 2)/log(2,n) by A2,A3
      .= (n to_power 2)*(log(2,n))";
    n to_power 2 > 0 by A4,POWER:34;
    then (n to_power 2)*(log(2,n))" > (n to_power 2)*0 by A5,XREAL_1:68;
    hence thesis by A6;
  end;
  then reconsider g as eventually-positive Real_Sequence;
A7: (1+e)-2 = e-1;
A8: for n st n >= 2 holds h.n = p.n
  proof
    let n;
    assume
A9: n >= 2;
    then
A10: n > 1 by XXREAL_0:2;
    h.n = f.n / g.n by Lm4
      .= (n to_power (1+e)) / g.n by A9,Def3
      .= (n to_power (1+e)) / ((n to_power 2) / log(2,n)) by A2,A10
      .= (n to_power (1+e)) * ((n to_power 2) / log(2,n))"
      .= (n to_power (1+e)) * (log(2,n) / (n to_power 2)) by XCMPLX_1:213
      .= (n to_power (1+e)) * (log(2,n) * (n to_power 2)")
      .= ((n to_power (1+e)) * (n to_power 2)") * log(2,n)
      .= ((n to_power (1+e)) / (n to_power 2)) * log(2,n)
      .= (n to_power -(1-e)) * log(2,n) by A7,A9,POWER:29
      .= log(2,n) * (1 / (n to_power (1-e))) by A9,POWER:28
      .= log(2,n) / (n to_power (1-e))
      .= seq.n / (n to_power (1-e)) by A9,Def2
      .= seq.n / seq1.n by A9,Def3
      .= p.n by Lm4;
    hence thesis;
  end;
  take g;
  0+e < 1 by A1;
  then
A11: 0 < 1-e by XREAL_1:20;
  then
A12: p is convergent by Lm11;
A13: lim p = 0 by A11,Lm11;
  then
A14: lim h = 0 by A12,A8,Lm22;
A15: h is convergent by A12,A13,A8,Lm22;
  then not g in Big_Oh(f) by A14,ASYMPT_0:16;
  then
A16: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A15,A14,ASYMPT_0:16;
  hence thesis by A16,Th4;
end;

theorem
  for f being Real_Sequence st (for n st n > 1 holds f.n = (n to_power 2
  )/log(2,n)) holds ex s being eventually-positive Real_Sequence st s = f &
  Big_Oh(s) c= Big_Oh(seq_n^(8)) & not Big_Oh(s) = Big_Oh(seq_n^(8))
proof
  set g = seq_n^(8);
  let f be Real_Sequence such that
A1: for n st n > 1 holds f.n = (n to_power 2)/log(2,n);
A2: f 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
A5: log(2,n) >= 1 by POWER:52;
    n > 1 by A4,XXREAL_0:2;
    then
A6: f.n = (n to_power 2)/log(2,n) by A1,A3
      .= (n to_power 2)*(log(2,n))";
    n to_power 2 > 0 by A4,POWER:34;
    then (n to_power 2)*(log(2,n))" > (n to_power 2)*0 by A5,XREAL_1:68;
    hence thesis by A6;
  end;
  set h = f/"g;
  reconsider f as eventually-positive Real_Sequence by A2;
A7: now
A8: log(2,3) > log(2,2) by POWER:57;
    let p be Real;
    assume
A9: p > 0;
A10: [/(p to_power -(1/6))\] >= (p to_power -(1/6)) by INT_1:def 7;
    reconsider p1 = p as Real;
    set N = max(3,[/(p1 to_power -(1/6))\]);
A11: N >= 3 by XXREAL_0:25;
A12: N is Integer by XXREAL_0:16;
A13: N >= [/(p to_power -(1/6))\] by XXREAL_0:25;
    N in NAT by A11,A12,INT_1:3;
    then reconsider N as Nat;
    take N;
    let n be Nat;
A14:  n in NAT by ORDINAL1:def 12;
    assume
A15: n >= N;
    then
A16: n >= 3 by A11,XXREAL_0:2;
    then
A17: n > 1 by XXREAL_0:2;
A18: h.n = f.n/g.n by Lm4
      .= ((n to_power 2)/log(2,n)) / g.n by A1,A17,A14
      .= ((n to_power 2)/log(2,n)) / (n to_power 8) by A11,A15,Def3,A14
      .= ((n to_power 2)*(log(2,n))") / (n to_power 8)
      .= ((log(2,n))"*(n to_power 2)) * (n to_power 8)"
      .= (log(2,n))"*((n to_power 2)*(n to_power 8)")
      .= (log(2,n))"*((n to_power 2)/(n to_power 8))
      .= (log(2,n))"*(n to_power (2-8)) by A11,A15,POWER:29
      .= (log(2,n))"*(n to_power -6)
      .= (log(2,n))"*(1/(n to_power 6)) by A11,A15,POWER:28
      .= (1/(n to_power 6))*(1/log(2,n))
      .= 1/((n to_power 6)*log(2,n)) by XCMPLX_1:102;
    n >= [/(p to_power -(1/6))\] by A13,A15,XXREAL_0:2;
    then
A19: n >= (p to_power -(1/6)) by A10,XXREAL_0:2;
    (p1 to_power -(1/6)) > 0 by A9,POWER:34;
    then n to_power 6 >= (p to_power -(1/6)) to_power 6 by A19,Lm6;
    then
A20: n to_power 6 >= p1 to_power ((-(1/6))*6) by A9,POWER:33;
    p1 to_power -1 > 0 by A9,POWER:34;
    then 1/(n to_power 6) <= 1/(p to_power -1) by A20,XREAL_1:85;
    then 1/(n to_power 6) <= 1/(1/(p1 to_power 1)) by A9,POWER:28;
    then
A21: 1/(n to_power 6) <= p by POWER:25;
    log(2,n) >= log(2,3) by A16,PRE_FF:10;
    then log(2,n) > log(2,2) by A8,XXREAL_0:2;
    then
A22: log(2,n) > 1 by POWER:52;
A23: n to_power 6 > 0 by A11,A15,POWER:34;
    then (n to_power 6)*1 < (n to_power 6)*log(2,n) by A22,XREAL_1:68;
    then h.n < 1/(n to_power 6) by A23,A18,XREAL_1:88;
    then h.n < p by A21,XXREAL_0:2;
    hence |.h.n-0.| < p by A22,A18,ABSVALUE:def 1;
  end;
  then
A24: h is convergent by SEQ_2:def 6;
  then
A25: lim h = 0 by A7,SEQ_2:def 7;
  then not g in Big_Oh(f) by A24,ASYMPT_0:16;
  then
A26: not f in Big_Omega(g) by ASYMPT_0:19;
  take f;
  f in Big_Oh(g) by A24,A25,ASYMPT_0:16;
  hence thesis by A26,Th4;
end;

theorem
  for g being Real_Sequence st (for n holds g.n = (n^2 - n + 1) to_power
4) holds ex s being eventually-positive Real_Sequence st s = g & Big_Oh(seq_n^(
  8)) = Big_Oh(s)
proof
  let g be Real_Sequence such that
A1: for n holds g.n = (n^2 - n + 1) to_power 4;
  g is eventually-positive
  proof
    take 0;
    let n be Nat;
A2:  n in NAT by ORDINAL1:def 12;
    assume n >= 0;
    g.n = (n^2 - n + 1) to_power 4 by A1,A2;
    hence thesis by Lm21,POWER:34,A2;
  end;
  then reconsider g as eventually-positive Real_Sequence;
  take g;
  set f = seq_n^(8);
A3: now
    let n;
A4: g.n = (n^2 -n + 1) to_power 4 by A1;
    assume
A5: n >= 1;
    then
A6: n^2 -n + 1 <= n^2 by Lm23;
    f.n = n to_power (2*4) by A5,Def3
      .= n to_power 2 to_power 4 by A5,POWER:33
      .= n^2 to_power 4 by POWER:46;
    hence g.n <= 1*f.n by A4,A6,Lm6,Lm21;
    thus g.n >= 0 by A4,Lm21,POWER:34;
  end;
A7: now
    let n;
A8: g.n = (n^2 -n + 1) to_power 4 by A1;
A9: (n^2 -n + 1) > 0 by Lm21;
    assume
A10: n >= 1;
    then
A11: f.n = n to_power (2*4) by Def3
      .= n to_power 2 to_power 4 by A10,POWER:33
      .= n^2 to_power 4 by POWER:46;
A12: n*n > n*0 by A10,XREAL_1:68;
    n^2 <= 2*(n^2 -n + 1) by A10,Lm24;
    then f.n <= (2*(n^2 -n + 1)) to_power 4 by A11,A12,Lm6;
    hence f.n <= 16*g.n by A8,A9,POWER:30,62;
    thus f.n >= 0 by A11,A12,POWER:34;
  end;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  then
A13: f in Big_Oh(g) by A7;
  g is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  then g in Big_Oh(f) by A3;
  hence thesis by A13,Lm5;
end;

theorem :: (Part 5, O(n^8) c O((1+e)^n))
  for e being Real st 0 < e & e < 1 holds ex s being eventually-positive
  Real_Sequence st s = seq_a^(1+e,1,0) & Big_Oh(seq_n^(8)) c= Big_Oh(s) & not
  Big_Oh(seq_n^(8)) = Big_Oh(s)
proof
  set f = seq_n^(8);
  let e be Real such that
A1: 0 < e and
A2: e < 1;
  consider N such that
A3: for n st n >= N holds n*log(2,1+e) - 8*log(2,n) > 8*log(2,n) by A1,A2,Lm25;
  set g = seq_a^(1+e,1,0);
  set h = f/"g;
  reconsider g as eventually-positive Real_Sequence by A1;
  take g;
  thus g = seq_a^(1+e,1,0);
A4: now
    let p be Real such that
A5: p > 0;
    reconsider p1 = p as Real;
A6: ((1/p1) to_power (1/8)) > 0 by A5,POWER:34;
    set N1 = max( N, max([/((1/p1) to_power (1/8))\], 2) );
A7: N1 >= N by XXREAL_0:25;
A8: N1 is Integer
    proof
      per cases by XXREAL_0:16;
      suppose
        N1 = N;
        hence thesis;
      end;
      suppose
        N1 = max([/((1/p) to_power (1/8))\], 2);
        hence thesis by XXREAL_0:16;
      end;
    end;
A9: N1 >= max([/((1/p) to_power (1/8))\], 2) by XXREAL_0:25;
    max([/((1/p) to_power (1/8))\], 2) >= [/((1/p) to_power (1/8))\] by
XXREAL_0:25;
    then
A10: N1 >= [/((1/p) to_power (1/8))\] by A9,XXREAL_0:2;
    N1 in NAT by A7,A8,INT_1:3;
    then reconsider N1 as Nat;
    take N1;
    let n be Nat;
A11:  n in NAT by ORDINAL1:def 12;
    assume
A12: n >= N1;
    then n >= N by A7,XXREAL_0:2;
    then ((n*log(2,1+e)) - (8*log(2,n))) > (8*log(2,n)) by A3,A11;
    then
A13: 2 to_power ((n*log(2,1+e)) - (8*log(2,n))) > 2 to_power (8*log(2,n))
    by POWER:39;
A14: max([/((1/p) to_power (1/8))\], 2) >= 2 by XXREAL_0:25;
A15: g.n = ((1+e) to_power (1*n + 0)) by Def1;
    h.n = f.n/g.n by Lm4;
    then
A16: h.n = (n to_power 8) / ((1+e) to_power n) by A9,A14,A12,A15,Def3
      .= (2 to_power (8*log(2,n))) / ((1+e) to_power n) by A9,A14,A12,Lm3
      .= (2 to_power (8*log(2,n))) / (2 to_power (n*log(2,1+e))) by A1,Lm3
      .= (2 to_power ((8*log(2,n)) - (n*log(2,1+e)))) by POWER:29
      .= (2 to_power -((n*log(2,1+e)) - (8*log(2,n))));
    [/((1/p) to_power (1/8))\] >= ((1/p) to_power (1/8)) by INT_1:def 7;
    then N1 >= ((1/p) to_power (1/8)) by A10,XXREAL_0:2;
    then n >= ((1/p) to_power (1/8)) by A12,XXREAL_0:2;
    then n to_power 8 >= ((1/p) to_power (1/8)) to_power 8 by A6,Lm6;
    then n to_power 8 >= (1/p1) to_power ((1/8)*8) by A5,POWER:33;
    then n to_power 8 >= 1/p1 by POWER:25;
    then 1 / (n to_power 8) <= 1 / (p") by A5,XREAL_1:85;
    then 1 / (2 to_power (8*log(2,n))) <= p by A9,A14,A12,Lm3;
    then
A17: 2 to_power -(8*log(2,n)) <= p by POWER:28;
    2 to_power (8*log(2,n)) > 0 by POWER:34;
    then
    1 / (2 to_power ((n*log(2,1+e)) - (8*log(2,n)))) < 1 / (2 to_power (8
    *log(2,n))) by A13,XREAL_1:88;
    then
    2 to_power -((n*log(2,1+e)) - (8*log(2,n))) < 1 / (2 to_power (8*log(
    2,n))) by POWER:28;
    then h.n < 2 to_power -(8*log(2,n)) by A16,POWER:28;
    then
A18: h.n < p by A17,XXREAL_0:2;
    h.n > 0 by A16,POWER:34;
    hence |.h.n-0.| < p by A18,ABSVALUE:def 1;
  end;
  then
A19: h is convergent by SEQ_2:def 6;
  then
A20: lim h = 0 by A4,SEQ_2:def 7;
  then not g in Big_Oh(f) by A19,ASYMPT_0:16;
  then
A21: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A19,A20,ASYMPT_0:16;
  hence thesis by A21,Th4;
end;

begin :: Problem 3.22

Lm26: 2 to_power 12 = 4096
proof
  thus 2 to_power 12 = 2 to_power (6+6) .= 64*64 by POWER:27,64
    .= 4096;
end;

Lm27: for n be Nat st n >= 3 holds n^2 > 2*n + 1
proof
  defpred P[Nat] means $1^2 > 2*$1 + 1;
A1: for n be Nat st n >= 3 & P[n] holds P[n+1]
  proof
    let n be Nat;
    assume that
A2: n >= 3 and
A3: n^2 > 2*n + 1;
    n > 1 by A2,XXREAL_0:2;
    then n + n > 1 + 0 by XREAL_1:8;
    then
A4: 2*n + 2*(n+1) > 1 + 2*(n+1) by XREAL_1:6;
    n^2 + (n + (n+1)) > 2*n + 1 + (n + (n+1)) by A3,XREAL_1:6;
    hence (n+1)^2 > 2*(n+1) + 1 by A4,XXREAL_0:2;
  end;
A5: P[3];
  for n be Nat st n >= 3 holds P[n] from NAT_1:sch 8(A5, A1);
  hence thesis;
end;

Lm28: for n st n >= 10 holds 2 to_power (n-1) > (2*n)^2
proof
  defpred P[Nat] means 2 to_power ($1-1) > (2*$1)^2;
A1: for n be Nat st n >= 10 & P[n] holds P[n+1]
  proof
    let n be Nat;
    assume that
A2: n >= 10 and
A3: 2 to_power (n-1) > (2*n)^2;
A4: now
      assume ((2*n)^2)*2 <= (2*2)*(n*n + 2*n + 1);
      then ((2*2)*(n*n))*2 <= (2*2)*(n*n) + (2*2)*(2*n + 1);
      then ((2*2)*(n*n))*2 - (2*2)*(n*n) <= (2*2)*(2*n + 1) by XREAL_1:20;
      then (2*2)"*((2*2)*(n*n)) <= (2*2)"*((2*2)*(2*n + 1)) by XREAL_1:64;
      then
A5:   n^2 <= 2*n + 1;
      n >= 3 by A2,XXREAL_0:2;
      hence contradiction by A5,Lm27;
    end;
    2 to_power ((n+1)-1) = 2 to_power ((n+-1)+1)
      .= (2 to_power (n-1))*(2 to_power 1) by POWER:27
      .= (2 to_power (n-1))*2 by POWER:25;
    then 2 to_power ((n+1)-1) > ((2*n)^2)*2 by A3,XREAL_1:68;
    hence 2 to_power ((n+1)-1) > (2*(n+1))^2 by A4,XXREAL_0:2;
  end;
  2 to_power (10-1) = 2 to_power (6+3) .= 64*(2 to_power (2+1)) by POWER:27,64
    .= 64*((2 to_power 2)*(2 to_power 1)) by POWER:27
    .= 64*((2 to_power (1+1))*2) by POWER:25
    .= 64*(((2 to_power 1)*(2 to_power 1))*2) by POWER:27
    .= 64*((2*(2 to_power 1))*2) by POWER:25
    .= 64*((2*2)*2) by POWER:25
    .= 512;
  then
A6: P[10];
  for n be Nat st n >= 10 holds P[n] from NAT_1:sch 8(A6, A1);
  hence thesis;
end;

Lm29: for n be Nat st n >= 9 holds (n+1) to_power 6 < 2*(n to_power 6)
proof
  defpred P[Nat] means ($1+1) to_power 6 < 2*($1 to_power 6);
A1: for n be Nat st n >= 9 & P[n] holds P[n+1]
  proof
    let n be Nat;
    assume that
A2: n >= 9 and
A3: (n+1) to_power 6 < 2*(n to_power 6);
    (n+1) to_power 6 / n to_power 6 < 2 by A2,A3,POWER:34,XREAL_1:83;
    then
A4: ((n+1) / n) to_power 6 < 2 by A2,POWER:31;
A5: now
      assume (n+2) / (n+1) >= (n+1) / n;
      then (n+2) / (n+1) * (n+1) >= (n+1) / n * (n+1) by XREAL_1:64;
      then (n+2) >= (n+1) / n * (n+1) by XCMPLX_1:87;
      then (n+2)*n >= (n+1) / n * (n+1) * n by XREAL_1:64;
      then (n+2)*n >= ((n+1) / n * n) * (n+1);
      then n^2 + 2*n >= (n+1)^2 by A2,XCMPLX_1:87;
      then n^2 + 2*n >= n^2 + 2*n + 1*1;
      then (n^2 + 2*n) - (n^2 + 2*n) >= 1 by XREAL_1:19;
      hence contradiction;
    end;
A6: (n+1) to_power 6 > 0 by POWER:34;
    (n+2)*((n+1)") > 0*((n+1)") by XREAL_1:68;
    then ((n+2) / (n+1)) to_power 6 < ((n+1) / n) to_power 6 by A5,POWER:37;
    then ((n+2) / (n+1)) to_power 6 < 2 by A4,XXREAL_0:2;
    then ((n+2) to_power 6) / ((n+1) to_power 6) < 2 by POWER:31;
    then
    ((n+2) to_power 6) / ((n+1) to_power 6) * ((n+1) to_power 6) < 2*((n+
    1) to_power 6) by A6,XREAL_1:68;
    hence thesis by A6,XCMPLX_1:87;
  end;
A7: P[9]
  proof
A8: 9 to_power 2 = 9 to_power (1+1)
      .= (9 to_power 1)*(9 to_power 1) by POWER:27
      .= 9*(9 to_power 1) by POWER:25
      .= 9*9 by POWER:25
      .= 81;
    2*(9 to_power 4) = 2*(9 to_power (2+2)) .= 2*(81*81) by A8,POWER:27
      .= 13122;
    then
A9: (13122*9)*9 = (2*((9 to_power 4)*9))*9
      .= (2*((9 to_power 4)*(9 to_power 1)))*9 by POWER:25
      .= (2*(9 to_power (4+1)))*9 by POWER:27
      .= 2*((9 to_power 5)*9)
      .= 2*((9 to_power 5)*(9 to_power 1)) by POWER:25
      .= 2*(9 to_power (5+1)) by POWER:27
      .= 2*(9 to_power 6);
    consider t6 being Element of NAT such that
A10: t6 = 10*10*10*10*10*10;
A11: 10 to_power 3 = 10 to_power (2+1)
      .= (10 to_power 2)*(10 to_power 1) by POWER:27
      .= (10 to_power (1+1))*10 by POWER:25
      .= ((10 to_power 1)*(10 to_power 1))*10 by POWER:27
      .= (10*(10 to_power 1))*10 by POWER:25
      .= (10*10)*10 by POWER:25;
    10 to_power 6 = 10 to_power (3+3) .= (10*10*10)*(10*10*10) by A11,POWER:27
      .= t6 by A10;
    hence thesis by A10,A9;
  end;
  for n be Nat st n >= 9 holds P[n] from NAT_1:sch 8(A7, A1);
  hence thesis;
end;

Lm30: for n st n >= 30 holds 2 to_power n > n to_power 6
proof
  defpred P[Nat] means 2 to_power $1 > $1 to_power 6;
A1: for n be Nat st n >= 30 & P[n] holds P[n+1]
  proof
    let n be Nat;
    assume that
A2: n >= 30 and
A3: 2 to_power n > n to_power 6;
    n >= 9 by A2,XXREAL_0:2;
    then
A4: (n+1) to_power 6 < 2*(n to_power 6) by Lm29;
A5: 2 to_power (n+1) = (2 to_power n)*(2 to_power 1) by POWER:27
      .= (2 to_power n)*2 by POWER:25;
    (2 to_power n)*2 > (n to_power 6)*2 by A3,XREAL_1:68;
    hence thesis by A5,A4,XXREAL_0:2;
  end;
  2 to_power 30 = 2 to_power (5*6) .= 32 to_power 6 by POWER:33,63;
  then
A6: P[30] by POWER:37;
  for n be Nat st n >= 30 holds P[n] from NAT_1:sch 8(A6, A1);
  hence thesis;
end;

Lm31: for x being Real st x > 9 holds 2 to_power x > (2*x)^2
proof
  let x be Real such that
A1: x > 9;
  set n = [/x\];
A2: n >= x by INT_1:def 7;
  reconsider n as Element of NAT by A1,INT_1:3;
  2*n >= 2*x by A2,XREAL_1:64;
  then
A3: (2*n)^2 >= (2*x)*(2*x) by A1,Lm20;
  n > 9 by A1,A2,XXREAL_0:2;
  then n >= 9+1 by NAT_1:13;
  then
A4: 2 to_power (n-1) > (2*n)^2 by Lm28;
  [/x\] - [\x/] <= 1
  proof
    per cases;
    suppose
      x is Integer;
      then [\x/] = [/x\];
      hence thesis;
    end;
    suppose
      not x is Integer;
      then not [\x/] = [/x\] by INT_1:34;
      then [\x/] + 1 = [/x\] by INT_1:41;
      hence thesis;
    end;
  end;
  then [/x\] <= 1 + [\x/] by XREAL_1:20;
  then [\x/] >= n-1 by XREAL_1:20;
  then
A5: 2 to_power [\x/] >= 2 to_power (n-1) by PRE_FF:8;
  x >= [\x/] by INT_1:def 6;
  then 2 to_power x >= 2 to_power [\x/] by PRE_FF:8;
  then 2 to_power x >= 2 to_power (n-1) by A5,XXREAL_0:2;
  then 2 to_power x > (2*n)^2 by A4,XXREAL_0:2;
  hence thesis by A3,XXREAL_0:2;
end;

Lm32: ex N st for n st n >= N holds sqrt n - log(2, n) > 1
proof
  ex N st for n st n >= N holds n/2 > log(2,n)*log(2,n)
  proof
    reconsider N = 2 to_power 10 as Element of NAT;
    now
      take N;
      let n;
      set x = log(2,n);
A1:   2 to_power 9 > 0 by POWER:34;
      assume
A2:   n >= N;
      then
A3:   n > 0 by POWER:34;
      2 to_power 10 > 2 to_power 0 by POWER:39;
      then n > 2 to_power 0 by A2,XXREAL_0:2;
      then n > 1 by POWER:24;
      then log(2,n) > log(2,1) by POWER:57;
      then log(2,n) > 0 by POWER:51;
      then log(2,n)*log(2,n) > 0*log(2,n) by XREAL_1:68;
      then
A4:   4*(log(2,n)*log(2,n)) > 2*(log(2,n)*log(2,n)) by XREAL_1:68;
      2 to_power 10 > 2 to_power 1 by POWER:39;
      then n > 2 to_power 1 by A2,XXREAL_0:2;
      then
A5:   n > 2 by POWER:25;
      then
A6:   2*n > 2*2 by XREAL_1:68;
      n*n > 2*n by A5,XREAL_1:68;
      then n^2 > 2*2 by A6,XXREAL_0:2;
      then log(2,n^2) > log(2,2^2) by POWER:57;
      then log(2,n^2) > log(2,2 to_power 2) by POWER:46;
      then log(2,n^2) > 2*log(2,2) by POWER:55;
      then
A7:   log(2,n^2) > 2*1 by POWER:52;
      then
A8:   (log(2,n^2))^2 > 0 by SQUARE_1:12;
      2 to_power 10 > 2 to_power 9 by POWER:39;
      then n > 2 to_power 9 by A2,XXREAL_0:2;
      then log(2,n) > log(2,2 to_power 9) by A1,POWER:57;
      then x > 9*log(2,2) by POWER:55;
      then
A9:   x > 9*1 by POWER:52;
      then
A10:  2*x > 0*x by XREAL_1:68;
      then (2*x)*(2*x) > 0*(2*x) by XREAL_1:68;
      then log(2, 2 to_power x) > log(2,(2*x)^2) by A9,Lm31,POWER:57;
      then x*log(2,2) > log(2,(2*x)^2) by POWER:55;
      then x*1 > log(2,(2*x)^2) by POWER:52;
      then x > log(2,(2*x) to_power 2) by POWER:46;
      then x > 2*log(2,2*x) by A10,POWER:55;
      then log(2,n) > 2*log(2,log(2,n to_power 2)) by A3,POWER:55;
      then log(2,n) > 2*log(2,log(2,n^2)) by POWER:46;
      then 2 to_power log(2,n) > 2 to_power (2*log(2,log(2,n^2))) by POWER:39;
      then n > 2 to_power (2*log(2,log(2,n^2))) by A3,POWER:def 3;
      then n > 2 to_power (log(2,log(2,n^2) to_power 2)) by A7,POWER:55;
      then n > 2 to_power (log(2,(log(2,n^2))^2)) by POWER:46;
      then n > (log(2,n^2))^2 by A8,POWER:def 3;
      then n > (log(2,n to_power 2))^2 by POWER:46;
      then n > (2*log(2,n))^2 by A3,POWER:55;
      then n > 2*(log(2,n)*log(2,n)) by A4,XXREAL_0:2;
      hence n/2 > log(2,n)*log(2,n) by XREAL_1:81;
    end;
    hence thesis;
  end;
  then consider N3 such that
A11: for n st n >= N3 holds n/2 > log(2,n)*log(2,n);
  now
    take N = 30;
    let n;
    assume
A12: n >= N;
    then
A13: n to_power 6 > 0 by POWER:34;
    2 to_power n > n to_power 6 by A12,Lm30;
    then log(2,2 to_power n) > log(2,n to_power 6) by A13,POWER:57;
    then n*log(2,2) > log(2,n to_power 6) by POWER:55;
    then n*1 > log(2,n to_power 6) by POWER:52;
    then n > (3*2)*log(2,n) by A12,POWER:55;
    then n > 3*(2*log(2,n));
    hence n/3 > 2*log(2,n) by XREAL_1:81;
  end;
  then consider N2 such that
A14: for n st n >= N2 holds n/3 > 2*log(2,n);
  now
    take N = 7;
    let n;
    assume n >= N;
    then n > 6 by XXREAL_0:2;
    then n/6 > 6/6 by XREAL_1:74;
    hence n/6 > 1;
  end;
  then consider N1 such that
A15: for n st n >= N1 holds n/6 > 1;
  set N = max( max(N1, 2), max( N2, N3 ) );
A16: N >= max(N1, 2) by XXREAL_0:25;
  max(N1, 2) >= 2 by XXREAL_0:25;
  then
A17: N >= 2 by A16,XXREAL_0:2;
A18: N >= max( N2, N3 ) by XXREAL_0:25;
  max( N2, N3 ) >= N3 by XXREAL_0:25;
  then
A19: N >= N3 by A18,XXREAL_0:2;
  max( N2, N3 ) >= N2 by XXREAL_0:25;
  then
A20: N >= N2 by A18,XXREAL_0:2;
  max(N1, 2) >= N1 by XXREAL_0:25;
  then
A21: N >= N1 by A16,XXREAL_0:2;
  now
    let n;
A22: (1 + 2*log(2,n)) + log(2,n)*log(2,n) = (1 + log(2,n))^2;
    assume
A23: n >= N;
    then n >= N2 by A20,XXREAL_0:2;
    then
A24: n/3 > 2*log(2,n) by A14;
    n >= 2 by A17,A23,XXREAL_0:2;
    then log(2,n) >= log(2,2) by PRE_FF:10;
    then
A25: log(2,n) >= 1 by POWER:52;
    n >= N1 by A21,A23,XXREAL_0:2;
    then n/6 > 1 by A15;
    then
A26: n/6 + n/3 > 1 + 2*log(2,n) by A24,XREAL_1:8;
    n >= N3 by A19,A23,XXREAL_0:2;
    then
A27: n/2 > log(2,n)*log(2,n) by A11;
    (n/6 + n/3) + n/2 = n;
    then n > (1 + log(2,n))^2 by A26,A27,A22,XREAL_1:8;
    then sqrt n > sqrt((1 + log(2,n))^2) by SQUARE_1:27,XREAL_1:63;
    then sqrt n > 1 + log(2,n) by A25,SQUARE_1:22;
    hence sqrt n - log(2,n) > 1 by XREAL_1:20;
  end;
  hence thesis;
end;

Lm33: 5! = 120
proof
  (4+1)! = (4+1)*(4!) by NEWTON:15
    .= 5*((3+1)*(3!)) by NEWTON:15
    .= 5*(4*((2+1)*(2!))) by NEWTON:15
    .= 120 by NEWTON:14;
  hence thesis;
end;

Lm34: for n st n >= 10 holds 2 to_power (2*n) / (n!) < 1/(2 to_power (n-9))
proof
  defpred P[Nat] means 2 to_power (2*$1) / ($1!) < 1/(2 to_power ($1-9));
A1: not 4096 / 14175 >= 1 / 2;
A2: 7 = 8-1;
A3: for k be Nat st k >= 10 & P[k] holds P[k+1]
  proof
    let k be Nat;
    assume that
A4: k >= 10 and
A5: 2 to_power (2*k) / (k!) < 1/(2 to_power (k-9));
A6: 2 to_power 1 > 0 by POWER:34;
A7: now
      assume ((2 to_power 2)/(k+1)) >= (1/(2 to_power 1));
      then (2 to_power 1)*((2 to_power 2)*(k+1)") >= (1/(2 to_power 1))*(2
      to_power 1) by XREAL_1:64;
      then ((2 to_power 1)*(2 to_power 2))*(k+1)" >= (1/(2 to_power 1))*(2
      to_power 1);
      then (2 to_power (1+2))*(k+1)" >= (1/(2 to_power 1))*(2 to_power 1) by
POWER:27;
      then 8/(k+1) >= 1 by A6,POWER:61,XCMPLX_1:106;
      then 8/(k+1)*(k+1) >= 1*(k+1) by XREAL_1:64;
      then 8 >= k+1 by XCMPLX_1:87;
      then 7 >= k by A2,XREAL_1:19;
      hence contradiction by A4,XXREAL_0:2;
    end;
    2 to_power -(k-9) > 0 by POWER:34;
    then (1/(2 to_power (k-9))) > 0 by POWER:28;
    then
A8: ((2 to_power 2)/(k+1))*(1/(2 to_power (k-9))) < (1/(2 to_power 1))*(1
    /(2 to_power (k-9))) by A7,XREAL_1:68;
    (2 to_power 2) > 0 by POWER:34;
    then
A9: (2 to_power 2)*(k+1)" > 0*(k+1)" by XREAL_1:68;
    2 to_power (2*(k+1)) / ((k+1)!) = (2 to_power (2*k + 2*1)) / ((k+1)!)
      .= ((2 to_power (2*k))*(2 to_power 2)) / ((k+1)!) by POWER:27
      .= ((2 to_power (2*k))*(2 to_power 2)) / ((k+1)*(k!)) by NEWTON:15
      .= ((2 to_power 2)/(k+1))* ((2 to_power (2*k))/(k!)) by XCMPLX_1:76;
    then 2 to_power (2*(k+1)) / ((k+1)!) < ((2 to_power 2)/(k+1))*(1/(2
    to_power (k-9))) by A5,A9,XREAL_1:68;
    then
    2 to_power (2*(k+1)) / ((k+1)!) < (1/(2 to_power 1))*(1/(2 to_power (
    k-9))) by A8,XXREAL_0:2;
    then
    2 to_power (2*(k+1)) / ((k+1)!) < (1/((2 to_power 1)*(2 to_power (k-9
    )))) by XCMPLX_1:102;
    then 2 to_power (2*(k+1)) / ((k+1)!) < (1/(2 to_power (1+(k+-9)))) by
POWER:27;
    hence 2 to_power (2*(k+1)) / ((k+1)!) < (1/(2 to_power ((k+1)-9)));
  end;
  2 to_power (2*10) / (10!) = 2 to_power 20 / ((9+1)*(9!)) by NEWTON:15
    .= 2 to_power (1+19) / (10*(9!))
    .= ((2 to_power 1)*(2 to_power 19)) / (10*(9!)) by POWER:27
    .= (2*(2 to_power 19)) / (2*(5*(9!))) by POWER:25
    .= (2 to_power 19) / (5*(9!)) by XCMPLX_1:91
    .= (2 to_power 19) / (5*((8+1)*(8!))) by NEWTON:15
    .= (2 to_power 19) / ((5*9)*(8!))
    .= (2 to_power 19) / (45*((7+1)*(7!))) by NEWTON:15
    .= (2 to_power (3+16)) / (8*(45*(7!)))
    .= (8*(2 to_power 16)) / (8*(45*(7!))) by POWER:27,61
    .= (2 to_power 16) / (45*(7!)) by XCMPLX_1:91
    .= (2 to_power (4+12)) / (45*((6+1)*(6!))) by NEWTON:15
    .= ((2 to_power (3+1))*4096) / (45*((6+1)*(6!))) by Lm26,POWER:27
    .= ((8*(2 to_power 1))*4096) / (45*((6+1)*(6!))) by POWER:27,61
    .= ((8*2)*4096) / (45*((6+1)*(6!))) by POWER:25
    .= (16*4096) / ((45*7)*(6!))
    .= (16*4096) / (315*((5+1)*(5!))) by NEWTON:15
    .= 4096 / 14175 by Lm33;
  then
A10: P[10] by A1,POWER:25;
  for n be Nat st n >= 10 holds P[n] from NAT_1:sch 8(A10, A3);
  hence thesis;
end;

Lm35: for n st n >= 3 holds 2*(n-2) >= n-1
proof
  defpred P[Nat] means 2*($1-2) >= $1-1;
A1: for n be Nat st n >= 3 & P[n] holds P[n+1]
  proof
    let n be Nat;
    assume that
    n >= 3 and
A2: 2*(n-2) >= n-1;
    2*(n-2) + 2 >= (n+-1) +1 by A2,XREAL_1:7;
    hence 2*((n+1)-2) >= (n+1)-1;
  end;
A3: P[3];
  for n be Nat st n >= 3 holds P[n] from NAT_1:sch 8(A3, A1);
  hence thesis;
end;

Lm36: 5 to_power 5 = 3125
proof
  5 to_power 5 = 5 to_power (4+1) .= (5 to_power 4)*(5 to_power 1) by POWER:27
    .= (5 to_power (3+1))*5 by POWER:25
    .= ((5 to_power 3)*(5 to_power 1))*5 by POWER:27
    .= ((5 to_power (2+1))*5)*5 by POWER:25
    .= (((5 to_power 2)*(5 to_power 1))*5)*5 by POWER:27
    .= (((5 to_power (1+1))*5)*5)*5 by POWER:25
    .= ((((5 to_power 1)*(5 to_power 1))*5)*5)*5 by POWER:27
    .= ((((5 to_power 1)*5)*5)*5)*5 by POWER:25
    .= (((5*5)*5)*5)*5 by POWER:25
    .= 3125;
  hence thesis;
end;

Lm37: 4 to_power 4 = 256
proof
  4 to_power 4 = 4 to_power (3+1) .= (4 to_power 3)*(4 to_power 1) by POWER:27
    .= (4 to_power (2+1))*4 by POWER:25
    .= ((4 to_power 2)*(4 to_power 1))*4 by POWER:27
    .= ((4 to_power (1+1))*4)*4 by POWER:25
    .= (((4 to_power 1)*(4 to_power 1))*4)*4 by POWER:27
    .= (((4 to_power 1)*4)*4)*4 by POWER:25
    .= ((4*4)*4)*4 by POWER:25
    .= 256;
  hence thesis;
end;

Lm38: for a,b,d,e being Real holds (a/b) / (d/e) = (a/d) * (e/b)
proof
  let a,b,d,e be Real;
  thus (a/b) / (d/e) = (a*e)/(b*d) by XCMPLX_1:84
    .= (a/d) * (e/b) by XCMPLX_1:76;
end;

Lm39: for x being Real st x>=0 holds sqrt x = x to_power (1/2)
proof
  let x be Real;
  assume
A1: x >= 0;
  per cases by A1;
  suppose
    x = 0;
    hence thesis by POWER:def 2;
  end;
  suppose
A2: x > 0;
    then
A3: x to_power (1/2)>0 by POWER:34;
    (x to_power (1/2))^2=(x to_power (1/2)) to_power 2 by POWER:46
      .=x to_power ((1/2)*2) by A2,POWER:33
      .=x by POWER:25;
    hence thesis by A3,SQUARE_1:22;
  end;
end;

Lm40: ex N st for n st n >= N holds n - sqrt n*log(2,n) > n/2
proof
  set seq1 = seq_n^(1/2);
  set seq = seq_logn;
  set p = seq /" seq1;
A1: lim p = 0 by Lm11;
  p is convergent by Lm11;
  then consider N being Nat such that
A2: for n being Nat st n >= N holds |.p.n-0.| < 1/2 by A1,SEQ_2:def 7;
  reconsider N as Element of NAT by ORDINAL1:def 12;
  set N1 = max(2, N);
A3: N1 >= 2 by XXREAL_0:25;
A4: N1 >= N by XXREAL_0:25;
  now
    let n;
    assume
A5: n >= N1;
    then
A6: sqrt n > 0 by A3,SQUARE_1:25;
    n >= N by A4,A5,XXREAL_0:2;
    then |.p.n-0.| < 1/2 by A2;
    then
A7: p.n < 1/2 by ABSVALUE:def 1;
A8: sqrt n <> 0 by A3,A5,SQUARE_1:25;
    p.n = seq.n / seq1.n by Lm4
      .= log(2,n) / seq1.n by A3,A5,Def2
      .= log(2,n) / (n to_power (1/2)) by A3,A5,Def3
      .= log(2,n) / sqrt n by Lm39;
    then log(2,n) / sqrt n * sqrt n < sqrt n * (1/2) by A6,A7,XREAL_1:68;
    then log(2,n) < sqrt n * (1/2) by A8,XCMPLX_1:87;
    then sqrt n*log(2,n) < sqrt n * (sqrt n * (1/2)) by A6,XREAL_1:68;
    then sqrt n*log(2,n) < ((sqrt n)^2) * (1/2);
    then sqrt n*log(2,n) < n * (1/2) by SQUARE_1:def 2;
    then n/2 + sqrt n*log(2,n) < n/2 + n/2 by XREAL_1:6;
    hence n/2 < n - sqrt n*log(2,n) by XREAL_1:20;
  end;
  hence thesis;
end;

Lm41: for s being Real_Sequence
   st for n being Nat holds s.n = (1 + 1/(n+1)) to_power (n+1)
 holds s is non-decreasing
proof
  let s be Real_Sequence such that
A1: for n be Nat holds s.n = (1 + 1/(n+1)) to_power (n+1);
  now
    let n be Nat;
A2: (1 + 1/(n+1+1))/(1 + 1/(n+1)) = ((1*(n+1+1) + 1)/(n+1+1))/(1 + 1/(n+1)
    ) by XCMPLX_1:113
      .= ((n+1+1+1)/(n+1+1))/((1*(n+1) + 1)/(n+1)) by XCMPLX_1:113
      .= ((n+(1+1)+1)*(n+1))/((n+2)*(n+2)) by XCMPLX_1:84
      .= (n*n+n*2+2*n+3+1-1)/((n+2)*(n+2))
      .= ((n+2)*(n+2))/((n+2)*(n+2)) - 1/((n+2)*(n+2))
      .= 1 - 1/((n+2)*(n+2)) by XCMPLX_1:6,60;
    n+1+1>0+1 by XREAL_1:6;
    then (n+2)*(n+2)>1 by XREAL_1:161;
    then 1/((n+2)*(n+2))<1 by XREAL_1:212;
    then - 1/((n+2)*(n+2)) > -1 by XREAL_1:24;
    then
    (1 + -1/((n+2)*(n+2))) to_power (n+1+1) >= 1 + (n+1+1)*(-1/((n+2)*(n+
    2) )) by POWER:49;
    then (1 - 1/((n+2)*(n+2))) to_power (n+1+1) >= 1 - (n+2)*1/((n+2)*(n+2));
    then (1 - 1/((n+2)*(n+2))) to_power (n+1+1) >= 1 - ((n+2)/(n+2)*1)/(n+2)
    by XCMPLX_1:83;
    then
A3: (1 - 1/((n+2)*(n+2))) to_power (n+1+1) >= 1 - (1*1)/(n+2) by XCMPLX_1:60;
    s.(n+1)/s.n =(1 + 1/(n+1+1)) to_power (n+1+1) / s.n by A1
      .=(1 + 1/(n+1+1)) to_power (n+1+1)/(1+1/(n+1)) to_power (n+1)*1
              by A1
      .=(1 + 1/(n+1+1)) to_power (n+1+1)/(1 + 1/(n+1)) to_power (n+1) * ((1+
    1/(n+1))/(1+1/(n+1))) by XCMPLX_1:60
      .=(1+1/(n+1)) * (1 + 1/(n+1+1)) to_power (n+1+1) / ((1 + 1/(n+1))
    to_power (n+1) * (1+1/(n+1))) by XCMPLX_1:76
      .=(1+1/(n+1)) * (1 + 1/(n+1+1)) to_power (n+1+1) / ((1 + 1/(n+1))
    to_power (n+1) * (1+1/(n+1)) to_power 1) by POWER:25
      .=(1+1/(n+1)) * (1 + 1/(n+1+1)) to_power (n+1+1) / (1 + 1/(n+1))
    to_power (n+1+1) by POWER:27
      .=(1+1/(n+1)) * ((1 + 1/(n+1+1)) to_power (n+1+1) / (1 + 1/(n+1))
    to_power (n+1+1))
      .=(1+1/(n+1)) * ((1 + 1/(n+1+1))/(1 + 1/(n+1))) to_power (n+1+1) by
POWER:31;
    then s.(n+1)/s.n >= (1 + 1/(n+1)) * (1 - 1/(n+2)) by A2,A3,XREAL_1:64;
    then s.(n+1)/s.n >= ((1*(n+1) + 1)/(n+1)) * (1 - 1/(n+2)) by XCMPLX_1:113;
    then s.(n+1)/s.n >= ((n+2)/(n+1)) * ((1*(n+2) - 1)/(n+2)) by XCMPLX_1:127;
    then s.(n+1)/s.n >= ((n+1)*(n+2))/((n+1)*(n+2)) by XCMPLX_1:76;
    then
A4: s.(n+1)/s.n >= 1 by XCMPLX_1:6,60;
    (1+1/(n+1)) to_power (n+1) > 0 by POWER:34;
    then s.n>0 by A1;
    hence s.(n+1)>=s.n by A4,XREAL_1:191;
  end;
  hence thesis;
end;

Lm42: for n st n >= 1 holds ((n+1)/n) to_power n <= ((n+2)/(n+1)) to_power (n+
1)
proof
  deffunc F(Nat) = (1 + 1/($1+1)) to_power ($1+1);
  let n;
  consider seq being Real_Sequence such that
A1: for n being Nat holds seq.n = F(n) from SEQ_1:sch 1;
  assume
A2: n >= 1;
  then reconsider m = n-1 as Element of NAT by INT_1:3;
  seq is non-decreasing by A1,Lm41;
  then seq.m <= seq.(m+1);
  then (1 + 1/(m+1)) to_power (m+1) <= seq.(m+1) by A1;
  then (1 + 1/n) to_power n <= (1 + 1/(n+1)) to_power (n+1) by A1;
  then (n/n + 1/n) to_power n <= (1 + 1/(n+1)) to_power (n+1) by A2,XCMPLX_1:60
;
  then ((n+1)/n) to_power n <= ((n+1)/(n+1) + 1/(n+1)) to_power (n+1) by
XCMPLX_1:60;
  hence thesis;
end;

theorem :: (Part 1, O(n^logn) c O(n^sqrt n))
  for f,g being Real_Sequence st (for n st n > 0 holds f.n = (n to_power
  log(2,n))) & (for n st n > 0 holds g.n = (n to_power sqrt n)) holds ex s,s1
being eventually-positive Real_Sequence st s = f & s1 = g & Big_Oh(s) c= Big_Oh
  (s1) & not Big_Oh(s) = Big_Oh(s1)
proof
  let f,g be Real_Sequence such that
A1: for n st n > 0 holds f.n = (n to_power log(2,n)) and
A2: for n st n > 0 holds g.n = (n to_power sqrt n);
  set h = f/"g;
  g is eventually-positive
  proof
    take 1;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume
A4: n >= 1;
    then g.n = n to_power sqrt n by A2,A3;
    hence thesis by A4,POWER:34;
  end;
  then reconsider g as eventually-positive Real_Sequence;
  f is eventually-positive
  proof
    take 1;
    let n be Nat;
A5:  n in NAT by ORDINAL1:def 12;
    assume
A6: n >= 1;
    then f.n = n to_power log(2,n) by A1,A5;
    hence thesis by A6,POWER:34;
  end;
  then reconsider f as eventually-positive Real_Sequence;
  take f,g;
  consider N such that
A7: for n st n >= N holds sqrt n - log(2, n) > 1 by Lm32;
A8: now
    let p be Real such that
A9: p > 0;
    set N1 = max( N, max([/1/p\], 2) );
A10: N1 >= N by XXREAL_0:25;
A11: N1 is Integer
    proof
      per cases by XXREAL_0:16;
      suppose
        N1 = N;
        hence thesis;
      end;
      suppose
        N1 = max([/1/p\], 2);
        hence thesis by XXREAL_0:16;
      end;
    end;
A12: N1 >= max([/1/p\], 2) by XXREAL_0:25;
    max([/1/p\], 2) >= [/1/p\] by XXREAL_0:25;
    then
A13: N1 >= [/1/p\] by A12,XXREAL_0:2;
A14: max([/1/p\], 2) >= 2 by XXREAL_0:25;
    then N1 >= 2 by A12,XXREAL_0:2;
    then
A15: N1 > 1 by XXREAL_0:2;
    N1 in NAT by A10,A11,INT_1:3;
    then reconsider N1 as Nat;
    take N1;
    let n be Nat;
A16:  n in NAT by ORDINAL1:def 12;
A17: h.n = f.n/g.n by Lm4;
    assume
A18: n >= N1;
    then f.n = n to_power log(2,n) by A1,A12,A14,A16;
    then
A19: h.n = (n to_power log(2,n)) / (n to_power sqrt n)
          by A2,A12,A14,A18,A17,A16
      .= n to_power (log(2,n) - sqrt n) by A12,A14,A18,POWER:29
      .= n to_power -(sqrt n - log(2,n));
    then
A20: h.n > 0 by A12,A14,A18,POWER:34;
    n >= N by A10,A18,XXREAL_0:2;
    then sqrt n - log(2, n) > 1 by A7,A16;
    then
A21: (-1)*(sqrt n - log(2, n)) < (-1)*1 by XREAL_1:69;
    n > 1 by A15,A18,XXREAL_0:2;
    then
A22: n to_power -(sqrt n - log(2,n)) < n to_power -1 by A21,POWER:39;
    [/1/p\] >= 1/p by INT_1:def 7;
    then N1 >= 1/p by A13,XXREAL_0:2;
    then n >= 1/p by A18,XXREAL_0:2;
    then
A23: 1/n <= 1/(1/p) by A9,XREAL_1:85;
    n to_power -1 = 1/(n to_power 1) by A12,A14,A18,POWER:28
      .= 1/n by POWER:25;
    then h.n < p by A19,A22,A23,XXREAL_0:2;
    hence |.h.n-0.| < p by A20,ABSVALUE:def 1;
  end;
  then
A24: h is convergent by SEQ_2:def 6;
  then
A25: lim h = 0 by A8,SEQ_2:def 7;
  then not g in Big_Oh(f) by A24,ASYMPT_0:16;
  then
A26: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A24,A25,ASYMPT_0:16;
  hence thesis by A26,Th4;
end;

theorem
  for f being Real_Sequence st (for n st n > 0 holds f.n = (n to_power
sqrt n)) holds ex s,s1 being eventually-positive Real_Sequence st s = f & s1 =
  seq_a^(2,1,0) & Big_Oh(s) c= Big_Oh(s1) & not Big_Oh(s) = Big_Oh(s1)
proof
  set g = seq_a^(2,1,0);
  let f be Real_Sequence such that
A1: for n st n > 0 holds f.n = (n to_power sqrt n);
A2: f is eventually-positive
  proof
    take 1;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume
A4: n >= 1;
    then f.n = n to_power sqrt n by A1,A3;
    hence thesis by A4,POWER:34;
  end;
  set h = f/"g;
  reconsider f as eventually-positive Real_Sequence by A2;
  reconsider g as eventually-positive Real_Sequence;
  take f,g;
  consider N such that
A5: for n st n >= N holds n - sqrt n*log(2,n) > n/2 by Lm40;
A6: now
    let p be Real;
    assume
A7: p > 0;
    set N1 = max( N, max(2*[/log(2,1/p)\], 2) );
A8: N1 >= N by XXREAL_0:25;
A9: N1 is Integer
    proof
      per cases by XXREAL_0:16;
      suppose
        N1 = N;
        hence thesis;
      end;
      suppose
        N1 = max(2*[/log(2,1/p)\], 2);
        hence thesis by XXREAL_0:16;
      end;
    end;
A10: N1 >= max(2*[/log(2,1/p)\], 2) by XXREAL_0:25;
    max(2*[/log(2,1/p)\], 2) >= 2*[/log(2,1/p)\] by XXREAL_0:25;
    then
A11: N1 >= 2*[/log(2,1/p)\] by A10,XXREAL_0:2;
    N1 in NAT by A8,A9,INT_1:3;
    then reconsider N1 as Nat;
    take N1;
    let n be Nat;
A12:  n in NAT by ORDINAL1:def 12;
A13: h.n = f.n/g.n by Lm4;
A14: [/log(2,1/p)\] >= log(2,1/p) by INT_1:def 7;
    assume
A15: n >= N1;
    then n >= 2*[/log(2,1/p)\] by A11,XXREAL_0:2;
    then n/2 >= [/log(2,1/p)\] by XREAL_1:77;
    then n/2 >= log(2,1/p) by A14,XXREAL_0:2;
    then -(n/2) <= -log(2,1/p) by XREAL_1:24;
    then 2 to_power -(n/2) <= 2 to_power -log(2,1/p) by PRE_FF:8;
    then 2 to_power -(n/2) <= 1/(2 to_power log(2,1/p)) by POWER:28;
    then
A16: 2 to_power -(n/2) <= 1/(1/p) by A7,POWER:def 3;
A17: g.n = 2 to_power (1*n+0) by Def1
      .= 2 to_power n;
A18: max(2*[/log(2,1/p)\], 2) >= 2 by XXREAL_0:25;
    then f.n = n to_power sqrt n by A1,A10,A15,A12
      .= 2 to_power (sqrt n*log(2,n)) by A10,A18,A15,Lm3;
    then
A19: h.n = 2 to_power ((sqrt n*log(2,n)) - n) by A13,A17,POWER:29
      .= 2 to_power -(n - sqrt n*log(2,n));
    then
A20: h.n > 0 by POWER:34;
    n >= N by A8,A15,XXREAL_0:2;
    then n - sqrt n*log(2,n) > n/2 by A5,A12;
    then -(n - sqrt n*log(2,n)) < -(n/2) by XREAL_1:24;
    then 2 to_power -(n - sqrt n*log(2,n)) < 2 to_power -(n/2) by POWER:39;
    then h.n < p by A19,A16,XXREAL_0:2;
    hence |.h.n-0.| < p by A20,ABSVALUE:def 1;
  end;
  then
A21: h is convergent by SEQ_2:def 6;
  then
A22: lim h = 0 by A6,SEQ_2:def 7;
  then not g in Big_Oh(f) by A21,ASYMPT_0:16;
  then
A23: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A21,A22,ASYMPT_0:16;
  hence thesis by A23,Th4;
end;

theorem
  ex s, s1 being eventually-positive Real_Sequence st s = seq_a^(2,1,0)
  & s1 = seq_a^(2,1,1) & Big_Oh(s) = Big_Oh(s1)
proof
  set g = seq_a^(2,1,1);
  set f = seq_a^(2,1,0);
  set h = f/"g;
  reconsider f as eventually-positive Real_Sequence;
  reconsider g as eventually-positive Real_Sequence;
  take f,g;
  thus f = seq_a^(2,1,0) & g = seq_a^(2,1,1);
A1: now
    let n;
A2: g.n = 2 to_power (1*n + 1) by Def1;
    f.n = 2 to_power (1*n + 0) by Def1;
    then h.n = (2 to_power n)/g.n by Lm4
      .= 2 to_power (n-(n+1)) by A2,POWER:29
      .= 2 to_power (0+-1)
      .= 1 / 2 to_power 1 by POWER:28
      .= 1 / 2 by POWER:25
      .= 2";
    hence h.n = 2";
  end;
A3: now
    let p be Real such that
A4: p > 0;
     reconsider N = 0 as Nat;
    take N;
    let n be Nat;
A5:  n in NAT by ORDINAL1:def 12;
    assume n >= N;
    |.h.n-2".| = |.2"-2".| by A1,A5
      .= 0 by ABSVALUE:2;
    hence |.h.n-2".| < p by A4;
  end;
  then
A6: h is convergent by SEQ_2:def 6;
  then lim h > 0 by A3,SEQ_2:def 7;
  hence thesis by A6,ASYMPT_0:15;
end;

theorem :: (Part 4, O(2^n) c O(2^2n))
  ex s, s1 being eventually-positive Real_Sequence st s = seq_a^(2,1,0)
  & s1 = seq_a^(2,2,0) & Big_Oh(s) c= Big_Oh(s1) & not Big_Oh(s) = Big_Oh(s1)
proof
  reconsider g = seq_a^(2,2,0) as eventually-positive Real_Sequence;
  reconsider f = seq_a^(2,1,0) as eventually-positive Real_Sequence;
  take f,g;
  thus f = seq_a^(2,1,0) & g = seq_a^(2,2,0);
  set h = f/"g;
A1: for n holds h.n = (2 to_power -n)
  proof
    let n;
    h.n = f.n/g.n by Lm4
      .= (2 to_power (1*n+0))/g.n by Def1
      .= (2 to_power (1*n))/(2 to_power (2*n+0)) by Def1
      .= 2 to_power (1*n-(2*n)) by POWER:29
      .= 2 to_power -n;
    hence thesis;
  end;
A2: now
    let p be Real;
    set N = max(1,[/log(2,1/p)\] + 1);
A3: N >= 1 by XXREAL_0:25;
A4: N is Integer by XXREAL_0:16;
A5: [/log(2,1/p)\] >= log(2,1/p) by INT_1:def 7;
    [/log(2,1/p)\] + 1 > [/log(2,1/p)\] by XREAL_1:29;
    then [/log(2,1/p)\] + 1 > log(2,1/p) by A5,XXREAL_0:2;
    then
A6: 2 to_power ([/log(2,1/p)\]+1) > 2 to_power log(2,1/p) by POWER:39;
    N in NAT by A3,A4,INT_1:3;
    then reconsider N as Nat;
    assume
A7: p > 0;
    take N;
    let n be Nat;
A8: n in NAT by ORDINAL1:def 12;
    [/log(2,1/p)\] + 1 <= N by XXREAL_0:25; then
    2 to_power N >= 2 to_power ([/log(2,1/p)\] + 1) by PRE_FF:8;
    then
A9: 2 to_power N > 2 to_power log(2,1/p) by A6,XXREAL_0:2;
    assume n >= N;
    then 2 to_power n >= 2 to_power N by PRE_FF:8;
    then 2 to_power n > 2 to_power log(2,1/p) by A9,XXREAL_0:2;
    then 2 to_power n > 1/p by A7,POWER:def 3;
    then (2 to_power n)*p > 1/p*p by A7,XREAL_1:68;
    then
A10: p*(2 to_power n) > 1 by A7,XCMPLX_1:87;
    2 to_power n > 0 by POWER:34;
    then (p*(2 to_power n))*(2 to_power n)" > 1*(2 to_power n)" by A10,
XREAL_1:68;
    then
A11: p*((2 to_power n)*(2 to_power n)") > (2 to_power n)";
    2 to_power n <> 0 by POWER:34;
    then p*1 > (2 to_power n)" by A11,XCMPLX_0:def 7;
    then
A12: p > 1/(2 to_power n);
A13: (2 to_power -n) > 0 by POWER:34;
    |.h.n-0.| = |.(2 to_power -n).| by A1,A8;
    then |.h.n-0.| = (2 to_power -n) by A13,ABSVALUE:def 1;
    hence |.h.n-0.| < p by A12,POWER:28;
  end;
  then
A14: h is convergent by SEQ_2:def 6;
  then
A15: lim h = 0 by A2,SEQ_2:def 7;
  then not g in Big_Oh(f) by A14,ASYMPT_0:16;
  then
A16: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A14,A15,ASYMPT_0:16;
  hence thesis by A16,Th4;
end;

theorem :: (Part 5, O(2^2n) c O(n!))
  ex s being eventually-positive Real_Sequence st s = seq_a^(2,2,0) &
  Big_Oh(s) c= Big_Oh(seq_n!(0)) & not Big_Oh(s) = Big_Oh(seq_n!(0))
proof
  reconsider f = seq_a^(2,2,0)as eventually-positive Real_Sequence;
  set g = seq_n!(0);
  take f;
  thus f = seq_a^(2,2,0);
  set h = f/"g;
A1: now
    let p be Real;
    assume
A2: p > 0;
    set N = max(10,[/9+log(2,1/p)\]);
A3: N >= 10 by XXREAL_0:25;
A4: N is Integer by XXREAL_0:16;
A5: N >= [/9+log(2,1/p)\] by XXREAL_0:25;
    N in NAT by A3,A4,INT_1:3;
    then reconsider N as Nat;
    take N;
    let n be Nat;
A6:  n in NAT by ORDINAL1:def 12;
A7: [/9+log(2,1/p)\] >= 9+log(2,1/p) by INT_1:def 7;
    assume
A8: n >= N;
    then n >= [/9+log(2,1/p)\] by A5,XXREAL_0:2;
    then n >= 9+log(2,1/p) by A7,XXREAL_0:2;
    then n-9 >= log(2,1/p) by XREAL_1:19;
    then 2 to_power (n-9) >= 2 to_power log(2,1/p) by PRE_FF:8;
    then 2 to_power (n-9) >= 1/p by A2,POWER:def 3;
    then
A9: 1 / (2 to_power (n-9)) <= 1/(1/p) by A2,XREAL_1:85;
A10: h.n = f.n/g.n by Lm4
      .= (2 to_power (2*n+0)) / g.n by Def1,A6
      .= (2 to_power (2*n+0)) / ((n+0)!) by Def4
      .= (2 to_power (2*n)) / (n!);
    n >= 10 by A3,A8,XXREAL_0:2;
    then h.n < 1 / (2 to_power (n-9)) by A10,Lm34,A6;
    then h.n < p by A9,XXREAL_0:2;
    hence |.h.n-0.| < p by A10,ABSVALUE:def 1;
  end;
  then
A11: h is convergent by SEQ_2:def 6;
  then
A12: lim h = 0 by A1,SEQ_2:def 7;
  then not g in Big_Oh(f) by A11,ASYMPT_0:16;
  then
A13: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A11,A12,ASYMPT_0:16;
  hence thesis by A13,Th4;
end;

theorem :: (Part 6, O(n!) c O((n+1)!))
  Big_Oh(seq_n!(0)) c= Big_Oh(seq_n!(1)) &
  Big_Oh(seq_n!(0)) <> Big_Oh(seq_n!(1))
proof
  set g = seq_n!(1);
  set f = seq_n!(0);
  set h = f/"g;
A1: for n holds h.n = 1/(n+1)
  proof
    let n;
A2: n! <> 0 by NEWTON:17;
    h.n = f.n/g.n by Lm4
      .= (n+0)!/g.n by Def4
      .= (n!)/((n+1)!) by Def4
      .= ((n!)*1)/((n+1)*(n!)) by NEWTON:15
      .= (1/(n+1))*((n!)/(n!)) by XCMPLX_1:76
      .= (1/(n+1))*1 by A2,XCMPLX_1:60;
    hence thesis;
  end;
A3: now
    let p be Real;
    assume
A4: p > 0;
    set N = max( 1, [/1/p\] );
A5: N >= 1 by XXREAL_0:25;
A6: N >= ([/1/p\]) by XXREAL_0:25;
    N is Integer by XXREAL_0:16;
    then reconsider N as Element of NAT by A5,INT_1:3;
    [/1/p\] >= 1/p by INT_1:def 7;
    then
A7: N >= 1/p by A6,XXREAL_0:2;
     reconsider N as Nat;
    take N;
    let n be Nat;
A8:  n in NAT by ORDINAL1:def 12;
    assume n >= N;
    then n+1 > N by NAT_1:13;
    then (n+1) > 1/p by A7,XXREAL_0:2;
    then 1/(n+1) < 1/(1/p) by A4,XREAL_1:88;
    then
A9: h.n < p by A1,A8;
A10: 0 < 1/(n+1);
    -p < -0 by A4,XREAL_1:24;
    then
A11: -p < h.n by A1,A10,A8;
    |.h.n.| < p
    proof
      per cases;
      suppose
        h.n >= 0;
        hence thesis by A9,ABSVALUE:def 1;
      end;
      suppose
A12:    h.n < 0;
A13:    (-1)*(-p) > (-1)*h.n by A11,XREAL_1:69;
        |.h.n.| = -h.n by A12,ABSVALUE:def 1;
        hence thesis by A13;
      end;
    end;
    hence |.h.n-0.| < p;
  end;
  then
A14: h is convergent by SEQ_2:def 6;
  then
A15: lim h = 0 by A3,SEQ_2:def 7;
  then not g in Big_Oh(f) by A14,ASYMPT_0:16;
  then
A16: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A14,A15,ASYMPT_0:16;
  hence thesis by A16,Th4;
end;

theorem :: (Part 7, O((n+1)!) c O(n^n))
  for g being Real_Sequence st (for n st n > 0 holds g.n = (n to_power n
)) holds ex s being eventually-positive Real_Sequence st s = g & Big_Oh(seq_n!(
  1)) c= Big_Oh(s) & not Big_Oh(seq_n!(1)) = Big_Oh(s)
proof
  set f = seq_n!(1);
  let g be Real_Sequence such that
A1: for n st n > 0 holds g.n = (n to_power n);
A2: g is eventually-positive
  proof
    take 1;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume
A4: n >= 1;
    then g.n = n to_power n by A1,A3;
    hence thesis by A4,POWER:34;
  end;
  set h = f/"g;
  reconsider g as eventually-positive Real_Sequence by A2;
  deffunc F(Nat) = h.$1 / h.($1+1);
  consider p being Real_Sequence such that
A5: for n being Nat holds p.n = F(n) from SEQ_1:sch 1;
  defpred P1[Nat] means p.$1 > 2;
A6: for n st n > 0 holds p.n = ((n+1)/(n+2)) * (((n+1)/n) to_power n)
  proof
    let n;
    assume
A7: n > 0;
A8: (n+1)! > 0 by NEWTON:17;
    p.n = h.n / h.(n+1) by A5
      .= (f.n / g.n) / h.(n+1) by Lm4
      .= ((n+1)! / g.n) / h.(n+1) by Def4
      .= ((n+1)! / (n to_power n)) / h.(n+1) by A1,A7
      .= ((n+1)! / (n to_power n)) / (f.(n+1) / g.(n+1)) by Lm4
      .= ((n+1)! / (n to_power n)) / (((n+1)+1)! / g.(n+1)) by Def4
      .= ((n+1)! / (n to_power n)) / (((n+1)+1)! / ((n+1) to_power (n+1)))
    by A1
      .= ((n+1)! / (((n+1)+1)!)) * (((n+1) to_power (n+1)) / (n to_power n))
    by Lm38
      .= ((n+1)! / (((n+1)+1)*((n+1)!))) * (((n+1) to_power (n+1)) / (n
    to_power n)) by NEWTON:15
      .= (1/((n+1)+1) * ((n+1)! / ((n+1)!))) * (((n+1) to_power (n+1)) / (n
    to_power n)) by XCMPLX_1:103
      .= ((1/((n+1)+1)) * 1) * (((n+1) to_power (n+1)) / (n to_power n)) by A8,
XCMPLX_1:60
      .= (1/(n+2)) * ((((n+1) to_power n)*((n+1) to_power 1)) / (n to_power
    n)) by POWER:27
      .= (1/(n+2)) * ((((n+1) to_power n)*(n+1)) / (n to_power n)) by POWER:25
      .= (1/(n+2)) * ((((n+1) to_power n)*(n+1)) * ((n to_power n)"))
      .= (1/(n+2)) * ((((n+1) to_power n)*((n to_power n)"))*(n+1))
      .= (1/(n+2)) * ((((n+1) to_power n)/(n to_power n))*(n+1))
      .= (1/(n+2)) * ((((n+1)/n) to_power n)*(n+1)) by A7,POWER:31
      .= ((n+1)*(1/(n+2))) * (((n+1)/n) to_power n)
      .= ((n+1)/(n+2)) * (((n+1)/n) to_power n);
    hence thesis;
  end;
A9: for k be Nat st k >= 4 & P1[k] holds P1[k+1]
  proof
    let k be Nat;
    assume that
A10: k >= 4 and
A11: p.k > 2;
    (k+2)*(k+1)" > 0*(k+1)" by XREAL_1:68;
    then
A12: (((k+2)/(k+1)) to_power (k+1)) > 0 by POWER:34;
    (k+1)*k" > 0*k" by A10,XREAL_1:68;
    then (((k+1)/k) to_power k) > 0 by POWER:34;
    then
A13: (((k+1)/k) to_power k)*(((k+2)/(k+1)) to_power (k+1))" > 0*(((k+2)/(k
    +1)) to_power (k+1))" by A12,XREAL_1:68;
A14: k in NAT by ORDINAL1:def 12;
A15: now
      assume ((k+1)*(k+3)) >= ((k+2)*(k+2));
      then (k*k + 4*k) + 3 >= k*k + 2*(2*k) + 2^2;
      hence contradiction by XREAL_1:6;
    end;
    then ((k+1)*(k+3)) < 1*((k+2)*(k+2));
    then
A16: (((k+1)*(k+3)) / ((k+2)*(k+2))) < 1 by XREAL_1:83;
    (k+1)*(k+3) > 0*(k+3) by XREAL_1:68;
    then
A17: (((k+1)*(k+3)) * ((k+2)*(k+2))") > 0*((k+2)*(k+2))" by A15,XREAL_1:68;
    k >= 1 by A10,XXREAL_0:2;
    then
    (((k+1)/k) to_power k) <= 1*(((k+2)/(k+1)) to_power (k+1)) by A14,Lm42;
    then (((k+1)/k) to_power k) / (((k+2)/(k+1)) to_power (k+1)) <= 1 by A12,
XREAL_1:79;
    then
A18: (((k+1)*(k+3)) / ((k+2)*(k+2))) * ((((k+1)/k) to_power k) / (((k+2)/(
    k+1)) to_power (k+1))) < 1*1 by A13,A17,A16,XREAL_1:98;
    (k+2)*(k+3)" > 0*(k+3)" by XREAL_1:68;
    then
A19: ((k+2)/(k+3))*(((k+2)/(k+1)) to_power (k+1)) > ((k+2)/(k+3))*0 by A12,
XREAL_1:68;
A20: p.(k+1) = (((k+1)+1)/((k+1)+2)*(((k+(1+1))/(k+1)) to_power (k+1))) by A6
      .= ((k+2)/(k+3)*(((k+2)/(k+1)) to_power (k+1)));
    then
    p.k / p.(k+1) = ((k+1)/(k+2)) * (((k+1)/k) to_power k) / ((k+2)/(k+3)
    *(((k+2)/(k+1)) to_power (k+1))) by A6,A10,A14
      .= (((k+1)/(k+2)) / ((k+2)/(k+3))) * ((((k+1)/k) to_power k) / (((k+2)
    /(k+1)) to_power (k+1))) by XCMPLX_1:76
      .= (((k+1)*(k+3)) / ((k+2)*(k+2))) * ((((k+1)/k) to_power k) / (((k+2)
    /(k+1)) to_power (k+1))) by XCMPLX_1:84;
    then p.k / p.(k+1) * p.(k+1) < 1*p.(k+1) by A20,A19,A18,XREAL_1:68;
    then p.(k+1) > p.k by A20,A19,XCMPLX_1:87;
    hence thesis by A11,XXREAL_0:2;
  end;
  defpred P[Nat] means h.$1 < 1/($1-2);
  take g;
A21: for n st n >= 1 holds h.n > 0
  proof
    let n;
A22: (n+1)! > 0 by NEWTON:17;
    assume
A23: n >= 1;
    then n to_power n > 0 by POWER:34;
    then
A24: (n+1)!*(1/(n to_power n)) > (n+1)!*0 by A22,XREAL_1:68;
    h.n = f.n/g.n by Lm4
      .= (n+1)! / g.n by Def4
      .= (n+1)! / (n to_power n) by A1,A23;
    hence thesis by A24;
  end;
  p.4 = ((4+1) / (4+2)) * (((4+1)/4) to_power 4) by A6
    .= (5 / 6) * ((5 to_power 4) / 256) by Lm37,POWER:31
    .= (5 * (5 to_power 4)) / (6 * 256)
    .= ((5 to_power 1)*(5 to_power 4)) / 1536 by POWER:25
    .= (5 to_power (4+1)) / 1536 by POWER:27
    .= 3125 / 1536 by Lm36;
  then
A25: P1[4];
A26: for n be Nat st n >= 4 holds P1[n] from NAT_1:sch 8(A25, A9);
A27: 3 = 4-1;
A28: for k be Nat st k >= 4 & P[k] holds P[k+1]
  proof
    let k be Nat;
    assume that
A29: k >= 4 and
A30: h.k < 1/(k-2);
A31: k in NAT by ORDINAL1:def 12;
A32: h.(k+1) > 0 by A21,NAT_1:11;
    p.k > 2 by A26,A29;
    then h.k / h.(k+1) > 2 by A5;
    then (h.k / h.(k+1)) * h.(k+1) > 2*h.(k+1) by A32,XREAL_1:68;
    then h.k > 2*h.(k+1) by A32,XCMPLX_1:87;
    then
A33: h.k/2 > h.(k+1) by XREAL_1:81;
A34: k-1 >= 3 by A27,A29,XREAL_1:9;
    k >= 3 by A29,XXREAL_0:2;
    then 2*(k-2) >= k-1 by A31,Lm35;
    then
A35: 1/(2*(k-2)) <= 1/(k-1) by A34,XREAL_1:85;
    h.k*(1/2) < (1/(k-2))*(1/2) by A30,XREAL_1:68;
    then h.k/2 < 1/(2*(k-2)) by XCMPLX_1:102;
    then h.k/2 < 1/(k-1) by A35,XXREAL_0:2;
    hence thesis by A33,XXREAL_0:2;
  end;
  h.4 = f.4/g.4 by Lm4
    .= (4+1)!/g.4 by Def4
    .= 120/256 by A1,Lm33,Lm37;
  then
A36: P[4];
A37: for n be Nat st n >= 4 holds P[n] from NAT_1:sch 8(A36, A28);
A38: now
    let p be Real;
    set N = [/1/p + 4\];
A39: [/1/p + 4\] >= 1/p + 4 by INT_1:def 7;
    assume
A40: p > 0;
    then
A41: 4 + 1/p > 4 by XREAL_1:29;
    then
A42: N >= 4 by A39,XXREAL_0:2;
    N in NAT by A41,INT_1:3;
    then reconsider N as Nat;
    take N;
    let n be Nat;
A43:  n in NAT by ORDINAL1:def 12;
    assume
A44: n >= N;
    then
A45: n >= 4 by A42,XXREAL_0:2;
    then n >= 1 by XXREAL_0:2;
    then
A46: h.n > 0 by A21,A43;
A47: 1/p + 2 > 1/p by XREAL_1:29;
    n >= (1/p + 2) + 2 by A39,A44,XXREAL_0:2;
    then n - 2 >= 1/p + 2 by XREAL_1:19;
    then n - 2 > 1/p by A47,XXREAL_0:2;
    then
A48: 1/(n-2) < 1/(1/p) by A40,XREAL_1:88;
    h.n < 1/(n-2) by A37,A45;
    then h.n < p by A48,XXREAL_0:2;
    hence |.h.n-0.| < p by A46,ABSVALUE:def 1;
  end;
  then
A49: h is convergent by SEQ_2:def 6;
  then
A50: lim h = 0 by A38,SEQ_2:def 7;
  then not g in Big_Oh(f) by A49,ASYMPT_0:16;
  then
A51: not f in Big_Omega(g) by ASYMPT_0:19;
  f in Big_Oh(g) by A49,A50,ASYMPT_0:16;
  hence thesis by A51,Th4;
end;

begin :: Problem 3.23

Lm43: for k,n being Nat st k <= n holds n choose k >= ((n+1) choose k) / (n+1)
proof
  let k,n be Nat ;
  set n1 = n+1;
  assume
A1: k <= n;
  then reconsider l = n-k as Element of NAT by INT_1:5;
  set l1 = l+1;
A2: l1 = n1-k;
  0+1 <= l+1 by XREAL_1:6;
  then 1/1 >= 1/l1 by XREAL_1:85;
  then
A3: (n choose k) * (1/1) >= (n choose k) * (1/l1) by XREAL_1:64;
  n + 0 <= n + 1 by XREAL_1:6;
  then k <= n+1 by A1,XXREAL_0:2;
  then (n1 choose k) / n1 = ((n1!)/((k!) * (l1!))) / n1 by A2,NEWTON:def 3
    .= (n1*(n!)/((k!) * (l1!))) / (n1*1) by NEWTON:15
    .= (n1*(n!)*((k!) * (l1!))") / (n1*1)
    .= (n1*((n!)*((k!) * (l1!))")) / (n1*1)
    .= (n1*((n!)/((k!) * (l1!)))) / (n1*1)
    .= (n1/n1) * (((n!)/((k!) * (l1!)))/1)
    .= 1 * (((n!)/((k!) * (l1!)))/1) by XCMPLX_1:60
    .= (n!)/((k!) * ((l!) * l1)) by NEWTON:15
    .= (n!)*1/((k!) * (l!) * l1)
    .= (n!)/((k!) * (l!)) * (1/l1) by XCMPLX_1:76
    .= (n choose k) * (1/l1) by A1,NEWTON:def 3;
  hence thesis by A3;
end;

theorem
  for n st n >= 1 holds for f being Real_Sequence, k being Element of
NAT st (for n holds f.n = Sum(seq_n^(k), n)) holds f.n >= (n to_power (k+1)) /
  (k+1)
proof
  defpred P[Nat] means for f being Real_Sequence, k being Element of NAT st (
for n holds f.n = Sum(seq_n^(k), n)) holds f.$1 >= ($1 to_power (k+1)) / (k+1);
A1: for n being Nat st n >= 1 & P[n] holds P[n+1]
  proof
    let n be Nat such that
    n >= 1 and
A2: for f being Real_Sequence, k being Element of NAT st (for n holds
    f.n = Sum(seq_n^(k), n)) holds f.n >= (n to_power (k+1)) / (k+1);
    reconsider n as Element of NAT by ORDINAL1:def 12;
    let f be Real_Sequence, k be Element of NAT such that
A3: for n holds f.n = Sum(seq_n^(k), n);
    set R3 = ((n,1) In_Power (k+1));
    len R3 = (k+1)+1 by NEWTON:def 4
      .= k+2;
    then reconsider R3 as Element of (k+2)-tuples_on REAL by FINSEQ_2:92;
    set R2 = ((k+1)")*((n,1) In_Power (k+1));
    len R2 = len ((n,1) In_Power (k+1)) by NEWTON:2
      .= (k+1)+1 by NEWTON:def 4
      .= k+2;
    then reconsider R2 as Element of (k+2)-tuples_on REAL by FINSEQ_2:92;
    reconsider nk = (n to_power (k+1)) / (k+1) as Element of REAL
            by XREAL_0:def 1;
    set R1 = <*nk*>^((n,1) In_Power k);
A4: len <*(n to_power (k+1)) / (k+1)*> = 1 by FINSEQ_1:40;
    set g = seq_n^(k);
    f.n >= (n to_power (k+1)) / (k+1) by A2,A3;
    then Sum(g,n) >= (n to_power (k+1)) / (k+1) by A3;
    then
A5: (Partial_Sums(g)).n >= (n to_power (k+1)) / (k+1) by SERIES_1:def 5;
    reconsider nk =(n to_power (k+1)) / (k+1) as Element of REAL
             by XREAL_0:def 1;
    g.(n+1) = (n+1) to_power k by Def3
      .= Sum((n,1) In_Power k) by NEWTON:30;
    then
A6: (n to_power (k+1)) / (k+1) + g.(n+1)
      = Sum (<*nk*>^((n,1) In_Power k)) by RVSUM_1:76;
    len ((n,1) In_Power k) = k+1 by NEWTON:def 4;
    then
A7: len R1 = (k+1)+1 by A4,FINSEQ_1:22
      .= k+2;
    then reconsider R1 as Element of (k+2)-tuples_on REAL
           by FINSEQ_2:92;
A8: for i being Nat st i in Seg (k+2) holds R2.i<=R1.i
    proof
      set k1 = (k+1)";
      let i be Nat such that
A9:   i in Seg (k+2);
A10:  1 <= i by A9,FINSEQ_1:1;
      set r2 = R2.i, r1 = R1.i;
A11:  i <= (k+2) by A9,FINSEQ_1:1;
      per cases by A10,XXREAL_0:1;
      suppose
A12:    i = 1;
        n|^(k+1) = R3.1 by NEWTON:28;
        then r2 = k1*(n|^(k+1)) by A12,RVSUM_1:45
          .= (n to_power (k+1)) / (k+1);
        hence thesis by A12,FINSEQ_1:41;
      end;
      suppose
A13:    i > 1;
        set i0 = i-1;
        set m = i0-1;
A14:    i-1 > 1-1 by A13,XREAL_1:9;
        then reconsider i0 as Element of NAT by INT_1:3;
        set l = k-m;
A15:    i0 >= 0+1 by A14,INT_1:7;
        then reconsider m as Element of NAT by INT_1:3;
        set i3 = (k+1)-i0;
        len (((n,1) In_Power k)) = k+1 by NEWTON:def 4;
        then
A16:    dom(((n,1) In_Power k)) = Seg(k+1) by FINSEQ_1:def 3;
        i-1 <= (k+2)-1 by A11,XREAL_1:9;
        then
A17:    i0 in dom(((n,1) In_Power k)) by A15,A16,FINSEQ_1:1;
        m = i-2;
        then
A18:    k >= m+0 by A11,XREAL_1:20;
        then l >= 0 by XREAL_1:19;
        then reconsider l as Element of NAT by INT_1:3;
A19:    i3 = l;
        then
A20:    i0 + 0 <= (k+1) by XREAL_1:19;
        reconsider i3 as Element of NAT by A19;
        len(((n,1) In_Power (k+1))) = (k+1)+1 by NEWTON:def 4;
        then dom(((n,1) In_Power (k+1))) = Seg(k+2) by FINSEQ_1:def 3;
        then R3.i = ((k+1) choose i0)*(n|^i3)*(1|^i0) by A9,NEWTON:def 4;
        then
A21:    r2 = k1*(((k+1) choose i0)*(n|^i3)*(1|^i0)) by RVSUM_1:45
          .= k1*(((k+1) choose l)*(n|^l)*(1|^i0)) by A20,NEWTON:20
          .= k1*(((k+1) choose l)*(n|^l)*1) by NEWTON:10
          .= k1*((k+1) choose l)*(n to_power l);
        k-m <= k-0 by XREAL_1:13;
        then
A22:    ((k+1) choose l) / (k+1) <= (k choose l) by Lm43;
        r1 = ((n,1) In_Power k).i0 by A4,A7,A11,A13,FINSEQ_1:24
          .= (k choose m)*(n|^l)*(1|^m) by A17,NEWTON:def 4
          .= (k choose l)*(n|^l)*(1|^m) by A18,NEWTON:20
          .= (k choose l)*(n|^l)*1 by NEWTON:10
          .= (k choose l)*(n to_power l);
        hence thesis by A21,A22,XREAL_1:64;
      end;
    end;
    ((n+1) to_power (k+1)) / (k+1) = ((n+1)|^(k+1))*(k+1)"
      .= Sum((n,1) In_Power (k+1))*(k+1)" by NEWTON:30
      .= Sum(((k+1)")*((n,1) In_Power (k+1))) by RVSUM_1:87;
    then
A23: ((n+1) to_power (k+1)) / (k+1) <= Sum R1 by A8,RVSUM_1:82;
    f.(n+1) = Sum(g,n+1) by A3
      .= (Partial_Sums(g)).(n+1) by SERIES_1:def 5
      .= (Partial_Sums(g)).n + g.(n+1) by SERIES_1:def 1;
    then f.(n+1) >= (n to_power (k+1)) / (k+1) + g.(n+1) by A5,XREAL_1:6;
    hence thesis by A6,A23,XXREAL_0:2;
  end;
A24: P[1]
  proof
    let f be Real_Sequence, k be Element of NAT such that
A25: for n holds f.n = Sum(seq_n^(k), n);
    set g = seq_n^(k);
A26: (1 to_power (k+1)) / (k+1) = 1 / (k+1) by POWER:26;
A27: 0+1 <= k+1 by XREAL_1:6;
    f.1 = Sum(g,1) by A25
      .= (Partial_Sums(g)).(0+1) by SERIES_1:def 5
      .= (Partial_Sums(g)).0 + g.1 by SERIES_1:def 1
      .= g.1 + g.0 by SERIES_1:def 1
      .= (1 to_power k) + g.0 by Def3
      .= 1 + g.0 by POWER:26
      .= 1 + 0 by Def3
      .= 1/1;
    hence thesis by A26,A27,XREAL_1:85;
  end;
  for n be Nat st n >= 1 holds P[n] from NAT_1:sch 8(A24, A1);
  hence thesis;
end;

begin :: Problem 3.24

Lm44: for f being Real_Sequence st (for n being Nat holds f.n = log(2,n!))
 for n holds f.n = Sum(seq_logn, n)
proof
  set g = seq_logn;
  let f be Real_Sequence such that
A1: for n being Nat holds f.n = log(2,n!);
  defpred P[Nat] means f.$1 = Sum(g, $1);
A2: for k being Nat st P[k] holds P[k+1]
  proof
    let k be Nat such that
A3: f.k = Sum(g, k);
A4: k! > 0 by NEWTON:17;
    f.(k+1) = log(2,(k+1)!) by A1
      .= log(2,(k+1)*(k!)) by NEWTON:15
      .= log(2,k+1) + log(2,k!) by A4,POWER:53
      .= log(2,k+1) + Sum(g, k) by A1,A3
      .= g.(k+1) + Sum(g, k) by Def2
      .= g.(k+1) + Partial_Sums(g).k by SERIES_1:def 5
      .= Partial_Sums(g).(k+1) by SERIES_1:def 1
      .= Sum(g, k+1) by SERIES_1:def 5;
    hence thesis;
  end;
A5: Sum(g, 0) = Partial_Sums(g).0 by SERIES_1:def 5
    .= g.0 by SERIES_1:def 1
    .= 0 by Def2;
  f.0 = log(2,1) by A1,NEWTON:12
    .= 0 by POWER:51;
  then
A6: P[0] by A5;
  for n being Nat holds P[n] from NAT_1:sch 2(A6, A2);
  hence thesis;
end;

Lm45: for n being Nat st n >= 4 holds n*log(2,n) >= 2*n
proof
  let n be Nat;
  assume n >= 4;
  then log(2,n) >= log(2,2^2) by PRE_FF:10;
  then log(2,n) >= log(2,2 to_power 2) by POWER:46;
  then log(2,n) >= 2*log(2,2) by POWER:55;
  then log(2,n) >= 2*1 by POWER:52;
  hence thesis by XREAL_1:64;
end;

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;
    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;
    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;

:: Problem 3.25 -- Proven in theorem ASYMPT_0:1

begin :: Problem 3.26
:: For a "natural" example of an algorithm that would take time in
:: O(t(n)), consider a naive algorithm that tries to find at least one
:: factor of a given Nat. For all even numbers, the task is trivial,
:: and for all odd numbers, the algorithm might try dividing the number by all
:: numbers smaller than it, giving a running time of n.

theorem
  for f being eventually-nondecreasing eventually-nonnegative
Real_Sequence , t being Real_Sequence st (for n holds (n mod 2 = 0 implies t.n
  = 1) & (n mod 2 = 1 implies t.n = n)) holds not t in Big_Theta(f)
proof
  let f be eventually-nondecreasing eventually-nonnegative Real_Sequence, t be
  Real_Sequence such that
A1: for n holds (n mod 2 = 0 implies t.n = 1) & (n mod 2 = 1 implies t.n = n);
A2: Big_Theta(f) = { 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*f.n <= s.n & s.n <= c*f.n } by
ASYMPT_0:27;
  hereby
    consider N0 being Nat such that
A3: for n being Nat st n >= N0 holds f.n <= f.(n+1) by ASYMPT_0:def 6;
    assume t in Big_Theta(f);
    then consider s being Element of Funcs(NAT, REAL) such that
A4: s = t and
A5: ex c,d,N st c > 0 & d > 0 & for n st n >= N holds d*f.n <= s.n & s
    .n <= c*f.n by A2;
    consider c,d,N such that
A6: c > 0 and
A7: d > 0 and
A8: for n st n >= N holds d*f.n <= s.n & s.n <= c*f.n by A5;
    set N1 = max([/c/d\] + 1, max(N, N0));
A9: N1 >= [/c/d\] + 1 by XXREAL_0:25;
A10: N1 is Integer by XXREAL_0:16;
A11: N1 >= max(N, N0) by XXREAL_0:25;
    max(N, N0) >= N0 by XXREAL_0:25;
    then
A12: N1 >= N0 by A11,XXREAL_0:2;
    max(N, N0) >= N by XXREAL_0:25;
    then
A13: N1 >= N by A11,XXREAL_0:2;
    reconsider N1 as Element of NAT by A11,A10,INT_1:3;
    thus contradiction
    proof
      per cases by NAT_D:12;
      suppose
A14:    N1 mod 2 = 1;
A15:    [/c/d\] >= c/d by INT_1:def 7;
        [/c/d\] + 1 > [/c/d\] + 0 by XREAL_1:8;
        then [/c/d\] + 1 > c/d by A15,XXREAL_0:2;
        then N1 > c/d by A9,XXREAL_0:2;
        then N1*c" > c"*(c/d) by A6,XREAL_1:68;
        then N1/c > (c"*c)*(1/d);
        then
A16:    N1/c > 1*(1/d) by A6,XCMPLX_0:def 7;
A17:    f.(N1+1) >= f.(N1) by A3,A12;
        s.N1 = N1 by A1,A4,A14;
        then N1 <= c*f.N1 by A8,A13;
        then N1/c <= f.N1 by A6,XREAL_1:79;
        then f.N1 > 1/d by A16,XXREAL_0:2;
        then f.(N1+1) > 1/d by A17,XXREAL_0:2;
        then
A18:    d*(1/d) < d*f.(N1+1) by A7,XREAL_1:68;
        N1+1 > N1+0 by XREAL_1:8;
        then
A19:    N1+1 > N by A13,XXREAL_0:2;
        (N1+1) mod 2 = (1+(1 mod 2)) mod 2 by A14,NAT_D:66
          .= (1+1) mod 2 by NAT_D:14
          .= 0 by NAT_D:25;
        then t.(N1+1) = 1 by A1;
        then d*f.(N1+1) <= 1 by A4,A8,A19;
        hence thesis by A7,A18,XCMPLX_1:106;
      end;
      suppose
A20:    N1 mod 2 = 0;
        then (N1+1) mod 2 = (0+(1 mod 2)) mod 2 by NAT_D:66
          .= (0+1) mod 2 by NAT_D:14
          .= 1 by NAT_D:14;
        then
A21:    s.(N1+1) = N1+1 by A1,A4;
A22:    [/c/d\] >= c/d by INT_1:def 7;
A23:    N1+1 > N1+0 by XREAL_1:8;
        then N1+1 > N0 by A12,XXREAL_0:2;
        then
A24:    f.((N1+1)+1) >= f.(N1+1) by A3;
        [/c/d\] + 1 > [/c/d\] + 0 by XREAL_1:8;
        then [/c/d\] + 1 > c/d by A22,XXREAL_0:2;
        then N1 > c/d by A9,XXREAL_0:2;
        then (N1+1) > c/d by A23,XXREAL_0:2;
        then (N1+1)*c" > c"*(c/d) by A6,XREAL_1:68;
        then (N1+1)/c > (c"*c)*(1/d);
        then
A25:    (N1+1)/c > 1*(1/d) by A6,XCMPLX_0:def 7;
        N1+1 > N by A13,A23,XXREAL_0:2;
        then N1+1 <= c*f.(N1+1) by A8,A21;
        then (N1+1)/c <= f.(N1+1) by A6,XREAL_1:79;
        then f.(N1+1) > 1/d by A25,XXREAL_0:2;
        then f.(N1+2) > 1/d by A24,XXREAL_0:2;
        then
A26:    d*(1/d) < d*f.(N1+2) by A7,XREAL_1:68;
        N1+2 > N1+0 by XREAL_1:8;
        then
A27:    N1+2 > N by A13,XXREAL_0:2;
        (N1+2) mod 2 = (0+(2 mod 2)) mod 2 by A20,NAT_D:66
          .= (0+0) mod 2 by NAT_D:25
          .= 0 by NAT_D:26;
        then t.(N1+2) = 1 by A1;
        then d*f.(N1+2) <= 1 by A4,A8,A27;
        hence thesis by A7,A26,XCMPLX_1:106;
      end;
    end;
  end;
end;

:: Problem 3.27 -- Proven as part of theorem ASYMPT_0:37

begin :: Problem 3.28

Lm46: for n being Nat st n >= 2 holds [/n/2\] < n
proof
  let n be Nat such that
A1: n >= 2;
A2: now
    assume n/2 + 1 > n;
    then 2*(n/2 + 1) > 2*n by XREAL_1:68;
    then 2*(n/2) + 2*1 > 2*n;
    then 2 > 2*n - n by XREAL_1:19;
    hence contradiction by A1;
  end;
  [/n/2\] < n/2 + 1 by INT_1:def 7;
  hence thesis by A2,XXREAL_0:2;
end;

:: Problem 3.29 -- Proven in theorems ASYMPT_0:39

begin :: Problem 3.30

definition
  func POWEROF2SET -> non empty Subset of NAT equals
  the set of all 2 to_power n where n is Element of NAT;
  coherence
  proof
    set IT = the set of all 2 to_power n where n is Element of NAT;
A1: now
      let x be object;
      assume x in IT;
      then ex n being Element of NAT st 2 to_power n = x;
      hence x in NAT;
    end;
    2 to_power 1 in IT;
    hence thesis by A1,TARSKI:def 3;
  end;
end;

Lm47: for n being Nat st n >= 2 holds n^2 > n+1
proof
  defpred P[Nat] means $1^2 > $1+1;
A1: for k be Nat st k >= 2 & P[k] holds P[k+1]
  proof
    let k be Nat such that
A2: k >= 2 and
A3: k^2 > k+1;
    2*k > 2*0 by A2,XREAL_1:68;
    then 2*k + 1 > 0 + 1 by XREAL_1:6;
    then
A4: (k+1) + (2*k + 1) > (k+1) + 1 by XREAL_1:6;
    k^2 + (2*k + 1) > (k+1) + (2*k + 1) by A3,XREAL_1:6;
    hence (k+1)^2 > (k+1) + 1 by A4,XXREAL_0:2;
  end;
A5: P[2];
  for n be Nat st n >= 2 holds P[n] from NAT_1:sch 8(A5, A1);
  hence thesis;
end;

Lm48: for n being Nat st n >= 1 holds (2 to_power (n+1)) - (2 to_power n) > 1
proof
  let n be Nat;
  assume n >= 1;
  then 2 to_power n >= 2 to_power 1 by PRE_FF:8;
  then (2 to_power n)*1 >= 2 by POWER:25;
  then (2 to_power n)*2 - (2 to_power n)*1 > 1 by XXREAL_0:2;
  then (2 to_power n)*(2 to_power 1) - (2 to_power n) > 1 by POWER:25;
  hence thesis by POWER:27;
end;

Lm49: for n being Nat st n >= 2 holds
  not ((2 to_power n) - 1) in POWEROF2SET
proof
A1: 1 = 2-1;
  let n be Nat;
  assume n >= 2;
  then n-1 >= 1 by A1,XREAL_1:9;
  then (2 to_power ((n+-1)+1)) - (2 to_power (n-1)) > 1 by Lm48;
  then (2 to_power n) > 1 + (2 to_power (n-1)) by XREAL_1:20;
  then
A3: (2 to_power n) - 1 > (2 to_power (n-1)) by XREAL_1:20;
  assume (2 to_power n) - 1 in POWEROF2SET;
  then consider m such that
A4: 2 to_power m = (2 to_power n) - 1;
  now
    assume m >= n;
    then
A5: 2 to_power m >= 2 to_power n by PRE_FF:8;
    (2 to_power n) + 1 > (2 to_power n) + 0 by XREAL_1:6;
    hence contradiction by A4,A5,XREAL_1:19;
  end;
  then m+1 <= n by INT_1:7;
  then
A6: m <= n-1 by XREAL_1:19;
  m >= n-1 by A4,A3,POWER:39;
  hence contradiction by A4,A3,A6,XXREAL_0:1;
end;

theorem :: Part a)
  for f being Real_Sequence st (for n holds (n in POWEROF2SET implies f.
  n = n) & (not n in POWEROF2SET implies f.n = 2 to_power n)) holds f in
  Big_Theta(seq_n^(1), POWEROF2SET) & not f in Big_Theta(seq_n^(1)) & seq_n^(1)
  is smooth & not f is eventually-nondecreasing
proof
  set X = POWEROF2SET;
  set p = seq_logn;
  set g = seq_n^(1);
  set h = (g taken_every 2);
  set q = p/"g;
A1: now
    let n;
    assume
A2: n >= 1;
    then
A3: 2*n > 2*0 by XREAL_1:68;
A4: h.n = g.(2*n) by ASYMPT_0:def 15
      .= (2*n) to_power 1 by A3,Def3
      .= 2*n by POWER:25;
    g.n = n to_power 1 by A2,Def3
      .= n by POWER:25;
    hence h.n <= 2*g.n by A4;
    thus h.n >= 0 by A4;
  end;
  let f be Real_Sequence such that
A5: for n holds (n in POWEROF2SET implies f.n = n) & (not n in
  POWEROF2SET implies f.n = 2 to_power n);
A6: now
    let n such that
A7: n >= 1 and
A8: n in X;
A9: g.n = n to_power 1 by A7,Def3
      .= n by POWER:25;
    hence 1*g.n <= f.n by A5,A8;
    thus f.n <= 1*g.n by A5,A8,A9;
  end;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  hence f in Big_Theta(g,X) by A6;
A10: Big_Theta(g) = { t where t is Element of Funcs(NAT, REAL) : ex c,d,N st
c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n } by
ASYMPT_0:27;
  hereby
A11: lim q = 0 by Lm11;
    q is convergent by Lm11;
    then consider N0 being Nat such that
A12: for m being Nat st m >= N0 holds |.q.m-0.| < 1/2 by A11,SEQ_2:def 7;
    assume f in Big_Theta(g);
    then consider t being Element of Funcs(NAT, REAL) such that
A13: t = f and
A14: ex c,d,N st c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n &
    t.n <= c*g.n by A10;
    consider c,d,N such that
A15: c > 0 and
    d > 0 and
A16: for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n by A14;
    set N2 = max( max(N0, N), max([/c\], 2) );
A17: N2 >= max(N0, N) by XXREAL_0:25;
A18: N2 is Integer
    proof
      per cases by XXREAL_0:16;
      suppose
        N2 = max(N0, N);
        hence thesis;
      end;
      suppose
        N2 = max([/c\],2);
        hence thesis by XXREAL_0:16;
      end;
    end;
    max(N0, N) >= N0 by XXREAL_0:25;
    then
A19: N2 >= N0 by A17,XXREAL_0:2;
A20: N2 >= max([/c\],2) by XXREAL_0:25;
    max([/c\],2) >= [/c\] by XXREAL_0:25;
    then
A21: N2 >= [/c\] by A20,XXREAL_0:2;
A22: max([/c\],2) >= 2 by XXREAL_0:25;
    then
A23: N2 >= 2 by A20,XXREAL_0:2;
    max(N0, N) >= N by XXREAL_0:25;
    then
A24: N2 >= N by A17,XXREAL_0:2;
A25: [/c\] >= c by INT_1:def 7;
    reconsider N2 as Element of NAT by A17,A18,INT_1:3;
    set N3 = (2 to_power N2) - 1;
    2 to_power N2 > 0 by POWER:34;
    then 2 to_power N2 >= 0 + 1 by NAT_1:13;
    then reconsider N3 as Element of NAT by INT_1:3;
A26: 2 to_power N3 > 0 by POWER:34;
    not N3 in POWEROF2SET by A20,A22,Lm49,XXREAL_0:2;
    then
A27: t.N3 = 2 to_power N3 by A5,A13;
    2 to_power N2 > N2 + 1 by A23,Lm1;
    then
A28: N3 > N2 by XREAL_1:20;
    then
A29: g.N3 = N3 to_power 1 by Def3
      .= N3 by POWER:25;
    N3 >= N by A24,A28,XXREAL_0:2;
    then 2 to_power N3 <= c*N3 by A16,A27,A29;
    then log(2,2 to_power N3) <= log(2,c*N3) by A26,PRE_FF:10;
    then N3*log(2,2) <= log(2,c*N3) by POWER:55;
    then N3*1 <= log(2,c*N3) by POWER:52;
    then
A30: N3 <= log(2,c) + log(2,N3) by A15,A28,POWER:53;
    N3 >= [/c\] by A21,A28,XXREAL_0:2;
    then N3 >= c by A25,XXREAL_0:2;
    then log(2,N3) >= log(2,c) by A15,PRE_FF:10;
    then log(2,N3) + log(2,N3) >= log(2,c) + log(2,N3) by XREAL_1:6;
    then N3 <= 2*log(2,N3) by A30,XXREAL_0:2;
    then N3 / 2 <= log(2,N3) by XREAL_1:79;
    then N3" * (N3 * (1/2)) <= log(2,N3) * N3" by XREAL_1:64;
    then (N3" * N3) * (1/2) <= log(2,N3) * N3";
    then
A31: log(2,N3) / N3 >= 1/2 by A28,XCMPLX_0:def 7;
    N3 >= N0 by A19,A28,XXREAL_0:2;
    then
A32: |.q.N3-0.| < 1/2 by A12;
    q.N3 = p.N3 / g.N3 by Lm4
      .= log(2,N3) / g.N3 by A28,Def2
      .= log(2,N3) / (N3 to_power 1) by A28,Def3
      .= log(2,N3) / N3 by POWER:25;
    hence contradiction by A31,A32,ABSVALUE:def 1;
  end;
  now
    let n be Nat;
A33:  n in NAT by ORDINAL1:def 12;
    assume n >= 0;
A34: n+0 <= n+1 by XREAL_1:6;
A35: g.n = n
    proof
      per cases;
      suppose
        n = 0;
        hence thesis by Def3;
      end;
      suppose
        n > 0;
        hence g.n = n to_power 1 by Def3,A33
          .= n by POWER:25;
      end;
    end;
    g.(n+1) = (n+1) to_power 1 by Def3
      .= n+1 by POWER:25;
    hence g.n <= g.(n+1) by A35,A34;
  end;
  then
A36: g is eventually-nondecreasing;
  h is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  then g is_smooth_wrt 2 by A36,A1;
  hence g is smooth by ASYMPT_0:37;
A37: 3 = 4-1;
  hereby
    assume f is eventually-nondecreasing;
    then consider N being Nat such that
A38: for n being Nat st n >= N holds f.n <= f.(n+1);
    set N1 = (2 to_power (N+2)) - 1;
A39: 2 to_power 2 = 2^2 by POWER:46
      .= 4;
A40: N+2 >= 0+2 by XREAL_1:6;
    then 2 to_power (N+2) >= 2 to_power 2 by PRE_FF:8;
    then N1 >= 3 by A37,A39,XREAL_1:9;
    then reconsider N1 as Element of NAT by INT_1:3;
    2 to_power (N+2) > (N+2) + 1 by A40,Lm1;
    then
A41: N1 > (N+2) by XREAL_1:20;
    N+2 >= N+0 by XREAL_1:6;
    then
A42: N1 >= N by A41,XXREAL_0:2;
    N1+1 in POWEROF2SET;
    then
A43: f.(N1+1) = N1+1 by A5;
    not N1 in POWEROF2SET by A40,Lm49;
    then f.N1 = 2 to_power N1 by A5;
    then f.N1 > f.(N1+1) by A43,A41,POWER:39;
    hence contradiction by A38,A42;
  end;
end;

theorem :: Part b)
  for f,g being Real_Sequence st (for n st n > 0 holds f.n = (n to_power
(2 to_power [\log(2,n)/] ))) & (for n st n > 0 holds g.n = (n to_power n)) ex s
  being eventually-positive Real_Sequence st s = g & f in Big_Theta(s,
  POWEROF2SET) & not f in Big_Theta(s) & f is eventually-nondecreasing & s is
  eventually-nondecreasing & not s is_smooth_wrt 2
proof
  set X = POWEROF2SET;
  let f,g be Real_Sequence such that
A1: for n st n > 0 holds f.n = (n to_power (2 to_power [\log(2,n)/] )) and
A2: for n st n > 0 holds g.n = (n to_power n);
A3: g is eventually-positive
  proof
    take 1;
    let n be Nat;
A4:  n in NAT by ORDINAL1:def 12;
    assume
A5: n >= 1;
    then g.n = n to_power n by A2,A4;
    hence thesis by A5,POWER:34;
  end;
  set h = (g taken_every 2);
  reconsider g as eventually-positive Real_Sequence by A3;
A6: now
    let n such that
A7: n >= 1 and
A8: n in X;
    consider n1 being Element of NAT such that
A9: n = 2 to_power n1 by A8;
A10: f.n = n to_power (2 to_power [\log(2,n)/]) by A1,A7;
    log(2,n) = n1*log(2,2) by A9,POWER:55
      .= n1*1 by POWER:52;
    then
A11: f.n = n to_power n by A10,A9;
    hence 1*g.n <= f.n by A2,A7;
    thus f.n <= 1*g.n by A2,A7,A11;
  end;
A12: Big_Theta(g) = { t where t is Element of Funcs(NAT, REAL) : ex c,d,N st
c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n } by
ASYMPT_0:27;
A13: now
    assume f in Big_Theta(g);
    then consider t being Element of Funcs(NAT, REAL) such that
A14: t = f and
A15: ex c,d,N st c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n &
    t.n <= c*g.n by A12;
    consider c,d,N such that
    c > 0 and
A16: d > 0 and
A17: for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n by A15;
    set N1 = max([/1/d\], max(N, 2));
A18: N1 >= [/1/d\] by XXREAL_0:25;
A19: N1 is Integer by XXREAL_0:16;
A20: N1 >= max(N, 2) by XXREAL_0:25;
    max(N, 2) >= N by XXREAL_0:25;
    then
A21: N1 >= N by A20,XXREAL_0:2;
    max(N, 2) >= 2 by XXREAL_0:25;
    then
A22: N1 >= 2 by A20,XXREAL_0:2;
    reconsider N1 as Element of NAT by A20,A19,INT_1:3;
    reconsider N2 = 2 to_power N1 as Element of NAT;
A23: N2 > N1 + 1 by A22,Lm1;
    N1 > 1 by A22,XXREAL_0:2;
    then 2 to_power (N1+1) - 2 to_power N1 > 1 by Lm48;
    then 2 to_power (N1+1) > N2 + 1 by XREAL_1:20;
    then log(2, 2 to_power (N1+1)) > log(2, N2+1) by POWER:57;
    then (N1+1)*log(2,2) > log(2, N2+1) by POWER:55;
    then
A24: (N1+1)*1 > log(2, N2+1) by POWER:52;
A25: now
      assume [\log(2,N2+1)/] > N1;
      then
A26:  [\log(2,N2+1)/] >= N1 + 1 by INT_1:7;
      log(2,N2+1) >= [\log(2,N2+1)/] by INT_1:def 6;
      hence contradiction by A24,A26,XXREAL_0:2;
    end;
A27: g.(N2+1) = (N2+1) to_power (N2+1) by A2;
    then
A28: g.(N2+1) > 0 by POWER:34;
    N1+1 > N1+0 by XREAL_1:8;
    then
A29: N2 > N1 by A23,XXREAL_0:2;
A30: N2+1 > N2+0 by XREAL_1:8;
    then N2+1 > N1 by A29,XXREAL_0:2;
    then N2+1 > N by A21,XXREAL_0:2;
    then
A31: d*g.(N2+1) <= t.(N2+1) by A17;
    [/1/d\] >= 1/d by INT_1:def 7;
    then N1 >= 1/d by A18,XXREAL_0:2;
    then N2 >= 1/d by A29,XXREAL_0:2;
    then
A32: N2+1 > 1/d + 0 by XREAL_1:8;
    log(2,N2) = N1*log(2,2) by POWER:55
      .= N1*1 by POWER:52;
    then log(2,N2+1) > N1 by A23,A30,POWER:57;
    then [\log(2,N2+1)/] >= [\N1/] by PRE_FF:9;
    then
A33: [\log(2,N2+1)/] >= N1;
    t.(N2+1) = (N2+1) to_power (2 to_power [\log(2,N2+1)/]) by A1,A14;
    then g.(N2+1) / t.(N2+1) = (N2+1) to_power (N2+1) / (N2+1) to_power N2 by
A27,A33,A25,XXREAL_0:1
      .= (N2+1) to_power ((N2+1) - N2) by POWER:29
      .= N2+1 by POWER:25;
    then 1 / (g.(N2+1) / t.(N2+1)) < 1/(1/d) by A16,A32,XREAL_1:88;
    then t.(N2+1) / g.(N2+1) < d by XCMPLX_1:57;
    then t.(N2+1) / g.(N2+1) * g.(N2+1) < d*g.(N2+1) by A28,XREAL_1:68;
    hence contradiction by A31,A28,XCMPLX_1:87;
  end;
A34: now
    assume g is_smooth_wrt 2;
    then consider t being Element of Funcs(NAT, REAL) such that
A35: t = h and
A36: ex c,N st c > 0 & for n st n >= N holds t.n <= c*g.n & t.n >= 0;
    consider c,N such that
    c > 0 and
A37: for n st n >= N holds t.n <= c*g.n & t.n >= 0 by A36;
    set N0 = max( [/c\], max(N, 2) );
A38: N0 >= [/c\] by XXREAL_0:25;
A39: N0 is Integer by XXREAL_0:16;
A40: N0 >= max(N, 2) by XXREAL_0:25;
    max(N, 2) >= N by XXREAL_0:25;
    then
A41: N0 >= N by A40,XXREAL_0:2;
A42: max(N, 2) >= 2 by XXREAL_0:25;
    then
A43: 2*N0 > 1*N0 by A40,XREAL_1:68;
A44: N0 >= 2 by A40,A42,XXREAL_0:2;
    then
A45: N0 > 1 by XXREAL_0:2;
    reconsider N0 as Element of NAT by A40,A39,INT_1:3;
    [/c\] >= c by INT_1:def 7;
    then
A46: N0 >= c by A38,XXREAL_0:2;
    N0 >= 1 by A44,XXREAL_0:2;
    then N0 + N0 >= N0 + 1 by XREAL_1:6;
    then
A47: N0 to_power (2*N0) >= N0 to_power (N0+1) by A45,PRE_FF:8;
    N0 to_power (N0+1) = (N0 to_power N0)*(N0 to_power 1) by A40,A42,POWER:27
      .= (N0 to_power N0)*N0 by POWER:25;
    then
A48: N0 to_power (N0+1) >= c*(N0 to_power N0) by A46,XREAL_1:64;
    h.N0 = g.(2*N0) by ASYMPT_0:def 15
      .= (2*N0) to_power (2*N0) by A2,A43;
    then h.N0 > N0 to_power (2*N0) by A40,A42,A43,POWER:37;
    then h.N0 > N0 to_power (N0+1) by A47,XXREAL_0:2;
    then h.N0 > c*(N0 to_power N0) by A48,XXREAL_0:2;
    then h.N0 > c*g.N0 by A2,A40,A42;
    hence contradiction by A35,A37,A41;
  end;
A49: now
    let n be Nat;
A50:  n in NAT by ORDINAL1:def 12;
A51: f.(n+1) = (n+1) to_power (2 to_power [\log(2,(n+1))/]) by A1;
    assume
A52: n >= 2;
    then
A53: f.n = n to_power (2 to_power [\log(2,n)/]) by A1,A50;
A54: n + 1 > n + 0 by XREAL_1:8;
    then log(2,n) <= log(2,(n+1)) by A52,POWER:57;
    then [\log(2,n)/] <= [\log(2,(n+1))/] by PRE_FF:9;
    then
A55: 2 to_power [\log(2,n)/] <= 2 to_power [\log(2,(n+1))/] by PRE_FF:8;
    n+1 > 0+1 by A52,XREAL_1:8;
    then
A56: (n+1) to_power (2 to_power [\log(2,n)/]) <= (n+1) to_power (2
    to_power [\log(2,(n+1))/]) by A55,PRE_FF:8;
    log(2,n) >= log(2,2) by A52,PRE_FF:10;
    then log(2,n) >= 1 by POWER:52;
    then [\log(2,n)/] >= [\1/] by PRE_FF:9;
    then [\log(2,n)/] >= 1;
    then 2 to_power [\log(2,n)/] > 2 to_power 0 by POWER:39;
    then
    n to_power (2 to_power [\log(2,n)/]) <= (n+1) to_power (2 to_power [\
    log(2,n)/]) by A52,A54,POWER:37;
    hence f.n <= f.(n+1) by A53,A51,A56,XXREAL_0:2;
  end;
A57: now
    let n be Nat;
A58:  n in NAT by ORDINAL1:def 12;
    assume
A59: n >= 1;
A60: n + 1 > n + 0 by XREAL_1:8;
    then
A61: n to_power n < (n+1) to_power n by A59,POWER:37;
    n+1 >= 1+1 by A59,XREAL_1:6;
    then n+1 > 1 by XXREAL_0:2;
    then
A62: (n+1) to_power n < (n+1) to_power (n+1) by A60,POWER:39;
A63: g.(n+1) = (n+1) to_power (n+1) by A2;
    g.n = n to_power n by A2,A59,A58;
    hence g.n <= g.(n+1) by A63,A62,A61,XXREAL_0:2;
  end;
  take g;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  hence thesis by A6,A13,A49,A57,A34;
end;

theorem
  for g being Real_Sequence st (for n holds (n in POWEROF2SET implies g.
  n = n) & (not n in POWEROF2SET implies g.n = n to_power 2))
 ex s being
  eventually-positive Real_Sequence st s = g & seq_n^(1) in Big_Theta(s,
  POWEROF2SET) & not seq_n^(1) in Big_Theta(s) & s taken_every 2 in Big_Oh(s) &
  seq_n^(1) is eventually-nondecreasing & s is not eventually-nondecreasing
proof
  let g be Real_Sequence such that
A1: for n holds (n in POWEROF2SET implies g.n = n) & (not n in
  POWEROF2SET implies g.n = n to_power 2);
A2: g is eventually-positive
  proof
    take 1;
    let n be Nat;
A3:  n in NAT by ORDINAL1:def 12;
    assume
A4: n >= 1;
    thus g.n > 0
    proof
      per cases;
      suppose
        n in POWEROF2SET;
        hence thesis by A1,A4;
      end;
      suppose
        not n in POWEROF2SET;
        then g.n = n to_power 2 by A1,A3;
        hence thesis by A4,POWER:34;
      end;
    end;
  end;
  set h = (g taken_every 2);
  reconsider s=g as eventually-positive Real_Sequence by A2;
  take s;
  thus s = g;
  set X = POWEROF2SET;
  set f = seq_n^(1);
A5: h is Element of Funcs(NAT, REAL) by FUNCT_2:8;
A6: now
    let n;
    assume n >= 0;
A7: h.n = g.(2*n) by ASYMPT_0:def 15;
    thus h.n <= 4*g.n
    proof
      per cases;
      suppose
A8:     n in POWEROF2SET;
        then consider m such that
A9:     n = 2 to_power m;
        2*n = (2 to_power 1)*(2 to_power m) by A9,POWER:25
          .= 2 to_power (m+1) by POWER:27;
        then 2*n in POWEROF2SET;
        then
A10:     g.(2*n) = 2*n by A1;
        g.n = n by A1,A8;
        hence thesis by A7,A10,XREAL_1:64;
      end;
      suppose
A11:    not n in POWEROF2SET;
        now
          assume 2*n in POWEROF2SET;
          then consider m such that
A12:      2*n = 2 to_power m;
          thus contradiction
          proof
            per cases;
            suppose
A13:          m = 0;
A14:          now
                assume 1/2 is Element of NAT;
                then 0+1 <= 1/2 by NAT_1:13;
                hence contradiction;
              end;
              (n*2)*2" = 1*2" by A12,A13,POWER:24;
              hence thesis by A14;
            end;
            suppose
              m > 0;
              then m >= 0+1 by NAT_1:13;
              then
A15:          m-1 is Element of NAT by INT_1:3;
              2*n = 2 to_power ((m+-1)+1) by A12
                .= (2 to_power (m-1))*(2 to_power 1) by POWER:27
                .= (2 to_power (m-1))*2 by POWER:25;
              hence thesis by A11,A15;
            end;
          end;
        end;
        then
A16:    g.(2*n) = (2*n) to_power 2 by A1
          .= (2*n)^2 by POWER:46
          .= 4*n^2;
        g.n = n to_power 2 by A1,A11
          .= n^2 by POWER:46;
        hence thesis by A16,ASYMPT_0:def 15;
      end;
    end;
    thus h.n >= 0
    proof
      per cases;
      suppose
        (2*n) in POWEROF2SET;
        hence thesis by A1,A7;
      end;
      suppose
        not (2*n) in POWEROF2SET;
        then g.(2*n) = (2*n) to_power 2 by A1;
        hence thesis by ASYMPT_0:def 15;
      end;
    end;
  end;
A17: Big_Theta s = { t where t is Element of Funcs(NAT, REAL) : ex c,d,N st
c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n } by
ASYMPT_0:27;
A18: now
    assume f in Big_Theta s;
    then consider t being Element of Funcs(NAT, REAL) such that
A19: t = f and
A20: ex c,d,N st c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n &
    t.n <= c*g.n by A17;
    consider c,d,N such that
    c > 0 and
A21: d > 0 and
A22: for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n by A20;
    set N0 = max(max(N,2), [/1/d\]);
A23: N0 >= max(N,2) by XXREAL_0:25;
    max(N,2) >= N by XXREAL_0:25;
    then
A24: N0 >= N by A23,XXREAL_0:2;
A25: N0 >= [/1/d\] by XXREAL_0:25;
A26: max(N,2) >= 2 by XXREAL_0:25;
    then
A27: N0 >= 2 by A23,XXREAL_0:2;
    N0 is Integer by XXREAL_0:16;
    then reconsider N0 as Element of NAT by A23,INT_1:3;
    set N1 = (2 to_power N0) - 1;
    2 to_power N0 > 0 by POWER:34;
    then 2 to_power N0 >= 0 + 1 by NAT_1:13;
    then reconsider N1 as Element of NAT by INT_1:3;
A28: [/1/d\] >= 1/d by INT_1:def 7;
    not N1 in POWEROF2SET by A23,A26,Lm49,XXREAL_0:2;
    then
A29: g.N1 = N1 to_power 2 by A1
      .= N1^2 by POWER:46;
    2 to_power N0 > N0 + 1 by A27,Lm1;
    then
A30: N1 > N0 by XREAL_1:20;
    then
A31: N1 >= N by A24,XXREAL_0:2;
    N1 > [/1/d\] by A25,A30,XXREAL_0:2;
    then N1 > 1/d by A28,XXREAL_0:2;
    then N1*N1 > N1*(1/d) by A30,XREAL_1:68;
    then d*N1^2 > (N1*(1/d))*d by A21,XREAL_1:68;
    then d*N1^2 > N1*(1/d*d);
    then
A32: d*N1^2 > N1*1 by A21,XCMPLX_1:87;
    t.N1 = N1 to_power 1 by A19,A30,Def3
      .= N1 by POWER:25;
    hence contradiction by A22,A31,A32,A29;
  end;
A33: 3 = 4-1;
A34: now
    assume g is eventually-nondecreasing;
    then consider N being Nat such that
A35: for n being Nat st n >= N holds g.n <= g.(n+1);
    set N0 = max(N, 1);
    set N1 = (2 to_power (2*N0)) - 1;
A36: N0 >= N by XXREAL_0:25;
    2 to_power (2*N0) >= 2 to_power 0 by PRE_FF:8;
    then 2 to_power (2*N0) >= 1 by POWER:24;
    then (2 to_power (2*N0)) - 1 >= 1 - 1 by XREAL_1:9;
    then reconsider N1 as Element of NAT by INT_1:3;
A37: 2*N0 >= 2*1 by XREAL_1:64,XXREAL_0:25;
    then 2 to_power (2*N0) > 2*N0 + 1 by Lm1;
    then
A38: N1 > 2*N0 by XREAL_1:20;
    2 to_power (2*N0) >= 2 to_power 2 by A37,PRE_FF:8;
    then 2 to_power (2*N0) >= 2^2 by POWER:46;
    then N1 >= 3 by A33,XREAL_1:9;
    then N1 >= 2 by XXREAL_0:2;
    then
A39: N1^2 > N1+1 by Lm47;
A40:  2*N0 in NAT by ORDINAL1:def 12;
    2*N0 >= 2*1 by XREAL_1:64,XXREAL_0:25;
    then not N1 in POWEROF2SET by Lm49;
    then
A41: g.N1 = N1 to_power 2 by A1;
    2*N0 >= 1*N0 by XREAL_1:64;
    then N1 >= N0 by A38,XXREAL_0:2;
    then
A42: N1 >= N by A36,XXREAL_0:2;
    N1+1 in POWEROF2SET by A40;
    then g.(N1+1) = N1+1 by A1;
    then g.N1 > g.(N1+1) by A41,A39,POWER:46;
    hence contradiction by A35,A42;
  end;
A43: now
    let n be Nat;
A44:  n in NAT by ORDINAL1:def 12;
    assume n >= 0;
A45: n+0 <= n+1 by XREAL_1:6;
A46: f.n = n
    proof
      per cases;
      suppose
        n = 0;
        hence thesis by Def3;
      end;
      suppose
        n > 0;
        hence f.n = n to_power 1 by Def3,A44
          .= n by POWER:25;
      end;
    end;
    f.(n+1) = (n+1) to_power 1 by Def3
      .= n+1 by POWER:25;
    hence f.n <= f.(n+1) by A46,A45;
  end;
  reconsider jj = 1 as Real;
  reconsider j = 1 as Element of NAT;
A47: now
    let n such that
A48: n >= j and
A49: n in X;
A50: f.n = n to_power 1 by A48,Def3
      .= n by POWER:25;
    hence jj*s.n <= f.n by A1,A49;
    thus f.n <= jj*s.n by A1,A49,A50;
  end;
  f is Element of Funcs(NAT, REAL) by FUNCT_2:8;
  hence seq_n^(1) in Big_Theta(s,POWEROF2SET) by A47;
 thus thesis by A18,A5,A6,A43,A34;
end;

begin :: Problem 3.31

Lm50: for n being Nat st n >= 2 holds n! > 1
proof
  defpred P[Nat] means $1! > 1;
A1: for k be Nat st k >= 2 & P[k] holds P[k+1]
  proof
    let k be Nat such that
A2: k >= 2 and
A3: k! > 1;
A4: k+1 > 0+1 by A2,XREAL_1:6;
    (k+1)*(k!) > (k+1)*1 by A3,XREAL_1:68;
    then (k+1)*(k!) > 1 by A4,XXREAL_0:2;
    hence thesis by NEWTON:15;
  end;
A5: P[2] by NEWTON:14;
  for n be Nat st n >= 2 holds P[n] from NAT_1:sch 8(A5, A1);
  hence thesis;
end;

Lm51: for n1, n being Nat st n <= n1 holds n! <= n1!
proof
  defpred P[Nat] means for n being Nat st n <= $1 holds n! <= ($1)!;
A1: for k being Nat st P[k] holds P[k+1]
  proof
    let k be Nat such that
A2: for n being Nat st n <= k holds n! <= k!;
    let n be Nat such that
A3: n <= k+1;
    per cases by A3,NAT_1:8;
    suppose
A4:   n <= k;
      k+1 >= 0+1 by XREAL_1:6;
      then (k+1)*(k!) >= 1*(k!) by XREAL_1:64;
      then
A5:   (k+1)! >= k! by NEWTON:15;
      n! <= k! by A2,A4;
      hence thesis by A5,XXREAL_0:2;
    end;
    suppose
      n = k+1;
      hence thesis;
    end;
  end;
A6: P[0];
  for n1 being Nat holds P[n1] from NAT_1:sch 2(A6, A1);
  hence thesis;
end;

Lm52: for k st k >= 1 holds
  ex n st (n! <= k & k < (n+1)! & for m st m! <= k & k < (m+1)! holds m = n)
proof
  defpred P[Nat] means ex n st (n! <= $1 & $1 < (n+1)! & for m st m! <= $1 &
  $1 < (m+1)! holds m = n);
A1: for k be Nat st k >= 1 & P[k] holds P[k+1]
  proof
    let k be Nat;
    assume that
    k >= 1 and
A2: ex n st (n! <= k & k < (n+1)! & for m st m! <= k & k < (m+1)! holds m = n);
    consider n such that
A3: n! <= k and
A4: k < (n+1)! and
    for m st m! <= k & k < (m+1)! holds m = n by A2;
A5: k+1 <= (n+1)! by A4,INT_1:7;
    per cases by A5,XXREAL_0:1;
    suppose
A6:   k+1 < (n+1)!;
      take n;
      k+0 <= k+1 by XREAL_1:6;
      hence n! <= k+1 by A3,XXREAL_0:2;
      thus k+1 < (n+1)! by A6;
      let m;
      assume that
A7:   m! <= k+1 and
A8:   k+1 < (m+1)!;
      now
        assume
A9:     m <> n;
        thus contradiction
        proof
          per cases by A9,XXREAL_0:1;
          suppose
            m > n;
            then m >= n+1 by NAT_1:13;
            then m! >= (n+1)! by Lm51;
            hence thesis by A6,A7,XXREAL_0:2;
          end;
          suppose
            m < n;
            then m+1 <= n by NAT_1:13;
            then (m+1)! <= n! by Lm51;
            then
A10:        (m+1)! <= k by A3,XXREAL_0:2;
            k <= k+1 by NAT_1:11;
            hence thesis by A8,A10,XXREAL_0:2;
          end;
        end;
      end;
      hence thesis;
    end;
    suppose
A11:  k+1 = (n+1)!;
      take N = n+1;
      thus N! <= k+1 by A11;
A12:  N! > 0 by NEWTON:17;
      N+1 > 0+1 by XREAL_1:6;
      then (N+1)*(N!) > 1*(N!) by A12,XREAL_1:68;
      hence k+1 < (N+1)! by A11,NEWTON:15;
      let m;
      assume that
A13:  m! <= k+1 and
A14:  k+1 < (m+1)!;
      now
        assume
A15:    m <> N;
        thus contradiction
        proof
          per cases by A15,XXREAL_0:1;
          suppose
            m > N;
            then m >= N+1 by NAT_1:13;
            then m! >= (N+1)! by Lm51;
            then
A16:        k+1 >= (N+1)! by A13,XXREAL_0:2;
            n + 2 >= 0 + 2 by XREAL_1:6;
            then
A17:        N+1 > 1 by XXREAL_0:2;
            N! > 0 by NEWTON:17;
            then (N+1)*(N!) > 1*(N!) by A17,XREAL_1:68;
            hence thesis by A11,A16,NEWTON:15;
          end;
          suppose
            m < N;
            then m+1 <= N by NAT_1:13;
            hence thesis by A11,A14,Lm51;
          end;
        end;
      end;
      hence thesis;
    end;
  end;
A18: P[1]
  proof
    take 1;
    thus 1! <= 1 & 1 < (1+1)! by NEWTON:13,14;
    let m;
    assume that
A19: m! <= 1 and
A20: 1 < (m+1)!;
A21: now
      assume m > 1;
      then m >= 1+1 by NAT_1:13;
      hence contradiction by A19,Lm50;
    end;
    m <> 0 by A20,NEWTON:13;
    then m >= 0+1 by NAT_1:13;
    hence thesis by A21,XXREAL_0:1;
  end;
  for k be Nat st k >= 1 holds P[k] from NAT_1:sch 8(A18,A1);
  hence thesis;
end;

definition
  let x be Nat;
  func Step1(x) -> Element of NAT means
  :Def6:
  ex n st n! <= x & x < (n+1)! & it = n! if x <> 0 otherwise it = 0;
  consistency;
  existence
  proof
A1: x in NAT by ORDINAL1:def 12;
    hereby
      assume x <> 0;
      then x >= 0+1 by NAT_1:13;
      then consider k being Element of NAT such that
A2:   k! <= x and
A3:   x < (k+1)! and
      for m st m! <= x & x < (m+1)! holds m = k by Lm52,A1;
      consider k1 being Real such that
A4:   k1 = k!;
      reconsider k1 as Element of NAT by A4;
      take k1;
      thus ex m st m! <= x & x < (m+1)! & k1 = m! by A2,A3,A4;
    end;
    thus thesis;
  end;
  uniqueness
  proof
    let n1, n2 be Element of NAT;
    now
      assume that
A5:   ex n st n! <= x & x < (n+1)! & n1 = n! and
A6:   ex n st n! <= x & x < (n+1)! & n2 = n!;
      consider n such that
A7:   n! <= x and
A8:   x < (n+1)! and
A9:   n1 = n! by A5;
      consider m such that
A10:   m! <= x and
A11:  x < (m+1)! and
A12:  n2 = m! by A6;
      now
        assume
A13:    m <> n;
        thus contradiction
        proof
          per cases by A13,XXREAL_0:1;
          suppose
            m > n;
            then m >= n+1 by INT_1:7;
            then m! >= (n+1)! by Lm51;
            hence thesis by A8,A10,XXREAL_0:2;
          end;
          suppose
            m < n;
            then m+1 <= n by INT_1:7;
            then (m+1)! <= n! by Lm51;
            hence thesis by A7,A11,XXREAL_0:2;
          end;
        end;
      end;
      hence n1 = n2 by A9,A12;
    end;
    hence thesis;
  end;
end;

Lm53: for n being Nat st n >= 3 holds n! > n
proof
  let n be Nat;
  assume
A1: n >= 3;
  set n1 = n-1;
  2 = 3-1;
  then
A2: n1 >= 2 by A1,XREAL_1:9;
  then reconsider n1 as Element of NAT by INT_1:3;
  n1! >= 2 by A2,Lm51,NEWTON:14;
  then n1! > 1 by XXREAL_0:2;
  then
A3: n*(n1!) > n*1 by A1,XREAL_1:68;
  n1+1 = n;
  hence thesis by A3,NEWTON:15;
end;

theorem
  for f being Real_Sequence st (for n holds f.n = Step1(n))
  ex s being eventually-positive Real_Sequence st s = f
  & s is not smooth & (for n holds f.n <= (seq_n^(1)).n)
  & f is eventually-nondecreasing
proof
  set g = seq_n^(1);
  let f be Real_Sequence such that
A1: for n holds f.n = Step1(n);
  f is eventually-positive
  proof
    take 1;
    let n be Nat;
A2:  n in NAT by ORDINAL1:def 12;
    assume n >= 1;
    then
A3: ex m st m! <= n & n < (m+1)! & Step1(n) = m! by Def6;
    f.n = Step1(n) by A1,A2;
    hence thesis by A3,NEWTON:17;
  end;
  then reconsider s=f as eventually-positive Real_Sequence;
  take s;
  thus s=f;
  now
    let k;
    thus f.k <= f.(k+1)
    proof
      per cases;
      suppose
A4:     k = 0;
A5:     f.(0+1) = Step1(1) by A1;
        f.0 = Step1(0) by A1
          .= 0 by Def6;
        hence thesis by A4,A5;
      end;
      suppose
        k > 0;
        then consider n1 such that
A6:     n1! <= k and
A7:     k < (n1+1)! and
A8:     Step1(k) = n1! by Def6;
A9:     k+1 <= (n1+1)! by A7,INT_1:7;
A10:     k <= k+1 by NAT_1:11;
A11:    f.k = n1! by A1,A8;
        per cases by A9,XXREAL_0:1;
        suppose
A12:      k+1 < (n1+1)!;
          n1! <= k+1 by A10,A6,XXREAL_0:2;
          then Step1(k+1) = n1! by A12,Def6;
          hence thesis by A1,A11;
        end;
        suppose
A13:      k+1 = (n1+1)!;
A14:      (n1+1)! > 0 by NEWTON:17;
          n1 + 2 > 0 + 1 by XREAL_1:8;
          then 1*((n1+1)!) < (n1+2)*((n1+1)!) by A14,XREAL_1:68;
          then
A15:      k+1 < ((n1+1)+1)! by A13,NEWTON:15;
          f.(k+1) = Step1(k+1) by A1
            .= (n1+1)! by A13,A15,Def6;
          hence thesis by A11,Lm51,NAT_1:11;
        end;
      end;
    end;
  end;
  then
A16: for k st k >= 0 holds f.k <= f.(k+1);
A17: 1 = 2-1;
  hereby
    set h = (f taken_every 2);
    assume s is smooth;
    then s is_smooth_wrt 2;
    then consider t being Element of Funcs(NAT, REAL) such that
A18: t = h and
A19: ex c,N st c > 0 & for n st n >= N holds t.n <= c*f.n & t.n >= 0;
    consider c,N such that
    c > 0 and
A20: for n st n >= N holds t.n <= c*f.n & t.n >= 0 by A19;
    set n2 = max(max(N,3), [/c\]+1);
A21: n2 >= max(N,3) by XXREAL_0:25;
    max(N,3) >= N by XXREAL_0:25;
    then
A22: n2 >= N by A21,XXREAL_0:2;
A23: n2 >= [/c\]+1 by XXREAL_0:25;
A24: n2 is Integer by XXREAL_0:16;
A25: max(N,3) >= 3 by XXREAL_0:25;
    then
A26: n2 >= 3 by A21,XXREAL_0:2;
    reconsider n2 as Element of NAT by A21,A24,INT_1:3;
    set n1 = n2!-1;
A27: n2 > 2 by A26,XXREAL_0:2;
    then
A28: n2! >= 2 by Lm51,NEWTON:14;
    then
A29: n1 >= 1 by A17,XREAL_1:9;
    set n3 = n2-1;
    1+1 <= n2 by A26,XXREAL_0:2;
    then
A30: 1 <= n2-1 by XREAL_1:19;
A31: n3 >= 1 by A17,A27,XREAL_1:9;
    reconsider n1 as Element of NAT by A29,INT_1:3;
A32: t.n1 = f.(2*n1) by A18,ASYMPT_0:def 15;
    n2! > n2 by A26,Lm53;
    then n2! >= n2 + 1 by INT_1:7;
    then n1 >= n2 by XREAL_1:19;
    then n1 >= N by A22,XXREAL_0:2;
    then
A33: t.n1 <= c*f.n1 by A20;
    n2 < n2+1 by NAT_1:13;
    then n2*(n2!) < (n2+1)*(n2!) by A28,XREAL_1:68;
    then
A34: n2*(n2!) < (n2+1)! by NEWTON:15;
    n2! + 2 <= n2! + n2! by A28,XREAL_1:6;
    then
A35: n2! <= 2*(n2!) - 2*1 by XREAL_1:19;
A36: n2!-1 < n2!-0 by XREAL_1:15;
    then
A37: 2*n1 < 2*(n2!) by XREAL_1:68;
    reconsider n3 as Element of NAT by A31,INT_1:3;
    n3! >= 1 by A31,Lm51,NEWTON:13;
    then 1*1 <= (n2-1)*(n3!) by A30,Lm20;
    then n2*1 <= (n2-1)*(n3!)*n2 by XREAL_1:64;
    then n2 <= (n2-1)*((n3!)*(n3+1));
    then n2 <= (n2-1)*(n2!) by NEWTON:15;
    then
A38: n2! + n2 <= (n2!)*1 + (n2-1)*(n2!) by XREAL_1:6;
A39: n3+1 = n2+0;
    then n2*(n3!) = n2! by NEWTON:15;
    then n2*(n3!) <= n2*(n2!) - n2 by A38,XREAL_1:19;
    then n3! <= (n2*(n2!-1))/(n2*1) by A21,A25,XREAL_1:77;
    then
A40: n3! <= (n2! - 1)/1 by A21,A25,XCMPLX_1:91;
A41: [/c\] >= c by INT_1:def 7;
    [/c\] + 1 > [/c\] + 0 by XREAL_1:8;
    then [/c\] + 1 > c by A41,XXREAL_0:2;
    then
A42: n2 > c by A23,XXREAL_0:2;
A43: n3! > 0 by NEWTON:17;
    2*(n2!) <= n2*(n2!) by A27,XREAL_1:64;
    then 2*(n2!) < (n2+1)! by A34,XXREAL_0:2;
    then
A44: 2*n1 < (n2+1)! by A37,XXREAL_0:2;
A45: f.(2*n1) = Step1(2*n1) by A1
      .= (n3+1)! by A28,A44,A35,Def6
      .= n2*(n3!) by NEWTON:15;
    f.n1 = Step1(n1) by A1
      .= n3! by A29,A36,A39,A40,Def6;
    hence contradiction by A33,A32,A45,A42,A43,XREAL_1:68;
  end;
  hereby
    let n;
    thus f.n <= g.n
    proof
      per cases;
      suppose
A46:    n = 0;
        f.0 = Step1(0) by A1
          .= 0 by Def6;
        hence thesis by A46,Def3;
      end;
      suppose
A47:    n > 0;
        then
A48:    g.n = n to_power 1 by Def3
          .= n by POWER:25;
        ex n1 st n1! <= n & n < (n1+1)! & Step1(n) = n1! by A47,Def6;
        hence thesis by A1,A48;
      end;
    end;
  end;
  reconsider zz=0 as Nat;
  take zz;
  let n be Nat;
   n in NAT by ORDINAL1:def 12;
  hence thesis by A16;
end;

:: Problem 3.32 -- omitted (corresponding theory section omitted)
:: Problem 3.33 -- Proven in theorems ASYMPT_0:41, ASYMPT_0:42

begin :: Problem 3.34

Lm54: seq_n^(1) - seq_const(1) is eventually-positive
proof
  take 2;
  set g = seq_const(1);
  set f = seq_n^(1);
  let n be Nat;
A1:  n in NAT by ORDINAL1:def 12;
A2: g.n = 1 by FUNCOP_1:7,A1;
  assume
A3: n >= 2;
  then
A4: n > 1+0 by XXREAL_0:2;
A5: f.n = n to_power 1 by A3,Def3,A1
    .= n by POWER:25;
  (f-g).n = f.n + (-g).n by SEQ_1:7
    .= n + -1 by A5,A2,SEQ_1:10
    .= n-1;
  hence thesis by A4,XREAL_1:20;
end;

:: This is to show that Big_Theta(n-1) + Big_Theta(n) = Big_Theta(n).
:: Note that it is not true that Big_Theta(n) = Big_Theta(n) - Big_Theta(n-1).
:: Consider n and n. The function n - n = 0, which is not in Big_Theta(n).

theorem
  for F being eventually-nonnegative Real_Sequence st F = seq_n^(1) -
  seq_const(1) holds Big_Theta(F) + Big_Theta(seq_n^(1)) = Big_Theta(seq_n^(1))
proof
  set q = seq_const(1);
  set p = seq_n^(1);
  set f = p - q;
  set g = p;
A1: Big_Theta(g) = { t where t is Element of Funcs(NAT, REAL) : ex c,d,N st
c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n } by
ASYMPT_0:27;
  let F be eventually-nonnegative Real_Sequence;
  assume F = seq_n^(1) - seq_const(1);
  then
A2: Big_Theta(F) = { t where t is Element of Funcs(NAT, REAL) : ex c,d,N st
  c > 0 & d > 0 & for n st n >= N holds d*f.n <= t.n & t.n <= c*f.n } by
ASYMPT_0:27;
  now
    let x be object;
    hereby
      assume x in Big_Theta(F) + Big_Theta(g);
      then consider t being Element of Funcs(NAT, REAL) such that
A3:   t = x and
A4:   ex f9,g9 being Element of Funcs(NAT,REAL) st f9 in Big_Theta(F)
      & g9 in Big_Theta(g) & for n being Element of NAT holds t.n = f9.n + g9.n
      ;
      consider f9,g9 being Element of Funcs(NAT,REAL) such that
A5:   f9 in Big_Theta(F) and
A6:   g9 in Big_Theta(g) and
A7:   for n being Element of NAT holds t.n = f9.n + g9.n by A4;
      ex r being Element of Funcs(NAT,REAL) st r = f9 & ex c,d,N st c
      > 0 & d > 0 & for n st n >= N holds d*f.n <= r.n & r.n <= c*f.n by A2,A5;
      then consider c1,d1,N1 such that
A8:   c1 > 0 and
A9:   d1 > 0 and
A10:  for n st n >= N1 holds d1*f.n <= f9.n & f9.n <= c1*f.n;
      ex s being Element of Funcs(NAT,REAL) st s = g9 & 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 A1,A6;
      then consider c2,d2,N2 such that
A11:  c2 > 0 and
A12:  d2 > 0 and
A13:  for n st n >= N2 holds d2*g.n <= g9.n & g9.n <= c2*g.n;
      set d = d2, c = c1+c2;
      set N = max(1,max(N1,N2));
A14:  N >= 1 by XXREAL_0:25;
A15:  N>=max(N1,N2) by XXREAL_0:25;
      max(N1,N2)>= N2 by XXREAL_0:25;
      then
A16:  N >= N2 by A15,XXREAL_0:2;
      max(N1,N2)>=N1 by XXREAL_0:25;
      then
A17:  N >= N1 by A15,XXREAL_0:2;
      now
        let n;
A18:    (seq_const(1)).n = 1 by FUNCOP_1:7;
        assume
A19:    n >= N;
        then
A20:    g.n = (n to_power 1) by A14,Def3
          .= n by POWER:25;
        n >= 1 by A14,A19,XXREAL_0:2;
        then -n <= -1 by XREAL_1:24;
        then (-n)*d1 <= (-1)*d1 by A9,XREAL_1:64;
        then
A21:    n*(-d1) + (d1+d2)*n <= -d1 + (d1+d2)*n by XREAL_1:6;
A22:    f.n = (seq_n^(1)).n + (-seq_const(1)).n by SEQ_1:7
          .= (seq_n^(1)).n + -((seq_const(1)).n) by SEQ_1:10
          .= (n to_power 1) + -((seq_const(1)).n) by A14,A19,Def3
          .= n + -1 by A18,POWER:25;
A23:    n >= N2 by A16,A19,XXREAL_0:2;
        then d2*g.n <= g9.n by A13;
        then
A24:    d1*f.n + d2*g.n <= d1*f.n + g9.n by XREAL_1:6;
        g9.n <= c2*g.n by A13,A23;
        then
A25:    c1*f.n+g9.n<=c1*f.n+c2*g.n by XREAL_1:6;
A26:    n >= N1 by A17,A19,XXREAL_0:2;
        then f9.n <= c1*f.n by A10;
        then f9.n+g9.n<=c1*f.n+g9.n by XREAL_1:6;
        then
A27:    f9.n + g9.n <= c1*f.n + c2*g.n by A25,XXREAL_0:2;
        d1*f.n <= f9.n by A10,A26;
        then d1*f.n + g9.n <= f9.n + g9.n by XREAL_1:6;
        then d1*f.n + d2*g.n <= f9.n + g9.n by A24,XXREAL_0:2;
        then d2*n <= f9.n + g9.n by A20,A22,A21,XXREAL_0:2;
        hence d*g.n <= t.n by A7,A20;
        -c1 + (c1+c2)*n <= 0 + (c1+c2)*n by A8,XREAL_1:6;
        then f9.n + g9.n <= (c1+c2)*n by A20,A22,A27,XXREAL_0:2;
        hence t.n <= c*g.n by A7,A20;
      end;
      hence x in Big_Theta(g) by A1,A3,A8,A11,A12;
    end;
    assume x in Big_Theta(g);
    then consider t being Element of Funcs(NAT, REAL) such that
A28: t = x and
A29: ex c,d,N st c > 0 & d > 0 & for n st n >= N holds d*g.n <= t.n &
    t.n <= c*g.n by A1;
    consider c,d,N such that
A30: c > 0 and
A31: d > 0 and
A32: for n st n >= N holds d*g.n <= t.n & t.n <= c*g.n by A29;
    set f9 = 2"(#)t, g9 = 2"(#)t;
A33: f9 is Element of Funcs(NAT,REAL) by FUNCT_2:8;
A34: for n being Element of NAT holds t.n = f9.n + g9.n
    proof
      let n be Element of NAT;
      f9.n = 2"*t.n by SEQ_1:9;
      hence thesis;
    end;
A35: 2"*d > 2"*0 by A31,XREAL_1:68;
    set N0 = max(N, 2);
A36: N0 >= N by XXREAL_0:25;
A37: N0 >= 2 by XXREAL_0:25;
    reconsider N0 as Element of NAT;
A38: now
      let n;
      assume n >= N0;
      then
A39:  n >= N by A36,XXREAL_0:2;
      then
A40:  2"*t.n <= 2"*(c*g.n) by A32,XREAL_1:64;
      2"*(d*g.n) <= 2"*t.n by A32,A39,XREAL_1:64;
      hence 2"*d*g.n <= g9.n & g9.n <= 2"*c*g.n by A40,SEQ_1:9;
    end;
    2"*c > 2"*0 by A30,XREAL_1:68;
    then
A41: g9 in Big_Theta(g) by A1,A35,A33,A38;
    now
      let n;
A42:  q.n = 1 by FUNCOP_1:7;
      assume
A43:  n >= N0;
      then
A44:  g.n = (n to_power 1) - 0 by A37,Def3
        .= n-0 by POWER:25;
      n >= 2 by A37,A43,XXREAL_0:2;
      then n + 2 <= n + n by XREAL_1:6;
      then n <= 2*n - 2*1 by XREAL_1:19;
      then 2"*n <= 2"*(2*(n-1)) by XREAL_1:64;
      then
A45:  c*(2"*n) <= c*(n-1) by A30,XREAL_1:64;
A46:  n >= N by A36,A43,XXREAL_0:2;
      then
A47:  2"*(d*g.n) <= 2"*t.n by A32,XREAL_1:64;
A48:  f.n = p.n + (-q).n by SEQ_1:7
        .= p.n + -1 by A42,SEQ_1:10
        .= p.n - 1
        .= (n to_power 1) - 1 by A37,A43,Def3
        .= n-1 by POWER:25;
      then f.n <= g.n by A44,XREAL_1:13;
      then 2"*d*f.n <= 2"*d*g.n by A31,XREAL_1:64;
      then 2"*d*f.n <= 2"*t.n by A47,XXREAL_0:2;
      hence (2"*d)*f.n <= f9.n by SEQ_1:9;
      2"*t.n <= 2"*(c*g.n) by A32,A46,XREAL_1:64;
      then 2"*t.n <= c*f.n by A48,A44,A45,XXREAL_0:2;
      hence f9.n <= c*f.n by SEQ_1:9;
    end;
    then f9 in Big_Theta(F) by A2,A30,A35,A33;
    hence x in Big_Theta(F) + Big_Theta(g) by A28,A33,A41,A34;
  end;
  hence thesis by TARSKI:2;
end;

begin :: Problem 3.35

theorem
  ex F being FUNCTION_DOMAIN of NAT,REAL st F = { seq_n^(1) } & (for n
  holds (seq_n^(-1)).n <= (seq_n^(1)).n) & not seq_n^(-1) in F to_power Big_Oh(
  seq_const(1))
proof
  set t = seq_n^(-1);
  reconsider F = { seq_n^(1) } as FUNCTION_DOMAIN of NAT,REAL by FUNCT_2:121;
  take F;
  thus F = { seq_n^(1) };
A1: now
    let n;
    per cases;
    suppose
A2:   n = 0;
      then (seq_n^(-1)).n = 0 by Def3;
      hence (seq_n^(-1)).n <= (seq_n^(1)).n by A2,Def3;
    end;
    suppose
A3:   n > 0;
      then
A4:   n >= 0+1 by INT_1:7;
A5:   n to_power (-1) <= n to_power 1
      proof
        per cases by A4,XXREAL_0:1;
        suppose
A6:       n = 1;
          then n to_power (-1) = 1 by POWER:26;
          hence thesis by A6,POWER:26;
        end;
        suppose
          n > 1;
          hence thesis by PRE_FF:8;
        end;
      end;
      (seq_n^(-1)).n=n to_power (-1) by A3,Def3;
      hence (seq_n^(-1)).n <= (seq_n^(1)).n by A3,A5,Def3;
    end;
  end;
  now
    assume
A7: t in F to_power Big_Oh(seq_const(1));
    ex H being FUNCTION_DOMAIN of NAT,REAL st H = F &( t in H to_power
Big_Oh(seq_const(1)) iff ex N,c,k st c>0 & for n st n >= N holds 1 <= t.n & t.n
    <= c*(seq_n^(k)).n) by Th9;
    then consider N0,c,k such that
    c>0 and
A8: for n st n >= N0 holds 1 <= t.n & t.n <= c*(seq_n^(k)).n by A7;
    set N = max(N0,2);
A9: N >= 2 by XXREAL_0:25;
A10: N >= N0 by XXREAL_0:25;
    now
      let n;
      assume
A11:  n >= N;
      then n >= 2 by A9,XXREAL_0:2;
      then
A12:  n > 1 by XXREAL_0:2;
      n >= N0 by A10,A11,XXREAL_0:2;
      then
A13:  t.n >= 1 by A8;
      t.n = n to_power (-1) by A9,A11,Def3;
      hence contradiction by A13,A12,POWER:36;
    end;
    hence contradiction;
  end;
  hence thesis by A1;
end;

begin :: Addition
:: In theorem ASYMPT_0:14, if we restrict our attentions to functions that
:: do not have a subsequence that converges to 0, then the reverse implication
:: is true.

theorem
  for c being non negative Real, x,f being eventually-nonnegative
  Real_Sequence st ex e,N st e > 0 & for n st n >= N holds f.n >= e holds x in
  Big_Oh(c+f) implies x in Big_Oh(f)
proof
  let c be non negative Real, x,f be eventually-nonnegative Real_Sequence;
  given e,N0 such that
A1: e > 0 and
A2: for n st n >= N0 holds f.n >= e;
  assume x in Big_Oh(c+f);
  then consider t being Element of Funcs(NAT, REAL) such that
A3: x = t and
A4: ex d,N st d > 0 & for n st n >= N holds t.n <= d*(c+f).n & t.n >= 0;
  consider d,N1 such that
A5: d > 0 and
A6: for n st n >= N1 holds t.n <= d*(c+f).n & t.n >= 0 by A4;
  set b = max(2*d, (2*d*c)/e);
  2*d > 2*0 by A5,XREAL_1:68;
  then
A7: b > 0 by XXREAL_0:25;
  set N = max(N0, N1);
A8: N >= N1 by XXREAL_0:25;
A9: N >= N0 by XXREAL_0:25;
  now
    let n;
    assume
A10: n >= N;
    then
A11: n >= N1 by A8,XXREAL_0:2;
    then t.n <= d*(c+f).n by A6;
    then
A12: t.n <= d*(c+f.n) by VALUED_1:2;
A13: n >= N0 by A9,A10,XXREAL_0:2;
    thus t.n <= b*f.n
    proof
      per cases;
      suppose
        c >= f.n;
        then d*c >= d*f.n by A5,XREAL_1:64;
        then d*c + d*c >= d*c + d*f.n by XREAL_1:6;
        then t.n <= (2*(d*c))*1 by A12,XXREAL_0:2;
        then
A14:    t.n <= (2*(d*c))*((1/e)*e) by A1,XCMPLX_1:106;
        b*e >= ((2*d*c)/e)*e by A1,XREAL_1:64,XXREAL_0:25;
        then
A15:    t.n <= b*e by A14,XXREAL_0:2;
        b*f.n >= b*e by A2,A7,A13,XREAL_1:64;
        hence thesis by A15,XXREAL_0:2;
      end;
      suppose
        c < f.n;
        then d*c < d*f.n by A5,XREAL_1:68;
        then d*c + d*f.n < d*f.n + d*f.n by XREAL_1:6;
        then
A16:    t.n < 2*(d*f.n) by A12,XXREAL_0:2;
        f.n > 0 by A1,A2,A13;
        then b*f.n >= (2*d)*f.n by XREAL_1:64,XXREAL_0:25;
        hence thesis by A16,XXREAL_0:2;
      end;
    end;
    thus t.n >= 0 by A6,A11;
  end;
  hence thesis by A3,A7;
end;

begin :: Potentially Useful Facts

theorem
  2 to_power 12 = 4096 by Lm26;

theorem
  for n st n >= 3 holds n^2 > 2*n + 1 by Lm27;

theorem
  for n st n >= 10 holds 2 to_power (n-1) > (2*n)^2 by Lm28;

theorem
  for n st n >= 9 holds (n+1) to_power 6 < 2*(n to_power 6) by Lm29;

theorem
  for n st n >= 30 holds 2 to_power n > n to_power 6 by Lm30;

theorem
  for x being Real st x > 9 holds 2 to_power x > (2*x)^2 by Lm31;

theorem
  ex N st for n st n >= N holds sqrt n - log(2, n) > 1 by Lm32;

theorem
  for a,b,c being Real st a > 0 & c > 0 & c <> 1 holds
    a to_power b = c to_power (b*log(c,a)) by Lm3;

theorem
  5! = 120 by Lm33;

theorem
  5 to_power 5 = 3125 by Lm36;

theorem
  4 to_power 4 = 256 by Lm37;

theorem
  for n holds (n^2 - n + 1) > 0 by Lm21;

theorem
  for n being Nat st n >= 2 holds n! > 1 by Lm50;

theorem
  for n1, n being Nat st n <= n1 holds n! <= n1! by Lm51;

theorem
  for k st k >= 1 holds
    ex n st (n! <= k & k < (n+1)! &
      for m st m! <= k & k < (m+1)! holds m = n) by Lm52;

theorem
  for n being Nat st n >= 2 holds [/n/2\] < n by Lm46;

theorem
  for n being Nat st n >= 3 holds n! > n by Lm53;

theorem
  seq_n^(1) - seq_const(1) is eventually-positive by Lm54;

theorem
  for n st n >= 2 holds 2 to_power n > n+1 by Lm1;

theorem
  for a being logbase Real, f being Real_Sequence st a > 1 & f.0 = 0 & (
  for n st n > 0 holds f.n = log(a,n)) holds f is eventually-positive by Lm2;

theorem
  for f,g being eventually-nonnegative Real_Sequence holds f in Big_Oh(g
  ) & g in Big_Oh(f) iff Big_Oh(f) = Big_Oh(g) by Lm5;

theorem
  for a, b, c being Real st 0 < a & a <= b & c >= 0 holds a to_power c
  <= b to_power c by Lm6;

theorem
  for n st n >= 4 holds 2*n + 3 < 2 to_power n by Lm7;

theorem
  for n st n >= 6 holds (n+1)^2 < 2 to_power n by Lm8;

theorem
  for c being Real st c > 6 holds c^2 < 2 to_power c by Lm9;

theorem
  for e being positive Real, f being Real_Sequence st f.0 = 0 & (for n
st n > 0 holds f.n = log(2,n to_power e)) holds (f /" seq_n^(e)) is convergent
  & lim (f /" seq_n^(e)) = 0 by Lm10;

theorem
  for e being Real st e > 0 holds (seq_logn/"seq_n^(e)) is convergent &
  lim(seq_logn/"seq_n^(e)) = 0 by Lm11;

theorem
  for f being Real_Sequence holds for N holds (for n st n <= N holds f.n
  >= 0) implies Sum(f,N) >= 0 by Lm12;

theorem
  for f,g being Real_Sequence holds for N holds (for n st n <= N holds f
  .n <= g.n) implies Sum(f,N) <= Sum (g,N) by Lm13;

theorem
  for f being Real_Sequence, b being Real st f.0 = 0 & (for n st n > 0
  holds f.n = b) holds for N being Element of NAT holds Sum(f,N) = b*N by Lm14;

theorem
  for f being Real_Sequence, N,M being Element of NAT holds Sum(f,N,M) +
  f.(N+1) = Sum(f,N+1,M) by Lm15;

theorem
  for f,g being Real_Sequence, M being Element of NAT holds for N st N
  >= M+1 holds (for n st M+1 <= n & n <= N holds f.n <= g.n) implies Sum(f,N,M)
  <= Sum (g,N,M) by Lm16;

theorem
  for n holds [/n/2\] <= n by Lm17;

theorem
  for f being Real_Sequence, b being Real, N being Element of NAT st f.0
= 0 & (for n st n > 0 holds f.n = b) holds for M being Element of NAT holds Sum
  (f, N, M) = b*(N-M) by Lm18;

theorem
  for f,g being Real_Sequence, N being Element of NAT, c being Real st f
  is convergent & lim f = c & for n st n >= N holds f.n = g.n holds g is
  convergent & lim g = c by Lm22;

theorem
  for n st n >= 1 holds (n^2 -n + 1) <= n^2 by Lm23;

theorem
  for n st n >= 1 holds n^2 <= 2*(n^2 -n + 1) by Lm24;

theorem
  for e being Real st 0 < e & e < 1 holds ex N st for n st n >= N holds
  n*log(2,1+e) - 8*log(2,n) > 8*log(2,n) by Lm25;

theorem
  for n st n >= 10 holds 2 to_power (2*n) / (n!) < 1/(2 to_power (n-9))
  by Lm34;

theorem
  for n st n >= 3 holds 2*(n-2) >= n-1 by Lm35;

theorem
  for c being Real st c >= 0 holds c to_power (1/2) = sqrt c by Lm39;

theorem
  ex N st for n st n >= N holds n - sqrt n*log(2,n) > n/2 by Lm40;

:: The proof of this theorem has been taken directly from the
:: article POWER.miz (with very slight modifications to fit this new theorem).

theorem
  for s being Real_Sequence st
for n being Nat holds s.n = (1 + 1/(n+1)) to_power
  (n+1) holds s is non-decreasing by Lm41;

:: (1 + 1/n)^n is non-decreasing

theorem
  for n st n >= 1 holds
    ((n+1)/n) to_power n <= ((n+2)/(n+1)) to_power (n+1) by Lm42;

theorem
  for k,n being Nat st k <= n holds n choose k >= ((n+1) choose k) / (n+1)
    by Lm43;

theorem
  for f being Real_Sequence st (for n being Nat holds f.n = log(2,n!))
 for n holds f.n = Sum(seq_logn, n) by Lm44;

theorem
  for n being Nat st n >= 4 holds n*log(2,n) >= 2*n by Lm45;

theorem
  for n being Nat st n >= 2 holds n^2 > n+1 by Lm47;

theorem
  for n being Nat st n >= 1 holds
    (2 to_power (n+1)) - (2 to_power n) > 1 by Lm48;

theorem
  for n being Nat st n >= 2 holds not ((2 to_power n) - 1) in POWEROF2SET
    by Lm49;

theorem
  for n,k st k >= 1 & n! <= k & k < (n+1)! holds Step1(k) = n! by Def6;

theorem
  for a,b,c being Real st a>1 & b>=a & c>=1 holds
  log(a,c) >= log(b,c) by Lm19;