Module for querying SymPy objects about assumptions.

Method for inferring properties about objects.

Syntax

where proposition is any boolean expression

Examples

>>> from sympy import ask, Q, pi
>>> from sympy.abc import x, y
False
True
False

Remarks

Relations in assumptions are not implemented (yet), so the following will not give a meaningful result.

>>> ask(Q.positive(x), Q.is_true(x > 0))


It is however a work in progress.

Method for inferring properties about objects.

Compute the various forms of knowledge compilation used by the assumptions system.

This function is typically applied to the variables known_facts and known_facts_keys defined at the bottom of this file.

Register a handler in the ask system. key must be a string and handler a class inheriting from AskHandler:

>>> from sympy.assumptions import register_handler, ask, Q
...     # Mersenne numbers are in the form 2**n + 1, n integer
...     @staticmethod
...     def Integer(expr, assumptions):
...         import math
...         return ask(Q.integer(math.log(expr + 1, 2)))
>>> register_handler('mersenne', MersenneHandler)
True