(expr, function1, function2)
return True
Test whether or not an expression is of the required form.
Test whether or not an expression is of the required form.
Test whether or not an expression is of the required form .
def _is_form(expr, function1, function2):
    """
    Test whether or not an expression is of the required form.

    """
    expr = sympify(expr)

    # Special case of an Atom
    if expr.is_Atom:
        return True

    # Special case of a single expression of function2
    if expr.func is function2:
        for lit in expr.args:
            if lit.func is Not:
                if not lit.args[0].is_Atom:
                    return False
            else:
                if not lit.is_Atom:
                    return False
        return True

    # Special case of a single negation
    if expr.func is Not:
        if not expr.args[0].is_Atom:
            return False

    if expr.func is not function1:
        return False

    for cls in expr.args:
        if cls.is_Atom:
            continue
        if cls.func is Not:
            if not cls.args[0].is_Atom:
                return False
        elif cls.func is not function2:
            return False
        for lit in cls.args:
            if lit.func is Not:
                if not lit.args[0].is_Atom:
                    return False
            else:
                if not lit.is_Atom:
                    return False

    return True
def _is_form ( expr , function1 , function2 ) : expr = sympify ( expr ) # Special case of an Atom if expr . is_Atom : return True # Special case of a single expression of function2 if expr . func is function2 : for lit in expr . args : if lit . func is Not : if not lit . args [ 0 ] . is_Atom : return False else : if not lit . is_Atom : return False return True # Special case of a single negation if expr . func is Not : if not expr . args [ 0 ] . is_Atom : return False if expr . func is not function1 : return False for cls in expr . args : if cls . is_Atom : continue if cls . func is Not : if not cls . args [ 0 ] . is_Atom : return False elif cls . func is not function2 : return False for lit in cls . args : if lit . func is Not : if not lit . args [ 0 ] . is_Atom : return False else : if not lit . is_Atom : return False return True