1
use conjure_cp::ast::{Expression as Expr, Metadata, Moo, SymbolTable};
2
use conjure_cp::rule_engine::{
3
    ApplicationError::RuleNotApplicable, ApplicationResult, RuleEffect, register_rule,
4
    register_rule_set,
5
};
6
use conjure_cp::settings::SolverFamily;
7

            
8
// BOOLEAN SAT ENCODING RULES:
9

            
10
// One rule set covers all three integer encodings. Which encoding a variable gets is a
11
// representation choice made per declaration, so every encoding's rules have to be live at once;
12
// each declines when its operands are not in its own encoding.
13
register_rule_set!("SAT", ("Base"), |f: &SolverFamily| matches!(
14
294803
    f,
15
    SolverFamily::Sat
16
));
17

            
18
/// An auxiliary declaration is an equality.
19
///
20
/// See the note on the SMT copy of this rule: only Minion has flat constraint forms to absorb an
21
/// auxiliary into, so every other backend asserts the equality instead.
22
#[register_rule("SAT", 2000, [AuxDeclaration])]
23
40614
fn aux_declaration_is_equality(expr: &Expr, _: &SymbolTable) -> ApplicationResult {
24
40614
    let Expr::AuxDeclaration(_, reference, value) = expr else {
25
21
        return Err(RuleNotApplicable);
26
    };
27
40593
    Ok(RuleEffect::pure(Expr::Eq(
28
40593
        Metadata::new(),
29
40593
        Moo::new(reference.clone().into()),
30
40593
        value.clone(),
31
40593
    )))
32
40614
}