def _extract_main_soln(sol, soln_imageset):
    "separate the Complements, Intersections, ImageSet lambda expr\n            and it's base_set.\n            "
    if isinstance(sol, Complement):
        complements[sym] = sol.args[1]
        sol = sol.args[0]
    if isinstance(sol, Intersection):
        if (sol.args[0] != Interval((- oo), oo)):
            intersections[sym] = sol.args[0]
        sol = sol.args[1]
    if isinstance(sol, ImageSet):
        soln_imagest = sol
        expr2 = sol.lamda.expr
        sol = FiniteSet(expr2)
        soln_imageset[expr2] = soln_imagest
    if isinstance(sol, Union):
        sol_args = sol.args
        sol = S.EmptySet
        for sol_arg2 in sol_args:
            if isinstance(sol_arg2, FiniteSet):
                sol += sol_arg2
            else:
                sol += FiniteSet(sol_arg2)
    if (not isinstance(sol, FiniteSet)):
        sol = FiniteSet(sol)
    return (sol, soln_imageset)
separate the Complements, Intersections, ImageSet lambda expr
and it's base_set.
def _extract_main_soln(sol, soln_imageset):
    "separate the Complements, Intersections, ImageSet lambda expr\n            and it's base_set.\n            "
    if isinstance(sol, Complement):
        complements[sym] = sol.args[1]
        sol = sol.args[0]
    if isinstance(sol, Intersection):
        if (sol.args[0] != Interval((- oo), oo)):
            intersections[sym] = sol.args[0]
        sol = sol.args[1]
    if isinstance(sol, ImageSet):
        soln_imagest = sol
        expr2 = sol.lamda.expr
        sol = FiniteSet(expr2)
        soln_imageset[expr2] = soln_imagest
    if isinstance(sol, Union):
        sol_args = sol.args
        sol = S.EmptySet
        for sol_arg2 in sol_args:
            if isinstance(sol_arg2, FiniteSet):
                sol += sol_arg2
            else:
                sol += FiniteSet(sol_arg2)
    if (not isinstance(sol, FiniteSet)):
        sol = FiniteSet(sol)
    return (sol, soln_imageset)