def eq_comm(u, v, eq=None):
    """ Goal for commutative equality

    >>> from logpy import run, var, fact
    >>> from logpy.assoccomm import eq_comm as eq
    >>> from logpy.assoccomm import commutative, associative

    >>> fact(commutative, 'add')    # declare that 'add' is commutative
    >>> fact(associative, 'add')    # declare that 'add' is associative

    >>> x = var()
    >>> run(0, x, eq(('add', 1, 2, 3), ('add', 2, x, 1)))
    (3,)
    """
    eq = eq or eq_comm
    op = var()
    utail = var()
    vtail = var()
    if isvar(u) and isvar(v):
        return (core.eq, u, v)
        raise EarlyGoalError()
    uop, uargs = op_args(u)
    vop, vargs = op_args(v)
    if not uop and not vop:
        return (core.eq, u, v)
    if vop and not uop:
        uop, uargs = vop, vargs
        v, u = u, v
    return (conde, ((core.eq, u, v),),
                   ((commutative, uop),
                    (buildo, uop, vtail, v),
                    (permuteq, uargs, vtail, eq)))
dataset/ETHPy150Open logpy/logpy/logpy/assoccomm.py/eq_comm/original