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

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