Repository: sympy/sympy (Python)

Issue:
diophantine and diop_solve ignore assumptions
Using `solvers.diophantine` `diophantine` and `diop_solve` functions with integer and positive assumed symbols, also `{(0, 0)}` and negative solutions are returned.
For example:
```python
from sympy import Symbol
from sympy.solvers.diophantine import diophantine, diop_solve

x = Symbol("x", integer=True, positive=True)
y = Symbol("y", integer=True, positive=True)
eq = 10*x**2 + 5*x*y - 3*y
print(diophantine(eq))
print(diop_solve(eq))
```
prints
```
{(0, 0)}
{(1, -5), (-3, 5), (0, 0)}
```
while it should print at least an empty solution set.


Discussion:
It seems currently `diop_quadratic()` will always return a trivial solution if applied when no other solutions are found.
https://github.com/sympy/sympy/blob/3a812204052176854bdfc1ea9d12097c3f9307ca/sympy/solvers/diophantine/diophantine.py#L1479-L1485
Maybe we should rearrange the logic? By the way, you should use `diophantine()` rather than `diop_solve()` since the latter won't filter out the negative solutions. 
I'm not inside `sympy` logic, but if a symbol is subjected to certain assumptions, intuitively I expect that functions I call on that symbols are going to adhere to such assumptions. So yes, probably editing `diophantine()` to make it returns an empty set if the trivial solution is not compatible with assumptions will be a better choice. Regarding `diop_solve()`, as it is an internal use function only, maybe adding in the documentation the warning that it does not necessarily respect assumptions (except the obvious `integer=True`) is the way.



Patch:
diff --git a/sympy/solvers/diophantine/diophantine.py b/sympy/solvers/diophantine/diophantine.py
index d02d0689d814..8200ef6da21e 100644
--- a/sympy/solvers/diophantine/diophantine.py
+++ b/sympy/solvers/diophantine/diophantine.py
@@ -1482,7 +1482,9 @@ def diophantine(eq, param=symbols("t", integer=True), syms=None,
     null = tuple([0]*len(var))
     # if there is no solution, return trivial solution
     if not sols and eq.subs(zip(var, null)).is_zero:
-        sols.add(null)
+        if all(check_assumptions(val, **s.assumptions0) is not False for val, s in zip(null, var)):
+            sols.add(null)
+
     final_soln = set()
     for sol in sols:
         if all(int_valued(s) for s in sol):
@@ -1558,7 +1560,8 @@ def diop_solve(eq, param=symbols("t", integer=True)):
 
     Use of ``diophantine()`` is recommended over other helper functions.
     ``diop_solve()`` can return either a set or a tuple depending on the
-    nature of the equation.
+    nature of the equation. All non-trivial solutions are returned: assumptions
+    on symbols are ignored.
 
     Usage
     =====


Test patch:
diff --git a/sympy/solvers/diophantine/tests/test_diophantine.py b/sympy/solvers/diophantine/tests/test_diophantine.py
index a500903fc06f..e36c4c9ad165 100644
--- a/sympy/solvers/diophantine/tests/test_diophantine.py
+++ b/sympy/solvers/diophantine/tests/test_diophantine.py
@@ -752,6 +752,18 @@ def test_assumptions():
     diof = diophantine(a*b + 2*a + 3*b - 6)
     assert diof == {(-15, -3), (-9, -4), (-7, -5), (-6, -6), (-5, -8), (-4, -14)}
 
+    x, y = symbols('x y', integer=True)
+    diof = diophantine(10*x**2 + 5*x*y - 3*y)
+    assert diof == {(1, -5), (-3, 5), (0, 0)}
+
+    x, y = symbols('x y', integer=True, positive=True)
+    diof = diophantine(10*x**2 + 5*x*y - 3*y)
+    assert diof == set()
+
+    x, y = symbols('x y', integer=True, negative=False)
+    diof = diophantine(10*x**2 + 5*x*y - 3*y)
+    assert diof == {(0, 0)}
+
 
 def check_solutions(eq):
     """