Ask Your Question

Revision history [back]

I don't think there's a method that queries the assumptions data. You can write a simple function to test this using the output of assumptions():

sage: a=var('a')
sage: assume(a, 'integer')
sage: any('a is integer' in str(x) for x in assumptions())
sage: any('a is real' in str(x) for x in assumptions())

The assumptions function returns a list of GenericDeclaration objects which are turned into strings above.

sage: type(assumptions()[0])
<class 'sage.symbolic.assumptions.GenericDeclaration'>

Beware that the only subsystem of Sage that respects (or takes account of) symbolic assumptions is Maxima. So some symbolic operations will "know" about the assumptions (the ones that use Maxima under the hood) and some won't.