#NEWLINE# def dpll_satisfiable( expr , all_models = False ) : #NEWLINE# #INDENT# '\n    Check satisfiability of a propositional sentence.\n    It returns a model rather than True when it succeeds.\n    Returns a generator of all models if all_models is True.\n\n    Examples\n    ========\n\n    >>> from sympy.abc import A, B\n    >>> from sympy.logic.algorithms.dpll2 import dpll_satisfiable\n    >>> dpll_satisfiable(A & ~B)\n    {A: True, B: False}\n    >>> dpll_satisfiable(A & ~A)\n    False\n\n    ' #NEWLINE# clauses = conjuncts ( to_cnf ( expr ) ) #NEWLINE# if ( False in clauses ) : #NEWLINE# #INDENT# if all_models : #NEWLINE# #INDENT# return ( f for f in [ False ] ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# symbols = sorted ( _find_predicates ( expr ) , key = default_sort_key ) #NEWLINE# symbols_int_repr = range ( 1 , ( len ( symbols ) + 1 ) ) #NEWLINE# clauses_int_repr = to_int_repr ( clauses , symbols ) #NEWLINE# solver = SATSolver ( clauses_int_repr , symbols_int_repr , set ( ) , symbols ) #NEWLINE# models = solver . _find_model ( ) #NEWLINE# if all_models : #NEWLINE# #INDENT# return _all_models ( models ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return next ( models ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# return False