Repository: sympy/sympy

Issue:
solveset(Abs(sin(x)) + 1, x, S.Reals) returns `Non-Empty`
```
>>> solveset(Abs(sin(x)) + 1, x, S.Reals)
{x | x ∈ ℝ ∧ False }        # this should return S.EmptySet
```
While the `Eq` version works correctly
```
>>> solveset(Eq(Abs(sin(x)), -1), x, S.Reals)
∅
```
The reason for this i think is(i am guessing):
```
>>> imageset(Lambda(n, S.false), S.Naturals)
{False | n ∈ ℕ }
```

Discussion:

Patch:
diff --git a/sympy/sets/conditionset.py b/sympy/sets/conditionset.py
index c3627b9486..2e0c3daaf5 100644
--- a/sympy/sets/conditionset.py
+++ b/sympy/sets/conditionset.py
@@ -1,5 +1,6 @@
 from __future__ import print_function, division
 
+from sympy import S
 from sympy.core.basic import Basic
 from sympy.logic.boolalg import And
 from sympy.sets.sets import (Set, Interval, Intersection, EmptySet, Union,
@@ -28,6 +29,10 @@ class ConditionSet(Set):
     True
     """
     def __new__(cls, condition, base_set):
+        if condition.args[1] is S.false:
+            return S.EmptySet
+        if condition.args[1] is S.true:
+            return base_set
         return Basic.__new__(cls, condition, base_set)
 
     condition = property(lambda self: self.args[0])


Test patch:
diff --git a/sympy/sets/tests/test_conditionset.py b/sympy/sets/tests/test_conditionset.py
index c7ba55c399..368621310f 100644
--- a/sympy/sets/tests/test_conditionset.py
+++ b/sympy/sets/tests/test_conditionset.py
@@ -1,5 +1,5 @@
 from sympy.sets import (ConditionSet, Intersection)
-from sympy import (Symbol, Eq, S, sin, pi, Lambda, Interval)
+from sympy import (Symbol, Eq, S, Abs, sin, pi, Lambda, Interval)
 
 x = Symbol('x')
 
@@ -19,3 +19,8 @@ def test_CondSet_intersect():
     other_domain = Interval(0, 3, False, False)
     output_conditionset = ConditionSet(Lambda(x, x**2 > 4), Interval(1, 3, False, False))
     assert Intersection(input_conditionset, other_domain) == output_conditionset
+
+
+def test_issue_9849():
+    assert ConditionSet(Lambda(x, Eq(x, x)), S.Naturals) == S.Naturals
+    assert ConditionSet(Lambda(x, Eq(Abs(sin(x)), -1)), S.Naturals) == S.EmptySet
diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py
index 44f3548acc..fae00b37ed 100644
--- a/sympy/solvers/tests/test_solveset.py
+++ b/sympy/solvers/tests/test_solveset.py
@@ -1009,3 +1009,7 @@ def test_issue_9778():
 @XFAIL
 def test_issue_failing_pow():
     assert solveset(x**(S(3)/2) + 4, x, S.Reals) == S.EmptySet
+
+
+def test_issue_9849():
+    assert solveset(Abs(sin(x)) + 1, x, S.Reals) == S.EmptySet