Updates:
        Cc: [email protected]

Comment #58 on issue 1047 by [email protected]: Suggested new assumption system
http://code.google.com/p/sympy/issues/detail?id=1047

What about creating a standard object that contains a Basic and a set of applied predicates? I like the idea of passing around ContextualizedBasics.

    expr = contextualize(x*y, Q.positive(x) & Q.positive(y))

in this case expr would behave in many ways like an expression. When you printed it out you would just get "x*y". When two contextualized basics meet they would have their sub-expressions interact and merge their sets of applied predicates.

Statements like

    Symbol('x', real=True)

would produce a ContextualizedBasic with args == [Symbol('x'), {Q.real(Symbol('x'))}]

Statements with two interacting ContextualizedBasics like `x + y` would create a new ContextualizedBasic with args `[x.expr + y.expr, union(x.appliedpredicates, y.appliedpredicates]`. As long as ContextualizedBasic implements all operators and applies them cleanly down to the constituent expression changes should be somewhat localized.

I think/hope that this could be done so that much of internal sympy code wouldn't need to be changed. Code that uses arithmetic operators would be fine without alteration. Code that uses classes directly (like using Add for sum or Mul for product) or code that dealt with args directly might cause issues. This is, admittedly, a large amount of the core.

Maybe this idea was already around and has been discussed at length. If this is the case then I apologize.

I like this idea because it doesn't force users to carry around their context and because it doesn't inject/rely upon global assumptions. I think that global assumptions are likely to cause issues.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to