feat: sd-dnnf-checker - #24
Conversation
|
I'll also clean up a bit the code in this PR, i have some commented out code that i should remove. |
* this adds a bottom-up checker that walks the circuit once, and checks - decomposability: no variable appears in more than one child of an AND - smoothness: every child of an OR mentions exactly the same variable scope Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
* exported symbols (e.g. check_sdnnf) are visible for linking and debugging Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
* this commit will be eventually reversed Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
3ba6338 to
ce22597
Compare
- following stricter c++ guidelines: https://google.github.io/styleguide/cppguide.html#Namespaces Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
d606b48 to
e7e8deb
Compare
enables safe subclassing of circuit from external consumers (e.g. kompyle). Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Replace the determinism comment with a more accurate note: checking determinism on arbitrary NNF circuits is coNP-complete. Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Also drops the stale comment explaining why get_indices is bound on Circuit. Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Not all tests are run during ci. Run all tests manually `pytest tests/* -vv -rs` Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
|
@jjcmoon Would it be possible to bump the version when deciding to merge these changes ? |
jjcmoon
left a comment
There was a problem hiding this comment.
I think this could simplified quite a bit, c.f. the comments.
| std::vector<Node*> roots = {}; | ||
|
|
||
| ~Circuit() { | ||
| virtual ~Circuit() { |
There was a problem hiding this comment.
Why make Circuit virtual? I feel this isn't necessary.
There was a problem hiding this comment.
It's handy when inheriting the circuit class, although, it doesn't fit this PR,
I could move this to another PR if needed ?
In kompyle, for example, I inherit the circuit class in order to add an extra field,
but that fields doesn't fit in the klay project. So, i thought that would be the best solution ?
The field is to have a mapping from variable names to indices such that you can process
multiple non-cnf files into the same klay circuit and don't have the same name from different
files map to different indices in the same klay circuit.
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include <cassert> |
|
|
||
| std::string sdnnf_summary(const SDNNFResult& r); | ||
|
|
||
| class IPropertyChecker { |
There was a problem hiding this comment.
This seems over-engineered. Can't you just make two methods that check decomposability and smoothness?
There was a problem hiding this comment.
sure, basically, have only the methods:
SDNNFResult check_decomposability(const Circuit& circuit, std::size_t max_violations);
SDNNFResult check_smooth(const Circuit& circuit, std::size_t max_violations);
SDNNFResult check_sdnnf(const Circuit& circuit, std::size_t max_violations);
There was a problem hiding this comment.
i have done what was ordered from me, am i free to go my lord ?
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
* gets automatically detected by pytest, which is used in CI Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
* removing unused code Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
* was used to check certain things when completing the search trough the klay circuit, but is now unused. Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
* moving certain dependencies to cpp Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Remove the IPropertyChecker interface, DecomposabilityChecker and SmoothnessChecker classes, and the run_checks dispatcher in favour of two static helpers (check_and_decomp, check_or_smooth) called directly from check_decomposability, check_smooth and check_sdnnf. Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
Signed-off-by: IbrahimElk <ibrahim_elkaddouri@outlook.com>
This PR adds some property-checks for sd-DNNF circuits implemented using Klay.
Primarily, syntactic checks including decomposability and smoothness, and exposes the results to python.
This PR also adds tests covering these new check methods.