Repository: sympy/sympy
File: sympy/assumptions/ask.py (Python)

Code before:
    """
    Register a handler in the ask system. key must be a string and handler a
    class inheriting from AskHandler.

    .. deprecated:: 1.8.
        Use multipledispatch handler instead. See :obj:`~.Predicate`.

    """
    sympy_deprecation_warning(
        """
        The AskHandler system is deprecated. The register_handler() function
        should be replaced with the multipledispatch handler of Predicate.
        """,
        deprecated_since_version="1.8",
        active_deprecations_target='deprecated-askhandler',
    )
    if isinstance(key, Predicate):
        key = key.name.name
    Qkey = getattr(Q, key, None)
    if Qkey is not None:
        Qkey.add_handler(handler)
    else:
        setattr(Q, key, Predicate(key, handlers=[handler]))


def remove_handler(key, handler):
    """
    Removes a handler from the ask system.

    .. deprecated:: 1.8.
        Use multipledispatch handler instead. See :obj:`~.Predicate`.

    """
    sympy_deprecation_warning(
        """
        The AskHandler system is deprecated. The remove_handler() function
        should be replaced with the multipledispatch handler of Predicate.
        """,
        deprecated_since_version="1.8",
        active_deprecations_target='deprecated-askhandler',
    )
    if isinstance(key, Predicate):
        key = key.name.name
    # Don't show the same warning again recursively
    with ignore_warnings(SymPyDeprecationWarning):
        getattr(Q, key).remove_handler(handler)


from sympy.assumptions.ask_generated import (get_all_known_facts,
    get_known_facts_dict)


Review comment (suggestion):
As I understand it, the effective change here is that previously this wasn't doing anything for the is_Not case (because of the `else None`) and now it does work in that case. 

Code after:

    If proposition rejects the assumption, return ``False``.

    >>> key, assump = Q.even, Q.odd
    >>> local_facts = CNF.from_prop(assump)
    >>> _ask_single_fact(key, local_facts)
    False
    """
    if not local_facts.clauses:
        return None

    known_facts_dict = get_known_facts_dict()
    get_facts = lambda k: known_facts_dict.get(k, (set(), set()))

    for clause in local_facts.clauses:
        if len(clause) != 1:
            continue
        (f,) = clause
        pred, negated = f.arg, f.is_Not

        # Negative literal
        key_req, _ = get_facts(key)
        if negated and pred in key_req:
            # If key implies pred and pred is false,
            # then key must be false.
            return False

        # Positive literal
        if not negated:
            req, rej = get_facts(pred)
            if key in req:
                # key is implied by pred
                return True
            if key in rej:
                # ~key is implied by pred
                return False

    return None


def register_handler(key, handler):
    """
    Register a handler in the ask system. key must be a string and handler a
    class inheriting from AskHandler.

    .. deprecated:: 1.8.
        Use multipledispatch handler instead. See :obj:`~.Predicate`.

    """
    sympy_deprecation_warning(
        """