def test_float_1(): z = 1.0 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == True assert ask(Q.rational(z)) == True assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == True assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == True z = 7.2123 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == True assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_float_1(): z = 1.0 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == True assert ask(Q.rational(z)) == True assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == True assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == True z = 7.2123 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == True assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_I(): I = S.ImaginaryUnit z = I assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == False assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == True assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = 1 + I assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == False assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = I*(1+I) assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == False assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_I(): I = S.ImaginaryUnit z = I assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == False assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == True assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = 1 + I assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == False assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = I * (1 + I) assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == False assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == False assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def Mul(expr, assumptions): """ Infinitesimal*Bounded -> Infinitesimal """ if expr.is_number: return AskInfinitesimalHandler._number(expr, assumptions) result = False for arg in expr.args: if ask(Q.infinitesimal(arg), assumptions): result = True elif ask(Q.bounded(arg), assumptions): continue else: break else: return result
def Mul(expr, assumptions): """ Infinitesimal*Bounded -> Infinitesimal """ if expr.is_number: return AskInfinitesimalHandler._number(expr, assumptions) result = False for arg in expr.args: if ask(Q.infinitesimal(arg), assumptions): result = True elif ask(Q.bounded(arg), assumptions): continue else: break else: return result
def test_zero_0(): z = Integer(0) assert ask(Q.nonzero(z)) == False assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == True assert ask(Q.rational(z)) == True assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == True assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == True assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_zero_0(): z = Integer(0) assert ask(Q.nonzero(z)) == False assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == True assert ask(Q.rational(z)) == True assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == False assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == True assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == True assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_E(): z = S.Exp1 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_E(): z = S.Exp1 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_Rational_number(): r = Rational(3,4) assert ask(Q.commutative(r)) == True assert ask(Q.integer(r)) == False assert ask(Q.rational(r)) == True assert ask(Q.real(r)) == True assert ask(Q.complex(r)) == True assert ask(Q.irrational(r)) == False assert ask(Q.imaginary(r)) == False assert ask(Q.positive(r)) == True assert ask(Q.negative(r)) == False assert ask(Q.even(r)) == False assert ask(Q.odd(r)) == False assert ask(Q.bounded(r)) == True assert ask(Q.infinitesimal(r)) == False assert ask(Q.prime(r)) == False assert ask(Q.composite(r)) == False r = Rational(1,4) assert ask(Q.positive(r)) == True assert ask(Q.negative(r)) == False r = Rational(5,4) assert ask(Q.negative(r)) == False assert ask(Q.positive(r)) == True r = Rational(5,3) assert ask(Q.positive(r)) == True assert ask(Q.negative(r)) == False r = Rational(-3,4) assert ask(Q.positive(r)) == False assert ask(Q.negative(r)) == True r = Rational(-1,4) assert ask(Q.positive(r)) == False assert ask(Q.negative(r)) == True r = Rational(-5,4) assert ask(Q.negative(r)) == True assert ask(Q.positive(r)) == False r = Rational(-5,3) assert ask(Q.positive(r)) == False assert ask(Q.negative(r)) == True
def test_Rational_number(): r = Rational(3, 4) assert ask(Q.commutative(r)) == True assert ask(Q.integer(r)) == False assert ask(Q.rational(r)) == True assert ask(Q.real(r)) == True assert ask(Q.complex(r)) == True assert ask(Q.irrational(r)) == False assert ask(Q.imaginary(r)) == False assert ask(Q.positive(r)) == True assert ask(Q.negative(r)) == False assert ask(Q.even(r)) == False assert ask(Q.odd(r)) == False assert ask(Q.bounded(r)) == True assert ask(Q.infinitesimal(r)) == False assert ask(Q.prime(r)) == False assert ask(Q.composite(r)) == False r = Rational(1, 4) assert ask(Q.positive(r)) == True assert ask(Q.negative(r)) == False r = Rational(5, 4) assert ask(Q.negative(r)) == False assert ask(Q.positive(r)) == True r = Rational(5, 3) assert ask(Q.positive(r)) == True assert ask(Q.negative(r)) == False r = Rational(-3, 4) assert ask(Q.positive(r)) == False assert ask(Q.negative(r)) == True r = Rational(-1, 4) assert ask(Q.positive(r)) == False assert ask(Q.negative(r)) == True r = Rational(-5, 4) assert ask(Q.negative(r)) == True assert ask(Q.positive(r)) == False r = Rational(-5, 3) assert ask(Q.positive(r)) == False assert ask(Q.negative(r)) == True
def test_nan(): nan = S.NaN assert ask(Q.commutative(nan)) == True assert ask(Q.integer(nan)) == False assert ask(Q.rational(nan)) == False assert ask(Q.real(nan)) == False assert ask(Q.extended_real(nan)) == False assert ask(Q.complex(nan)) == False assert ask(Q.irrational(nan)) == False assert ask(Q.imaginary(nan)) == False assert ask(Q.positive(nan)) == False assert ask(Q.nonzero(nan)) == True assert ask(Q.even(nan)) == False assert ask(Q.odd(nan)) == False assert ask(Q.bounded(nan)) == False assert ask(Q.infinitesimal(nan)) == False assert ask(Q.prime(nan)) == False assert ask(Q.composite(nan)) == False
def test_neg_infinity(): mm = S.NegativeInfinity assert ask(Q.commutative(mm)) == True assert ask(Q.integer(mm)) == False assert ask(Q.rational(mm)) == False assert ask(Q.real(mm)) == False assert ask(Q.extended_real(mm)) == True assert ask(Q.complex(mm)) == False assert ask(Q.irrational(mm)) == False assert ask(Q.imaginary(mm)) == False assert ask(Q.positive(mm)) == False assert ask(Q.negative(mm)) == True assert ask(Q.even(mm)) == False assert ask(Q.odd(mm)) == False assert ask(Q.bounded(mm)) == False assert ask(Q.infinitesimal(mm)) == False assert ask(Q.prime(mm)) == False assert ask(Q.composite(mm)) == False
def test_infinity(): oo = S.Infinity assert ask(Q.commutative(oo)) == True assert ask(Q.integer(oo)) == False assert ask(Q.rational(oo)) == False assert ask(Q.real(oo)) == False assert ask(Q.extended_real(oo)) == True assert ask(Q.complex(oo)) == False assert ask(Q.irrational(oo)) == False assert ask(Q.imaginary(oo)) == False assert ask(Q.positive(oo)) == True assert ask(Q.negative(oo)) == False assert ask(Q.even(oo)) == False assert ask(Q.odd(oo)) == False assert ask(Q.bounded(oo)) == False assert ask(Q.infinitesimal(oo)) == False assert ask(Q.prime(oo)) == False assert ask(Q.composite(oo)) == False
def test_nan(): nan = S.NaN assert ask(Q.commutative(nan)) == True assert ask(Q.integer(nan)) == False assert ask(Q.rational(nan)) == False assert ask(Q.real(nan)) == False assert ask(Q.extended_real(nan)) == False assert ask(Q.complex(nan)) == False assert ask(Q.irrational(nan)) == False assert ask(Q.imaginary(nan)) == False assert ask(Q.positive(nan)) == False assert ask(Q.nonzero(nan)) == True assert ask(Q.even(nan)) == False assert ask(Q.odd(nan)) == False assert ask(Q.bounded(nan)) == False assert ask(Q.infinitesimal(nan)) == False assert ask(Q.prime(nan)) == False assert ask(Q.composite(nan)) == False
def test_neg_infinity(): mm = S.NegativeInfinity assert ask(Q.commutative(mm)) == True assert ask(Q.integer(mm)) == False assert ask(Q.rational(mm)) == False assert ask(Q.real(mm)) == False assert ask(Q.extended_real(mm)) == True assert ask(Q.complex(mm)) == False assert ask(Q.irrational(mm)) == False assert ask(Q.imaginary(mm)) == False assert ask(Q.positive(mm)) == False assert ask(Q.negative(mm)) == True assert ask(Q.even(mm)) == False assert ask(Q.odd(mm)) == False assert ask(Q.bounded(mm)) == False assert ask(Q.infinitesimal(mm)) == False assert ask(Q.prime(mm)) == False assert ask(Q.composite(mm)) == False
def test_infinity(): oo = S.Infinity assert ask(Q.commutative(oo)) == True assert ask(Q.integer(oo)) == False assert ask(Q.rational(oo)) == False assert ask(Q.real(oo)) == False assert ask(Q.extended_real(oo)) == True assert ask(Q.complex(oo)) == False assert ask(Q.irrational(oo)) == False assert ask(Q.imaginary(oo)) == False assert ask(Q.positive(oo)) == True assert ask(Q.negative(oo)) == False assert ask(Q.even(oo)) == False assert ask(Q.odd(oo)) == False assert ask(Q.bounded(oo)) == False assert ask(Q.infinitesimal(oo)) == False assert ask(Q.prime(oo)) == False assert ask(Q.composite(oo)) == False
def test_pi(): z = S.Pi assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = S.Pi + 1 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = 2 * S.Pi assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = S.Pi**2 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = (1 + S.Pi)**2 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False
def test_infinitesimal(): x, y = symbols('x,y') assert ask(Q.infinitesimal(x)) == None assert ask(Q.infinitesimal(x), Q.infinitesimal(x)) == True assert ask(Q.infinitesimal(2 * x), Q.infinitesimal(x)) == True assert ask(Q.infinitesimal(x * y), Q.infinitesimal(x)) == None assert ask(Q.infinitesimal(x * y), Q.infinitesimal(x) & Q.infinitesimal(y)) == True assert ask(Q.infinitesimal(x * y), Q.infinitesimal(x) & Q.bounded(y)) == True assert ask(Q.infinitesimal(x**2), Q.infinitesimal(x)) == True
def test_infinitesimal(): x, y = symbols('x,y') assert ask(Q.infinitesimal(x)) == None assert ask(Q.infinitesimal(x), Q.infinitesimal(x)) == True assert ask(Q.infinitesimal(2*x), Q.infinitesimal(x)) == True assert ask(Q.infinitesimal(x*y), Q.infinitesimal(x)) == None assert ask(Q.infinitesimal(x*y), Q.infinitesimal(x) & Q.infinitesimal(y)) == True assert ask(Q.infinitesimal(x*y), Q.infinitesimal(x) & Q.bounded(y)) == True assert ask(Q.infinitesimal(x**2), Q.infinitesimal(x)) == True
def test_pi(): z = S.Pi assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = S.Pi + 1 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = 2*S.Pi assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = S.Pi ** 2 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False z = (1+S.Pi) ** 2 assert ask(Q.commutative(z)) == True assert ask(Q.integer(z)) == False assert ask(Q.rational(z)) == False assert ask(Q.real(z)) == True assert ask(Q.complex(z)) == True assert ask(Q.irrational(z)) == True assert ask(Q.imaginary(z)) == False assert ask(Q.positive(z)) == True assert ask(Q.negative(z)) == False assert ask(Q.even(z)) == False assert ask(Q.odd(z)) == False assert ask(Q.bounded(z)) == True assert ask(Q.infinitesimal(z)) == False assert ask(Q.prime(z)) == False assert ask(Q.composite(z)) == False