Repository: sympy/sympy

Issue:
i think mod(a,b) are considering only integers solutions
Hello guys, i have a simplification of my code which is:

```
import sympy as sp
import itertools

Zp = range(3)
Zq = range(3) 
sextetos = itertools.product(Zp, Zp, Zp, Zq, Zq, Zq)


x, y, z, w = sp.symbols('x y z w', real=True)
system = []
#it will test the generic form: B(a,b) = x*a1*b1+y*a1*b2+z*a2*b1+w*a2*b2, for all pairs a= (a1,a2), b=(b1,b2) e c=(c1,c2)
#both mapping axioms, and return the set of conditions that x, y, z e w must satisfy.

for a1, b1, c1, a2, b2, c2 in sextetos:
 d1 = (b1 + c1) % p
 d2 = (b2 + c2) % q   
 if (a1, b1, c1, a2, b2, c2) != (0, b1, c1, 0, b2, c2):
    print(a1,b1,c1,a2,b2,c2)
    eq1 = ((x * (a1 * b1+b1 * a1)+y * (a1 * b2+b1 * a2)+z * (a2*b1+b2 * a1)+w * (a2 * b2+a2 * b2))) % 2
    system.append(eq1)
    eq2 = (x * (a1 * ((b1+c1)%p))+y * (a1 * ((b2+c2)%q))+z * (a2 * ((b1+c1)%p))+w * (a2*((b2+c2)%q)) - (x * a1 * (b1+c1)+y * a1 * (b2+c2)+z * a2*(b1+c1)+w * a2 * (b2+c2))) % 2
    eq2 = (x * a1 * (sp.Mod(b1+c1,p)-(b1+c1))+y * a1 * (sp.Mod(b2+c2,q)-(b2+c2))+z * a2 * (sp.Mod(b1+c1,p)-(b1+c1))+w * a2 * (sp.Mod(b2+c2,q)-(b2+c2))) % 2
    print(eq1)
    print(eq2)
    input()
vars = [x, y, z, w]
print(sp.nonlinsolve(system, vars)) 
```

I was feeling something was a litte bit wrong with this code, because the conditionset it returns has some rules that i know that doesnt exist, like for the sexteto (a1,b1,c1,a2,b2,c2) = (0,0,0,1,1,2), eq2 should be w * 1 * (-3) % 2. Or, with sp tools: Eq(3*Mod(w,2),0), considering the possibility of w = 2/3 (example). However, the code returns me just Eq(Mod(w,2),0), and i just cant understand why...

Important that: the error is before the nonlinsolve function. If u just put a print(eq2) with the equations.append(eq2), it will return (Eq(Mod(w,2),0). 

If someone have an ideia of what is happening, please give me a hand. 

Merry Christmas, gifhubbers :D



Discussion:

Patch:
diff --git a/sympy/core/mod.py b/sympy/core/mod.py
index 873e815cb2..3f0e07a561 100644
--- a/sympy/core/mod.py
+++ b/sympy/core/mod.py
@@ -164,8 +164,10 @@ def number_eval(p, q):
                 return prod_non_mod*cls(net, q)
 
             if q.is_Integer and q is not S.One:
-                non_mod_l = [i % q if i.is_Integer and (i % q is not S.Zero) else i for
-                             i in non_mod_l]
+                if all(t.is_integer for t in p.args):
+                    non_mod_l = [i % q if i.is_Integer else i for i in p.args]
+                    if any(iq is S.Zero for iq in non_mod_l):
+                        return S.Zero
 
             p = Mul(*(non_mod_l + mod_l))
 


Test patch:
diff --git a/sympy/core/tests/test_arit.py b/sympy/core/tests/test_arit.py
index 90086b4289..d9848c39eb 100644
--- a/sympy/core/tests/test_arit.py
+++ b/sympy/core/tests/test_arit.py
@@ -1996,6 +1996,11 @@ def test_Mod():
     from sympy.abc import phi
     assert Mod(4.0*Mod(phi, 1) , 2) == 2.0*(Mod(2*(Mod(phi, 1)), 1))
 
+    xi = symbols('x', integer=True)
+    assert unchanged(Mod, xi, 2)
+    assert Mod(3*xi, 2) == Mod(xi, 2)
+    assert unchanged(Mod, 3*x, 2)
+
 
 def test_Mod_Pow():
     # modular exponentiation