reserve c, c1, d for Real,
  k for Nat,
  n, m, N, n1, N1, N2, N3, N4, N5, M for Element of NAT,
  x for set;

theorem :: Threshold Rule (page 81)
  for f being positive Real_Sequence, t being eventually-nonnegative
Real_Sequence holds t in Big_Oh(f) iff ex c st c > 0 & for n holds t.n <= c*f.n
proof
  let f be positive Real_Sequence, t be eventually-nonnegative Real_Sequence;
  hereby
    assume t in Big_Oh(f);
    then consider s being Element of Funcs(NAT, REAL) such that
A1: t = s and
A2: ex c,N st c > 0 & for n st n >= N holds s.n <= c*f.n & s.n >= 0;
    consider c,N such that
A3: c > 0 and
A4: for n st n >= N holds s.n <= c*f.n & s.n >= 0 by A2;
    per cases;
    suppose
A5:   N = 0;
      take c;
      thus c > 0 by A3;
      let n;
      thus t.n <= c*f.n by A1,A4,A5;
    end;
    suppose
A6:   N > 0;
      deffunc F(Element of NAT) = t.$1 / f.$1;
      reconsider B = { F(n) : n < N } as finite non empty Subset of REAL from
      FinImInit2(A6);
      set b = max B;
A7:   for n st n < N holds t.n <= b*f.n
      proof
        let n;
A8:     f.n > 0 by Def3;
        assume n < N;
        then t.n / f.n in B;
        then t.n / f.n <= b by XXREAL_2:def 8;
        then t.n / f.n * f.n <= b * f.n by A8,XREAL_1:64;
        hence thesis by A8,XCMPLX_1:87;
      end;
      thus ex c st c > 0 & for n holds t.n <= c*f.n
      proof
        per cases;
        suppose
A9:       b <= c;
          take c;
          thus c > 0 by A3;
          let n;
          thus t.n <= c*f.n
          proof
            per cases;
            suppose
A10:          n < N;
              f.n > 0 by Def3;
              then
A11:          b*f.n <= c*f.n by A9,XREAL_1:64;
              t.n <= b*f.n by A7,A10;
              hence thesis by A11,XXREAL_0:2;
            end;
            suppose
              n >= N;
              hence thesis by A1,A4;
            end;
          end;
        end;
        suppose
A12:      b > c;
          reconsider b as Element of REAL by XREAL_0:def 1;
          take b;
          thus b > 0 by A3,A12;
          let n;
          thus t.n <= b*f.n
          proof
            per cases;
            suppose
              n < N;
              hence thesis by A7;
            end;
            suppose
A13:          n >= N;
              f.n > 0 by Def3;
              then
A14:          c*f.n <= b*f.n by A12,XREAL_1:64;
              t.n <= c*f.n by A1,A4,A13;
              hence thesis by A14,XXREAL_0:2;
            end;
          end;
        end;
      end;
    end;
  end;
  given c such that
A15: c > 0 and
A16: for n holds t.n <= c*f.n;
  consider N being Nat such that
A17: for n being Nat st n >= N holds t.n >= 0 by Def2;
A18: N in NAT by ORDINAL1:def 12;
  t is Element of Funcs(NAT, REAL) & for n st n >= N holds t.n <= c*f.n &
  t.n >= 0 by A16,A17,FUNCT_2:8;
  hence t in Big_Oh(f) by A15,A18;
end;
