{"id":22326540,"url":"https://github.com/jsfpdn/sdd-rs","last_synced_at":"2025-07-29T16:34:08.870Z","repository":{"id":220645959,"uuid":"752191505","full_name":"jsfpdn/sdd-rs","owner":"jsfpdn","description":"Bottom-up sentential decision diagram compiler.","archived":false,"fork":false,"pushed_at":"2024-11-24T22:55:35.000Z","size":361,"stargazers_count":4,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-24T23:28:03.847Z","etag":null,"topics":["decision-diagram","knowledge-compilation","model-counting","model-enumeration","satisfiability-problem","sdd","sentential-decision-diagram"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsfpdn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-03T09:53:51.000Z","updated_at":"2024-11-24T22:55:39.000Z","dependencies_parsed_at":"2024-02-15T13:27:26.012Z","dependency_job_id":"68b29d03-4092-4067-9b38-572324bc04df","html_url":"https://github.com/jsfpdn/sdd-rs","commit_stats":null,"previous_names":["jsfpdn/sdd-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsfpdn%2Fsdd-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsfpdn%2Fsdd-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsfpdn%2Fsdd-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsfpdn%2Fsdd-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsfpdn","download_url":"https://codeload.github.com/jsfpdn/sdd-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228029990,"owners_count":17858434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decision-diagram","knowledge-compilation","model-counting","model-enumeration","satisfiability-problem","sdd","sentential-decision-diagram"],"created_at":"2024-12-04T02:18:03.660Z","updated_at":"2025-07-29T16:34:08.859Z","avatar_url":"https://github.com/jsfpdn.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :books: sddrs: Bottom-Up Sentential Decision Diagram Compiler\n\n\u003cimg align=\"right\"  width=\"130\" height=\"200\" src=\"static/sdd.png\" alt=\"SDD for (A ∧ B) ∨ C\"\u003e\n\n**Incrementally build, manipualate, and optimize\n[Sentential Decision Diagrams (SDD)](https://en.wikipedia.org/wiki/Sentential_decision_diagram):\na succinct representation of Boolean functions.**\n\nCrate's API documentation can be found [here](https://docs.rs/sddrs/latest/sddrs/).\n\n## :tada: Features\n\nThe compiler currently supports:\n\n* incremental compilation of Boolean functions (knowledge bases) to *compressed* and *trimmed* SDDs,\n* efficient querying of model count, model enumeration, and equivalence of SDDs,\n* dynamic minimization of SDDs via *vtree fragments*,\n* garbage collection of dead nodes,\n* SDD compilation from CNF in\n  [DIMACS](https://www21.in.tum.de/~lammich/2015_SS_Seminar_SAT/resources/dimacs-cnf.pdf) format.\n\n## Usage\n\n### :package: Library\n\nTo use the compiler within a project, add the following line to your Cargo.toml:\n\n```toml\n[dependencies]\nsddrs = { version = \"0.1\" }\n```\n\nThen import the crate, initialize an `SddManager` and compile Boolean functions!\nThe following snippet compiles the function $(A \\land B) \\lor C$ to an SDD,\ncomputes number of its models, enumerates and prints them to the stdout,\nand renders the compiled SDD and its vtree to the DOT format.\n\n```rust\nuse sddrs::manager::{options, GCStatistics, SddManager};\nuse sddrs::literal::literal::Polarity;\nuse bon::arr;\n\nfn main() {\n    let options = options::SddOptions::builder()\n        // Create right-linear vtree.\n        .vtree_strategy(options::VTreeStragey::RightLinear)\n        // Initialize the manager with variables A, B, and C.\n        .variables([\"A\".to_string(), \"B\".to_string(), \"C\"])\n        .build();\n    let manager = SddManager::new(options);\n\n    // Retrieve SDDs for literals A, B, and C.\n    let a = manager.literal(\"A\", Polarity::Positive).unwrap();\n    let b = manager.literal(\"B\", Polarity::Positive).unwrap();\n    let c = manager.literal(\"C\", Polarity::Positive).unwrap();\n\n    // Compute \"A ∧ B\"\n    let a_and_b = manager.conjoin(\u0026a, \u0026b);\n    // Compute \"(A ∧ B) ∨ C\"\n    let a_and_b_or_c = manager.disjoin(\u0026a_and_b, \u0026c);\n\n    let model_count = manager.model_count(\u0026a_and_b_or_c);\n    let models = manager.model_enumeration(\u0026a_and_b_or_c);\n\n    println!(\"'(A ∧ B) ∨ C' has {model_count} models.\");\n    println!(\"They are:\\n{models}\");\n\n    let sdd_path = \"my_formula.dot\"\n    let f = File::create(sdd_path).unwrap();\n    let mut b = BufWriter::new(f);\n    manager\n        .draw_sdd(\u0026mut b as \u0026mut dyn std::io::Write, \u0026sdd)\n        .unwrap();\n\n    let vtree_path = \"my_vtree.dot\"\n    let f = File::create(vtree_path).unwrap();\n    let mut b = BufWriter::new(f);\n    manager\n        .draw_vtree(\u0026mut b as \u0026mut dyn std::io::Write)\n        .unwrap();\n\n    println!(\"Rendered SDD to '{sdd_path}' and vtree to '{vtree_path}'\");\n}\n```\n\n**See [examples](https://github.com/jsfpdn/sdd-rs/tree/main/sddrs/examples) for more examples.**\n\n### Binary\n\nThe compiler can be also compiled and invoked as a command-line utility.\n\n```sh\ncargo build --release\n./target/release/sddrsc \\\n    --count-models \\\n    --enumerate-models \\\n    --vtree right-linear \\\n    --minimize-after-k-clauses 2 \\\n    --print-statistics \\\n    --collect-garbage  \\\n    --sdd.dot \\\n    --dimacs-path ./static/datasets/easy.cnf\n```\n\nTo render the SDD, install [Graphviz](https://graphviz.org/) and run\n\n```sh\ndot sdd.dot -Tpng -o sdd.png\n```\n\n## :page_with_curl: Related Links\n\n* [SDD: A New Canonical Representation of Propositional Knowledge Bases - Adnad Darwiche](http://reasoning.cs.ucla.edu/fetch.php?id=121\u0026type=pdf):\n  paper introducing SDDs\n* [Dynamic Minimization of Sentential Decision Diagrams - Arthur Choi and Adnan Darwiche](http://reasoning.cs.ucla.edu/fetch.php?id=128\u0026type=pdf):\n  paper describing dynamic minimization of SDDs\n* [SDD: A New Canonical Representation of Propositional Knowledge Bases – Adnan Darwiche (YouTube tutorial)](https://www.youtube.com/watch?v=_5Estmve91o)\n* [Bottom-Up Knowledge Compilers – Adnan Darwiche (YouTube tutorial)](https://www.youtube.com/watch?v=8yZapazT9Ls)\n* [The SDD Package homepage](http://reasoning.cs.ucla.edu/sdd/): homepage of the original C SDD compiler\n* [RSDD](https://github.com/neuppl/rsdd): alternative implementation of SDD in Rust\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsfpdn%2Fsdd-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsfpdn%2Fsdd-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsfpdn%2Fsdd-rs/lists"}