(expr, form=None, deep=True)
This function simplifies a boolean function to its simplified version
    in SOP or POS form. The return type is an Or or And object in SymPy.

    Parameters
    ==========

    expr : string or boolean expression
    form : string ('cnf' or 'dnf') or None (default).
        If 'cnf' or 'dnf', the simplest expression in the corresponding
        normal form is returned; if None, the answer is returned
        according to the form with fewest args (in CNF by default).
    deep : boolean (default True)
        indicates whether to recursively simplify any
        non-boolean functions contained within the input.

    Examples
    ========

    >>> from sympy.logic import simplify_logic
    >>> from sympy.abc import x, y, z
    >>> from sympy import S
    >>> b = '(~x & ~y & ~z) | ( ~x & ~y & z)'
    >>> simplify_logic(b)
    And(Not(x), Not(y))

    >>> S(b)
    Or(And(Not(x), Not(y), Not(z)), And(Not(x), Not(y), z))
    >>> simplify_logic(_)
    And(Not(x), Not(y))
This function simplifies a boolean function to its simplified version
    in SOP or POS form. The return type is an Or or And object in SymPy.
This function simplifies a boolean function to its simplified version in SOP or POS form . The return type is an Or or And object in SymPy .
def simplify_logic(expr, form=None, deep=True):
    """
    This function simplifies a boolean function to its simplified version
    in SOP or POS form. The return type is an Or or And object in SymPy.

    Parameters
    ==========

    expr : string or boolean expression
    form : string ('cnf' or 'dnf') or None (default).
        If 'cnf' or 'dnf', the simplest expression in the corresponding
        normal form is returned; if None, the answer is returned
        according to the form with fewest args (in CNF by default).
    deep : boolean (default True)
        indicates whether to recursively simplify any
        non-boolean functions contained within the input.

    Examples
    ========

    >>> from sympy.logic import simplify_logic
    >>> from sympy.abc import x, y, z
    >>> from sympy import S
    >>> b = '(~x & ~y & ~z) | ( ~x & ~y & z)'
    >>> simplify_logic(b)
    And(Not(x), Not(y))

    >>> S(b)
    Or(And(Not(x), Not(y), Not(z)), And(Not(x), Not(y), z))
    >>> simplify_logic(_)
    And(Not(x), Not(y))

    """

    if form == 'cnf' or form == 'dnf' or form is None:
        expr = sympify(expr)
        if not isinstance(expr, BooleanFunction):
            return expr
        variables = _find_predicates(expr)
        truthtable = []
        for t in product([0, 1], repeat=len(variables)):
            t = list(t)
            if expr.xreplace(dict(zip(variables, t))) == True:
                truthtable.append(t)
        if deep:
            from sympy.simplify.simplify import simplify
            variables = [simplify(v) for v in variables]
        if form == 'dnf' or \
           (form is None and len(truthtable) >= (2 ** (len(variables) - 1))):
            return SOPform(variables, truthtable)
        elif form == 'cnf' or form is None:
            return POSform(variables, truthtable)
    else:
        raise ValueError("form can be cnf or dnf only")
def simplify_logic ( expr , form = None , deep = True ) : if form == 'cnf' or form == 'dnf' or form is None : expr = sympify ( expr ) if not isinstance ( expr , BooleanFunction ) : return expr variables = _find_predicates ( expr ) truthtable = [ ] for t in product ( [ 0 , 1 ] , repeat = len ( variables ) ) : t = list ( t ) if expr . xreplace ( dict ( zip ( variables , t ) ) ) == True : truthtable . append ( t ) if deep : from sympy . simplify . simplify import simplify variables = [ simplify ( v ) for v in variables ] if form == 'dnf' or ( form is None and len ( truthtable ) >= ( 2 ** ( len ( variables ) - 1 ) ) ) : return SOPform ( variables , truthtable ) elif form == 'cnf' or form is None : return POSform ( variables , truthtable ) else : raise ValueError ( "form can be cnf or dnf only" )