Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should bound symbols gain limit assumptions at instantiation? #19129

Open
smichr opened this issue Apr 16, 2020 · 1 comment
Open

should bound symbols gain limit assumptions at instantiation? #19129

smichr opened this issue Apr 16, 2020 · 1 comment

Comments

@smichr
Copy link
Member

smichr commented Apr 16, 2020

I noticed that the condition k >= 1 is unevaluated in the first case:

>>> var('k',positive=True)
k
>>> Sum(Piecewise((1, k >= 1), (0, True)), (k, 1, 10))
Sum(Piecewise((1, k >= 1), (0, True)), (k, 1, 10))

but not in this case -- even though the context of the Sum warrants the change:

>>> var('k',positive=True, integer=True)
k
>>> Sum(Piecewise((1, k >= 1), (0, True)), (k, 1, 10))
Sum(1, (k, 1, 10))

Inheritance of the attributes of the range is only done during doit. Would it make sense to do so at instantiation if evaluate is not False? Instantiation could happen in two steps: obj.xreplace({bound:bound_with_assumptions}).xreplace({bound_with_assumptions: bound}). The first step would allow anything to evaluate based on assumptions; the second step would allow the user to still access that symbol.

@smichr
Copy link
Member Author

smichr commented Apr 20, 2020

It might be good to include a check for assumptions that the integration variable has that a limit expression does not have, e.g. the summation variable has been declared as a positive integer in the following:

>>> lim = [var('i',integer=1,positive=1),0, var('n',integer=True)]
>>> Sum(Piecewise((1, n>=0),(0,True)),lim)
Sum(Piecewise((1, n >= 0), (0, True)), (i, 0, n))

but two issues

  1. it should be nonnegative since the lower limit is 0 (or else an error should be raised)
  2. the upper limit appears in the Piecewise because it was not conveyed that it was a nonnegative value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants