

def eq_comm(u, v, eq=None):
    " Goal for commutative equality\n\n    >>> from logpy import run, var, fact\n    >>> from logpy.assoccomm import eq_comm as eq\n    >>> from logpy.assoccomm import commutative, associative\n\n    >>> fact(commutative, 'add')    # declare that 'add' is commutative\n    >>> fact(associative, 'add')    # declare that 'add' is associative\n\n    >>> x = var()\n    >>> run(0, x, eq(('add', 1, 2, 3), ('add', 2, x, 1)))\n    (3,)\n    "
    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