-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
383 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"rust": { | ||
{ | ||
"rust-analyzer.check.command": "check", | ||
"editor.defaultFormatter": "rust-lang.rust-analyzer", | ||
"editor.formatOnSave": true | ||
"editor.formatOnSave": true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
pub mod error; | ||
pub mod find_conjure; | ||
pub mod parse; | ||
pub mod rules; | ||
mod solvers; | ||
mod rules; | ||
pub mod solvers; | ||
|
||
pub use conjure_core::ast; // re-export core::ast as conjure_oxide::ast | ||
pub use conjure_core::ast::Model; // rexport core::ast::Model as conjure_oxide::Model | ||
pub use conjure_core::solvers::Solver; | ||
|
||
pub use error::Error; | ||
pub use error::Error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,81 @@ | ||
use conjure_core::{ast::Expression, rule::RuleApplicationError}; | ||
use conjure_core::{ast::Expression as Expr, rule::RuleApplicationError}; | ||
use conjure_rules::register_rule; | ||
|
||
// #[register_rule] | ||
// fn identity(expr: &Expr) -> Result<Expr, RuleApplicationError> { | ||
// Ok(expr.clone()) | ||
// } | ||
|
||
#[register_rule] | ||
fn sum_constants(expr: &Expr) -> Result<Expr, RuleApplicationError> { | ||
match expr { | ||
Expr::Sum(exprs) => { | ||
let mut sum = 0; | ||
let mut new_exprs = Vec::new(); | ||
let mut changed = false; | ||
for e in exprs { | ||
match e { | ||
Expr::ConstantInt(i) => { | ||
sum += i; | ||
changed = true; | ||
} | ||
_ => new_exprs.push(e.clone()), | ||
} | ||
} | ||
if !changed { | ||
return Err(RuleApplicationError::RuleNotApplicable); | ||
} | ||
new_exprs.push(Expr::ConstantInt(sum)); | ||
Ok(Expr::Sum(new_exprs)) // Let other rules handle only one Expr being contained in the sum | ||
} | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
} | ||
} | ||
|
||
#[register_rule] | ||
fn unwrap_sum(expr: &Expr) -> Result<Expr, RuleApplicationError> { | ||
match expr { | ||
Expr::Sum(exprs) if (exprs.len() == 1) => Ok(exprs[0].clone()), | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
} | ||
} | ||
|
||
#[register_rule] | ||
fn flatten_sum_geq(expr: &Expr) -> Result<Expr, RuleApplicationError> { | ||
match expr { | ||
Expr::Geq(a, b) => { | ||
let exprs = match a.as_ref() { | ||
Expr::Sum(exprs) => Ok(exprs), | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
}?; | ||
Ok(Expr::SumGeq(exprs.clone(), b.clone())) | ||
} | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
} | ||
} | ||
|
||
#[register_rule] | ||
fn sum_leq_to_sumleq(expr: &Expr) -> Result<Expr, RuleApplicationError> { | ||
match expr { | ||
Expr::Leq(a, b) => { | ||
let exprs = match a.as_ref() { | ||
Expr::Sum(exprs) => Ok(exprs), | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
}?; | ||
Ok(Expr::SumLeq(exprs.clone(), b.clone())) | ||
} | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
} | ||
} | ||
|
||
#[register_rule] | ||
fn identity(expr: &Expression) -> Result<Expression, RuleApplicationError> { | ||
Ok(expr.clone()) | ||
fn lt_to_ineq(expr: &Expr) -> Result<Expr, RuleApplicationError> { | ||
match expr { | ||
Expr::Lt(a, b) => Ok(Expr::Ineq( | ||
a.clone(), | ||
b.clone(), | ||
Box::new(Expr::ConstantInt(-1)), | ||
)), | ||
_ => Err(RuleApplicationError::RuleNotApplicable), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
mod error; | ||
|
||
pub mod minion; | ||
pub mod kissat; | ||
|
||
|
Oops, something went wrong.