Opened 2 years ago

Closed 2 years ago

#22026 closed defect (fixed)

Doctests: Even reals are integers

Reported by: pelegm Owned by:
Priority: major Milestone: sage-8.0
Component: symbolics Keywords: is_integer, assume
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 81e3fba (Commits) Commit: 81e3fbabc4d05832f20d04ff216e112e607aa1d1
Dependencies: #22219 Stopgaps:

Description (last modified by rws)

Check this:

sage: assume(x, 'even')
sage: assume(x, 'real')
sage: simplify((-1)**x)
1
sage: x.is_integer()
False

At least for real numbers (or even for complex numbers), an even number should be assumed to be an integer.

This is how it works in SymPy:

In [2]: x = Symbol('x', even=True)

In [3]: x.is_integer
Out[3]: True

Was supposed to be fixed in pynac-0.7.4. This will also work and should be doctested here:

sage: sage: assume(x, 'even')
....: sage: assume(x, 'real')
....: 
sage: (-1)^x
1
sage: (-gamma(pi))^x
gamma(pi)^x

Change History (11)

comment:1 Changed 2 years ago by pelegm

I wasn't sure if I should report this as a defect or as an enhancement.

I'll add that if one tries

sage: assume(x, 'noninteger')

an error is raised:

Traceback (most recent call last):
...
ValueError: Assumption is inconsistent

so "someone" knows x is an integer...

comment:2 Changed 2 years ago by rws

Yes, Maxima knows. The inference logic however is in Pynac.

comment:3 Changed 2 years ago by rws

  • Report Upstream changed from N/A to Reported upstream. Developers acknowledge bug.

comment:4 Changed 2 years ago by rws

  • Dependencies set to pynac-0.7.4

comment:5 Changed 2 years ago by rws

  • Description modified (diff)
  • Report Upstream changed from Reported upstream. Developers acknowledge bug. to Fixed upstream, but not in a stable release.

comment:6 Changed 2 years ago by rws

  • Description modified (diff)

Not fixed in Pynac, huh.

comment:7 Changed 2 years ago by rws

  • Summary changed from Even reals are integers to Doctests: Even reals are integers

Issue is fixed. Only doctests needed.

comment:8 Changed 2 years ago by rws

  • Branch set to u/rws/doctests__even_reals_are_integers

comment:9 Changed 2 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to 81e3fbabc4d05832f20d04ff216e112e607aa1d1
  • Dependencies changed from pynac-0.7.4 to #22219
  • Milestone changed from sage-7.5 to sage-8.0
  • Report Upstream changed from Fixed upstream, but not in a stable release. to N/A
  • Status changed from new to needs_review

New commits:

81e3fba22026: Doctest: Even reals are integer

comment:10 Changed 2 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM.

comment:11 Changed 2 years ago by vbraun

  • Branch changed from u/rws/doctests__even_reals_are_integers to 81e3fbabc4d05832f20d04ff216e112e607aa1d1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.