Coverage for sympy/assumptions/handlers/common.py : 37%
        
        
    Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
| 
 
 
 """Base class that all Ask Handlers must inherit""" 
 
 """Defines some useful methods common to most Handlers """ 
 def AlwaysTrue(expr, assumptions): 
 def AlwaysFalse(expr, assumptions): 
 
 
 """ Handler for key 'commutative' """ 
 def Symbol(expr, assumptions): """Objects are expected to be commutative unless otherwise stated""" assumps = conjuncts(assumptions) if expr.is_commutative is not None: return expr.is_commutative and not ~Q.commutative(expr) in assumps if Q.commutative(expr) in assumps: return True elif ~Q.commutative(expr) in assumps: return False return True 
 def Basic(expr, assumptions): for arg in expr.args: if not ask(Q.commutative(arg), assumptions): return False return True 
 
 
 """Wrapper allowing to query the truth value of a boolean expression.""" 
 def bool(expr, assumptions): return expr 
 
 def AppliedPredicate(expr, assumptions): return ask(expr, assumptions) 
 def Not(expr, assumptions): value = ask(expr.args[0], assumptions=assumptions) if value in (True, False): return not value else: return None 
 def Or(expr, assumptions): result = False for arg in expr.args: p = ask(arg, assumptions=assumptions) if p is True: return True if p is None: result = None return result 
 def And(expr, assumptions): result = True for arg in expr.args: p = ask(arg, assumptions=assumptions) if p is False: return False if p is None: result = None return result 
 def Implies(expr, assumptions): p, q = expr.args return ask(~p | q, assumptions=assumptions) 
 def Equivalent(expr, assumptions): p, q = expr.args pt = ask(p, assumptions=assumptions) if pt is None: return None qt = ask(q, assumptions=assumptions) if qt is None: return None return pt == qt 
 
 #### Helper methods """ Test for membership in a group with respect to the current operation """ return _fuzzy_group( (ask(key(a), assumptions) for a in expr.args), quick_exit=True)  |