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