(expr, simplify=False)
return distribute_and_over_or(expr)
Convert a propositional logical sentence s to conjunctive normal form.
    That is, of the form ((A | ~B | ...) & (B | C | ...) & ...)
    If simplify is True, the expr is evaluated to its simplest CNF form.

    Examples
    ========

    >>> from sympy.logic.boolalg import to_cnf
    >>> from sympy.abc import A, B, D
    >>> to_cnf(~(A | B) | D)
    And(Or(D, Not(A)), Or(D, Not(B)))
    >>> to_cnf((A | B) & (A | ~A), True)
    Or(A, B)
Convert a propositional logical sentence s to conjunctive normal form.
    That is, of the form ((A | ~B | ...) & (B | C | ...) & ...)
    If simplify is True, the expr is evaluated to its simplest CNF form.
Convert a propositional logical sentence s to conjunctive normal form . That is of the form (( A | ~B | ... ) & ( B | C | ... ) & ... ) If simplify is True the expr is evaluated to its simplest CNF form .
def to_cnf(expr, simplify=False):
    """
    Convert a propositional logical sentence s to conjunctive normal form.
    That is, of the form ((A | ~B | ...) & (B | C | ...) & ...)
    If simplify is True, the expr is evaluated to its simplest CNF form.

    Examples
    ========

    >>> from sympy.logic.boolalg import to_cnf
    >>> from sympy.abc import A, B, D
    >>> to_cnf(~(A | B) | D)
    And(Or(D, Not(A)), Or(D, Not(B)))
    >>> to_cnf((A | B) & (A | ~A), True)
    Or(A, B)

    """
    expr = sympify(expr)
    if not isinstance(expr, BooleanFunction):
        return expr

    if simplify:
        return simplify_logic(expr, 'cnf', True)

    # Don't convert unless we have to
    if is_cnf(expr):
        return expr

    expr = eliminate_implications(expr)
    return distribute_and_over_or(expr)
def to_cnf ( expr , simplify = False ) : expr = sympify ( expr ) if not isinstance ( expr , BooleanFunction ) : return expr if simplify : return simplify_logic ( expr , 'cnf' , True ) # Don't convert unless we have to if is_cnf ( expr ) : return expr expr = eliminate_implications ( expr ) return distribute_and_over_or ( expr )