Assume¶
- 
class sympy.assumptions.assume.AppliedPredicate(predicate, arg)[source]¶
- The class of expressions resulting from applying a Predicate. - Examples - >>> from sympy import Q, Symbol >>> x = Symbol('x') >>> Q.integer(x) Q.integer(x) >>> type(Q.integer(x)) <class 'sympy.assumptions.assume.AppliedPredicate'> - 
property arg¶
- Return the expression used by this assumption. - Examples - >>> from sympy import Q, Symbol >>> x = Symbol('x') >>> a = Q.integer(x + 1) >>> a.arg x + 1 
 
- 
property 
- 
class sympy.assumptions.assume.AssumptionsContext[source]¶
- Set representing assumptions. - This is used to represent global assumptions, but you can also use this class to create your own local assumptions contexts. It is basically a thin wrapper to Python’s set, so see its documentation for advanced usage. - Examples - >>> from sympy import AppliedPredicate, Q >>> from sympy.assumptions.assume import global_assumptions >>> global_assumptions AssumptionsContext() >>> from sympy.abc import x >>> global_assumptions.add(Q.real(x)) >>> global_assumptions AssumptionsContext({Q.real(x)}) >>> global_assumptions.remove(Q.real(x)) >>> global_assumptions AssumptionsContext() >>> global_assumptions.clear() 
- 
class sympy.assumptions.assume.Predicate(name, handlers=None)[source]¶
- A predicate is a function that returns a boolean value. - Predicates merely wrap their argument and remain unevaluated: - >>> from sympy import Q, ask >>> type(Q.prime) <class 'sympy.assumptions.assume.Predicate'> >>> Q.prime.name 'prime' >>> Q.prime(7) Q.prime(7) >>> _.func.name 'prime' - To obtain the truth value of an expression containing predicates, use the function - ask:- >>> ask(Q.prime(7)) True - The tautological predicate - Q.is_truecan be used to wrap other objects:- >>> from sympy.abc import x >>> Q.is_true(x > 1) Q.is_true(x > 1) 
- 
sympy.assumptions.assume.assuming(*assumptions)[source]¶
- Context manager for assumptions - Examples - >>> from sympy.assumptions import assuming, Q, ask >>> from sympy.abc import x, y - >>> print(ask(Q.integer(x + y))) None - >>> with assuming(Q.integer(x), Q.integer(y)): ... print(ask(Q.integer(x + y))) True 
