1
// Supset rule for sets
2
use conjure_cp::ast::Metadata;
3
use conjure_cp::ast::{Expression as Expr, Moo, ReturnType, SymbolTable, Typeable};
4
use conjure_cp::rule_engine::Reduction;
5
use conjure_cp::rule_engine::{
6
    ApplicationError::RuleNotApplicable, ApplicationResult, register_rule,
7
};
8

            
9
#[register_rule(("Base", 8700))]
10
fn neq_not_eq_sets(expr: &Expr, _: &SymbolTable) -> ApplicationResult {
11
    match expr {
12
        Expr::Neq(_, a, b)
13
            if matches!(a.as_ref().return_type(), ReturnType::Set(_))
14
                && matches!(b.as_ref().return_type(), ReturnType::Set(_)) =>
15
        {
16
            Ok(Reduction::pure(Expr::Not(
17
                Metadata::new(),
18
                Moo::new(Expr::Eq(Metadata::new(), b.clone(), a.clone())),
19
            )))
20
        }
21
        _ => Err(RuleNotApplicable),
22
    }
23
}