Repository: sympy/sympy

Issue:
nonlinsolve throwing AttributeError
```python3
>>> from sympy import symbols, nonlinsolve
>>> n,m = symbols('n m')
>>> nonlinsolve([ 2**m - 2**(2*n),  4*2**m - 2**(4*n) ], m,  n)
```
This code is throwing the following error: `AttributeError: 'ConditionSet' object has no attribute 'as_coeff_Mul'`
Shouldn't the expected output be m=2 and n=1?

Discussion:
sympy-bot: :white_check_mark:

Hi, I am the [SymPy bot](https://github.com/sympy/sympy-bot) (v161). I'm here to help you write a release notes entry. Please read the [guide on how to write release notes](https://github.com/sympy/sympy/wiki/Writing-Release-Notes).



Your release notes are in good order.

Here is what the release notes will look like:
* solvers
  * fixed a bug in nonlinsolve() method in solveset. ([#21929](https://github.com/sympy/sympy/pull/21929) by [@praneethratna](https://github.com/praneethratna))

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.9.

<details><summary>Click here to see the pull request description that was parsed.</summary>

    <!-- Your title above should be a short description of what
    was changed. Do not include the issue number in the title. -->

    #### References to other Issues or PRs
    <!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
    format, e.g. "Fixes #1234" (see
    https://tinyurl.com/auto-closing for more information). Also, please
    write a comment on that issue linking back to this pull request once it is
    open. -->


    #### Brief description of what is fixed or changed
    Fixes #19814 and now `nonlinsolve([ 2**m - 2**(2*n),  4*2**m - 2**(4*n) ], m,  n)` returns `FiniteSet((log(2**(2*n))/log(2), S.Complexes))` instead of `AttributeError: 'ConditionSet' object has no attribute 'as_coeff_Mul'` and also added a regression test in test_solveset.py

    #### Other comments


    #### Release Notes

    <!-- Write the release notes for this release below between the BEGIN and END
    statements. The basic format is a bulleted list with the name of the subpackage
    and the release note for this PR. For example:

    * solvers
      * Added a new solver for logarithmic equations.

    * functions
      * Fixed a bug with log of integers.

    or if no release note(s) should be included use:

    NO ENTRY

    See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
    information on how to write release notes. The bot will check your release
    notes automatically to see if they are formatted correctly. -->

    <!-- BEGIN RELEASE NOTES -->
    * solvers
       * fixed a bug in nonlinsolve() method in solveset.
    <!-- END RELEASE NOTES -->


</details><p>

github-actions[bot]: Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with `+` are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with `-` are speedups.

Significantly changed benchmark results (PR vs master)
```diff

```
Significantly changed benchmark results (master vs previous release)
```diff
       before           after         ratio
     [ed9a550f]       [b17378ca]
     <sympy-1.8^0>                 
-      1.34±0.02s          177±3ms     0.13  dsolve.TimeDsolve01.time_dsolve
-      11.4±0.01s       5.54±0.02s     0.49  integrate.TimeIntegrationRisch02.time_doit(100)
-      11.3±0.01s       5.56±0.01s     0.49  integrate.TimeIntegrationRisch02.time_doit_risch(100)
-         102±3μs       37.2±0.3μs     0.37  matrices.TimeDiagonalEigenvals.time_eigenvals
-         117±6μs         76.1±1μs     0.65  matrices.TimeMatrixGetItem.time_ImmutableDenseMatrix_getitem
-         114±3μs         75.6±1μs     0.66  matrices.TimeMatrixGetItem.time_ImmutableSparseMatrix_getitem
-         114±1μs         75.7±1μs     0.67  matrices.TimeMatrixGetItem.time_MutableSparseMatrix_getitem
-       107±0.4μs       66.7±0.9μs     0.62  solve.TimeMatrixArithmetic.time_dense_add(10, 0)
+         113±2μs          170±2μs     1.51  solve.TimeMatrixArithmetic.time_dense_add(10, 5)
+      14.5±0.1μs       24.0±0.4μs     1.66  solve.TimeMatrixArithmetic.time_dense_add(3, 0)
+      17.8±0.2μs       39.9±0.2μs     2.24  solve.TimeMatrixArithmetic.time_dense_add(3, 5)
+      26.5±0.6μs       51.3±0.4μs     1.94  solve.TimeMatrixArithmetic.time_dense_add(4, 5)
+      47.2±0.3μs        81.2±10μs     1.72  solve.TimeMatrixArithmetic.time_dense_add(6, 5)
-     1.59±0.01ms          280±4μs     0.18  solve.TimeMatrixArithmetic.time_dense_multiply(10, 0)
-      61.3±0.2μs       31.3±0.1μs     0.51  solve.TimeMatrixArithmetic.time_dense_multiply(3, 0)
+      96.3±0.6μs          172±2μs     1.79  solve.TimeMatrixArithmetic.time_dense_multiply(3, 5)
-         130±2μs       40.2±0.5μs     0.31  solve.TimeMatrixArithmetic.time_dense_multiply(4, 0)
-         383±5μs       82.4±0.4μs     0.22  solve.TimeMatrixArithmetic.time_dense_multiply(6, 0)
-       121±0.7μs       56.0±0.9μs     0.46  solve.TimeMatrixOperations.time_det(3, 0)
-         222±2μs        130±0.7μs     0.58  solve.TimeMatrixOperations.time_det(3, 2)
-         214±3μs          119±2μs     0.56  solve.TimeMatrixOperations.time_det(3, 5)
-         122±1μs       56.6±0.6μs     0.46  solve.TimeMatrixOperations.time_det_bareiss(3, 0)
-         220±1μs          132±1μs     0.60  solve.TimeMatrixOperations.time_det_bareiss(3, 2)
-         213±4μs        119±0.5μs     0.56  solve.TimeMatrixOperations.time_det_bareiss(3, 5)
-       120±0.8μs         55.8±2μs     0.46  solve.TimeMatrixOperations.time_det_berkowitz(3, 0)
-         223±3μs          132±1μs     0.59  solve.TimeMatrixOperations.time_det_berkowitz(3, 2)
-        227±20μs          120±2μs     0.53  solve.TimeMatrixOperations.time_det_berkowitz(3, 5)
+        961±30μs      1.49±0.02ms     1.56  solve.TimeMatrixOperations.time_det_berkowitz(4, 0)
+     1.14±0.02ms       2.19±0.2ms     1.92  solve.TimeMatrixOperations.time_det_berkowitz(4, 2)
+     1.19±0.02ms      2.31±0.05ms     1.94  solve.TimeMatrixOperations.time_det_berkowitz(4, 5)
+         364±9μs         600±30μs     1.65  solve.TimeMatrixOperations.time_rank(3, 0)
+         557±5μs         875±20μs     1.57  solve.TimeMatrixOperations.time_rank(4, 0)
+         162±2μs          249±2μs     1.54  solve.TimeMatrixOperations.time_rref(3, 0)
-      6.58±0.1ms      3.54±0.04ms     0.54  solve.TimeRationalSystem.time_linsolve(10)
-     1.38±0.07ms          849±9μs     0.62  solve.TimeRationalSystem.time_linsolve(5)
+     3.97±0.04ms      6.02±0.08ms     1.52  solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
-     1.61±0.04ms      1.05±0.01ms     0.65  solve.TimeSparseSystem.time_linsolve_eqs(10)
-     2.90±0.03ms      1.91±0.08ms     0.66  solve.TimeSparseSystem.time_linsolve_eqs(20)
-     4.34±0.05ms      2.75±0.01ms     0.63  solve.TimeSparseSystem.time_linsolve_eqs(30)

```
Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

Patch:
diff --git a/.mailmap b/.mailmap
index 0f72ee40aa..81d25a3fc2 100644
--- a/.mailmap
+++ b/.mailmap
@@ -554,6 +554,7 @@ Bhaskar Joshi <bhaskar.joshi@research.iiit.ac.in> BhaskarJoshi-01 <bhaskar.joshi
 Miguel Torres Costa <miguelptcosta1995@gmail.com>
 Elisha Hollander <just4now666666@gmail.com> donno2048 <just4now666666@gmail.com>
 Mamidi Ratna Praneeth <praneethratna@gmail.com> praneeth <praneethratna@gmail.com>
+Mamidi Ratna Praneeth <praneethratna@gmail.com> Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
 Zach Carmichael <20629897+craymichael@users.noreply.github.com> Zach <20629897+craymichael@users.noreply.github.com>
 Anup Parikh <parikhanupk@gmail.com> Anup Parikh <84572003+parikhanupk@users.noreply.github.com>
 Harshit Yadav <harshityadav2k@gmail.com> Harshit Yadav <45384915+hyadav2k@users.noreply.github.com>
diff --git a/sympy/solvers/solveset.py b/sympy/solvers/solveset.py
index b2797e59c3..363ef1de9b 100644
--- a/sympy/solvers/solveset.py
+++ b/sympy/solvers/solveset.py
@@ -3303,7 +3303,7 @@ def _solve_using_known_values(result, solver):
                         # in the new result list (solution for symbol `s`)
                         # along with old results.
                         for k, v in res.items():
-                            if isinstance(v, Expr):
+                            if isinstance(v, Expr) and isinstance(sol, Expr):
                                 # if any unsolved symbol is present
                                 # Then subs known value
                                 rnew[k] = v.subs(sym, sol)


Test patch:
diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py
index 079d233a52..548356abcb 100644
--- a/sympy/solvers/tests/test_solveset.py
+++ b/sympy/solvers/tests/test_solveset.py
@@ -2895,3 +2895,8 @@ def test_issue_21236():
 def test_issue_21908():
     assert nonlinsolve([(x**2 + 2*x - y**2)*exp(x), -2*y*exp(x)], x, y
                       ) == {(-2, 0), (0, 0)}
+
+
+def test_issue_19814():
+    assert nonlinsolve([ 2**m - 2**(2*n), 4*2**m - 2**(4*n)], m, n
+                      ) == FiniteSet((log(2**(2*n))/log(2), S.Complexes))