How to use ask method in avocado

Best Python code snippet using avocado_python Github


Full Screen

...21from sympy.assumptions.assume import assuming22import math23def test_int_1():24 z = 125 assert ask(Q.commutative(z)) is True26 assert ask(Q.integer(z)) is True27 assert ask(Q.rational(z)) is True28 assert ask(Q.real(z)) is True29 assert ask(Q.complex(z)) is True30 assert ask(Q.irrational(z)) is False31 assert ask(Q.imaginary(z)) is False32 assert ask(Q.positive(z)) is True33 assert ask(Q.negative(z)) is False34 assert ask(Q.even(z)) is False35 assert ask(Q.odd(z)) is True36 assert ask(Q.finite(z)) is True37 assert ask( is False38 assert ask(Q.composite(z)) is False39 assert ask(Q.hermitian(z)) is True40 assert ask(Q.antihermitian(z)) is False41def test_int_11():42 z = 1143 assert ask(Q.commutative(z)) is True44 assert ask(Q.integer(z)) is True45 assert ask(Q.rational(z)) is True46 assert ask(Q.real(z)) is True47 assert ask(Q.complex(z)) is True48 assert ask(Q.irrational(z)) is False49 assert ask(Q.imaginary(z)) is False50 assert ask(Q.positive(z)) is True51 assert ask(Q.negative(z)) is False52 assert ask(Q.even(z)) is False53 assert ask(Q.odd(z)) is True54 assert ask(Q.finite(z)) is True55 assert ask( is True56 assert ask(Q.composite(z)) is False57 assert ask(Q.hermitian(z)) is True58 assert ask(Q.antihermitian(z)) is False59def test_int_12():60 z = 1261 assert ask(Q.commutative(z)) is True62 assert ask(Q.integer(z)) is True63 assert ask(Q.rational(z)) is True64 assert ask(Q.real(z)) is True65 assert ask(Q.complex(z)) is True66 assert ask(Q.irrational(z)) is False67 assert ask(Q.imaginary(z)) is False68 assert ask(Q.positive(z)) is True69 assert ask(Q.negative(z)) is False70 assert ask(Q.even(z)) is True71 assert ask(Q.odd(z)) is False72 assert ask(Q.finite(z)) is True73 assert ask( is False74 assert ask(Q.composite(z)) is True75 assert ask(Q.hermitian(z)) is True76 assert ask(Q.antihermitian(z)) is False77def test_float_1():78 z = 1.079 assert ask(Q.commutative(z)) is True80 assert ask(Q.integer(z)) is False81 assert ask(Q.rational(z)) is None82 assert ask(Q.real(z)) is True83 assert ask(Q.complex(z)) is True84 assert ask(Q.irrational(z)) is None85 assert ask(Q.imaginary(z)) is False86 assert ask(Q.positive(z)) is True87 assert ask(Q.negative(z)) is False88 assert ask(Q.even(z)) is False89 assert ask(Q.odd(z)) is False90 assert ask(Q.finite(z)) is True91 assert ask( is False92 assert ask(Q.composite(z)) is False93 assert ask(Q.hermitian(z)) is True94 assert ask(Q.antihermitian(z)) is False95 z = 7.212396 assert ask(Q.commutative(z)) is True97 assert ask(Q.integer(z)) is False98 assert ask(Q.rational(z)) is None99 assert ask(Q.real(z)) is True100 assert ask(Q.complex(z)) is True101 assert ask(Q.irrational(z)) is None102 assert ask(Q.imaginary(z)) is False103 assert ask(Q.positive(z)) is True104 assert ask(Q.negative(z)) is False105 assert ask(Q.even(z)) is False106 assert ask(Q.odd(z)) is False107 assert ask(Q.finite(z)) is True108 assert ask( is False109 assert ask(Q.composite(z)) is False110 assert ask(Q.hermitian(z)) is True111 assert ask(Q.antihermitian(z)) is False112 # test for issue #12168113 assert ask(Q.rational(math.pi)) is None114def test_zero_0():115 z = Integer(0)116 assert ask(Q.nonzero(z)) is False117 assert ask( is True118 assert ask(Q.commutative(z)) is True119 assert ask(Q.integer(z)) is True120 assert ask(Q.rational(z)) is True121 assert ask(Q.real(z)) is True122 assert ask(Q.complex(z)) is True123 assert ask(Q.imaginary(z)) is False124 assert ask(Q.positive(z)) is False125 assert ask(Q.negative(z)) is False126 assert ask(Q.even(z)) is True127 assert ask(Q.odd(z)) is False128 assert ask(Q.finite(z)) is True129 assert ask( is False130 assert ask(Q.composite(z)) is False131 assert ask(Q.hermitian(z)) is True132 assert ask(Q.antihermitian(z)) is False133def test_negativeone():134 z = Integer(-1)135 assert ask(Q.nonzero(z)) is True136 assert ask( is False137 assert ask(Q.commutative(z)) is True138 assert ask(Q.integer(z)) is True139 assert ask(Q.rational(z)) is True140 assert ask(Q.real(z)) is True141 assert ask(Q.complex(z)) is True142 assert ask(Q.irrational(z)) is False143 assert ask(Q.imaginary(z)) is False144 assert ask(Q.positive(z)) is False145 assert ask(Q.negative(z)) is True146 assert ask(Q.even(z)) is False147 assert ask(Q.odd(z)) is True148 assert ask(Q.finite(z)) is True149 assert ask( is False150 assert ask(Q.composite(z)) is False151 assert ask(Q.hermitian(z)) is True152 assert ask(Q.antihermitian(z)) is False153def test_infinity():154 assert ask(Q.commutative(oo)) is True155 assert ask(Q.integer(oo)) is False156 assert ask(Q.rational(oo)) is False157 assert ask(Q.algebraic(oo)) is False158 assert ask(Q.real(oo)) is False159 assert ask(Q.extended_real(oo)) is True160 assert ask(Q.complex(oo)) is False161 assert ask(Q.irrational(oo)) is False162 assert ask(Q.imaginary(oo)) is False163 assert ask(Q.positive(oo)) is False164 #assert ask(Q.extended_positive(oo)) is True165 assert ask(Q.negative(oo)) is False166 assert ask(Q.even(oo)) is False167 assert ask(Q.odd(oo)) is False168 assert ask(Q.finite(oo)) is False169 assert ask( is False170 assert ask(Q.composite(oo)) is False171 assert ask(Q.hermitian(oo)) is False172 assert ask(Q.antihermitian(oo)) is False173def test_neg_infinity():174 mm = S.NegativeInfinity175 assert ask(Q.commutative(mm)) is True176 assert ask(Q.integer(mm)) is False177 assert ask(Q.rational(mm)) is False178 assert ask(Q.algebraic(mm)) is False179 assert ask(Q.real(mm)) is False180 assert ask(Q.extended_real(mm)) is True181 assert ask(Q.complex(mm)) is False182 assert ask(Q.irrational(mm)) is False183 assert ask(Q.imaginary(mm)) is False184 assert ask(Q.positive(mm)) is False185 assert ask(Q.negative(mm)) is False186 #assert ask(Q.extended_negative(mm)) is True187 assert ask(Q.even(mm)) is False188 assert ask(Q.odd(mm)) is False189 assert ask(Q.finite(mm)) is False190 assert ask( is False191 assert ask(Q.composite(mm)) is False192 assert ask(Q.hermitian(mm)) is False193 assert ask(Q.antihermitian(mm)) is False194def test_nan():195 nan = S.NaN196 assert ask(Q.commutative(nan)) is True197 assert ask(Q.integer(nan)) is False198 assert ask(Q.rational(nan)) is False199 assert ask(Q.algebraic(nan)) is False200 assert ask(Q.real(nan)) is False201 assert ask(Q.extended_real(nan)) is False202 assert ask(Q.complex(nan)) is False203 assert ask(Q.irrational(nan)) is False204 assert ask(Q.imaginary(nan)) is False205 assert ask(Q.positive(nan)) is False206 assert ask(Q.nonzero(nan)) is True207 assert ask( is False208 assert ask(Q.even(nan)) is False209 assert ask(Q.odd(nan)) is False210 assert ask(Q.finite(nan)) is False211 assert ask( is False212 assert ask(Q.composite(nan)) is False213 assert ask(Q.hermitian(nan)) is False214 assert ask(Q.antihermitian(nan)) is False215def test_Rational_number():216 r = Rational(3, 4)217 assert ask(Q.commutative(r)) is True218 assert ask(Q.integer(r)) is False219 assert ask(Q.rational(r)) is True220 assert ask(Q.real(r)) is True221 assert ask(Q.complex(r)) is True222 assert ask(Q.irrational(r)) is False223 assert ask(Q.imaginary(r)) is False224 assert ask(Q.positive(r)) is True225 assert ask(Q.negative(r)) is False226 assert ask(Q.even(r)) is False227 assert ask(Q.odd(r)) is False228 assert ask(Q.finite(r)) is True229 assert ask( is False230 assert ask(Q.composite(r)) is False231 assert ask(Q.hermitian(r)) is True232 assert ask(Q.antihermitian(r)) is False233 r = Rational(1, 4)234 assert ask(Q.positive(r)) is True235 assert ask(Q.negative(r)) is False236 r = Rational(5, 4)237 assert ask(Q.negative(r)) is False238 assert ask(Q.positive(r)) is True239 r = Rational(5, 3)240 assert ask(Q.positive(r)) is True241 assert ask(Q.negative(r)) is False242 r = Rational(-3, 4)243 assert ask(Q.positive(r)) is False244 assert ask(Q.negative(r)) is True245 r = Rational(-1, 4)246 assert ask(Q.positive(r)) is False247 assert ask(Q.negative(r)) is True248 r = Rational(-5, 4)249 assert ask(Q.negative(r)) is True250 assert ask(Q.positive(r)) is False251 r = Rational(-5, 3)252 assert ask(Q.positive(r)) is False253 assert ask(Q.negative(r)) is True254def test_sqrt_2():255 z = sqrt(2)256 assert ask(Q.commutative(z)) is True257 assert ask(Q.integer(z)) is False258 assert ask(Q.rational(z)) is False259 assert ask(Q.real(z)) is True260 assert ask(Q.complex(z)) is True261 assert ask(Q.irrational(z)) is True262 assert ask(Q.imaginary(z)) is False263 assert ask(Q.positive(z)) is True264 assert ask(Q.negative(z)) is False265 assert ask(Q.even(z)) is False266 assert ask(Q.odd(z)) is False267 assert ask(Q.finite(z)) is True268 assert ask( is False269 assert ask(Q.composite(z)) is False270 assert ask(Q.hermitian(z)) is True271 assert ask(Q.antihermitian(z)) is False272def test_pi():273 z = S.Pi274 assert ask(Q.commutative(z)) is True275 assert ask(Q.integer(z)) is False276 assert ask(Q.rational(z)) is False277 assert ask(Q.algebraic(z)) is False278 assert ask(Q.real(z)) is True279 assert ask(Q.complex(z)) is True280 assert ask(Q.irrational(z)) is True281 assert ask(Q.imaginary(z)) is False282 assert ask(Q.positive(z)) is True283 assert ask(Q.negative(z)) is False284 assert ask(Q.even(z)) is False285 assert ask(Q.odd(z)) is False286 assert ask(Q.finite(z)) is True287 assert ask( is False288 assert ask(Q.composite(z)) is False289 assert ask(Q.hermitian(z)) is True290 assert ask(Q.antihermitian(z)) is False291 z = S.Pi + 1292 assert ask(Q.commutative(z)) is True293 assert ask(Q.integer(z)) is False294 assert ask(Q.rational(z)) is False295 assert ask(Q.algebraic(z)) is False296 assert ask(Q.real(z)) is True297 assert ask(Q.complex(z)) is True298 assert ask(Q.irrational(z)) is True299 assert ask(Q.imaginary(z)) is False300 assert ask(Q.positive(z)) is True301 assert ask(Q.negative(z)) is False302 assert ask(Q.even(z)) is False303 assert ask(Q.odd(z)) is False304 assert ask(Q.finite(z)) is True305 assert ask( is False306 assert ask(Q.composite(z)) is False307 assert ask(Q.hermitian(z)) is True308 assert ask(Q.antihermitian(z)) is False309 z = 2*S.Pi310 assert ask(Q.commutative(z)) is True311 assert ask(Q.integer(z)) is False312 assert ask(Q.rational(z)) is False313 assert ask(Q.algebraic(z)) is False314 assert ask(Q.real(z)) is True315 assert ask(Q.complex(z)) is True316 assert ask(Q.irrational(z)) is True317 assert ask(Q.imaginary(z)) is False318 assert ask(Q.positive(z)) is True319 assert ask(Q.negative(z)) is False320 assert ask(Q.even(z)) is False321 assert ask(Q.odd(z)) is False322 assert ask(Q.finite(z)) is True323 assert ask( is False324 assert ask(Q.composite(z)) is False325 assert ask(Q.hermitian(z)) is True326 assert ask(Q.antihermitian(z)) is False327 z = S.Pi ** 2328 assert ask(Q.commutative(z)) is True329 assert ask(Q.integer(z)) is False330 assert ask(Q.rational(z)) is False331 assert ask(Q.algebraic(z)) is False332 assert ask(Q.real(z)) is True333 assert ask(Q.complex(z)) is True334 assert ask(Q.irrational(z)) is True335 assert ask(Q.imaginary(z)) is False336 assert ask(Q.positive(z)) is True337 assert ask(Q.negative(z)) is False338 assert ask(Q.even(z)) is False339 assert ask(Q.odd(z)) is False340 assert ask(Q.finite(z)) is True341 assert ask( is False342 assert ask(Q.composite(z)) is False343 assert ask(Q.hermitian(z)) is True344 assert ask(Q.antihermitian(z)) is False345 z = (1 + S.Pi) ** 2346 assert ask(Q.commutative(z)) is True347 assert ask(Q.integer(z)) is False348 assert ask(Q.rational(z)) is False349 assert ask(Q.algebraic(z)) is False350 assert ask(Q.real(z)) is True351 assert ask(Q.complex(z)) is True352 assert ask(Q.irrational(z)) is True353 assert ask(Q.imaginary(z)) is False354 assert ask(Q.positive(z)) is True355 assert ask(Q.negative(z)) is False356 assert ask(Q.even(z)) is False357 assert ask(Q.odd(z)) is False358 assert ask(Q.finite(z)) is True359 assert ask( is False360 assert ask(Q.composite(z)) is False361 assert ask(Q.hermitian(z)) is True362 assert ask(Q.antihermitian(z)) is False363def test_E():364 z = S.Exp1365 assert ask(Q.commutative(z)) is True366 assert ask(Q.integer(z)) is False367 assert ask(Q.rational(z)) is False368 assert ask(Q.algebraic(z)) is False369 assert ask(Q.real(z)) is True370 assert ask(Q.complex(z)) is True371 assert ask(Q.irrational(z)) is True372 assert ask(Q.imaginary(z)) is False373 assert ask(Q.positive(z)) is True374 assert ask(Q.negative(z)) is False375 assert ask(Q.even(z)) is False376 assert ask(Q.odd(z)) is False377 assert ask(Q.finite(z)) is True378 assert ask( is False379 assert ask(Q.composite(z)) is False380 assert ask(Q.hermitian(z)) is True381 assert ask(Q.antihermitian(z)) is False382def test_GoldenRatio():383 z = S.GoldenRatio384 assert ask(Q.commutative(z)) is True385 assert ask(Q.integer(z)) is False386 assert ask(Q.rational(z)) is False387 assert ask(Q.algebraic(z)) is True388 assert ask(Q.real(z)) is True389 assert ask(Q.complex(z)) is True390 assert ask(Q.irrational(z)) is True391 assert ask(Q.imaginary(z)) is False392 assert ask(Q.positive(z)) is True393 assert ask(Q.negative(z)) is False394 assert ask(Q.even(z)) is False395 assert ask(Q.odd(z)) is False396 assert ask(Q.finite(z)) is True397 assert ask( is False398 assert ask(Q.composite(z)) is False399 assert ask(Q.hermitian(z)) is True400 assert ask(Q.antihermitian(z)) is False401def test_TribonacciConstant():402 z = S.TribonacciConstant403 assert ask(Q.commutative(z)) is True404 assert ask(Q.integer(z)) is False405 assert ask(Q.rational(z)) is False406 assert ask(Q.algebraic(z)) is True407 assert ask(Q.real(z)) is True408 assert ask(Q.complex(z)) is True409 assert ask(Q.irrational(z)) is True410 assert ask(Q.imaginary(z)) is False411 assert ask(Q.positive(z)) is True412 assert ask(Q.negative(z)) is False413 assert ask(Q.even(z)) is False414 assert ask(Q.odd(z)) is False415 assert ask(Q.finite(z)) is True416 assert ask( is False417 assert ask(Q.composite(z)) is False418 assert ask(Q.hermitian(z)) is True419 assert ask(Q.antihermitian(z)) is False420def test_I():421 z = I422 assert ask(Q.commutative(z)) is True423 assert ask(Q.integer(z)) is False424 assert ask(Q.rational(z)) is False425 assert ask(Q.algebraic(z)) is True426 assert ask(Q.real(z)) is False427 assert ask(Q.complex(z)) is True428 assert ask(Q.irrational(z)) is False429 assert ask(Q.imaginary(z)) is True430 assert ask(Q.positive(z)) is False431 assert ask(Q.negative(z)) is False432 assert ask(Q.even(z)) is False433 assert ask(Q.odd(z)) is False434 assert ask(Q.finite(z)) is True435 assert ask( is False436 assert ask(Q.composite(z)) is False437 assert ask(Q.hermitian(z)) is False438 assert ask(Q.antihermitian(z)) is True439 z = 1 + I440 assert ask(Q.commutative(z)) is True441 assert ask(Q.integer(z)) is False442 assert ask(Q.rational(z)) is False443 assert ask(Q.algebraic(z)) is True444 assert ask(Q.real(z)) is False445 assert ask(Q.complex(z)) is True446 assert ask(Q.irrational(z)) is False447 assert ask(Q.imaginary(z)) is False448 assert ask(Q.positive(z)) is False449 assert ask(Q.negative(z)) is False450 assert ask(Q.even(z)) is False451 assert ask(Q.odd(z)) is False452 assert ask(Q.finite(z)) is True453 assert ask( is False454 assert ask(Q.composite(z)) is False455 assert ask(Q.hermitian(z)) is False456 assert ask(Q.antihermitian(z)) is False457 z = I*(1 + I)458 assert ask(Q.commutative(z)) is True459 assert ask(Q.integer(z)) is False460 assert ask(Q.rational(z)) is False461 assert ask(Q.algebraic(z)) is True462 assert ask(Q.real(z)) is False463 assert ask(Q.complex(z)) is True464 assert ask(Q.irrational(z)) is False465 assert ask(Q.imaginary(z)) is False466 assert ask(Q.positive(z)) is False467 assert ask(Q.negative(z)) is False468 assert ask(Q.even(z)) is False469 assert ask(Q.odd(z)) is False470 assert ask(Q.finite(z)) is True471 assert ask( is False472 assert ask(Q.composite(z)) is False473 assert ask(Q.hermitian(z)) is False474 assert ask(Q.antihermitian(z)) is False475 z = I**(I)476 assert ask(Q.imaginary(z)) is False477 assert ask(Q.real(z)) is True478 z = (-I)**(I)479 assert ask(Q.imaginary(z)) is False480 assert ask(Q.real(z)) is True481 z = (3*I)**(I)482 assert ask(Q.imaginary(z)) is False483 assert ask(Q.real(z)) is False484 z = (1)**(I)485 assert ask(Q.imaginary(z)) is False486 assert ask(Q.real(z)) is True487 z = (-1)**(I)488 assert ask(Q.imaginary(z)) is False489 assert ask(Q.real(z)) is True490 z = (1+I)**(I)491 assert ask(Q.imaginary(z)) is False492 assert ask(Q.real(z)) is False493 z = (I)**(I+3)494 assert ask(Q.imaginary(z)) is True495 assert ask(Q.real(z)) is False496 z = (I)**(I+2)497 assert ask(Q.imaginary(z)) is False498 assert ask(Q.real(z)) is True499 z = (I)**(2)500 assert ask(Q.imaginary(z)) is False501 assert ask(Q.real(z)) is True502 z = (I)**(3)503 assert ask(Q.imaginary(z)) is True504 assert ask(Q.real(z)) is False505 z = (3)**(I)506 assert ask(Q.imaginary(z)) is False507 assert ask(Q.real(z)) is False508 z = (I)**(0)509 assert ask(Q.imaginary(z)) is False510 assert ask(Q.real(z)) is True511def test_bounded():512 x, y, z = symbols('x,y,z')513 assert ask(Q.finite(x)) is None514 assert ask(Q.finite(x), Q.finite(x)) is True515 assert ask(Q.finite(x), Q.finite(y)) is None516 assert ask(Q.finite(x), Q.complex(x)) is None517 assert ask(Q.finite(x + 1)) is None518 assert ask(Q.finite(x + 1), Q.finite(x)) is True519 a = x + y520 x, y = a.args521 # B + B522 assert ask(Q.finite(a), Q.finite(x) & Q.finite(y)) is True523 assert ask(524 Q.finite(a), Q.finite(x) & Q.finite(y) & Q.positive(x)) is True525 assert ask(526 Q.finite(a), Q.finite(x) & Q.finite(y) & Q.positive(y)) is True527 assert ask(Q.finite(a),528 Q.finite(x) & Q.finite(y) & Q.positive(x) & Q.positive(y)) is True529 assert ask(Q.finite(a),530 Q.finite(x) & Q.finite(y) & Q.positive(x) & ~Q.positive(y)) is True531 assert ask(Q.finite(a),532 Q.finite(x) & Q.finite(y) & ~Q.positive(x) & Q.positive(y)) is True533 assert ask(Q.finite(a),534 Q.finite(x) & Q.finite(y) & ~Q.positive(x) & ~Q.positive(y)) is True535 # B + U536 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y)) is False537 assert ask(538 Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.positive(x)) is False539 assert ask(540 Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.positive(y)) is False541 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.positive(x) &542 Q.positive(y)) is False543 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.positive(x) &544 ~Q.positive(y)) is False545 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y) & ~Q.positive(x) &546 Q.positive(y)) is False547 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y) & ~Q.positive(x) &548 ~Q.positive(y)) is False549 # B + ?550 assert ask(Q.finite(a), Q.finite(x)) is None551 assert ask(Q.finite(a), Q.finite(x) & Q.positive(x)) is None552 assert ask(Q.finite(a), Q.finite(x) & Q.positive(y)) is None553 assert ask(554 Q.finite(a), Q.finite(x) & Q.positive(x) & Q.positive(y)) is None555 assert ask(556 Q.finite(a), Q.finite(x) & Q.positive(x) & ~Q.positive(y)) is None557 assert ask(558 Q.finite(a), Q.finite(x) & ~Q.positive(x) & Q.positive(y)) is None559 assert ask(560 Q.finite(a), Q.finite(x) & ~Q.positive(x) & ~Q.positive(y)) is None561 # U + U562 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y)) is None563 assert ask(564 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.positive(x)) is None565 assert ask(566 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.positive(y)) is None567 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.positive(x) &568 Q.positive(y)) is False569 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.positive(x) &570 ~Q.positive(y)) is None571 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & ~Q.positive(x) &572 Q.positive(y)) is None573 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & ~Q.positive(x) &574 ~Q.positive(y)) is False575 # U + ?576 assert ask(Q.finite(a), ~Q.finite(y)) is None577 assert ask(Q.finite(a), ~Q.finite(y) & Q.positive(x)) is None578 assert ask(Q.finite(a), ~Q.finite(y) & Q.positive(y)) is None579 assert ask(580 Q.finite(a), ~Q.finite(y) & Q.positive(x) & Q.positive(y)) is False581 assert ask(582 Q.finite(a), ~Q.finite(y) & Q.positive(x) & ~Q.positive(y)) is None583 assert ask(584 Q.finite(a), ~Q.finite(y) & ~Q.positive(x) & Q.positive(y)) is None585 assert ask(586 Q.finite(a), ~Q.finite(y) & ~Q.positive(x) & ~Q.positive(y)) is False587 # ? + ?588 assert ask(Q.finite(a),) is None589 assert ask(Q.finite(a), Q.positive(x)) is None590 assert ask(Q.finite(a), Q.positive(y)) is None591 assert ask(Q.finite(a), Q.positive(x) & Q.positive(y)) is None592 assert ask(Q.finite(a), Q.positive(x) & ~Q.positive(y)) is None593 assert ask(Q.finite(a), ~Q.positive(x) & Q.positive(y)) is None594 assert ask(Q.finite(a), ~Q.positive(x) & ~Q.positive(y)) is None595 x, y, z = symbols('x,y,z')596 a = x + y + z597 x, y, z = a.args598 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y) &599 Q.finite(y) & Q.negative(z) & Q.finite(z)) is True600 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &601 Q.negative(y) & Q.finite(y) & Q.finite(z)) is True602 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y) &603 Q.finite(y) & Q.positive(z) & Q.finite(z)) is True604 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y) &605 Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False606 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &607 Q.negative(y) & Q.finite(y) & ~Q.finite(z)) is False608 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y) &609 Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False610 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &611 Q.negative(y) & Q.finite(y) & Q.negative(z)) is None612 assert ask(Q.finite(a), Q.negative(x) &613 Q.finite(x) & Q.negative(y) & Q.finite(y)) is None614 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &615 Q.negative(y) & Q.finite(y) & Q.positive(z)) is None616 assert ask(Q.finite(a), Q.negative(x) &617 Q.finite(x) & Q.finite(y) & Q.finite(z)) is True618 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &619 Q.finite(y) & Q.positive(z) & Q.finite(z)) is True620 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &621 Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False622 assert ask(Q.finite(a), Q.negative(x) &623 Q.finite(x) & Q.finite(y) & ~Q.finite(z)) is False624 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &625 Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False626 assert ask(Q.finite(a), Q.negative(x) &627 Q.finite(x) & Q.finite(y) & Q.negative(z)) is None628 assert ask(629 Q.finite(a), Q.negative(x) & Q.finite(x) & Q.finite(y)) is None630 assert ask(Q.finite(a), Q.negative(x) &631 Q.finite(x) & Q.finite(y) & Q.positive(z)) is None632 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.positive(y) &633 Q.finite(y) & Q.positive(z) & Q.finite(z)) is True634 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.positive(y) &635 Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False636 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &637 Q.positive(y) & Q.finite(y) & ~Q.finite(z)) is False638 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.positive(y) &639 Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False640 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &641 Q.positive(y) & Q.finite(y) & Q.negative(z)) is None642 assert ask(Q.finite(a), Q.negative(x) &643 Q.finite(x) & Q.positive(y) & Q.finite(y)) is None644 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &645 Q.positive(y) & Q.finite(y) & Q.positive(z)) is None646 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y) &647 ~Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False648 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &649 Q.negative(y) & ~Q.finite(y) & ~Q.finite(z)) is None650 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y) &651 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None652 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &653 Q.negative(y) & ~Q.finite(y) & Q.negative(z)) is False654 assert ask(Q.finite(a), Q.negative(x) &655 Q.finite(x) & Q.negative(y) & ~Q.finite(y)) is None656 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &657 Q.negative(y) & ~Q.finite(y) & Q.positive(z)) is None658 assert ask(Q.finite(a), Q.negative(x) &659 Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is None660 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &661 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None662 assert ask(Q.finite(a), Q.negative(x) &663 Q.finite(x) & ~Q.finite(y) & Q.negative(z)) is None664 assert ask(665 Q.finite(a), Q.negative(x) & Q.finite(x) & ~Q.finite(y)) is None666 assert ask(Q.finite(a), Q.negative(x) &667 Q.finite(x) & ~Q.finite(y) & Q.positive(z)) is None668 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) & Q.positive(y) &669 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False670 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &671 Q.positive(y) & ~Q.finite(y) & Q.negative(z)) is None672 assert ask(Q.finite(a), Q.negative(x) &673 Q.finite(x) & Q.positive(y) & ~Q.finite(y)) is None674 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x) &675 Q.positive(y) & ~Q.finite(y) & Q.positive(z)) is False676 assert ask(Q.finite(a), Q.negative(x) &677 Q.finite(x) & Q.negative(y) & Q.negative(z)) is None678 assert ask(679 Q.finite(a), Q.negative(x) & Q.finite(x) & Q.negative(y)) is None680 assert ask(Q.finite(a), Q.negative(x) &681 Q.finite(x) & Q.negative(y) & Q.positive(z)) is None682 assert ask(Q.finite(a), Q.negative(x) & Q.finite(x)) is None683 assert ask(684 Q.finite(a), Q.negative(x) & Q.finite(x) & Q.positive(z)) is None685 assert ask(Q.finite(a), Q.negative(x) &686 Q.finite(x) & Q.positive(y) & Q.positive(z)) is None687 assert ask(688 Q.finite(a), Q.finite(x) & Q.finite(y) & Q.finite(z)) is True689 assert ask(Q.finite(a),690 Q.finite(x) & Q.finite(y) & Q.positive(z) & Q.finite(z)) is True691 assert ask(Q.finite(a), Q.finite(x) &692 Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False693 assert ask(694 Q.finite(a), Q.finite(x) & Q.finite(y) & ~Q.finite(z)) is False695 assert ask(Q.finite(a), Q.finite(x) &696 Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False697 assert ask(698 Q.finite(a), Q.finite(x) & Q.finite(y) & Q.negative(z)) is None699 assert ask(Q.finite(a), Q.finite(x) & Q.finite(y)) is None700 assert ask(701 Q.finite(a), Q.finite(x) & Q.finite(y) & Q.positive(z)) is None702 assert ask(Q.finite(a), Q.finite(x) & Q.positive(y) &703 Q.finite(y) & Q.positive(z) & Q.finite(z)) is True704 assert ask(Q.finite(a), Q.finite(x) & Q.positive(y) &705 Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False706 assert ask(Q.finite(a), Q.finite(x) &707 Q.positive(y) & Q.finite(y) & ~Q.finite(z)) is False708 assert ask(Q.finite(a), Q.finite(x) & Q.positive(y) &709 Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False710 assert ask(Q.finite(a), Q.finite(x) &711 Q.positive(y) & Q.finite(y) & Q.negative(z)) is None712 assert ask(713 Q.finite(a), Q.finite(x) & Q.positive(y) & Q.finite(y)) is None714 assert ask(Q.finite(a), Q.finite(x) &715 Q.positive(y) & Q.finite(y) & Q.positive(z)) is None716 assert ask(Q.finite(a), Q.finite(x) & Q.negative(y) &717 ~Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False718 assert ask(Q.finite(a), Q.finite(x) &719 Q.negative(y) & ~Q.finite(y) & ~Q.finite(z)) is None720 assert ask(Q.finite(a), Q.finite(x) & Q.negative(y) &721 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None722 assert ask(Q.finite(a), Q.finite(x) &723 Q.negative(y) & ~Q.finite(y) & Q.negative(z)) is False724 assert ask(725 Q.finite(a), Q.finite(x) & Q.negative(y) & ~Q.finite(y)) is None726 assert ask(Q.finite(a), Q.finite(x) &727 Q.negative(y) & ~Q.finite(y) & Q.positive(z)) is None728 assert ask(729 Q.finite(a), Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is None730 assert ask(Q.finite(a), Q.finite(x) &731 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None732 assert ask(733 Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.negative(z)) is None734 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y)) is None735 assert ask(736 Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.positive(z)) is None737 assert ask(Q.finite(a), Q.finite(x) & Q.positive(y) &738 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False739 assert ask(Q.finite(a), Q.finite(x) &740 Q.positive(y) & ~Q.finite(y) & Q.negative(z)) is None741 assert ask(742 Q.finite(a), Q.finite(x) & Q.positive(y) & ~Q.finite(y)) is None743 assert ask(Q.finite(a), Q.finite(x) &744 Q.positive(y) & ~Q.finite(y) & Q.positive(z)) is False745 assert ask(746 Q.finite(a), Q.finite(x) & Q.negative(y) & Q.negative(z)) is None747 assert ask(Q.finite(a), Q.finite(x) & Q.negative(y)) is None748 assert ask(749 Q.finite(a), Q.finite(x) & Q.negative(y) & Q.positive(z)) is None750 assert ask(Q.finite(a), Q.finite(x)) is None751 assert ask(Q.finite(a), Q.finite(x) & Q.positive(z)) is None752 assert ask(753 Q.finite(a), Q.finite(x) & Q.positive(y) & Q.positive(z)) is None754 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) & Q.positive(y) &755 Q.finite(y) & Q.positive(z) & Q.finite(z)) is True756 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) & Q.positive(y) &757 Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False758 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &759 Q.positive(y) & Q.finite(y) & ~Q.finite(z)) is False760 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) & Q.positive(y) &761 Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False762 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &763 Q.positive(y) & Q.finite(y) & Q.negative(z)) is None764 assert ask(Q.finite(a), Q.positive(x) &765 Q.finite(x) & Q.positive(y) & Q.finite(y)) is None766 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &767 Q.positive(y) & Q.finite(y) & Q.positive(z)) is None768 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) & Q.negative(y) &769 ~Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False770 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &771 Q.negative(y) & ~Q.finite(y) & ~Q.finite(z)) is None772 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) & Q.negative(y) &773 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None774 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &775 Q.negative(y) & ~Q.finite(y) & Q.negative(z)) is False776 assert ask(Q.finite(a), Q.positive(x) &777 Q.finite(x) & Q.negative(y) & ~Q.finite(y)) is None778 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &779 Q.negative(y) & ~Q.finite(y) & Q.positive(z)) is None780 assert ask(Q.finite(a), Q.positive(x) &781 Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is None782 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &783 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None784 assert ask(Q.finite(a), Q.positive(x) &785 Q.finite(x) & ~Q.finite(y) & Q.negative(z)) is None786 assert ask(787 Q.finite(a), Q.positive(x) & Q.finite(x) & ~Q.finite(y)) is None788 assert ask(Q.finite(a), Q.positive(x) &789 Q.finite(x) & ~Q.finite(y) & Q.positive(z)) is None790 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) & Q.positive(y) &791 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False792 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &793 Q.positive(y) & ~Q.finite(y) & Q.negative(z)) is None794 assert ask(Q.finite(a), Q.positive(x) &795 Q.finite(x) & Q.positive(y) & ~Q.finite(y)) is None796 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x) &797 Q.positive(y) & ~Q.finite(y) & Q.positive(z)) is False798 assert ask(Q.finite(a), Q.positive(x) &799 Q.finite(x) & Q.negative(y) & Q.negative(z)) is None800 assert ask(801 Q.finite(a), Q.positive(x) & Q.finite(x) & Q.negative(y)) is None802 assert ask(Q.finite(a), Q.positive(x) &803 Q.finite(x) & Q.negative(y) & Q.positive(z)) is None804 assert ask(Q.finite(a), Q.positive(x) & Q.finite(x)) is None805 assert ask(806 Q.finite(a), Q.positive(x) & Q.finite(x) & Q.positive(z)) is None807 assert ask(Q.finite(a), Q.positive(x) &808 Q.finite(x) & Q.positive(y) & Q.positive(z)) is None809 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) & Q.negative(y) &810 ~Q.finite(y) & Q.negative(z) & ~Q.finite(z)) is False811 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) &812 Q.negative(y) & ~Q.finite(y) & ~Q.finite(z)) is None813 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) & Q.negative(y) &814 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None815 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) &816 Q.negative(y) & ~Q.finite(y) & Q.negative(z)) is False817 assert ask(Q.finite(a), Q.negative(x) &818 ~Q.finite(x) & Q.negative(y) & ~Q.finite(y)) is None819 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) &820 Q.negative(y) & ~Q.finite(y) & Q.positive(z)) is None821 assert ask(Q.finite(a), Q.negative(x) &822 ~Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is None823 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) &824 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None825 assert ask(Q.finite(a), Q.negative(x) &826 ~Q.finite(x) & ~Q.finite(y) & Q.negative(z)) is None827 assert ask(828 Q.finite(a), Q.negative(x) & ~Q.finite(x) & ~Q.finite(y)) is None829 assert ask(Q.finite(a), Q.negative(x) &830 ~Q.finite(x) & ~Q.finite(y) & Q.positive(z)) is None831 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) & Q.positive(y) &832 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None833 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) &834 Q.positive(y) & ~Q.finite(y) & Q.negative(z)) is None835 assert ask(Q.finite(a), Q.negative(x) &836 ~Q.finite(x) & Q.positive(y) & ~Q.finite(y)) is None837 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x) &838 Q.positive(y) & ~Q.finite(y) & Q.positive(z)) is None839 assert ask(Q.finite(a), Q.negative(x) &840 ~Q.finite(x) & Q.negative(y) & Q.negative(z)) is False841 assert ask(842 Q.finite(a), Q.negative(x) & ~Q.finite(x) & Q.negative(y)) is None843 assert ask(Q.finite(a), Q.negative(x) &844 ~Q.finite(x) & Q.negative(y) & Q.positive(z)) is None845 assert ask(Q.finite(a), Q.negative(x) & ~Q.finite(x)) is None846 assert ask(847 Q.finite(a), Q.negative(x) & ~Q.finite(x) & Q.positive(z)) is None848 assert ask(Q.finite(a), Q.negative(x) &849 ~Q.finite(x) & Q.positive(y) & Q.positive(z)) is None850 assert ask(851 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is None852 assert ask(Q.finite(a), ~Q.finite(x) &853 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None854 assert ask(855 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.negative(z)) is None856 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y)) is None857 assert ask(858 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.positive(z)) is None859 assert ask(Q.finite(a), ~Q.finite(x) & Q.positive(y) &860 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is None861 assert ask(Q.finite(a), ~Q.finite(x) &862 Q.positive(y) & ~Q.finite(y) & Q.negative(z)) is None863 assert ask(864 Q.finite(a), ~Q.finite(x) & Q.positive(y) & ~Q.finite(y)) is None865 assert ask(Q.finite(a), ~Q.finite(x) &866 Q.positive(y) & ~Q.finite(y) & Q.positive(z)) is None867 assert ask(868 Q.finite(a), ~Q.finite(x) & Q.negative(y) & Q.negative(z)) is None869 assert ask(Q.finite(a), ~Q.finite(x) & Q.negative(y)) is None870 assert ask(871 Q.finite(a), ~Q.finite(x) & Q.negative(y) & Q.positive(z)) is None872 assert ask(Q.finite(a), ~Q.finite(x)) is None873 assert ask(Q.finite(a), ~Q.finite(x) & Q.positive(z)) is None874 assert ask(875 Q.finite(a), ~Q.finite(x) & Q.positive(y) & Q.positive(z)) is None876 assert ask(Q.finite(a), Q.positive(x) & ~Q.finite(x) & Q.positive(y) &877 ~Q.finite(y) & Q.positive(z) & ~Q.finite(z)) is False878 assert ask(Q.finite(a), Q.positive(x) & ~Q.finite(x) &879 Q.positive(y) & ~Q.finite(y) & Q.negative(z)) is None880 assert ask(Q.finite(a), Q.positive(x) &881 ~Q.finite(x) & Q.positive(y) & ~Q.finite(y)) is None882 assert ask(Q.finite(a), Q.positive(x) & ~Q.finite(x) &883 Q.positive(y) & ~Q.finite(y) & Q.positive(z)) is False884 assert ask(Q.finite(a), Q.positive(x) &885 ~Q.finite(x) & Q.negative(y) & Q.negative(z)) is None886 assert ask(887 Q.finite(a), Q.positive(x) & ~Q.finite(x) & Q.negative(y)) is None888 assert ask(Q.finite(a), Q.positive(x) &889 ~Q.finite(x) & Q.negative(y) & Q.positive(z)) is None890 assert ask(Q.finite(a), Q.positive(x) & ~Q.finite(x)) is None891 assert ask(892 Q.finite(a), Q.positive(x) & ~Q.finite(x) & Q.positive(z)) is None893 assert ask(Q.finite(a), Q.positive(x) &894 ~Q.finite(x) & Q.positive(y) & Q.positive(z)) is False895 assert ask(896 Q.finite(a), Q.negative(x) & Q.negative(y) & Q.negative(z)) is None897 assert ask(Q.finite(a), Q.negative(x) & Q.negative(y)) is None898 assert ask(899 Q.finite(a), Q.negative(x) & Q.negative(y) & Q.positive(z)) is None900 assert ask(Q.finite(a), Q.negative(x)) is None901 assert ask(Q.finite(a), Q.negative(x) & Q.positive(z)) is None902 assert ask(903 Q.finite(a), Q.negative(x) & Q.positive(y) & Q.positive(z)) is None904 assert ask(Q.finite(a)) is None905 assert ask(Q.finite(a), Q.positive(z)) is None906 assert ask(Q.finite(a), Q.positive(y) & Q.positive(z)) is None907 assert ask(908 Q.finite(a), Q.positive(x) & Q.positive(y) & Q.positive(z)) is None909 assert ask(Q.finite(2*x)) is None910 assert ask(Q.finite(2*x), Q.finite(x)) is True911 x, y, z = symbols('x,y,z')912 a = x*y913 x, y = a.args914 assert ask(Q.finite(a), Q.finite(x) & Q.finite(y)) is True915 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y)) is False916 assert ask(Q.finite(a), Q.finite(x)) is None917 assert ask(Q.finite(a), ~Q.finite(x) & Q.finite(y)) is False918 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y)) is False919 assert ask(Q.finite(a), ~Q.finite(x)) is None920 assert ask(Q.finite(a), Q.finite(y)) is None921 assert ask(Q.finite(a), ~Q.finite(y)) is None922 assert ask(Q.finite(a)) is None923 a = x*y*z924 x, y, z = a.args925 assert ask(926 Q.finite(a), Q.finite(x) & Q.finite(y) & Q.finite(z)) is True927 assert ask(928 Q.finite(a), Q.finite(x) & Q.finite(y) & ~Q.finite(z)) is False929 assert ask(Q.finite(a), Q.finite(x) & Q.finite(y)) is None930 assert ask(931 Q.finite(a), Q.finite(x) & ~Q.finite(y) & Q.finite(z)) is False932 assert ask(933 Q.finite(a), Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is False934 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(y)) is None935 assert ask(Q.finite(a), Q.finite(x) & Q.finite(z)) is None936 assert ask(Q.finite(a), Q.finite(x) & ~Q.finite(z)) is None937 assert ask(Q.finite(a), Q.finite(x)) is None938 assert ask(939 Q.finite(a), ~Q.finite(x) & Q.finite(y) & Q.finite(z)) is False940 assert ask(941 Q.finite(a), ~Q.finite(x) & Q.finite(y) & ~Q.finite(z)) is False942 assert ask(Q.finite(a), ~Q.finite(x) & Q.finite(y)) is None943 assert ask(944 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & Q.finite(z)) is False945 assert ask(946 Q.finite(a), ~Q.finite(x) & ~Q.finite(y) & ~Q.finite(z)) is False947 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(y)) is None948 assert ask(Q.finite(a), ~Q.finite(x) & Q.finite(z)) is None949 assert ask(Q.finite(a), ~Q.finite(x) & ~Q.finite(z)) is None950 assert ask(Q.finite(a), ~Q.finite(x)) is None951 assert ask(Q.finite(a), Q.finite(y) & Q.finite(z)) is None952 assert ask(Q.finite(a), Q.finite(y) & ~Q.finite(z)) is None953 assert ask(Q.finite(a), Q.finite(y)) is None954 assert ask(Q.finite(a), ~Q.finite(y) & Q.finite(z)) is None955 assert ask(Q.finite(a), ~Q.finite(y) & ~Q.finite(z)) is None956 assert ask(Q.finite(a), ~Q.finite(y)) is None957 assert ask(Q.finite(a), Q.finite(z)) is None958 assert ask(Q.finite(a), ~Q.finite(z)) is None959 assert ask(Q.finite(a), ~Q.finite(z) &960 Q.nonzero(x) & Q.nonzero(y) & Q.nonzero(z)) is None961 assert ask(Q.finite(a), ~Q.finite(y) & ~Q.finite(z) &962 Q.nonzero(x) & Q.nonzero(y) & Q.nonzero(z)) is False963 x, y, z = symbols('x,y,z')964 assert ask(Q.finite(x**2)) is None965 assert ask(Q.finite(2**x)) is None966 assert ask(Q.finite(2**x), Q.finite(x)) is True967 assert ask(Q.finite(x**x)) is None968 assert ask(Q.finite(S.Half ** x)) is None969 assert ask(Q.finite(S.Half ** x), Q.positive(x)) is True970 assert ask(Q.finite(S.Half ** x), Q.negative(x)) is None971 assert ask(Q.finite(2**x), Q.negative(x)) is True972 assert ask(Q.finite(sqrt(x))) is None973 assert ask(Q.finite(2**x), ~Q.finite(x)) is False974 assert ask(Q.finite(x**2), ~Q.finite(x)) is False975 # sign function976 assert ask(Q.finite(sign(x))) is True977 assert ask(Q.finite(sign(x)), ~Q.finite(x)) is True978 # exponential functions979 assert ask(Q.finite(log(x))) is None980 assert ask(Q.finite(log(x)), Q.finite(x)) is True981 assert ask(Q.finite(exp(x))) is None982 assert ask(Q.finite(exp(x)), Q.finite(x)) is True983 assert ask(Q.finite(exp(2))) is True984 # trigonometric functions985 assert ask(Q.finite(sin(x))) is True986 assert ask(Q.finite(sin(x)), ~Q.finite(x)) is True987 assert ask(Q.finite(cos(x))) is True988 assert ask(Q.finite(cos(x)), ~Q.finite(x)) is True989 assert ask(Q.finite(2*sin(x))) is True990 assert ask(Q.finite(sin(x)**2)) is True991 assert ask(Q.finite(cos(x)**2)) is True992 assert ask(Q.finite(cos(x) + sin(x))) is True993@XFAIL994def test_bounded_xfail():995 """We need to support relations in ask for this to work"""996 assert ask(Q.finite(sin(x)**x)) is True997 assert ask(Q.finite(cos(x)**x)) is True998def test_commutative():999 """By default objects are Q.commutative that is why it returns True1000 for both key=True and key=False"""1001 assert ask(Q.commutative(x)) is True1002 assert ask(Q.commutative(x), ~Q.commutative(x)) is False1003 assert ask(Q.commutative(x), Q.complex(x)) is True1004 assert ask(Q.commutative(x), Q.imaginary(x)) is True1005 assert ask(Q.commutative(x), Q.real(x)) is True1006 assert ask(Q.commutative(x), Q.positive(x)) is True1007 assert ask(Q.commutative(x), ~Q.commutative(y)) is True1008 assert ask(Q.commutative(2*x)) is True1009 assert ask(Q.commutative(2*x), ~Q.commutative(x)) is False1010 assert ask(Q.commutative(x + 1)) is True1011 assert ask(Q.commutative(x + 1), ~Q.commutative(x)) is False1012 assert ask(Q.commutative(x**2)) is True1013 assert ask(Q.commutative(x**2), ~Q.commutative(x)) is False1014 assert ask(Q.commutative(log(x))) is True1015def test_complex():1016 assert ask(Q.complex(x)) is None1017 assert ask(Q.complex(x), Q.complex(x)) is True1018 assert ask(Q.complex(x), Q.complex(y)) is None1019 assert ask(Q.complex(x), ~Q.complex(x)) is False1020 assert ask(Q.complex(x), Q.real(x)) is True1021 assert ask(Q.complex(x), ~Q.real(x)) is None1022 assert ask(Q.complex(x), Q.rational(x)) is True1023 assert ask(Q.complex(x), Q.irrational(x)) is True1024 assert ask(Q.complex(x), Q.positive(x)) is True1025 assert ask(Q.complex(x), Q.imaginary(x)) is True1026 assert ask(Q.complex(x), Q.algebraic(x)) is True1027 # a+b1028 assert ask(Q.complex(x + 1), Q.complex(x)) is True1029 assert ask(Q.complex(x + 1), Q.real(x)) is True1030 assert ask(Q.complex(x + 1), Q.rational(x)) is True1031 assert ask(Q.complex(x + 1), Q.irrational(x)) is True1032 assert ask(Q.complex(x + 1), Q.imaginary(x)) is True1033 assert ask(Q.complex(x + 1), Q.integer(x)) is True1034 assert ask(Q.complex(x + 1), Q.even(x)) is True1035 assert ask(Q.complex(x + 1), Q.odd(x)) is True1036 assert ask(Q.complex(x + y), Q.complex(x) & Q.complex(y)) is True1037 assert ask(Q.complex(x + y), Q.real(x) & Q.imaginary(y)) is True1038 # a*x +b1039 assert ask(Q.complex(2*x + 1), Q.complex(x)) is True1040 assert ask(Q.complex(2*x + 1), Q.real(x)) is True1041 assert ask(Q.complex(2*x + 1), Q.positive(x)) is True1042 assert ask(Q.complex(2*x + 1), Q.rational(x)) is True1043 assert ask(Q.complex(2*x + 1), Q.irrational(x)) is True1044 assert ask(Q.complex(2*x + 1), Q.imaginary(x)) is True1045 assert ask(Q.complex(2*x + 1), Q.integer(x)) is True1046 assert ask(Q.complex(2*x + 1), Q.even(x)) is True1047 assert ask(Q.complex(2*x + 1), Q.odd(x)) is True1048 # x**21049 assert ask(Q.complex(x**2), Q.complex(x)) is True1050 assert ask(Q.complex(x**2), Q.real(x)) is True1051 assert ask(Q.complex(x**2), Q.positive(x)) is True1052 assert ask(Q.complex(x**2), Q.rational(x)) is True1053 assert ask(Q.complex(x**2), Q.irrational(x)) is True1054 assert ask(Q.complex(x**2), Q.imaginary(x)) is True1055 assert ask(Q.complex(x**2), Q.integer(x)) is True1056 assert ask(Q.complex(x**2), Q.even(x)) is True1057 assert ask(Q.complex(x**2), Q.odd(x)) is True1058 # 2**x1059 assert ask(Q.complex(2**x), Q.complex(x)) is True1060 assert ask(Q.complex(2**x), Q.real(x)) is True1061 assert ask(Q.complex(2**x), Q.positive(x)) is True1062 assert ask(Q.complex(2**x), Q.rational(x)) is True1063 assert ask(Q.complex(2**x), Q.irrational(x)) is True1064 assert ask(Q.complex(2**x), Q.imaginary(x)) is True1065 assert ask(Q.complex(2**x), Q.integer(x)) is True1066 assert ask(Q.complex(2**x), Q.even(x)) is True1067 assert ask(Q.complex(2**x), Q.odd(x)) is True1068 assert ask(Q.complex(x**y), Q.complex(x) & Q.complex(y)) is True1069 # trigonometric expressions1070 assert ask(Q.complex(sin(x))) is True1071 assert ask(Q.complex(sin(2*x + 1))) is True1072 assert ask(Q.complex(cos(x))) is True1073 assert ask(Q.complex(cos(2*x + 1))) is True1074 # exponential1075 assert ask(Q.complex(exp(x))) is True1076 assert ask(Q.complex(exp(x))) is True1077 # Q.complexes1078 assert ask(Q.complex(Abs(x))) is True1079 assert ask(Q.complex(re(x))) is True1080 assert ask(Q.complex(im(x))) is True1081def test_even_query():1082 assert ask(Q.even(x)) is None1083 assert ask(Q.even(x), Q.integer(x)) is None1084 assert ask(Q.even(x), ~Q.integer(x)) is False1085 assert ask(Q.even(x), Q.rational(x)) is None1086 assert ask(Q.even(x), Q.positive(x)) is None1087 assert ask(Q.even(2*x)) is None1088 assert ask(Q.even(2*x), Q.integer(x)) is True1089 assert ask(Q.even(2*x), Q.even(x)) is True1090 assert ask(Q.even(2*x), Q.irrational(x)) is False1091 assert ask(Q.even(2*x), Q.odd(x)) is True1092 assert ask(Q.even(2*x), ~Q.integer(x)) is None1093 assert ask(Q.even(3*x), Q.integer(x)) is None1094 assert ask(Q.even(3*x), Q.even(x)) is True1095 assert ask(Q.even(3*x), Q.odd(x)) is False1096 assert ask(Q.even(x + 1), Q.odd(x)) is True1097 assert ask(Q.even(x + 1), Q.even(x)) is False1098 assert ask(Q.even(x + 2), Q.odd(x)) is False1099 assert ask(Q.even(x + 2), Q.even(x)) is True1100 assert ask(Q.even(7 - x), Q.odd(x)) is True1101 assert ask(Q.even(7 + x), Q.odd(x)) is True1102 assert ask(Q.even(x + y), Q.odd(x) & Q.odd(y)) is True1103 assert ask(Q.even(x + y), Q.odd(x) & Q.even(y)) is False1104 assert ask(Q.even(x + y), Q.even(x) & Q.even(y)) is True1105 assert ask(Q.even(2*x + 1), Q.integer(x)) is False1106 assert ask(Q.even(2*x*y), Q.rational(x) & Q.rational(x)) is None1107 assert ask(Q.even(2*x*y), Q.irrational(x) & Q.irrational(x)) is None1108 assert ask(Q.even(x + y + z), Q.odd(x) & Q.odd(y) & Q.even(z)) is True1109 assert ask(Q.even(x + y + z + t),1110 Q.odd(x) & Q.odd(y) & Q.even(z) & Q.integer(t)) is None1111 assert ask(Q.even(Abs(x)), Q.even(x)) is True1112 assert ask(Q.even(Abs(x)), ~Q.even(x)) is None1113 assert ask(Q.even(re(x)), Q.even(x)) is True1114 assert ask(Q.even(re(x)), ~Q.even(x)) is None1115 assert ask(Q.even(im(x)), Q.even(x)) is True1116 assert ask(Q.even(im(x)), Q.real(x)) is True1117 assert ask(Q.even((-1)**n), Q.integer(n)) is False1118 assert ask(Q.even(k**2), Q.even(k)) is True1119 assert ask(Q.even(n**2), Q.odd(n)) is False1120 assert ask(Q.even(2**k), Q.even(k)) is None1121 assert ask(Q.even(x**2)) is None1122 assert ask(Q.even(k**m), Q.even(k) & Q.integer(m) & ~Q.negative(m)) is None1123 assert ask(Q.even(n**m), Q.odd(n) & Q.integer(m) & ~Q.negative(m)) is False1124 assert ask(Q.even(k**p), Q.even(k) & Q.integer(p) & Q.positive(p)) is True1125 assert ask(Q.even(n**p), Q.odd(n) & Q.integer(p) & Q.positive(p)) is False1126 assert ask(Q.even(m**k), Q.even(k) & Q.integer(m) & ~Q.negative(m)) is None1127 assert ask(Q.even(p**k), Q.even(k) & Q.integer(p) & Q.positive(p)) is None1128 assert ask(Q.even(m**n), Q.odd(n) & Q.integer(m) & ~Q.negative(m)) is None1129 assert ask(Q.even(p**n), Q.odd(n) & Q.integer(p) & Q.positive(p)) is None1130 assert ask(Q.even(k**x), Q.even(k)) is None1131 assert ask(Q.even(n**x), Q.odd(n)) is None1132 assert ask(Q.even(x*y), Q.integer(x) & Q.integer(y)) is None1133 assert ask(Q.even(x*x), Q.integer(x)) is None1134 assert ask(Q.even(x*(x + y)), Q.integer(x) & Q.odd(y)) is True1135 assert ask(Q.even(x*(x + y)), Q.integer(x) & Q.even(y)) is None1136@XFAIL1137def test_evenness_in_ternary_integer_product_with_odd():1138 # Tests that oddness inference is independent of term ordering.1139 # Term ordering at the point of testing depends on SymPy's symbol order, so1140 # we try to force a different order by modifying symbol names.1141 assert ask(Q.even(x*y*(y + z)), Q.integer(x) & Q.integer(y) & Q.odd(z)) is True1142 assert ask(Q.even(y*x*(x + z)), Q.integer(x) & Q.integer(y) & Q.odd(z)) is True1143def test_evenness_in_ternary_integer_product_with_even():1144 assert ask(Q.even(x*y*(y + z)), Q.integer(x) & Q.integer(y) & Q.even(z)) is None1145def test_extended_real():1146 assert ask(Q.extended_real(x), Q.positive(x)) is True1147 assert ask(Q.extended_real(-x), Q.positive(x)) is True1148 assert ask(Q.extended_real(-x), Q.negative(x)) is True1149 assert ask(Q.extended_real(x + S.Infinity), Q.real(x)) is True1150def test_rational():1151 assert ask(Q.rational(x), Q.integer(x)) is True1152 assert ask(Q.rational(x), Q.irrational(x)) is False1153 assert ask(Q.rational(x), Q.real(x)) is None1154 assert ask(Q.rational(x), Q.positive(x)) is None1155 assert ask(Q.rational(x), Q.negative(x)) is None1156 assert ask(Q.rational(x), Q.nonzero(x)) is None1157 assert ask(Q.rational(x), ~Q.algebraic(x)) is False1158 assert ask(Q.rational(2*x), Q.rational(x)) is True1159 assert ask(Q.rational(2*x), Q.integer(x)) is True1160 assert ask(Q.rational(2*x), Q.even(x)) is True1161 assert ask(Q.rational(2*x), Q.odd(x)) is True1162 assert ask(Q.rational(2*x), Q.irrational(x)) is False1163 assert ask(Q.rational(x/2), Q.rational(x)) is True1164 assert ask(Q.rational(x/2), Q.integer(x)) is True1165 assert ask(Q.rational(x/2), Q.even(x)) is True1166 assert ask(Q.rational(x/2), Q.odd(x)) is True1167 assert ask(Q.rational(x/2), Q.irrational(x)) is False1168 assert ask(Q.rational(1/x), Q.rational(x)) is True1169 assert ask(Q.rational(1/x), Q.integer(x)) is True1170 assert ask(Q.rational(1/x), Q.even(x)) is True1171 assert ask(Q.rational(1/x), Q.odd(x)) is True1172 assert ask(Q.rational(1/x), Q.irrational(x)) is False1173 assert ask(Q.rational(2/x), Q.rational(x)) is True1174 assert ask(Q.rational(2/x), Q.integer(x)) is True1175 assert ask(Q.rational(2/x), Q.even(x)) is True1176 assert ask(Q.rational(2/x), Q.odd(x)) is True1177 assert ask(Q.rational(2/x), Q.irrational(x)) is False1178 assert ask(Q.rational(x), ~Q.algebraic(x)) is False1179 # with multiple symbols1180 assert ask(Q.rational(x*y), Q.irrational(x) & Q.irrational(y)) is None1181 assert ask(Q.rational(y/x), Q.rational(x) & Q.rational(y)) is True1182 assert ask(Q.rational(y/x), Q.integer(x) & Q.rational(y)) is True1183 assert ask(Q.rational(y/x), Q.even(x) & Q.rational(y)) is True1184 assert ask(Q.rational(y/x), Q.odd(x) & Q.rational(y)) is True1185 assert ask(Q.rational(y/x), Q.irrational(x) & Q.rational(y)) is False1186 for f in [exp, sin, tan, asin, atan, cos]:1187 assert ask(Q.rational(f(7))) is False1188 assert ask(Q.rational(f(7, evaluate=False))) is False1189 assert ask(Q.rational(f(0, evaluate=False))) is True1190 assert ask(Q.rational(f(x)), Q.rational(x)) is None1191 assert ask(Q.rational(f(x)), Q.rational(x) & Q.nonzero(x)) is False1192 for g in [log, acos]:1193 assert ask(Q.rational(g(7))) is False1194 assert ask(Q.rational(g(7, evaluate=False))) is False1195 assert ask(Q.rational(g(1, evaluate=False))) is True1196 assert ask(Q.rational(g(x)), Q.rational(x)) is None1197 assert ask(Q.rational(g(x)), Q.rational(x) & Q.nonzero(x - 1)) is False1198 for h in [cot, acot]:1199 assert ask(Q.rational(h(7))) is False1200 assert ask(Q.rational(h(7, evaluate=False))) is False1201 assert ask(Q.rational(h(x)), Q.rational(x)) is False1202def test_hermitian():1203 assert ask(Q.hermitian(x)) is None1204 assert ask(Q.hermitian(x), Q.antihermitian(x)) is False1205 assert ask(Q.hermitian(x), Q.imaginary(x)) is False1206 assert ask(Q.hermitian(x), is True1207 assert ask(Q.hermitian(x), Q.real(x)) is True1208 assert ask(Q.hermitian(x + 1), Q.antihermitian(x)) is False1209 assert ask(Q.hermitian(x + 1), Q.complex(x)) is None1210 assert ask(Q.hermitian(x + 1), Q.hermitian(x)) is True1211 assert ask(Q.hermitian(x + 1), Q.imaginary(x)) is False1212 assert ask(Q.hermitian(x + 1), Q.real(x)) is True1213 assert ask(Q.hermitian(x + I), Q.antihermitian(x)) is None1214 assert ask(Q.hermitian(x + I), Q.complex(x)) is None1215 assert ask(Q.hermitian(x + I), Q.hermitian(x)) is False1216 assert ask(Q.hermitian(x + I), Q.imaginary(x)) is None1217 assert ask(Q.hermitian(x + I), Q.real(x)) is False1218 assert ask(1219 Q.hermitian(x + y), Q.antihermitian(x) & Q.antihermitian(y)) is None1220 assert ask(Q.hermitian(x + y), Q.antihermitian(x) & Q.complex(y)) is None1221 assert ask(1222 Q.hermitian(x + y), Q.antihermitian(x) & Q.hermitian(y)) is False1223 assert ask(Q.hermitian(x + y), Q.antihermitian(x) & Q.imaginary(y)) is None1224 assert ask(Q.hermitian(x + y), Q.antihermitian(x) & Q.real(y)) is False1225 assert ask(Q.hermitian(x + y), Q.hermitian(x) & Q.complex(y)) is None1226 assert ask(Q.hermitian(x + y), Q.hermitian(x) & Q.hermitian(y)) is True1227 assert ask(Q.hermitian(x + y), Q.hermitian(x) & Q.imaginary(y)) is False1228 assert ask(Q.hermitian(x + y), Q.hermitian(x) & Q.real(y)) is True1229 assert ask(Q.hermitian(x + y), Q.imaginary(x) & Q.complex(y)) is None1230 assert ask(Q.hermitian(x + y), Q.imaginary(x) & Q.imaginary(y)) is None1231 assert ask(Q.hermitian(x + y), Q.imaginary(x) & Q.real(y)) is False1232 assert ask(Q.hermitian(x + y), Q.real(x) & Q.complex(y)) is None1233 assert ask(Q.hermitian(x + y), Q.real(x) & Q.real(y)) is True1234 assert ask(Q.hermitian(I*x), Q.antihermitian(x)) is True1235 assert ask(Q.hermitian(I*x), Q.complex(x)) is None1236 assert ask(Q.hermitian(I*x), Q.hermitian(x)) is False1237 assert ask(Q.hermitian(I*x), Q.imaginary(x)) is True1238 assert ask(Q.hermitian(I*x), Q.real(x)) is False1239 assert ask(Q.hermitian(x*y), Q.hermitian(x) & Q.real(y)) is True1240 assert ask(1241 Q.hermitian(x + y + z), Q.real(x) & Q.real(y) & Q.real(z)) is True1242 assert ask(Q.hermitian(x + y + z),1243 Q.real(x) & Q.real(y) & Q.imaginary(z)) is False1244 assert ask(Q.hermitian(x + y + z),1245 Q.real(x) & Q.imaginary(y) & Q.imaginary(z)) is None1246 assert ask(Q.hermitian(x + y + z),1247 Q.imaginary(x) & Q.imaginary(y) & Q.imaginary(z)) is None1248 assert ask(Q.antihermitian(x)) is None1249 assert ask(Q.antihermitian(x), Q.real(x)) is False1250 assert ask(Q.antihermitian(x), is False1251 assert ask(Q.antihermitian(x + 1), Q.antihermitian(x)) is False1252 assert ask(Q.antihermitian(x + 1), Q.complex(x)) is None1253 assert ask(Q.antihermitian(x + 1), Q.hermitian(x)) is None1254 assert ask(Q.antihermitian(x + 1), Q.imaginary(x)) is False1255 assert ask(Q.antihermitian(x + 1), Q.real(x)) is False1256 assert ask(Q.antihermitian(x + I), Q.antihermitian(x)) is True1257 assert ask(Q.antihermitian(x + I), Q.complex(x)) is None1258 assert ask(Q.antihermitian(x + I), Q.hermitian(x)) is False1259 assert ask(Q.antihermitian(x + I), Q.imaginary(x)) is True1260 assert ask(Q.antihermitian(x + I), Q.real(x)) is False1261 assert ask(1262 Q.antihermitian(x + y), Q.antihermitian(x) & Q.antihermitian(y)1263 ) is True1264 assert ask(1265 Q.antihermitian(x + y), Q.antihermitian(x) & Q.complex(y)) is None1266 assert ask(1267 Q.antihermitian(x + y), Q.antihermitian(x) & Q.hermitian(y)) is False1268 assert ask(1269 Q.antihermitian(x + y), Q.antihermitian(x) & Q.imaginary(y)) is True1270 assert ask(Q.antihermitian(x + y), Q.antihermitian(x) & Q.real(y)1271 ) is False1272 assert ask(Q.antihermitian(x + y), Q.hermitian(x) & Q.complex(y)) is None1273 assert ask(Q.antihermitian(x + y), Q.hermitian(x) & Q.hermitian(y)1274 ) is None1275 assert ask(1276 Q.antihermitian(x + y), Q.hermitian(x) & Q.imaginary(y)) is False1277 assert ask(Q.antihermitian(x + y), Q.hermitian(x) & Q.real(y)) is None1278 assert ask(Q.antihermitian(x + y), Q.imaginary(x) & Q.complex(y)) is None1279 assert ask(Q.antihermitian(x + y), Q.imaginary(x) & Q.imaginary(y)) is True1280 assert ask(Q.antihermitian(x + y), Q.imaginary(x) & Q.real(y)) is False1281 assert ask(Q.antihermitian(x + y), Q.real(x) & Q.complex(y)) is None1282 assert ask(Q.antihermitian(x + y), Q.real(x) & Q.real(y)) is False1283 assert ask(Q.antihermitian(I*x), Q.real(x)) is True1284 assert ask(Q.antihermitian(I*x), Q.antihermitian(x)) is False1285 assert ask(Q.antihermitian(I*x), Q.complex(x)) is None1286 assert ask(Q.antihermitian(x*y), Q.antihermitian(x) & Q.real(y)) is True1287 assert ask(Q.antihermitian(x + y + z),1288 Q.real(x) & Q.real(y) & Q.real(z)) is False1289 assert ask(Q.antihermitian(x + y + z),1290 Q.real(x) & Q.real(y) & Q.imaginary(z)) is None1291 assert ask(Q.antihermitian(x + y + z),1292 Q.real(x) & Q.imaginary(y) & Q.imaginary(z)) is False1293 assert ask(Q.antihermitian(x + y + z),1294 Q.imaginary(x) & Q.imaginary(y) & Q.imaginary(z)) is True1295def test_imaginary():1296 assert ask(Q.imaginary(x)) is None1297 assert ask(Q.imaginary(x), Q.real(x)) is False1298 assert ask(Q.imaginary(x), is False1299 assert ask(Q.imaginary(x + 1), Q.real(x)) is False1300 assert ask(Q.imaginary(x + 1), Q.imaginary(x)) is False1301 assert ask(Q.imaginary(x + I), Q.real(x)) is False1302 assert ask(Q.imaginary(x + I), Q.imaginary(x)) is True1303 assert ask(Q.imaginary(x + y), Q.imaginary(x) & Q.imaginary(y)) is True1304 assert ask(Q.imaginary(x + y), Q.real(x) & Q.real(y)) is False1305 assert ask(Q.imaginary(x + y), Q.imaginary(x) & Q.real(y)) is False1306 assert ask(Q.imaginary(x + y), Q.complex(x) & Q.real(y)) is None1307 assert ask(1308 Q.imaginary(x + y + z), Q.real(x) & Q.real(y) & Q.real(z)) is False1309 assert ask(Q.imaginary(x + y + z),1310 Q.real(x) & Q.real(y) & Q.imaginary(z)) is None1311 assert ask(Q.imaginary(x + y + z),1312 Q.real(x) & Q.imaginary(y) & Q.imaginary(z)) is False1313 assert ask(Q.imaginary(I*x), Q.real(x)) is True1314 assert ask(Q.imaginary(I*x), Q.imaginary(x)) is False1315 assert ask(Q.imaginary(I*x), Q.complex(x)) is None1316 assert ask(Q.imaginary(x*y), Q.imaginary(x) & Q.real(y)) is True1317 assert ask(Q.imaginary(x*y), Q.real(x) & Q.real(y)) is False1318 assert ask(Q.imaginary(I**x), Q.negative(x)) is None1319 assert ask(Q.imaginary(I**x), Q.positive(x)) is None1320 assert ask(Q.imaginary(I**x), Q.even(x)) is False1321 assert ask(Q.imaginary(I**x), Q.odd(x)) is True1322 assert ask(Q.imaginary(I**x), Q.imaginary(x)) is False1323 assert ask(Q.imaginary((2*I)**x), Q.imaginary(x)) is False1324 assert ask(Q.imaginary(x**0), Q.imaginary(x)) is False1325 assert ask(Q.imaginary(x**y), Q.imaginary(x) & Q.imaginary(y)) is None1326 assert ask(Q.imaginary(x**y), Q.imaginary(x) & Q.real(y)) is None1327 assert ask(Q.imaginary(x**y), Q.real(x) & Q.imaginary(y)) is None1328 assert ask(Q.imaginary(x**y), Q.real(x) & Q.real(y)) is None1329 assert ask(Q.imaginary(x**y), Q.imaginary(x) & Q.integer(y)) is None1330 assert ask(Q.imaginary(x**y), Q.imaginary(y) & Q.integer(x)) is None1331 assert ask(Q.imaginary(x**y), Q.imaginary(x) & Q.odd(y)) is True1332 assert ask(Q.imaginary(x**y), Q.imaginary(x) & Q.rational(y)) is None1333 assert ask(Q.imaginary(x**y), Q.imaginary(x) & Q.even(y)) is False1334 assert ask(Q.imaginary(x**y), Q.real(x) & Q.integer(y)) is False1335 assert ask(Q.imaginary(x**y), Q.positive(x) & Q.real(y)) is False1336 assert ask(Q.imaginary(x**y), Q.negative(x) & Q.real(y)) is None1337 assert ask(Q.imaginary(x**y), Q.negative(x) & Q.real(y) & ~Q.rational(y)) is False1338 assert ask(Q.imaginary(x**y), Q.integer(x) & Q.imaginary(y)) is None1339 assert ask(Q.imaginary(x**y), Q.negative(x) & Q.rational(y) & Q.integer(2*y)) is True1340 assert ask(Q.imaginary(x**y), Q.negative(x) & Q.rational(y) & ~Q.integer(2*y)) is False1341 assert ask(Q.imaginary(x**y), Q.negative(x) & Q.rational(y)) is None1342 assert ask(Q.imaginary(x**y), Q.real(x) & Q.rational(y) & ~Q.integer(2*y)) is False1343 assert ask(Q.imaginary(x**y), Q.real(x) & Q.rational(y) & Q.integer(2*y)) is None1344 # logarithm1345 assert ask(Q.imaginary(log(I))) is True1346 assert ask(Q.imaginary(log(2*I))) is False1347 assert ask(Q.imaginary(log(I + 1))) is False1348 assert ask(Q.imaginary(log(x)), Q.complex(x)) is None1349 assert ask(Q.imaginary(log(x)), Q.imaginary(x)) is None1350 assert ask(Q.imaginary(log(x)), Q.positive(x)) is False1351 assert ask(Q.imaginary(log(exp(x))), Q.complex(x)) is None1352 assert ask(Q.imaginary(log(exp(x))), Q.imaginary(x)) is None # zoo/I/a+I*b1353 assert ask(Q.imaginary(log(exp(I)))) is True1354 # exponential1355 assert ask(Q.imaginary(exp(x)**x), Q.imaginary(x)) is False1356 eq = Pow(exp(pi*I*x, evaluate=False), x, evaluate=False)1357 assert ask(Q.imaginary(eq), Q.even(x)) is False1358 eq = Pow(exp(pi*I*x/2, evaluate=False), x, evaluate=False)1359 assert ask(Q.imaginary(eq), Q.odd(x)) is True1360 assert ask(Q.imaginary(exp(3*I*pi*x)**x), Q.integer(x)) is False1361 assert ask(Q.imaginary(exp(2*pi*I, evaluate=False))) is False1362 assert ask(Q.imaginary(exp(pi*I/2, evaluate=False))) is True1363 # issue 78861364 assert ask(Q.imaginary(Pow(x, Rational(1, 4))), Q.real(x) & Q.negative(x)) is False1365def test_integer():1366 assert ask(Q.integer(x)) is None1367 assert ask(Q.integer(x), Q.integer(x)) is True1368 assert ask(Q.integer(x), ~Q.integer(x)) is False1369 assert ask(Q.integer(x), ~Q.real(x)) is False1370 assert ask(Q.integer(x), ~Q.positive(x)) is None1371 assert ask(Q.integer(x), Q.even(x) | Q.odd(x)) is True1372 assert ask(Q.integer(2*x), Q.integer(x)) is True1373 assert ask(Q.integer(2*x), Q.even(x)) is True1374 assert ask(Q.integer(2*x), is True1375 assert ask(Q.integer(2*x), Q.rational(x)) is None1376 assert ask(Q.integer(2*x), Q.real(x)) is None1377 assert ask(Q.integer(sqrt(2)*x), Q.integer(x)) is False1378 assert ask(Q.integer(sqrt(2)*x), Q.irrational(x)) is None1379 assert ask(Q.integer(x/2), Q.odd(x)) is False1380 assert ask(Q.integer(x/2), Q.even(x)) is True1381 assert ask(Q.integer(x/3), Q.odd(x)) is None1382 assert ask(Q.integer(x/3), Q.even(x)) is None1383def test_negative():1384 assert ask(Q.negative(x), Q.negative(x)) is True1385 assert ask(Q.negative(x), Q.positive(x)) is False1386 assert ask(Q.negative(x), ~Q.real(x)) is False1387 assert ask(Q.negative(x), is False1388 assert ask(Q.negative(x), is None1389 assert ask(Q.negative(-x), Q.positive(x)) is True1390 assert ask(Q.negative(-x), ~Q.positive(x)) is None1391 assert ask(Q.negative(-x), Q.negative(x)) is False1392 assert ask(Q.negative(-x), Q.positive(x)) is True1393 assert ask(Q.negative(x - 1), Q.negative(x)) is True1394 assert ask(Q.negative(x + y)) is None1395 assert ask(Q.negative(x + y), Q.negative(x)) is None1396 assert ask(Q.negative(x + y), Q.negative(x) & Q.negative(y)) is True1397 assert ask(Q.negative(x + y), Q.negative(x) & Q.nonpositive(y)) is True1398 assert ask(Q.negative(2 + I)) is False1399 # although this could be False, it is representative of expressions1400 # that don't evaluate to a zero with precision1401 assert ask(Q.negative(cos(I)**2 + sin(I)**2 - 1)) is None1402 assert ask(Q.negative(-I + I*(cos(2)**2 + sin(2)**2))) is None1403 assert ask(Q.negative(x**2)) is None1404 assert ask(Q.negative(x**2), Q.real(x)) is False1405 assert ask(Q.negative(x**1.4), Q.real(x)) is None1406 assert ask(Q.negative(x**I), Q.positive(x)) is None1407 assert ask(Q.negative(x*y)) is None1408 assert ask(Q.negative(x*y), Q.positive(x) & Q.positive(y)) is False1409 assert ask(Q.negative(x*y), Q.positive(x) & Q.negative(y)) is True1410 assert ask(Q.negative(x*y), Q.complex(x) & Q.complex(y)) is None1411 assert ask(Q.negative(x**y)) is None1412 assert ask(Q.negative(x**y), Q.negative(x) & Q.even(y)) is False1413 assert ask(Q.negative(x**y), Q.negative(x) & Q.odd(y)) is True1414 assert ask(Q.negative(x**y), Q.positive(x) & Q.integer(y)) is False1415 assert ask(Q.negative(Abs(x))) is False1416def test_nonzero():1417 assert ask(Q.nonzero(x)) is None1418 assert ask(Q.nonzero(x), Q.real(x)) is None1419 assert ask(Q.nonzero(x), Q.positive(x)) is True1420 assert ask(Q.nonzero(x), Q.negative(x)) is True1421 assert ask(Q.nonzero(x), Q.negative(x) | Q.positive(x)) is True1422 assert ask(Q.nonzero(x + y)) is None1423 assert ask(Q.nonzero(x + y), Q.positive(x) & Q.positive(y)) is True1424 assert ask(Q.nonzero(x + y), Q.positive(x) & Q.negative(y)) is None1425 assert ask(Q.nonzero(x + y), Q.negative(x) & Q.negative(y)) is True1426 assert ask(Q.nonzero(2*x)) is None1427 assert ask(Q.nonzero(2*x), Q.positive(x)) is True1428 assert ask(Q.nonzero(2*x), Q.negative(x)) is True1429 assert ask(Q.nonzero(x*y), Q.nonzero(x)) is None1430 assert ask(Q.nonzero(x*y), Q.nonzero(x) & Q.nonzero(y)) is True1431 assert ask(Q.nonzero(x**y), Q.nonzero(x)) is True1432 assert ask(Q.nonzero(Abs(x))) is None1433 assert ask(Q.nonzero(Abs(x)), Q.nonzero(x)) is True1434 assert ask(Q.nonzero(log(exp(2*I)))) is False1435 # although this could be False, it is representative of expressions1436 # that don't evaluate to a zero with precision1437 assert ask(Q.nonzero(cos(1)**2 + sin(1)**2 - 1)) is None1438def test_zero():1439 assert ask( is None1440 assert ask(, Q.real(x)) is None1441 assert ask(, Q.positive(x)) is False1442 assert ask(, Q.negative(x)) is False1443 assert ask(, Q.negative(x) | Q.positive(x)) is False1444 assert ask(, Q.nonnegative(x) & Q.nonpositive(x)) is True1445 assert ask( + y)) is None1446 assert ask( + y), Q.positive(x) & Q.positive(y)) is False1447 assert ask( + y), Q.positive(x) & Q.negative(y)) is None1448 assert ask( + y), Q.negative(x) & Q.negative(y)) is False1449 assert ask(*x)) is None1450 assert ask(*x), Q.positive(x)) is False1451 assert ask(*x), Q.negative(x)) is False1452 assert ask(*y), Q.nonzero(x)) is None1453 assert ask( is None1454 assert ask(, is True1455 assert ask(Q.integer(x), is True1456 assert ask(Q.even(x), is True1457 assert ask(Q.odd(x), is False1458 assert ask(, Q.even(x)) is None1459 assert ask(, Q.odd(x)) is False1460 assert ask( |,*y)) is True1461def test_odd_query():1462 assert ask(Q.odd(x)) is None1463 assert ask(Q.odd(x), Q.odd(x)) is True1464 assert ask(Q.odd(x), Q.integer(x)) is None1465 assert ask(Q.odd(x), ~Q.integer(x)) is False1466 assert ask(Q.odd(x), Q.rational(x)) is None1467 assert ask(Q.odd(x), Q.positive(x)) is None1468 assert ask(Q.odd(-x), Q.odd(x)) is True1469 assert ask(Q.odd(2*x)) is None1470 assert ask(Q.odd(2*x), Q.integer(x)) is False1471 assert ask(Q.odd(2*x), Q.odd(x)) is False1472 assert ask(Q.odd(2*x), Q.irrational(x)) is False1473 assert ask(Q.odd(2*x), ~Q.integer(x)) is None1474 assert ask(Q.odd(3*x), Q.integer(x)) is None1475 assert ask(Q.odd(x/3), Q.odd(x)) is None1476 assert ask(Q.odd(x/3), Q.even(x)) is None1477 assert ask(Q.odd(x + 1), Q.even(x)) is True1478 assert ask(Q.odd(x + 2), Q.even(x)) is False1479 assert ask(Q.odd(x + 2), Q.odd(x)) is True1480 assert ask(Q.odd(3 - x), Q.odd(x)) is False1481 assert ask(Q.odd(3 - x), Q.even(x)) is True1482 assert ask(Q.odd(3 + x), Q.odd(x)) is False1483 assert ask(Q.odd(3 + x), Q.even(x)) is True1484 assert ask(Q.odd(x + y), Q.odd(x) & Q.odd(y)) is False1485 assert ask(Q.odd(x + y), Q.odd(x) & Q.even(y)) is True1486 assert ask(Q.odd(x - y), Q.even(x) & Q.odd(y)) is True1487 assert ask(Q.odd(x - y), Q.odd(x) & Q.odd(y)) is False1488 assert ask(Q.odd(x + y + z), Q.odd(x) & Q.odd(y) & Q.even(z)) is False1489 assert ask(Q.odd(x + y + z + t),1490 Q.odd(x) & Q.odd(y) & Q.even(z) & Q.integer(t)) is None1491 assert ask(Q.odd(2*x + 1), Q.integer(x)) is True1492 assert ask(Q.odd(2*x + y), Q.integer(x) & Q.odd(y)) is True1493 assert ask(Q.odd(2*x + y), Q.integer(x) & Q.even(y)) is False1494 assert ask(Q.odd(2*x + y), Q.integer(x) & Q.integer(y)) is None1495 assert ask(Q.odd(x*y), Q.odd(x) & Q.even(y)) is False1496 assert ask(Q.odd(x*y), Q.odd(x) & Q.odd(y)) is True1497 assert ask(Q.odd(2*x*y), Q.rational(x) & Q.rational(x)) is None1498 assert ask(Q.odd(2*x*y), Q.irrational(x) & Q.irrational(x)) is None1499 assert ask(Q.odd(Abs(x)), Q.odd(x)) is True1500 assert ask(Q.odd((-1)**n), Q.integer(n)) is True1501 assert ask(Q.odd(k**2), Q.even(k)) is False1502 assert ask(Q.odd(n**2), Q.odd(n)) is True1503 assert ask(Q.odd(3**k), Q.even(k)) is None1504 assert ask(Q.odd(k**m), Q.even(k) & Q.integer(m) & ~Q.negative(m)) is None1505 assert ask(Q.odd(n**m), Q.odd(n) & Q.integer(m) & ~Q.negative(m)) is True1506 assert ask(Q.odd(k**p), Q.even(k) & Q.integer(p) & Q.positive(p)) is False1507 assert ask(Q.odd(n**p), Q.odd(n) & Q.integer(p) & Q.positive(p)) is True1508 assert ask(Q.odd(m**k), Q.even(k) & Q.integer(m) & ~Q.negative(m)) is None1509 assert ask(Q.odd(p**k), Q.even(k) & Q.integer(p) & Q.positive(p)) is None1510 assert ask(Q.odd(m**n), Q.odd(n) & Q.integer(m) & ~Q.negative(m)) is None1511 assert ask(Q.odd(p**n), Q.odd(n) & Q.integer(p) & Q.positive(p)) is None1512 assert ask(Q.odd(k**x), Q.even(k)) is None1513 assert ask(Q.odd(n**x), Q.odd(n)) is None1514 assert ask(Q.odd(x*y), Q.integer(x) & Q.integer(y)) is None1515 assert ask(Q.odd(x*x), Q.integer(x)) is None1516 assert ask(Q.odd(x*(x + y)), Q.integer(x) & Q.odd(y)) is False1517 assert ask(Q.odd(x*(x + y)), Q.integer(x) & Q.even(y)) is None1518@XFAIL1519def test_oddness_in_ternary_integer_product_with_odd():1520 # Tests that oddness inference is independent of term ordering.1521 # Term ordering at the point of testing depends on SymPy's symbol order, so1522 # we try to force a different order by modifying symbol names.1523 assert ask(Q.odd(x*y*(y + z)), Q.integer(x) & Q.integer(y) & Q.odd(z)) is False1524 assert ask(Q.odd(y*x*(x + z)), Q.integer(x) & Q.integer(y) & Q.odd(z)) is False1525def test_oddness_in_ternary_integer_product_with_even():1526 assert ask(Q.odd(x*y*(y + z)), Q.integer(x) & Q.integer(y) & Q.even(z)) is None1527def test_prime():1528 assert ask(, is True1529 assert ask(, is False1530 assert ask(, Q.integer(x)) is None1531 assert ask(, ~Q.integer(x)) is False1532 assert ask(*x), Q.integer(x)) is None1533 assert ask(*y)) is None1534 assert ask(*y), is None1535 assert ask(*y), Q.integer(x) & Q.integer(y)) is None1536 assert ask(*x), Q.integer(x)) is False1537 assert ask(*x)) is None1538 assert ask(**2), Q.integer(x)) is False1539 assert ask(**2), is False1540 assert ask(**y), Q.integer(x) & Q.integer(y)) is False1541def test_positive():1542 assert ask(Q.positive(x), Q.positive(x)) is True1543 assert ask(Q.positive(x), Q.negative(x)) is False1544 assert ask(Q.positive(x), Q.nonzero(x)) is None1545 assert ask(Q.positive(-x), Q.positive(x)) is False1546 assert ask(Q.positive(-x), Q.negative(x)) is True1547 assert ask(Q.positive(x + y), Q.positive(x) & Q.positive(y)) is True1548 assert ask(Q.positive(x + y), Q.positive(x) & Q.nonnegative(y)) is True1549 assert ask(Q.positive(x + y), Q.positive(x) & Q.negative(y)) is None1550 assert ask(Q.positive(x + y), Q.positive(x) & Q.imaginary(y)) is False1551 assert ask(Q.positive(2*x), Q.positive(x)) is True1552 assumptions = Q.positive(x) & Q.negative(y) & Q.negative(z) & Q.positive(w)1553 assert ask(Q.positive(x*y*z)) is None1554 assert ask(Q.positive(x*y*z), assumptions) is True1555 assert ask(Q.positive(-x*y*z), assumptions) is False1556 assert ask(Q.positive(x**I), Q.positive(x)) is None1557 assert ask(Q.positive(x**2), Q.positive(x)) is True1558 assert ask(Q.positive(x**2), Q.negative(x)) is True1559 assert ask(Q.positive(x**3), Q.negative(x)) is False1560 assert ask(Q.positive(1/(1 + x**2)), Q.real(x)) is True1561 assert ask(Q.positive(2**I)) is False1562 assert ask(Q.positive(2 + I)) is False1563 # although this could be False, it is representative of expressions1564 # that don't evaluate to a zero with precision1565 assert ask(Q.positive(cos(I)**2 + sin(I)**2 - 1)) is None1566 assert ask(Q.positive(-I + I*(cos(2)**2 + sin(2)**2))) is None1567 #exponential1568 assert ask(Q.positive(exp(x)), Q.real(x)) is True1569 assert ask(~Q.negative(exp(x)), Q.real(x)) is True1570 assert ask(Q.positive(x + exp(x)), Q.real(x)) is None1571 assert ask(Q.positive(exp(x)), Q.imaginary(x)) is None1572 assert ask(Q.positive(exp(2*pi*I, evaluate=False)), Q.imaginary(x)) is True1573 assert ask(Q.negative(exp(pi*I, evaluate=False)), Q.imaginary(x)) is True1574 assert ask(Q.positive(exp(x*pi*I)), Q.even(x)) is True1575 assert ask(Q.positive(exp(x*pi*I)), Q.odd(x)) is False1576 assert ask(Q.positive(exp(x*pi*I)), Q.real(x)) is None1577 # logarithm1578 assert ask(Q.positive(log(x)), Q.imaginary(x)) is False1579 assert ask(Q.positive(log(x)), Q.negative(x)) is False1580 assert ask(Q.positive(log(x)), Q.positive(x)) is None1581 assert ask(Q.positive(log(x + 2)), Q.positive(x)) is True1582 # factorial1583 assert ask(Q.positive(factorial(x)), Q.integer(x) & Q.positive(x))1584 assert ask(Q.positive(factorial(x)), Q.integer(x)) is None1585 #absolute value1586 assert ask(Q.positive(Abs(x))) is None # Abs(0) = 01587 assert ask(Q.positive(Abs(x)), Q.positive(x)) is True1588def test_nonpositive():1589 assert ask(Q.nonpositive(-1))1590 assert ask(Q.nonpositive(0))1591 assert ask(Q.nonpositive(1)) is False1592 assert ask(~Q.positive(x), Q.nonpositive(x))1593 assert ask(Q.nonpositive(x), Q.positive(x)) is False1594 assert ask(Q.nonpositive(sqrt(-1))) is False1595 assert ask(Q.nonpositive(x), Q.imaginary(x)) is False1596def test_nonnegative():1597 assert ask(Q.nonnegative(-1)) is False1598 assert ask(Q.nonnegative(0))1599 assert ask(Q.nonnegative(1))1600 assert ask(~Q.negative(x), Q.nonnegative(x))1601 assert ask(Q.nonnegative(x), Q.negative(x)) is False1602 assert ask(Q.nonnegative(sqrt(-1))) is False1603 assert ask(Q.nonnegative(x), Q.imaginary(x)) is False1604def test_real_basic():1605 assert ask(Q.real(x)) is None1606 assert ask(Q.real(x), Q.real(x)) is True1607 assert ask(Q.real(x), Q.nonzero(x)) is True1608 assert ask(Q.real(x), Q.positive(x)) is True1609 assert ask(Q.real(x), Q.negative(x)) is True1610 assert ask(Q.real(x), Q.integer(x)) is True1611 assert ask(Q.real(x), Q.even(x)) is True1612 assert ask(Q.real(x), is True1613 assert ask(Q.real(x/sqrt(2)), Q.real(x)) is True1614 assert ask(Q.real(x/sqrt(-2)), Q.real(x)) is False1615 assert ask(Q.real(x + 1), Q.real(x)) is True1616 assert ask(Q.real(x + I), Q.real(x)) is False1617 assert ask(Q.real(x + I), Q.complex(x)) is None1618 assert ask(Q.real(2*x), Q.real(x)) is True1619 assert ask(Q.real(I*x), Q.real(x)) is False1620 assert ask(Q.real(I*x), Q.imaginary(x)) is True1621 assert ask(Q.real(I*x), Q.complex(x)) is None1622def test_real_pow():1623 assert ask(Q.real(x**2), Q.real(x)) is True1624 assert ask(Q.real(sqrt(x)), Q.negative(x)) is False1625 assert ask(Q.real(x**y), Q.real(x) & Q.integer(y)) is True1626 assert ask(Q.real(x**y), Q.real(x) & Q.real(y)) is None1627 assert ask(Q.real(x**y), Q.positive(x) & Q.real(y)) is True1628 assert ask(Q.real(x**y), Q.imaginary(x) & Q.imaginary(y)) is None # I**I or (2*I)**I1629 assert ask(Q.real(x**y), Q.imaginary(x) & Q.real(y)) is None # I**1 or I**01630 assert ask(Q.real(x**y), Q.real(x) & Q.imaginary(y)) is None # could be exp(2*pi*I) or 2**I1631 assert ask(Q.real(x**0), Q.imaginary(x)) is True1632 assert ask(Q.real(x**y), Q.real(x) & Q.integer(y)) is True1633 assert ask(Q.real(x**y), Q.positive(x) & Q.real(y)) is True1634 assert ask(Q.real(x**y), Q.real(x) & Q.rational(y)) is None1635 assert ask(Q.real(x**y), Q.imaginary(x) & Q.integer(y)) is None1636 assert ask(Q.real(x**y), Q.imaginary(x) & Q.odd(y)) is False1637 assert ask(Q.real(x**y), Q.imaginary(x) & Q.even(y)) is True1638 assert ask(Q.real(x**(y/z)), Q.real(x) & Q.real(y/z) & Q.rational(y/z) & Q.even(z) & Q.positive(x)) is True1639 assert ask(Q.real(x**(y/z)), Q.real(x) & Q.rational(y/z) & Q.even(z) & Q.negative(x)) is False1640 assert ask(Q.real(x**(y/z)), Q.real(x) & Q.integer(y/z)) is True1641 assert ask(Q.real(x**(y/z)), Q.real(x) & Q.real(y/z) & Q.positive(x)) is True1642 assert ask(Q.real(x**(y/z)), Q.real(x) & Q.real(y/z) & Q.negative(x)) is False1643 assert ask(Q.real((-I)**i), Q.imaginary(i)) is True1644 assert ask(Q.real(I**i), Q.imaginary(i)) is True1645 assert ask(Q.real(i**i), Q.imaginary(i)) is None # i might be 2*I1646 assert ask(Q.real(x**i), Q.imaginary(i)) is None # x could be 01647 assert ask(Q.real(x**(I*pi/log(x))), Q.real(x)) is True1648def test_real_functions():1649 # trigonometric functions1650 assert ask(Q.real(sin(x))) is None1651 assert ask(Q.real(cos(x))) is None1652 assert ask(Q.real(sin(x)), Q.real(x)) is True1653 assert ask(Q.real(cos(x)), Q.real(x)) is True1654 # exponential function1655 assert ask(Q.real(exp(x))) is None1656 assert ask(Q.real(exp(x)), Q.real(x)) is True1657 assert ask(Q.real(x + exp(x)), Q.real(x)) is True1658 assert ask(Q.real(exp(2*pi*I, evaluate=False))) is True1659 assert ask(Q.real(exp(pi*I, evaluate=False))) is True1660 assert ask(Q.real(exp(pi*I/2, evaluate=False))) is False1661 # logarithm1662 assert ask(Q.real(log(I))) is False1663 assert ask(Q.real(log(2*I))) is False1664 assert ask(Q.real(log(I + 1))) is False1665 assert ask(Q.real(log(x)), Q.complex(x)) is None1666 assert ask(Q.real(log(x)), Q.imaginary(x)) is False1667 assert ask(Q.real(log(exp(x))), Q.imaginary(x)) is None # exp(2*pi*I) is 1, log(exp(pi*I)) is pi*I (disregarding periodicity)1668 assert ask(Q.real(log(exp(x))), Q.complex(x)) is None1669 eq = Pow(exp(2*pi*I*x, evaluate=False), x, evaluate=False)1670 assert ask(Q.real(eq), Q.integer(x)) is True1671 assert ask(Q.real(exp(x)**x), Q.imaginary(x)) is True1672 assert ask(Q.real(exp(x)**x), Q.complex(x)) is None1673 # Q.complexes1674 assert ask(Q.real(re(x))) is True1675 assert ask(Q.real(im(x))) is True1676def test_matrix():1677 # hermitian1678 assert ask(Q.hermitian(Matrix([[2, 2 + I, 4], [2 - I, 3, I], [4, -I, 1]]))) == True1679 assert ask(Q.hermitian(Matrix([[2, 2 + I, 4], [2 + I, 3, I], [4, -I, 1]]))) == False1680 z = symbols('z', complex=True)1681 assert ask(Q.hermitian(Matrix([[2, 2 + I, z], [2 - I, 3, I], [4, -I, 1]]))) == None1682 assert ask(Q.hermitian(SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11))))) == True1683 assert ask(Q.hermitian(SparseMatrix(((25, 15, -5), (15, I, 0), (-5, 0, 11))))) == False1684 assert ask(Q.hermitian(SparseMatrix(((25, 15, -5), (15, z, 0), (-5, 0, 11))))) == None1685 # antihermitian1686 A = Matrix([[0, -2 - I, 0], [2 - I, 0, -I], [0, -I, 0]])1687 B = Matrix([[-I, 2 + I, 0], [-2 + I, 0, 2 + I], [0, -2 + I, -I]])1688 assert ask(Q.antihermitian(A)) is True1689 assert ask(Q.antihermitian(B)) is True1690 assert ask(Q.antihermitian(A**2)) is False1691 C = (B**3)1692 C.simplify()1693 assert ask(Q.antihermitian(C)) is True1694 _A = Matrix([[0, -2 - I, 0], [z, 0, -I], [0, -I, 0]])1695 assert ask(Q.antihermitian(_A)) is None1696def test_algebraic():1697 assert ask(Q.algebraic(x)) is None1698 assert ask(Q.algebraic(I)) is True1699 assert ask(Q.algebraic(2*I)) is True1700 assert ask(Q.algebraic(I/3)) is True1701 assert ask(Q.algebraic(sqrt(7))) is True1702 assert ask(Q.algebraic(2*sqrt(7))) is True1703 assert ask(Q.algebraic(sqrt(7)/3)) is True1704 assert ask(Q.algebraic(I*sqrt(3))) is True1705 assert ask(Q.algebraic(sqrt(1 + I*sqrt(3)))) is True1706 assert ask(Q.algebraic(1 + I*sqrt(3)**Rational(17, 31))) is True1707 assert ask(Q.algebraic(1 + I*sqrt(3)**(17/pi))) is False1708 for f in [exp, sin, tan, asin, atan, cos]:1709 assert ask(Q.algebraic(f(7))) is False1710 assert ask(Q.algebraic(f(7, evaluate=False))) is False1711 assert ask(Q.algebraic(f(0, evaluate=False))) is True1712 assert ask(Q.algebraic(f(x)), Q.algebraic(x)) is None1713 assert ask(Q.algebraic(f(x)), Q.algebraic(x) & Q.nonzero(x)) is False1714 for g in [log, acos]:1715 assert ask(Q.algebraic(g(7))) is False1716 assert ask(Q.algebraic(g(7, evaluate=False))) is False1717 assert ask(Q.algebraic(g(1, evaluate=False))) is True1718 assert ask(Q.algebraic(g(x)), Q.algebraic(x)) is None1719 assert ask(Q.algebraic(g(x)), Q.algebraic(x) & Q.nonzero(x - 1)) is False1720 for h in [cot, acot]:1721 assert ask(Q.algebraic(h(7))) is False1722 assert ask(Q.algebraic(h(7, evaluate=False))) is False1723 assert ask(Q.algebraic(h(x)), Q.algebraic(x)) is False1724 assert ask(Q.algebraic(sqrt(sin(7)))) is False1725 assert ask(Q.algebraic(sqrt(y + I*sqrt(7)))) is None1726 assert ask(Q.algebraic(2.47)) is True1727 assert ask(Q.algebraic(x), Q.transcendental(x)) is False1728 assert ask(Q.transcendental(x), Q.algebraic(x)) is False1729def test_global():1730 """Test ask with global assumptions"""1731 assert ask(Q.integer(x)) is None1732 global_assumptions.add(Q.integer(x))1733 assert ask(Q.integer(x)) is True1734 global_assumptions.clear()1735 assert ask(Q.integer(x)) is None1736def test_custom_context():1737 """Test ask with custom assumptions context"""1738 assert ask(Q.integer(x)) is None1739 local_context = AssumptionsContext()1740 local_context.add(Q.integer(x))1741 assert ask(Q.integer(x), context=local_context) is True1742 assert ask(Q.integer(x)) is None1743def test_functions_in_assumptions():1744 assert ask(Q.negative(x), Q.real(x) >> Q.positive(x)) is False1745 assert ask(Q.negative(x), Equivalent(Q.real(x), Q.positive(x))) is False1746 assert ask(Q.negative(x), Xor(Q.real(x), Q.negative(x))) is False1747def test_composite_ask():1748 assert ask(Q.negative(x) & Q.integer(x),1749 assumptions=Q.real(x) >> Q.positive(x)) is False1750def test_composite_proposition():1751 assert ask(True) is True1752 assert ask(False) is False1753 assert ask(~Q.negative(x), Q.positive(x)) is True1754 assert ask(~Q.real(x), Q.commutative(x)) is None1755 assert ask(Q.negative(x) & Q.integer(x), Q.positive(x)) is False1756 assert ask(Q.negative(x) & Q.integer(x)) is None1757 assert ask(Q.real(x) | Q.integer(x), Q.positive(x)) is True1758 assert ask(Q.real(x) | Q.integer(x)) is None1759 assert ask(Q.real(x) >> Q.positive(x), Q.negative(x)) is False1760 assert ask(Implies(1761 Q.real(x), Q.positive(x), evaluate=False), Q.negative(x)) is False1762 assert ask(Implies(Q.real(x), Q.positive(x), evaluate=False)) is None1763 assert ask(Equivalent(Q.integer(x), Q.even(x)), Q.even(x)) is True1764 assert ask(Equivalent(Q.integer(x), Q.even(x))) is None1765 assert ask(Equivalent(Q.positive(x), Q.integer(x)), Q.integer(x)) is None1766 assert ask(Q.real(x) | Q.integer(x), Q.real(x) | Q.integer(x)) is True1767def test_tautology():1768 assert ask(Q.real(x) | ~Q.real(x)) is True1769 assert ask(Q.real(x) & ~Q.real(x)) is False1770def test_composite_assumptions():1771 assert ask(Q.real(x), Q.real(x) & Q.real(y)) is True1772 assert ask(Q.positive(x), Q.positive(x) | Q.positive(y)) is None1773 assert ask(Q.positive(x), Q.real(x) >> Q.positive(y)) is None1774 assert ask(Q.real(x), ~(Q.real(x) >> Q.real(y))) is True1775def test_incompatible_resolutors():1776 class Prime2AskHandler(AskHandler):1777 @staticmethod1778 def Number(expr, assumptions):1779 return True1780 register_handler('prime', Prime2AskHandler)1781 raises(ValueError, lambda: ask( remove_handler('prime', Prime2AskHandler)1783 class InconclusiveHandler(AskHandler):1784 @staticmethod1785 def Number(expr, assumptions):1786 return None1787 register_handler('prime', InconclusiveHandler)1788 assert ask( is True1789 remove_handler('prime', InconclusiveHandler)1790def test_key_extensibility():1791 """test that you can add keys to the ask system at runtime"""1792 # make sure the key is not defined1793 raises(AttributeError, lambda: ask(Q.my_key(x)))1794 class MyAskHandler(AskHandler):1795 @staticmethod1796 def Symbol(expr, assumptions):1797 return True1798 register_handler('my_key', MyAskHandler)1799 assert ask(Q.my_key(x)) is True1800 assert ask(Q.my_key(x + 1)) is None1801 remove_handler('my_key', MyAskHandler)1802 del Q.my_key1803 raises(AttributeError, lambda: ask(Q.my_key(x)))1804def test_type_extensibility():1805 """test that new types can be added to the ask system at runtime1806 We create a custom type MyType, and override ask with handler1807 MyAskHandler for this type1808 TODO: test incompatible resolutors1809 """1810 from sympy.core import Basic1811 class MyType(Basic):1812 pass1813 class MyAskHandler(AskHandler):1814 @staticmethod1815 def MyType(expr, assumptions):1816 return True1817 a = MyType()1818 register_handler(, MyAskHandler)1819 assert ask( is True1820def test_single_fact_lookup():1821 known_facts = And(Implies(Q.integer, Q.rational),1822 Implies(Q.rational, Q.real),1823 Implies(Q.real, Q.complex))1824 known_facts_keys = {Q.integer, Q.rational, Q.real, Q.complex}1825 known_facts_cnf = to_cnf(known_facts)1826 mapping = single_fact_lookup(known_facts_keys, known_facts_cnf)1827 assert mapping[Q.rational] == {Q.real, Q.rational, Q.complex}1828def test_compute_known_facts():1829 known_facts = And(Implies(Q.integer, Q.rational),1830 Implies(Q.rational, Q.real),1831 Implies(Q.real, Q.complex))1832 known_facts_keys = {Q.integer, Q.rational, Q.real, Q.complex}1833 compute_known_facts(known_facts, known_facts_keys)1834@slow1835def test_known_facts_consistent():1836 """"Test that is up-to-date"""1837 from sympy.assumptions.ask import get_known_facts, get_known_facts_keys1838 from os.path import abspath, dirname, join1839 filename = join(dirname(dirname(abspath(__file__))), '')1840 with open(filename) as f:1841 assert == \1842 compute_known_facts(get_known_facts(), get_known_facts_keys())1843def test_Add_queries():1844 assert ask( + (cos(1)**2 + sin(1)**2))) is True1845 assert ask(Q.even(Add(S(2), S(2), evaluate=0))) is True1846 assert ask(, S(2), evaluate=0))) is False1847 assert ask(Q.integer(Add(S(2), S(2), evaluate=0))) is True1848def test_positive_assuming():1849 with assuming(Q.positive(x + 1)):1850 assert not ask(Q.positive(x))1851def test_issue_5421():1852 raises(TypeError, lambda: ask(pi/log(x), Q.real))1853def test_issue_3906():1854 raises(TypeError, lambda: ask(Q.positive))1855def test_issue_5833():1856 assert ask(Q.positive(log(x)**2), Q.positive(x)) is None1857 assert ask(~Q.negative(log(x)**2), Q.positive(x)) is True1858def test_issue_6732():1859 raises(ValueError, lambda: ask(Q.positive(x), Q.positive(x) & Q.negative(x)))1860 raises(ValueError, lambda: ask(Q.negative(x), Q.positive(x) & Q.negative(x)))1861def test_issue_7246():1862 assert ask(Q.positive(atan(p)), Q.positive(p)) is True1863 assert ask(Q.positive(atan(p)), Q.negative(p)) is False1864 assert ask(Q.positive(atan(p)), is False1865 assert ask(Q.positive(atan(x))) is None1866 assert ask(Q.positive(asin(p)), Q.positive(p)) is None1867 assert ask(Q.positive(asin(p)), is None1868 assert ask(Q.positive(asin(Rational(1, 7)))) is True1869 assert ask(Q.positive(asin(x)), Q.positive(x) & Q.nonpositive(x - 1)) is True1870 assert ask(Q.positive(asin(x)), Q.negative(x) & Q.nonnegative(x + 1)) is False1871 assert ask(Q.positive(acos(p)), Q.positive(p)) is None1872 assert ask(Q.positive(acos(Rational(1, 7)))) is True1873 assert ask(Q.positive(acos(x)), Q.nonnegative(x + 1) & Q.nonpositive(x - 1)) is True1874 assert ask(Q.positive(acos(x)), Q.nonnegative(x - 1)) is None1875 assert ask(Q.positive(acot(x)), Q.positive(x)) is True1876 assert ask(Q.positive(acot(x)), Q.real(x)) is True1877 assert ask(Q.positive(acot(x)), Q.imaginary(x)) is False1878 assert ask(Q.positive(acot(x))) is None1879@XFAIL1880def test_issue_7246_failing():1881 #Move this test to test_issue_7246 once1882 #the new assumptions module is improved.1883 assert ask(Q.positive(acos(x)), is True1884def test_check_old_assumption():1885 x = symbols('x', real=True)1886 assert ask(Q.real(x)) is True1887 assert ask(Q.imaginary(x)) is False1888 assert ask(Q.complex(x)) is True1889 x = symbols('x', imaginary=True)1890 assert ask(Q.real(x)) is False1891 assert ask(Q.imaginary(x)) is True1892 assert ask(Q.complex(x)) is True1893 x = symbols('x', complex=True)1894 assert ask(Q.real(x)) is None1895 assert ask(Q.complex(x)) is True1896 x = symbols('x', positive=True, finite=True)1897 assert ask(Q.positive(x)) is True1898 assert ask(Q.negative(x)) is False1899 assert ask(Q.real(x)) is True1900 x = symbols('x', commutative=False)1901 assert ask(Q.commutative(x)) is False1902 x = symbols('x', negative=True)1903 assert ask(Q.positive(x)) is False1904 assert ask(Q.negative(x)) is True1905 x = symbols('x', nonnegative=True)1906 assert ask(Q.negative(x)) is False1907 assert ask(Q.positive(x)) is None1908 assert ask( is None1909 x = symbols('x', finite=True)1910 assert ask(Q.finite(x)) is True1911 x = symbols('x', prime=True)1912 assert ask( is True1913 assert ask(Q.composite(x)) is False1914 x = symbols('x', composite=True)1915 assert ask( is False1916 assert ask(Q.composite(x)) is True1917 x = symbols('x', even=True)1918 assert ask(Q.even(x)) is True1919 assert ask(Q.odd(x)) is False1920 x = symbols('x', odd=True)1921 assert ask(Q.even(x)) is False1922 assert ask(Q.odd(x)) is True1923 x = symbols('x', nonzero=True)1924 assert ask(Q.nonzero(x)) is True1925 assert ask( is False1926 x = symbols('x', zero=True)1927 assert ask( is True1928 x = symbols('x', integer=True)1929 assert ask(Q.integer(x)) is True1930 x = symbols('x', rational=True)1931 assert ask(Q.rational(x)) is True1932 assert ask(Q.irrational(x)) is False1933 x = symbols('x', irrational=True)1934 assert ask(Q.irrational(x)) is True1935 assert ask(Q.rational(x)) is False1936def test_issue_9636():1937 assert ask(Q.integer(1.0)) is False1938 assert ask( is False1939 assert ask(Q.composite(4.0)) is False1940 assert ask(Q.even(2.0)) is False1941 assert ask(Q.odd(3.0)) is False1942def test_autosimp_used_to_fail():1943 # See issue #98071944 assert ask(Q.imaginary(0**I)) is False1945 assert ask(Q.imaginary(0**(-I))) is False1946 assert ask(Q.real(0**I)) is False1947 assert ask(Q.real(0**(-I))) is False1948def test_custom_AskHandler():1949 from sympy.assumptions import register_handler, ask, Q1950 from sympy.assumptions.handlers import AskHandler1951 from sympy.logic.boolalg import conjuncts1952 from sympy import Symbol1953 class MersenneHandler(AskHandler):1954 @staticmethod1955 def Integer(expr, assumptions):1956 from sympy import log1957 if ask(Q.integer(log(expr + 1, 2))):1958 return True1959 @staticmethod1960 def Symbol(expr, assumptions):1961 if expr in conjuncts(assumptions):1962 return True1963 register_handler('mersenne', MersenneHandler)1964 n = Symbol('n', integer=True)...

Full Screen

Full Screen Github


Full Screen

...12C0x0 = MatrixSymbol('C0x0', 0, 0)13V1 = MatrixSymbol('V1', 2, 1)14V2 = MatrixSymbol('V2', 2, 1)15def test_square():16 assert ask(Q.square(X))17 assert not ask(Q.square(Y))18 assert ask(Q.square(Y*Y.T))19def test_invertible():20 assert ask(Q.invertible(X), Q.invertible(X))21 assert ask(Q.invertible(Y)) is False22 assert ask(Q.invertible(X*Y), Q.invertible(X)) is False23 assert ask(Q.invertible(X*Z), Q.invertible(X)) is None24 assert ask(Q.invertible(X*Z), Q.invertible(X) & Q.invertible(Z)) is True25 assert ask(Q.invertible(X.T)) is None26 assert ask(Q.invertible(X.T), Q.invertible(X)) is True27 assert ask(Q.invertible(X.I)) is True28 assert ask(Q.invertible(Identity(3))) is True29 assert ask(Q.invertible(ZeroMatrix(3, 3))) is False30 assert ask(Q.invertible(OneMatrix(1, 1))) is True31 assert ask(Q.invertible(OneMatrix(3, 3))) is False32 assert ask(Q.invertible(X), Q.fullrank(X) & Q.square(X))33def test_singular():34 assert ask(Q.singular(X)) is None35 assert ask(Q.singular(X), Q.invertible(X)) is False36 assert ask(Q.singular(X), ~Q.invertible(X)) is True37@XFAIL38def test_invertible_fullrank():39 assert ask(Q.invertible(X), Q.fullrank(X)) is True40def test_invertible_BlockMatrix():41 assert ask(Q.invertible(BlockMatrix([Identity(3)]))) == True42 assert ask(Q.invertible(BlockMatrix([ZeroMatrix(3, 3)]))) == False43 X = Matrix([[1, 2, 3], [3, 5, 4]])44 Y = Matrix([[4, 2, 7], [2, 3, 5]])45 # non-invertible A block46 assert ask(Q.invertible(BlockMatrix([47 [Matrix.ones(3, 3), Y.T],48 [X, Matrix.eye(2)],49 ]))) == True50 # non-invertible B block51 assert ask(Q.invertible(BlockMatrix([52 [Y.T, Matrix.ones(3, 3)],53 [Matrix.eye(2), X],54 ]))) == True55 # non-invertible C block56 assert ask(Q.invertible(BlockMatrix([57 [X, Matrix.eye(2)],58 [Matrix.ones(3, 3), Y.T],59 ]))) == True60 # non-invertible D block61 assert ask(Q.invertible(BlockMatrix([62 [Matrix.eye(2), X],63 [Y.T, Matrix.ones(3, 3)],64 ]))) == True65def test_invertible_BlockDiagMatrix():66 assert ask(Q.invertible(BlockDiagMatrix(Identity(3), Identity(5)))) == True67 assert ask(Q.invertible(BlockDiagMatrix(ZeroMatrix(3, 3), Identity(5)))) == False68 assert ask(Q.invertible(BlockDiagMatrix(Identity(3), OneMatrix(5, 5)))) == False69def test_symmetric():70 assert ask(Q.symmetric(X), Q.symmetric(X))71 assert ask(Q.symmetric(X*Z), Q.symmetric(X)) is None72 assert ask(Q.symmetric(X*Z), Q.symmetric(X) & Q.symmetric(Z)) is True73 assert ask(Q.symmetric(X + Z), Q.symmetric(X) & Q.symmetric(Z)) is True74 assert ask(Q.symmetric(Y)) is False75 assert ask(Q.symmetric(Y*Y.T)) is True76 assert ask(Q.symmetric(Y.T*X*Y)) is None77 assert ask(Q.symmetric(Y.T*X*Y), Q.symmetric(X)) is True78 assert ask(Q.symmetric(X**10), Q.symmetric(X)) is True79 assert ask(Q.symmetric(A1x1)) is True80 assert ask(Q.symmetric(A1x1 + B1x1)) is True81 assert ask(Q.symmetric(A1x1 * B1x1)) is True82 assert ask(Q.symmetric(V1.T*V1)) is True83 assert ask(Q.symmetric(V1.T*(V1 + V2))) is True84 assert ask(Q.symmetric(V1.T*(V1 + V2) + A1x1)) is True85 assert ask(Q.symmetric(MatrixSlice(Y, (0, 1), (1, 2)))) is True86 assert ask(Q.symmetric(Identity(3))) is True87 assert ask(Q.symmetric(ZeroMatrix(3, 3))) is True88 assert ask(Q.symmetric(OneMatrix(3, 3))) is True89def _test_orthogonal_unitary(predicate):90 assert ask(predicate(X), predicate(X))91 assert ask(predicate(X.T), predicate(X)) is True92 assert ask(predicate(X.I), predicate(X)) is True93 assert ask(predicate(X**2), predicate(X))94 assert ask(predicate(Y)) is False95 assert ask(predicate(X)) is None96 assert ask(predicate(X), ~Q.invertible(X)) is False97 assert ask(predicate(X*Z*X), predicate(X) & predicate(Z)) is True98 assert ask(predicate(Identity(3))) is True99 assert ask(predicate(ZeroMatrix(3, 3))) is False100 assert ask(Q.invertible(X), predicate(X))101 assert not ask(predicate(X + Z), predicate(X) & predicate(Z))102def test_orthogonal():103 _test_orthogonal_unitary(Q.orthogonal)104def test_unitary():105 _test_orthogonal_unitary(Q.unitary)106 assert ask(Q.unitary(X), Q.orthogonal(X))107def test_fullrank():108 assert ask(Q.fullrank(X), Q.fullrank(X))109 assert ask(Q.fullrank(X**2), Q.fullrank(X))110 assert ask(Q.fullrank(X.T), Q.fullrank(X)) is True111 assert ask(Q.fullrank(X)) is None112 assert ask(Q.fullrank(Y)) is None113 assert ask(Q.fullrank(X*Z), Q.fullrank(X) & Q.fullrank(Z)) is True114 assert ask(Q.fullrank(Identity(3))) is True115 assert ask(Q.fullrank(ZeroMatrix(3, 3))) is False116 assert ask(Q.fullrank(OneMatrix(1, 1))) is True117 assert ask(Q.fullrank(OneMatrix(3, 3))) is False118 assert ask(Q.invertible(X), ~Q.fullrank(X)) == False119def test_positive_definite():120 assert ask(Q.positive_definite(X), Q.positive_definite(X))121 assert ask(Q.positive_definite(X.T), Q.positive_definite(X)) is True122 assert ask(Q.positive_definite(X.I), Q.positive_definite(X)) is True123 assert ask(Q.positive_definite(Y)) is False124 assert ask(Q.positive_definite(X)) is None125 assert ask(Q.positive_definite(X**3), Q.positive_definite(X))126 assert ask(Q.positive_definite(X*Z*X),127 Q.positive_definite(X) & Q.positive_definite(Z)) is True128 assert ask(Q.positive_definite(X), Q.orthogonal(X))129 assert ask(Q.positive_definite(Y.T*X*Y),130 Q.positive_definite(X) & Q.fullrank(Y)) is True131 assert not ask(Q.positive_definite(Y.T*X*Y), Q.positive_definite(X))132 assert ask(Q.positive_definite(Identity(3))) is True133 assert ask(Q.positive_definite(ZeroMatrix(3, 3))) is False134 assert ask(Q.positive_definite(OneMatrix(1, 1))) is True135 assert ask(Q.positive_definite(OneMatrix(3, 3))) is False136 assert ask(Q.positive_definite(X + Z), Q.positive_definite(X) &137 Q.positive_definite(Z)) is True138 assert not ask(Q.positive_definite(-X), Q.positive_definite(X))139 assert ask(Q.positive(X[1, 1]), Q.positive_definite(X))140def test_triangular():141 assert ask(Q.upper_triangular(X + Z.T + Identity(2)), Q.upper_triangular(X) &142 Q.lower_triangular(Z)) is True143 assert ask(Q.upper_triangular(X*Z.T), Q.upper_triangular(X) &144 Q.lower_triangular(Z)) is True145 assert ask(Q.lower_triangular(Identity(3))) is True146 assert ask(Q.lower_triangular(ZeroMatrix(3, 3))) is True147 assert ask(Q.upper_triangular(ZeroMatrix(3, 3))) is True148 assert ask(Q.lower_triangular(OneMatrix(1, 1))) is True149 assert ask(Q.upper_triangular(OneMatrix(1, 1))) is True150 assert ask(Q.lower_triangular(OneMatrix(3, 3))) is False151 assert ask(Q.upper_triangular(OneMatrix(3, 3))) is False152 assert ask(Q.triangular(X), Q.unit_triangular(X))153 assert ask(Q.upper_triangular(X**3), Q.upper_triangular(X))154 assert ask(Q.lower_triangular(X**3), Q.lower_triangular(X))155def test_diagonal():156 assert ask(Q.diagonal(X + Z.T + Identity(2)), Q.diagonal(X) &157 Q.diagonal(Z)) is True158 assert ask(Q.diagonal(ZeroMatrix(3, 3)))159 assert ask(Q.diagonal(OneMatrix(1, 1))) is True160 assert ask(Q.diagonal(OneMatrix(3, 3))) is False161 assert ask(Q.lower_triangular(X) & Q.upper_triangular(X), Q.diagonal(X))162 assert ask(Q.diagonal(X), Q.lower_triangular(X) & Q.upper_triangular(X))163 assert ask(Q.symmetric(X), Q.diagonal(X))164 assert ask(Q.triangular(X), Q.diagonal(X))165 assert ask(Q.diagonal(C0x0))166 assert ask(Q.diagonal(A1x1))167 assert ask(Q.diagonal(A1x1 + B1x1))168 assert ask(Q.diagonal(A1x1*B1x1))169 assert ask(Q.diagonal(V1.T*V2))170 assert ask(Q.diagonal(V1.T*(X + Z)*V1))171 assert ask(Q.diagonal(MatrixSlice(Y, (0, 1), (1, 2)))) is True172 assert ask(Q.diagonal(V1.T*(V1 + V2))) is True173 assert ask(Q.diagonal(X**3), Q.diagonal(X))174 assert ask(Q.diagonal(Identity(3)))175 assert ask(Q.diagonal(DiagMatrix(V1)))176 assert ask(Q.diagonal(DiagonalMatrix(X)))177def test_non_atoms():178 assert ask(Q.real(Trace(X)), Q.positive(Trace(X)))179@XFAIL180def test_non_trivial_implies():181 X = MatrixSymbol('X', 3, 3)182 Y = MatrixSymbol('Y', 3, 3)183 assert ask(Q.lower_triangular(X+Y), Q.lower_triangular(X) &184 Q.lower_triangular(Y)) is True185 assert ask(Q.triangular(X), Q.lower_triangular(X)) is True186 assert ask(Q.triangular(X+Y), Q.lower_triangular(X) &187 Q.lower_triangular(Y)) is True188def test_MatrixSlice():189 X = MatrixSymbol('X', 4, 4)190 B = MatrixSlice(X, (1, 3), (1, 3))191 C = MatrixSlice(X, (0, 3), (1, 3))192 assert ask(Q.symmetric(B), Q.symmetric(X))193 assert ask(Q.invertible(B), Q.invertible(X))194 assert ask(Q.diagonal(B), Q.diagonal(X))195 assert ask(Q.orthogonal(B), Q.orthogonal(X))196 assert ask(Q.upper_triangular(B), Q.upper_triangular(X))197 assert not ask(Q.symmetric(C), Q.symmetric(X))198 assert not ask(Q.invertible(C), Q.invertible(X))199 assert not ask(Q.diagonal(C), Q.diagonal(X))200 assert not ask(Q.orthogonal(C), Q.orthogonal(X))201 assert not ask(Q.upper_triangular(C), Q.upper_triangular(X))202def test_det_trace_positive():203 X = MatrixSymbol('X', 4, 4)204 assert ask(Q.positive(Trace(X)), Q.positive_definite(X))205 assert ask(Q.positive(Determinant(X)), Q.positive_definite(X))206def test_field_assumptions():207 X = MatrixSymbol('X', 4, 4)208 Y = MatrixSymbol('Y', 4, 4)209 assert ask(Q.real_elements(X), Q.real_elements(X))210 assert not ask(Q.integer_elements(X), Q.real_elements(X))211 assert ask(Q.complex_elements(X), Q.real_elements(X))212 assert ask(Q.complex_elements(X**2), Q.real_elements(X))213 assert ask(Q.real_elements(X**2), Q.integer_elements(X))214 assert ask(Q.real_elements(X+Y), Q.real_elements(X)) is None215 assert ask(Q.real_elements(X+Y), Q.real_elements(X) & Q.real_elements(Y))216 from sympy.matrices.expressions.hadamard import HadamardProduct217 assert ask(Q.real_elements(HadamardProduct(X, Y)),218 Q.real_elements(X) & Q.real_elements(Y))219 assert ask(Q.complex_elements(X+Y), Q.real_elements(X) & Q.complex_elements(Y))220 assert ask(Q.real_elements(X.T), Q.real_elements(X))221 assert ask(Q.real_elements(X.I), Q.real_elements(X) & Q.invertible(X))222 assert ask(Q.real_elements(Trace(X)), Q.real_elements(X))223 assert ask(Q.integer_elements(Determinant(X)), Q.integer_elements(X))224 assert not ask(Q.integer_elements(X.I), Q.integer_elements(X))225 alpha = Symbol('alpha')226 assert ask(Q.real_elements(alpha*X), Q.real_elements(X) & Q.real(alpha))227 assert ask(Q.real_elements(LofLU(X)), Q.real_elements(X))228 e = Symbol('e', integer=True, negative=True)229 assert ask(Q.real_elements(X**e), Q.real_elements(X) & Q.invertible(X))230 assert ask(Q.real_elements(X**e), Q.real_elements(X)) is None231def test_matrix_element_sets():232 X = MatrixSymbol('X', 4, 4)233 assert ask(Q.real(X[1, 2]), Q.real_elements(X))234 assert ask(Q.integer(X[1, 2]), Q.integer_elements(X))235 assert ask(Q.complex(X[1, 2]), Q.complex_elements(X))236 assert ask(Q.integer_elements(Identity(3)))237 assert ask(Q.integer_elements(ZeroMatrix(3, 3)))238 assert ask(Q.integer_elements(OneMatrix(3, 3)))239 from sympy.matrices.expressions.fourier import DFT240 assert ask(Q.complex_elements(DFT(3)))241def test_matrix_element_sets_slices_blocks():242 X = MatrixSymbol('X', 4, 4)243 assert ask(Q.integer_elements(X[:, 3]), Q.integer_elements(X))244 assert ask(Q.integer_elements(BlockMatrix([[X], [X]])),245 Q.integer_elements(X))246def test_matrix_element_sets_determinant_trace():247 assert ask(Q.integer(Determinant(X)), Q.integer_elements(X))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?