Opened 12 years ago

Closed 11 years ago

# assume doesn't interact well with solve

Reported by: Owned by: robertwb burcin major sage-4.3.3 calculus sage-4.3.3.alpha0 Robert Bradshaw Burcin Erocal N/A

### Description

This has been brought up several times on the mailing lists. As a specific example

```sage: assume(x>0)
sage: solve([x^2-1],x)
[x == -1, x == 1]
```

At the very least, we could probably filter out the "solutions" that violate the assumptions.

```sage: [all(a.subs(s) for a in assumptions()) for s in solve(x^2-1==0, x)]
[False, True]
```

### comment:1 Changed 12 years ago by kcrisman

It sounds like Maxima (intentionally?) doesn't use assumptions in solve, see for instance http://www.math.utexas.edu/pipermail/maxima/2008/013152.html and other similar threads. The above solution seems reasonable.

### comment:2 Changed 11 years ago by kcrisman

Update: the solution above works well for single equations in one variable, but is tricky to implement for multiple equations (you can't subs x+y==3, for instance). Also, one has to keep in mind how to check assumptions like 'x is Integer', which can't be subs'ed in.

### comment:3 Changed 11 years ago by robertwb

• Report Upstream set to N/A
• Status changed from new to needs_review

### comment:4 Changed 11 years ago by robertwb

It doesn't catch everything, but is better than what we have now.

### Changed 11 years ago by burcin

minor documentation fixes

### comment:5 Changed 11 years ago by burcin

• Authors set to Robert Bradshaw
• Reviewers set to Burcin Erocal

The patch looks good and doctests pass. There is one minor problem, the line

```sage: GenericDeclaration(x, 'rational').contradicts(y==pi)
```

is repeated several times in the doctest for `sage.symbolic.assumptions.GenericDeclaration.contradicts()`.

I attached a patch to change these lines and add an `INPUT` field to the docstring. Can you look over my patch and change the status to positive_review if you agree with the changes?

### comment:6 Changed 11 years ago by robertwb

• Status changed from needs_review to positive_review

Thanks for looking at this. Nice catches, I approve of your changes.

### comment:7 Changed 11 years ago by mpatel

For the record: Applying the patch to 4.3.2 + a long queue gives

```applying 6515-solve-assume.patch
patching file sage/symbolic/expression.pyx
Hunk #2 succeeded at 5952 with fuzz 2 (offset 40 lines).
Hunk #3 succeeded at 6037 with fuzz 1 (offset 83 lines).
```

Please let us know (via sage-devel) about the best order in which to apply the symbolics and calculus patches.

### comment:8 Changed 11 years ago by mpatel

The first patch is missing a Mercurial header and the ticket number. I've applied a refreshed patch to 4.3.3.alpha0.

### comment:9 Changed 11 years ago by mpatel

• Merged in set to sage-4.3.3.alpha0
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.