<commit_before>from __future__ import print_function, division

from sympy.core import Basic, Mul, Add, Pow

from sympy.assumptions.assume import global_assumptions, AppliedPredicate
from sympy.logic.inference import satisfiable
from sympy.logic.boolalg import And, Implies, Equivalent, Or
from sympy.assumptions.ask import Q
from sympy.utilities.iterables import sift

def newask(proposition, assumptions=True, context=global_assumptions):
    relevant_facts = get_all_relevant_facts(proposition, assumptions, context)

    # TODO: Can this be faster to do it in one pass using xor?
    can_be_true = satisfiable(And(proposition, assumptions,
        relevant_facts, *context))
    can_be_false = satisfiable(And(~proposition, assumptions,
        relevant_facts, *context))

    if can_be_true and can_be_false:
        return None

    if can_be_true and not can_be_false:
        return True

    if not can_be_true and can_be_false:
        return False

    if not can_be_true and not can_be_false:
        # TODO: Run additional checks to see which combination of the
        # assumptions, global_assumptions, and relevant_facts are
        # inconsistent.
        raise ValueError("Inconsistent assumptions")

equiv_any_args = set(((Q.zero, Mul),))

def get_relevant_facts(proposition, assumptions=True, context=global_assumptions):
    keys = proposition.atoms(AppliedPredicate)
    if isinstance(assumptions, Basic):
        # XXX: We need this since True/False are not Basic
        keys |= assumptions.atoms(AppliedPredicate)
    if context:
        keys |= And(*context).atoms(AppliedPredicate)
<commit_msg>add Q.infinity(Add(args)) <==> any(map(Q.infinity, args))<commit_after>from __future__ import print_function, division

from sympy.core import Basic, Mul, Add, Pow

from sympy.assumptions.assume import global_assumptions, AppliedPredicate
from sympy.logic.inference import satisfiable
from sympy.logic.boolalg import And, Implies, Equivalent, Or
from sympy.assumptions.ask import Q
from sympy.utilities.iterables import sift

def newask(proposition, assumptions=True, context=global_assumptions):
    relevant_facts = get_all_relevant_facts(proposition, assumptions, context)

    # TODO: Can this be faster to do it in one pass using xor?
    can_be_true = satisfiable(And(proposition, assumptions,
        relevant_facts, *context))
    can_be_false = satisfiable(And(~proposition, assumptions,
        relevant_facts, *context))

    if can_be_true and can_be_false:
        return None

    if can_be_true and not can_be_false:
        return True

    if not can_be_true and can_be_false:
        return False

    if not can_be_true and not can_be_false:
        # TODO: Run additional checks to see which combination of the
        # assumptions, global_assumptions, and relevant_facts are
        # inconsistent.
        raise ValueError("Inconsistent assumptions")

equiv_any_args = set(((Q.zero, Mul),
                      (Q.infinity, Add)))

def get_relevant_facts(proposition, assumptions=True, context=global_assumptions):
    keys = proposition.atoms(AppliedPredicate)
    if isinstance(assumptions, Basic):
        # XXX: We need this since True/False are not Basic
        keys |= assumptions.atoms(AppliedPredicate)
    if context:
        keys |= And(*context).atoms(AppliedPredicate)

{'fraction_non_alphanumeric': 0.07366205652435358, 'fraction_numerical': 0.0, 'mean_word_length': 3.980538922155689, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2945951', 'n_tokens_mistral': 988, 'n_tokens_neox': 955, 'n_words': 283}