Skip to content

Commit

Permalink
refactor(ast): Rename DivEq and ModEq
Browse files Browse the repository at this point in the history
Rename DivEq to DivEqUndefZero and ModEq to ModulusEqUndefZero. The
latter names match more closely to the underlying Minion constraints
being used, reflecting that we are using the undefzero variants of both
  • Loading branch information
niklasdewally committed Nov 17, 2024
1 parent 7579a40 commit 77107a0
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 48 deletions.
4 changes: 2 additions & 2 deletions conjure_oxide/tests/generated_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn assert_vector_operators_have_partially_evaluated(model: &conjure_core::Model)
SumEq(_, vec, _) => assert_constants_leq_one(&x, vec),
SumGeq(_, vec, _) => assert_constants_leq_one(&x, vec),
SumLeq(_, vec, _) => assert_constants_leq_one(&x, vec),
DivEq(_, _, _, _) => (),
DivEqUndefZero(_, _, _, _) => (),
Ineq(_, _, _, _) => (),
// this is a vector operation, but we don't want to fold values into each-other in this
// one
Expand All @@ -261,7 +261,7 @@ fn assert_vector_operators_have_partially_evaluated(model: &conjure_core::Model)
AuxDeclaration(_, _, _) => (),
UnsafeMod(_, _, _) => (),
SafeMod(_, _, _) => (),
ModEq(_, _, _, _) => (),
ModuloEqUndefZero(_, _, _, _) => (),
};
x.clone()
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down Expand Up @@ -98,7 +98,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -121,7 +121,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -132,7 +132,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -155,7 +155,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down Expand Up @@ -108,7 +108,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -131,7 +131,7 @@
]
},
{
"DivEq": [
"DivEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
[
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down Expand Up @@ -98,7 +98,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -121,7 +121,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -132,7 +132,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -155,7 +155,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down Expand Up @@ -108,7 +108,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand All @@ -131,7 +131,7 @@
]
},
{
"ModEq": [
"ModuloEqUndefZero": [
{
"clean": false,
"etype": null
Expand Down
12 changes: 6 additions & 6 deletions crates/conjure_core/src/ast/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ pub enum Expression {

/// `a / b = c`
#[compatible(Minion)]
DivEq(Metadata, Atom, Atom, Atom),
DivEqUndefZero(Metadata, Atom, Atom, Atom),

/// `a % b = c`
#[compatible(Minion)]
ModEq(Metadata, Atom, Atom, Atom),
ModuloEqUndefZero(Metadata, Atom, Atom, Atom),

#[compatible(Minion)]
Ineq(Metadata, Box<Expression>, Box<Expression>, Box<Expression>),
Expand Down Expand Up @@ -294,7 +294,7 @@ impl Expression {
Expression::SumEq(_, _, _) => Some(ReturnType::Bool),
Expression::SumGeq(_, _, _) => Some(ReturnType::Bool),
Expression::SumLeq(_, _, _) => Some(ReturnType::Bool),
Expression::DivEq(_, _, _, _) => Some(ReturnType::Bool),
Expression::DivEqUndefZero(_, _, _, _) => Some(ReturnType::Bool),
Expression::Ineq(_, _, _, _) => Some(ReturnType::Bool),
Expression::AllDiff(_, _) => Some(ReturnType::Bool),
Expression::Bubble(_, _, _) => None, // TODO: (flm8) should this be a bool?
Expand All @@ -303,7 +303,7 @@ impl Expression {
Expression::AuxDeclaration(_, _, _) => Some(ReturnType::Bool),
Expression::UnsafeMod(_, _, _) => Some(ReturnType::Int),
Expression::SafeMod(_, _, _) => Some(ReturnType::Int),
Expression::ModEq(_, _, _, _) => Some(ReturnType::Bool),
Expression::ModuloEqUndefZero(_, _, _, _) => Some(ReturnType::Bool),
}
}

Expand Down Expand Up @@ -437,7 +437,7 @@ impl Display for Expression {
Expression::UnsafeDiv(_, box1, box2) => {
write!(f, "UnsafeDiv({}, {})", box1.clone(), box2.clone())
}
Expression::DivEq(_, box1, box2, box3) => {
Expression::DivEqUndefZero(_, box1, box2, box3) => {
write!(
f,
"DivEq({}, {}, {})",
Expand All @@ -446,7 +446,7 @@ impl Display for Expression {
box3.clone()
)
}
Expression::ModEq(_, box1, box2, box3) => {
Expression::ModuloEqUndefZero(_, box1, box2, box3) => {
write!(
f,
"ModEq({}, {}, {})",
Expand Down
5 changes: 4 additions & 1 deletion crates/conjure_core/src/rules/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ fn remove_empty_expression(expr: &Expr, _: &Model) -> ApplicationResult {
// excluded expressions
if matches!(
expr,
Atomic(_, _) | WatchedLiteral(_, _, _) | DivEq(_, _, _, _) | ModEq(_, _, _, _)
Atomic(_, _)
| WatchedLiteral(_, _, _)
| DivEqUndefZero(_, _, _, _)
| ModuloEqUndefZero(_, _, _, _)
) {
return Err(ApplicationError::RuleNotApplicable);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/conjure_core/src/rules/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn eval_constant(expr: &Expr) -> Option<Lit> {
}
bin_op::<i32, i32>(|a, b| a % b, a, b).map(Lit::Int)
}
Expr::DivEq(_, a, b, c) => {
Expr::DivEqUndefZero(_, a, b, c) => {
let a = unwrap_atom::<i32>(a)?;
let b = unwrap_atom::<i32>(b)?;
let c = unwrap_atom::<i32>(c)?;
Expand Down
Loading

0 comments on commit 77107a0

Please sign in to comment.