-
Notifications
You must be signed in to change notification settings - Fork 28
feat(pumpkin-core): Introduce runtime consistency verification of propagators #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maartenflippo
wants to merge
32
commits into
main
Choose a base branch
from
feat/propagation-checkers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
2e9cba5
Initial implementation of consistency checkers
maartenflippo aacd712
Run the consistency checkers when enabled
maartenflippo ece98c7
Implement bound consistency checker
maartenflippo 5013527
Give access to domains in witness generator
maartenflippo c7a3b9c
Implement checker for absolute value
maartenflippo 5fbad25
Remove redundant min
maartenflippo fd04f2e
Include the value to support in linear witness generator
maartenflippo 0e7329e
Don't add to supported values of the domain being witnessed
maartenflippo 5c7a9d1
Proper mechanism to add to the scope
maartenflippo 8b143be
Update todo notes
maartenflippo 4c5eda3
Implement Witness generator for multiplication
maartenflippo 348779d
Transform consistency checker interface.
maartenflippo 5fd33cb
Implement new interface
maartenflippo 0c5afe2
Implement weak consistency checkers
maartenflippo 9a528c3
Remove the dedicated concept of Scope
maartenflippo 43a80a2
Proper witness generator for linear
maartenflippo 7b4bab9
Add documentation to strong consistency checker
maartenflippo 6998a47
Proper witness generator for multiplication bound consistency
maartenflippo 7ec48e0
Remove unused import
maartenflippo c295d0c
Implement witness generator for maximum
maartenflippo 360c961
No consistency checking for multiplication
maartenflippo d545f47
Add circuit and witness generator for element
maartenflippo 7088788
Fixup element propagator
maartenflippo 380e2e0
Disable circuit due to consistency bugs
maartenflippo b4eeb11
Separate flags for consistency and inference checking
maartenflippo 91ef2ea
Implement consistency checking for reified
maartenflippo 1615dee
Filter checkers and fix reified checker
maartenflippo 96c6ae5
Fix propagator checker filter cli
maartenflippo 09eec3d
Enable filtering of checker types
maartenflippo d5ac88c
Add circuit propagator
maartenflippo c47ab88
Get the final propagators in
maartenflippo dca7515
More bug fixes
maartenflippo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
34 changes: 34 additions & 0 deletions
34
pumpkin-crates/core/src/propagation/checkers/bound_consistency_checker.rs
This file contains hidden or 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,34 @@ | ||
| use pumpkin_checking::InferenceChecker; | ||
|
|
||
| use crate::predicates::Predicate; | ||
| use crate::propagation::Domains; | ||
| use crate::propagation::checkers::ConsistencyChecker; | ||
| use crate::propagation::checkers::Scope; | ||
| use crate::propagation::checkers::WitnessGenerator; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct BoundConsistencyChecker<C> { | ||
| witness_generator: C, | ||
| } | ||
|
|
||
| impl<C> BoundConsistencyChecker<C> { | ||
| pub fn new(witness_generator: C) -> Self { | ||
| BoundConsistencyChecker { witness_generator } | ||
| } | ||
| } | ||
|
|
||
| impl<C> ConsistencyChecker for BoundConsistencyChecker<C> | ||
| where | ||
| C: WitnessGenerator + InferenceChecker<Predicate> + Clone, | ||
| { | ||
| fn check_consistency(&self, domains: Domains<'_>, scope: &Scope) -> bool { | ||
| super::assert_consistency( | ||
| domains, | ||
| scope, | ||
| &self.witness_generator, | ||
| super::Consistency::Bounds, | ||
| ); | ||
|
|
||
| true | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
pumpkin-crates/core/src/propagation/checkers/consistency_checker.rs
This file contains hidden or 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,39 @@ | ||
| use std::fmt::Debug; | ||
|
|
||
| use dyn_clone::DynClone; | ||
|
|
||
| use crate::propagation::Domains; | ||
| use crate::propagation::checkers::Scope; | ||
|
|
||
| /// A consistency checker ensures that a propagator is at a certain level of consistency. | ||
| /// | ||
| /// Given a current set of domains and a scope, the checker identifies whether the desired | ||
| /// consistency level is reached. | ||
| pub trait ConsistencyChecker: Debug + DynClone { | ||
| /// Returns `true` if the variables in `scope` are at the required consistency in | ||
| /// `domains`. | ||
| fn check_consistency(&self, domains: Domains<'_>, scope: &Scope) -> bool; | ||
| } | ||
|
|
||
| /// Wrapper around `Box<dyn ConsistencyChecker>` that implements [`Clone`]. | ||
| #[derive(Debug)] | ||
| pub struct BoxedConsistencyChecker(Box<dyn ConsistencyChecker>); | ||
|
|
||
| impl Clone for BoxedConsistencyChecker { | ||
| fn clone(&self) -> Self { | ||
| BoxedConsistencyChecker(dyn_clone::clone_box(&*self.0)) | ||
| } | ||
| } | ||
|
|
||
| impl From<Box<dyn ConsistencyChecker>> for BoxedConsistencyChecker { | ||
| fn from(value: Box<dyn ConsistencyChecker>) -> Self { | ||
| BoxedConsistencyChecker(value) | ||
| } | ||
| } | ||
|
|
||
| impl BoxedConsistencyChecker { | ||
| /// See [`ConsistencyChecker::check_consistency`]. | ||
| pub fn check_consistency(&self, domains: Domains<'_>, scope: &Scope) -> bool { | ||
| self.0.check_consistency(domains, scope) | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
pumpkin-crates/core/src/propagation/checkers/domain_consistency_checker.rs
This file contains hidden or 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,34 @@ | ||
| use pumpkin_checking::InferenceChecker; | ||
|
|
||
| use crate::predicates::Predicate; | ||
| use crate::propagation::Domains; | ||
| use crate::propagation::checkers::ConsistencyChecker; | ||
| use crate::propagation::checkers::Scope; | ||
| use crate::propagation::checkers::WitnessGenerator; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct DomainConsistencyChecker<C> { | ||
| witness_generator: C, | ||
| } | ||
|
|
||
| impl<C> DomainConsistencyChecker<C> { | ||
| pub fn new(witness_generator: C) -> Self { | ||
| DomainConsistencyChecker { witness_generator } | ||
| } | ||
| } | ||
|
|
||
| impl<C> ConsistencyChecker for DomainConsistencyChecker<C> | ||
| where | ||
| C: WitnessGenerator + InferenceChecker<Predicate> + Clone, | ||
| { | ||
| fn check_consistency(&self, domains: Domains<'_>, scope: &Scope) -> bool { | ||
| super::assert_consistency( | ||
| domains, | ||
| scope, | ||
| &self.witness_generator, | ||
| super::Consistency::Domain, | ||
| ); | ||
|
|
||
| true | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.