-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from knowsys/feature/421-aggregates-and-arith…
…metics Add ability to use arithmetic expressions and aggregates together
- Loading branch information
Showing
22 changed files
with
260 additions
and
95 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ pub use atom::*; | |
|
||
mod constructor; | ||
pub use constructor::*; | ||
|
||
pub(crate) mod variable; |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::model::{Identifier, Variable}; | ||
|
||
/// Prefix used for generated aggregate variables in a [`ChaseRule`] | ||
pub(super) const AGGREGATE_VARIABLE_PREFIX: &str = "_AGGREGATE_"; | ||
/// Prefix used for generated variables encoding equality constraints in a [`ChaseRule`] | ||
pub(super) const EQUALITY_VARIABLE_PREFIX: &str = "_EQUALITY_"; | ||
/// Prefix used for generated variables for storing the value of complex terms in a [`ChaseRule`]. | ||
pub(super) const CONSTRUCT_VARIABLE_PREFIX: &str = "_CONSTRUCT_"; | ||
|
||
fn is_aggregate_identifier(identifier: &Identifier) -> bool { | ||
identifier.name().starts_with(AGGREGATE_VARIABLE_PREFIX) | ||
} | ||
|
||
/// Check if a variable is a aggregate placeholder variable, representing the output of an aggregate. | ||
pub(crate) fn is_aggregate_variable(variable: &Variable) -> bool { | ||
match variable { | ||
Variable::Universal(identifier) => is_aggregate_identifier(identifier), | ||
Variable::Existential(identifier) => { | ||
debug_assert!( | ||
!is_aggregate_identifier(identifier), | ||
"aggregate variables must be universal variables" | ||
); | ||
false | ||
} | ||
} | ||
} | ||
|
||
fn is_construct_identifier(identifier: &Identifier) -> bool { | ||
identifier.name().starts_with(CONSTRUCT_VARIABLE_PREFIX) | ||
} | ||
|
||
/// Check if a variable is a constructor variable | ||
pub(crate) fn is_construct_variable(variable: &Variable) -> bool { | ||
match variable { | ||
Variable::Universal(identifier) => is_construct_identifier(identifier), | ||
Variable::Existential(identifier) => { | ||
debug_assert!( | ||
!is_construct_identifier(identifier), | ||
"construct variables must be universal variables" | ||
); | ||
false | ||
} | ||
} | ||
} |
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
Oops, something went wrong.