diff --git a/gh-pages/_config.yml b/gh-pages/_config.yml new file mode 100644 index 0000000..db849c7 --- /dev/null +++ b/gh-pages/_config.yml @@ -0,0 +1,10 @@ +theme: jekyll-theme-architect +show_downloads: false +markdown: kramdown +defaults: + - scope: + path = "" + type = docs + values: + sidebar: + nav: docs diff --git a/gh-pages/_data/navigation.yaml b/gh-pages/_data/navigation.yaml new file mode 100644 index 0000000..0b7de83 --- /dev/null +++ b/gh-pages/_data/navigation.yaml @@ -0,0 +1,7 @@ +docs: + - title: "Getting started" + url: index.md + - title: "Binary" + url: adf-bdd.md + - title: "Library" + url: adf_bdd.md diff --git a/gh-pages/adf-bdd.md b/gh-pages/adf-bdd.md new file mode 100644 index 0000000..4163b4b --- /dev/null +++ b/gh-pages/adf-bdd.md @@ -0,0 +1,122 @@ +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ellmau/adf-obdd/Code%20coverage%20with%20tarpaulin) [![Coveralls](https://img.shields.io/coveralls/github/ellmau/adf-obdd)](https://coveralls.io/github/ellmau/adf-obdd) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/ellmau/adf-obdd?include_prereleases) ![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/ellmau/adf-obdd?label=release%20from) ![GitHub top language](https://img.shields.io/github/languages/top/ellmau/adf-obdd) [![GitHub all releases](https://img.shields.io/github/downloads/ellmau/adf-obdd/total)](https://github.com/ellmau/adf-obdd/releases) [![GitHub Discussions](https://img.shields.io/github/discussions/ellmau/adf-obdd)](https://github.com/ellmau/adf-obdd/discussions) ![rust-edition](https://img.shields.io/badge/Rust--edition-2021-blue?logo=rust) + +# Abstract Dialectical Frameworks solved by Binary Decision Diagrams; developed in Dresden (ADF-BDD) +This is the readme for the executable solver. + +## Usage +``` +USAGE: + adf_bdd [OPTIONS] + +ARGS: + Input filename + +OPTIONS: + --an Sorts variables in an alphanumeric manner + --com Compute the complete models + --counter Set if the (counter-)models shall be computed and printed, + possible values are 'nai' and 'mem' for naive and memoization + repectively (only works in hybrid and naive mode) + --export Export the adf-bdd state after parsing and BDD instantiation to + the given filename + --grd Compute the grounded model + -h, --help Print help information + --import Import an adf- bdd state instead of an adf + --lib choose the bdd implementation of either 'biodivine', 'naive', or + hybrid [default: hybrid] + --lx Sorts variables in an lexicographic manner + -q Sets log verbosity to only errors + --rust_log Sets the verbosity to 'warn', 'info', 'debug' or 'trace' if -v and + -q are not use [env: RUST_LOG=debug] + --stm Compute the stable models + --stmca Compute the stable models with the help of modelcounting using + heuristics a + --stmcb Compute the stable models with the help of modelcounting using + heuristics b + --stmpre Compute the stable models with a pre-filter (only hybrid lib-mode) + --stmrew Compute the stable models with a single-formula rewriting (only + hybrid lib-mode) + --stmrew2 Compute the stable models with a single-formula rewriting on + internal representation(only hybrid lib-mode) + -v Sets log verbosity (multiple times means more verbose) + -V, --version Print version information +``` + +Note that import and export only works if the naive library is chosen + +Right now there is no additional information to the computed models, so if you use --com --grd --stm the borders between the results are not obviously communicated. +They can be easily identified though: +- The computation is always in the same order + - grd + - com + - stm +- We know that there is always exactly one grounded model +- We know that there always exist at least one complete model (i.e. the grounded one) +- We know that there does not need to exist a stable model +- We know that every stable model is a complete model too + + +## Input-file format: +Each statement is defined by an ASP-style unary predicate s, where the enclosed term represents the label of the statement. +The binary predicate ac relates each statement to one propositional formula in prefix notation, with the logical operations and constants as follows: +- and(x,y): conjunction +- or(x,y): disjunctin +- iff(x,Y): if and only if +- xor(x,y): exclusive or +- neg(x): classical negation +- c(v): constant symbol "verum" - tautology/top +- c(f): constant symbol "falsum" - inconsistency/bot + +# Development notes +To build the binary, you need to run +```bash +$> cargo build --workspace --release +``` + +To build the binary with debug-symbols, run +```bash +$> cargo build --workspace +``` + +To run all the tests placed in the submodule you need to run +```bash +$> git submodule init +``` +at the first time. +Afterwards you need to update the content of the submodule to be on the currently used revision by +```bash +$> git submodule update +``` + +The tests can be started by using the test-framework of cargo, i.e. +```bash +$> cargo test +``` +Note that some of the instances are quite big and it might take some time to finish all the tests. +If you do not initialise the submodule, tests will "only" run on the other unit-tests and (possibly forthcoming) other integration tests. +Due to the way of the generated test-modules you need to call +```bash +$> cargo clean +``` +if you change some of your test-cases. + +To remove the tests just type +```bash +$> git submodule deinit res/adf-instances +``` +or +```bash +$> git submodule deinit --all +``` + +# Acknowledgements +This work is partly supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in projects number 389792660 (TRR 248, [Center for Perspicuous Systems](https://www.perspicuous-computing.science/)), +the Bundesministerium für Bildung und Forschung (BMBF, Federal Ministry of Education and Research) in the +[Center for Scalable Data Analytics and Artificial Intelligence](https://www.scads.de) (ScaDS.AI), +and by the [Center for Advancing Electronics Dresden](https://cfaed.tu-dresden.de) (cfaed). + +# Affiliation +This work has been partly developed by the [Knowledge-Based Systems Group](http://kbs.inf.tu-dresden.de/), [Faculty of Computer Science](https://tu-dresden.de/ing/informatik) of [TU Dresden](https://tu-dresden.de). + +# Disclaimer +Hosting content here does not establish any formal or legal relation to TU Dresden diff --git a/gh-pages/adf_bdd.md b/gh-pages/adf_bdd.md new file mode 100644 index 0000000..47af6fa --- /dev/null +++ b/gh-pages/adf_bdd.md @@ -0,0 +1,164 @@ +[![Crates.io](https://img.shields.io/crates/v/adf_bdd)](https://crates.io/crates/adf_bdd) +[![docs.rs](https://img.shields.io/docsrs/adf_bdd?label=docs.rs)](https://docs.rs/adf_bdd/latest/adf_bdd/) +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ellmau/adf-obdd/Code%20coverage%20with%20tarpaulin) +[![Coveralls](https://img.shields.io/coveralls/github/ellmau/adf-obdd)](https://coveralls.io/github/ellmau/adf-obdd) +![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/ellmau/adf-obdd?include_prereleases) +![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/ellmau/adf-obdd?label=release%20from) ![GitHub top language](https://img.shields.io/github/languages/top/ellmau/adf-obdd) +[![GitHub all releases](https://img.shields.io/github/downloads/ellmau/adf-obdd/total)](https://github.com/ellmau/adf-obdd/releases) +![Crates.io](https://img.shields.io/crates/l/adf_bdd) +[![GitHub Discussions](https://img.shields.io/github/discussions/ellmau/adf-obdd)](https://github.com/ellmau/adf-obdd/discussions) ![rust-edition](https://img.shields.io/badge/Rust--edition-2021-blue?logo=rust) + +# Abstract Dialectical Frameworks solved by Binary Decision Diagrams; developed in Dresden (ADF_BDD) +This library contains an efficient representation of Abstract Dialectical Frameworks (ADf) by utilising an implementation of Ordered Binary Decision Diagrams (OBDD) + +## Noteworthy relations between ADF semantics + +They can be easily identified though: + +* The computation is always in the same order + * grd + * com + * stm +* We know that there is always exactly one grounded model +* We know that there always exist at least one complete model (i.e. the grounded one) +* We know that there does not need to exist a stable model +* We know that every stable model is a complete model too + + +## Ordered Binary Decision Diagram + +An ordered binary decision diagram is a normalised representation of binary functions, where satisfiability- and validity checks can be done relatively cheap. + +Note that one advantage of this implementation is that only one oBDD is used for all acceptance conditions. This can be done because all of them have the identical signature (i.e. the set of all statements + top and bottom concepts). Due to this uniform representation reductions on subformulae which are shared by two or more statements only need to be computed once and is already cached in the data structure for further applications. + +The used algorithm to create a BDD, based on a given formula does not perform well on bigger formulae, therefore it is possible to use a state-of-the art library to instantiate the BDD (https://github.com/sybila/biodivine-lib-bdd). It is possible to either stay with the biodivine library or switch back to the variant implemented by adf-bdd. The variant implemented in this library offers reuse of already done reductions and memoisation techniques, which are not offered by biodivine. In addition some further features, like counter-model counting is not supported by biodivine. + +Note that import and export only works if the naive library is chosen + +## Input-file format: + +Each statement is defined by an ASP-style unary predicate s, where the enclosed term represents the label of the statement. The binary predicate ac relates each statement to one propositional formula in prefix notation, with the logical operations and constants as follows: +```plain +and(x,y): conjunction +or(x,y): disjunctin +iff(x,Y): if and only if +xor(x,y): exclusive or +neg(x): classical negation +c(v): constant symbol “verum” - tautology/top +c(f): constant symbol “falsum” - inconsistency/bot +``` + +### Example input file: +```plain +s(a). +s(b). +s(c). +s(d). + +ac(a,c(v)). +ac(b,or(a,b)). +ac(c,neg(b)). +ac(d,d). +``` + +## Usage examples + +First parse a given ADF and sort the statements, if needed. + +```rust +use adf_bdd::parser::AdfParser; +use adf_bdd::adf::Adf; +// use the above example as input +let input = "s(a).s(b).s(c).s(d).ac(a,c(v)).ac(b,or(a,b)).ac(c,neg(b)).ac(d,d)."; +let parser = AdfParser::default(); +match parser.parse()(&input) { + Ok(_) => log::info!("[Done] parsing"), + Err(e) => { + log::error!( + "Error during parsing:\n{} \n\n cannot continue, panic!", + e + ); + panic!("Parsing failed, see log for further details") + } +} +// sort lexicographic +parser.varsort_lexi(); +``` +use the naive/in-crate implementation + +```rust +// create Adf +let mut adf = Adf::from_parser(&parser); +// compute and print the complete models +let printer = adf.print_dictionary(); +for model in adf.complete() { + print!("{}", printer.print_interpretation(&model)); +} +``` +use the biodivine implementation +```rust +// create Adf +let adf = adf_bdd::adfbiodivine::Adf::from_parser(&parser); +// compute and print the complete models +let printer = adf.print_dictionary(); +for model in adf.complete() { + print!("{}", printer.print_interpretation(&model)); +} +``` +use the hybrid approach implementation +```rust +// create biodivine Adf +let badf = adf_bdd::adfbiodivine::Adf::from_parser(&parser); +// instantiate the internally used adf after the reduction done by biodivine +let mut adf = badf.hybrid_step(); +// compute and print the complete models +let printer = adf.print_dictionary(); +for model in adf.complete() { + print!("{}", printer.print_interpretation(&model)); +} +``` + +use the new `NoGood`-based algorithm and utilise the new interface with channels: +```rust +use adf_bdd::parser::AdfParser; +use adf_bdd::adf::Adf; +use adf_bdd::adf::heuristics::Heuristic; +use adf_bdd::datatypes::{Term, adf::VarContainer}; +// create a channel +let (s, r) = crossbeam_channel::unbounded(); +let variables = VarContainer::default(); +let variables_worker = variables.clone(); +// spawn a solver thread +let solving = std::thread::spawn(move || { + // use the above example as input + let input = "s(a).s(b).s(c).s(d).ac(a,c(v)).ac(b,or(a,b)).ac(c,neg(b)).ac(d,d)."; + let parser = AdfParser::with_var_container(variables_worker); + parser.parse()(&input).expect("parsing worked well"); + // use hybrid approach + let mut adf = adf_bdd::adfbiodivine::Adf::from_parser(&parser).hybrid_step(); + // compute stable with the simple heuristic + adf.stable_nogood_channel(Heuristic::Simple, s); +}); + +let printer = variables.print_dictionary(); +// print results as they are computed +while let Ok(result) = r.recv() { + print!("stable model: {:?} \n", result); + // use dictionary + print!("stable model with variable names: {}", printer.print_interpretation(&result)); +} +// waiting for the other thread to close +solving.join().unwrap(); +``` + +# Acknowledgements +This work is partly supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in projects number 389792660 (TRR 248, [Center for Perspicuous Systems](https://www.perspicuous-computing.science/)), +the Bundesministerium für Bildung und Forschung (BMBF, Federal Ministry of Education and Research) in the +[Center for Scalable Data Analytics and Artificial Intelligence](https://www.scads.de) (ScaDS.AI), +and by the [Center for Advancing Electronics Dresden](https://cfaed.tu-dresden.de) (cfaed). + +# Affiliation +This work has been partly developed by the [Knowledge-Based Systems Group](http://kbs.inf.tu-dresden.de/), [Faculty of Computer Science](https://tu-dresden.de/ing/informatik) of [TU Dresden](https://tu-dresden.de). + +# Disclaimer +Hosting content here does not establish any formal or legal relation to TU Dresden diff --git a/gh-pages/index.md b/gh-pages/index.md new file mode 100644 index 0000000..2bc2828 --- /dev/null +++ b/gh-pages/index.md @@ -0,0 +1,54 @@ +[![Crates.io](https://img.shields.io/crates/v/adf_bdd)](https://crates.io/crates/adf_bdd) +[![docs.rs](https://img.shields.io/docsrs/adf_bdd?label=docs.rs)](https://docs.rs/adf_bdd/latest/adf_bdd/) +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ellmau/adf-obdd/Code%20coverage%20with%20tarpaulin) +[![Coveralls](https://img.shields.io/coveralls/github/ellmau/adf-obdd)](https://coveralls.io/github/ellmau/adf-obdd) +![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/ellmau/adf-obdd?include_prereleases) +![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/ellmau/adf-obdd?label=release%20from) ![GitHub top language](https://img.shields.io/github/languages/top/ellmau/adf-obdd) +[![GitHub all releases](https://img.shields.io/github/downloads/ellmau/adf-obdd/total)](https://github.com/ellmau/adf-obdd/releases) +![Crates.io](https://img.shields.io/crates/l/adf_bdd) +[![GitHub Discussions](https://img.shields.io/github/discussions/ellmau/adf-obdd)](https://github.com/ellmau/adf-obdd/discussions) ![rust-edition](https://img.shields.io/badge/Rust--edition-2021-blue?logo=rust) + +# Abstract Dialectical Frameworks solved by (ordered) Binary Decision Diagrams; developed in Dresden (ADF-oBDD project) + +This project is currently split into two parts: +- a [binary (adf-bdd)](adf-bdd.md), which allows one to easily answer semantics questions on abstract dialectical frameworks +- a [library (adf_bdd)](adf_bdd.md), which contains all the necessary algorithms and an open API which compute the answers to the semantics questions + + +## Abstract Dialectical Frameworks +An abstract dialectical framework (ADF) consists of abstract statements. Each statement has an unique label and might be related to other statements (s) in the ADF. This relation is defined by a so-called acceptance condition (ac), which intuitively is a propositional formula, where the variable symbols are the labels of the statements. An interpretation is a three valued function which maps to each statement a truth value (true, false, undecided). We call such an interpretation a model, if each acceptance condition agrees to the interpration. +## Ordered Binary Decision Diagram +An ordered binary decision diagram is a normalised representation of binary functions, where satisfiability- and validity checks can be done relatively cheap. + +## Input-file format: +Each statement is defined by an ASP-style unary predicate s, where the enclosed term represents the label of the statement. +The binary predicate ac relates each statement to one propositional formula in prefix notation, with the logical operations and constants as follows: +- and(x,y): conjunction +- or(x,y): disjunctin +- iff(x,Y): if and only if +- xor(x,y): exclusive or +- neg(x): classical negation +- c(v): constant symbol "verum" - tautology/top +- c(f): constant symbol "falsum" - inconsistency/bot + +# Features + +- `adhoccounting` will cache the modelcount on-the-fly during the construction of the BDD +- `adhoccountmodels` allows in addition to compute the models ad-hoc too. Note that the memoization approach for modelcounting does not work correctly if `adhoccounting` is set and `adhoccountmodels` is not. + +# Development notes +Additional information for contribution, testing, and development in general can be found here. +## Contributing to the project +You want to help and contribute to the project? That is great. Please see the [contributing guidelines](https://github.com/ellmau/adf-obdd/blob/main/.github/CONTRIBUTING.md) first. + +# Acknowledgements +This work is partly supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in projects number 389792660 (TRR 248, [Center for Perspicuous Systems](https://www.perspicuous-computing.science/)), +the Bundesministerium für Bildung und Forschung (BMBF, Federal Ministry of Education and Research) in the +[Center for Scalable Data Analytics and Artificial Intelligence](https://www.scads.de) (ScaDS.AI), +and by the [Center for Advancing Electronics Dresden](https://cfaed.tu-dresden.de) (cfaed). + +# Affiliation +This work has been partly developed by the [Knowledge-Based Systems Group](http://kbs.inf.tu-dresden.de/), [Faculty of Computer Science](https://tu-dresden.de/ing/informatik) of [TU Dresden](https://tu-dresden.de). + +# Disclaimer +Hosting content here does not establish any formal or legal relation to TU Dresden