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

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