fn commute_ops(u: &Term, v: &Term) -> bool {
    fn a2p(a: &[Term]) -> (&Term, &Term) {
        (&a[0], &a[1])
    }
    match (u.as_expression(), v.as_expression()) {
        (
            Ok(Operation {
                operator: op_a,
                args: arg_a,
            }),
            Ok(Operation {
                operator: op_b,
                args: arg_b,
            }),
        ) if op_a == op_b && arg_a.len() == arg_b.len() => {
            let op = *op_a;
            if arg_a.len() == 2
                && (op == Operator::Unify
                    || op == Operator::Eq
                    || op == Operator::Neq
                    || op == Operator::And
                    || op == Operator::Or)
            {
                let (a, b) = (a2p(arg_a), a2p(arg_b));
                commute_ops(a.0, b.0) && commute_ops(a.1, b.1)
                    || commute_ops(a.0, b.1) && commute_ops(a.1, b.0)
            } else {
                arg_a
                    .iter()
                    .enumerate()
                    .all(|(i, x)| commute_ops(&arg_b[i], x))
            }
        }
        _ => u == v,
    }
}
/// equality test for polar expressions that takes symmetric operators
/// into account, eg. a = b == b = a
equality test for polar expressions that takes symmetric operators
into account, eg.
equality test for polar expressions that takes symmetric operators into account eg .
fn commute_ops(u: &Term, v: &Term) -> bool {
    fn a2p(a: &[Term]) -> (&Term, &Term) {
        (&a[0], &a[1])
    }
    match (u.as_expression(), v.as_expression()) {
        (
            Ok(Operation {
                operator: op_a,
                args: arg_a,
            }),
            Ok(Operation {
                operator: op_b,
                args: arg_b,
            }),
        ) if op_a == op_b && arg_a.len() == arg_b.len() => {
            let op = *op_a;
            if arg_a.len() == 2
                && (op == Operator::Unify
                    || op == Operator::Eq
                    || op == Operator::Neq
                    || op == Operator::And
                    || op == Operator::Or)
            {
                let (a, b) = (a2p(arg_a), a2p(arg_b));
                commute_ops(a.0, b.0) && commute_ops(a.1, b.1)
                    || commute_ops(a.0, b.1) && commute_ops(a.1, b.0)
            } else {
                arg_a
                    .iter()
                    .enumerate()
                    .all(|(i, x)| commute_ops(&arg_b[i], x))
            }
        }
        _ => u == v,
    }
}
fn commute_ops ( u : & Term , v : & Term ) -> bool { fn a2p ( a : & [ Term ] ) -> ( & Term , & Term ) { ( & a [ 0 ] , & a [ 1 ] ) } match ( u . as_expression ( ) , v . as_expression ( ) ) { ( Ok ( Operation { operator : op_a , args : arg_a , } ) , Ok ( Operation { operator : op_b , args : arg_b , } ) , ) if op_a == op_b && arg_a . len ( ) == arg_b . len ( ) => { let op = * op_a ; if arg_a . len ( ) == 2 && ( op == Operator :: Unify || op == Operator :: Eq || op == Operator :: Neq || op == Operator :: And || op == Operator :: Or ) { let ( a , b ) = ( a2p ( arg_a ) , a2p ( arg_b ) ) ; commute_ops ( a . 0 , b . 0 ) && commute_ops ( a . 1 , b . 1 ) || commute_ops ( a . 0 , b . 1 ) && commute_ops ( a . 1 , b . 0 ) } else { arg_a . iter ( ) . enumerate ( ) . all ( | ( i , x ) | commute_ops ( & arg_b [ i ] , x ) ) } } _ => u == v , } }
equality test for polar expressions that takes symmetric operators
into account, eg.
equality test for polar expressions that takes symmetric operators into account eg .
u
&Term
v
&Term
u
&Term
v
&Term