Repository: sympy/sympy

Issue:
solveset_real(Eq(x, 1), x) gives NotImplementedError
```python
In [2]: solveset_real(Eq(x, 1), x)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-ea6b87ce2d43> in <module>()
----> 1 solveset_real(Eq(x, 1), x)

NameError: name 'solveset_real' is not defined

In [3]: from sympy.solvers.solveset import *

In [4]: x, y, z, a, b, c = symbols('x y z a b c')

In [5]: solveset_real(Eq(x, 1), x)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-5-ea6b87ce2d43> in <module>()
----> 1 solveset_real(Eq(x, 1), x)

/home/amit/Desktop/myrepo/sympy/sympy/solvers/solveset.pyc in solveset_real(f, symbol)
    443                         result += _solve_as_rational(equation, symbol,
    444                                                      solveset_solver=solveset_real,
--> 445                                                      as_poly_solver=_solve_as_poly_real)
    446                 else:
    447                     result += solveset_real(equation, symbol)

/home/amit/Desktop/myrepo/sympy/sympy/solvers/solveset.pyc in _solve_as_rational(f, symbol, solveset_solver, as_poly_solver)
    463     g, h = fraction(f)
    464     if not h.has(symbol):
--> 465         return as_poly_solver(g, symbol)
    466     else:
    467         valid_solns = solveset_solver(g, symbol)

/home/amit/Desktop/myrepo/sympy/sympy/solvers/solveset.pyc in _solve_as_poly_real(f, symbol)
    566     return _solve_as_poly(f, symbol,
    567                           solveset_solver=solveset_real,
--> 568                           invert_func=invert_real)
    569 
    570 

/home/amit/Desktop/myrepo/sympy/sympy/solvers/solveset.pyc in _solve_as_poly(f, symbol, solveset_solver, invert_func)
    556         return result
    557     else:
--> 558         raise NotImplementedError
    559 
    560 

NotImplementedError: 
```

Discussion:

Patch:
diff --git a/sympy/solvers/solveset.py b/sympy/solvers/solveset.py
index f1914a6a15..05dd5fef19 100644
--- a/sympy/solvers/solveset.py
+++ b/sympy/solvers/solveset.py
@@ -393,6 +393,16 @@ def solveset_real(f, symbol):
         raise ValueError(" %s is not a symbol" % (symbol))
 
     f = sympify(f)
+    if isinstance(f, Eq):
+        from sympy.core import Add
+        f = Add(f.lhs, - f.rhs, evaluate=False)
+
+    if f is S.true:
+        return S.Reals
+
+    if f is S.false:
+        return EmptySet()
+
     if not isinstance(f, (Expr, Number)):
         raise ValueError(" %s is not a valid sympy expression" % (f))
 


Test patch:
diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py
index 55a298f26e..5e04e3e863 100644
--- a/sympy/solvers/tests/test_solveset.py
+++ b/sympy/solvers/tests/test_solveset.py
@@ -898,3 +898,10 @@ def test_issue_9557():
 
     assert solveset(x**2 + a, x) == Intersection(S.Reals,
         FiniteSet(-sqrt(-a), sqrt(-a)))
+
+
+def test_issue_9686():
+    x = Symbol('x')
+    assert solveset_real(Eq(x, 1), x) == FiniteSet(1)
+    assert solveset_real(Eq(1, 1), x) == S.Reals
+    assert solveset_real(Eq(2, 1), x) == S.EmptySet