{"id":17494802,"url":"https://github.com/curtisfenner/cnf-solver","last_synced_at":"2025-03-28T18:22:29.517Z","repository":{"id":75645761,"uuid":"142045686","full_name":"CurtisFenner/cnf-solver","owner":"CurtisFenner","description":"A small CNF-SAT solver implementing simple conflict driven clause learning (CDCL) and a simple branching heuristic.","archived":false,"fork":false,"pushed_at":"2018-09-14T03:02:55.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T00:15:59.429Z","etag":null,"topics":["cnf","sat-solver"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CurtisFenner.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-07-23T17:16:58.000Z","updated_at":"2024-04-27T19:00:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb7374df-bfda-4ee0-9b72-76d90a1fd233","html_url":"https://github.com/CurtisFenner/cnf-solver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CurtisFenner%2Fcnf-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CurtisFenner%2Fcnf-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CurtisFenner%2Fcnf-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CurtisFenner%2Fcnf-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CurtisFenner","download_url":"https://codeload.github.com/CurtisFenner/cnf-solver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246077096,"owners_count":20719926,"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":["cnf","sat-solver"],"created_at":"2024-10-19T13:43:05.579Z","updated_at":"2025-03-28T18:22:29.464Z","avatar_url":"https://github.com/CurtisFenner.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cnf-solver, a simple CNF-SAT solver\n\nThe CNF-SAT problem is a well-known and well-studied NP-complete problem. This\nmeans computer scientists and mathematicians believe there is no algorithm that\nis guaranteed to terminate in polynomial time (or even in sub-exponential time).\n\nDespite this theoretical limitation, many approaches have been found to solve\nmany instances of the CNF-SAT problem very quickly. Two early methods have\nproven extremely effective:\n\n* Unit propagation (aka boolean constraint propagation):\n    force an assignment whenever a clause has only one remaining literal\n* Conflict Driven Clause Learning (CDCL):\n    add additional clauses to prune the search space further\n\ncnf-solver implements these in Lua with thorough documentation. Lua was chosen\nbecause it is simple, readable, and portable. These features make this\ncnf-solver very easy to run and learn from.\n\n## Getting started\n\nThese instructions explain how to use the scripts provided to solve (small) CNF\ninstances.\n\n### Prerequisites\n\nYou need a version of [Lua](https://lua.org) to run the CNF solver. You may\nalready have Lua installed on your system; try `lua -v` to see the version.\n\nThis project is compatible with Lua versions 5.1, 5.2, and 5.3, in addition to\nLuaJIT. LuaJIT runs the solver 2x-3x faster than the standard Lua interpreter.\n\n### Solving DIMACS .cnf files\n\nThe `run_dimacs.lua` script can read simple DIMACS-style .cnf files. Check out\n[the example inputs](input) for what this format looks like.\n\n    $ lua run_dimacs.lua \u003c input/too_hard.cnf\n    SAT:    true\n            x7      =\u003e      true\n            x6      =\u003e      false\n            x5      =\u003e      false\n            x4      =\u003e      true\n            x2      =\u003e      true\n            x3      =\u003e      true\n            x1      =\u003e      false\n            x8      =\u003e      false\n            x9      =\u003e      false\n\n## Using the ClauseDatabase library\n\nRequire the Lua library as usual. A CNF formula is created by calling the\n`CNF.new()` constructor.\n\n    local CNF = require \"clausedatabase\"\n    local formula = CNF.new()\n\nAdd clauses to the formula by invoking `:addClause`. Clauses are passed as lists\nof *literals*, where each literal is a `{term, truth}` pair. For example,\n\"(not a) or b\" can be encoded as\n\n    formula:addClause {{\"a\", false}, {\"b\", true}}\n\nAsk the formula for a satisfying assignment by invoking `:isSatisfiable()`:\n\n    local model = formula:isSatisfiable()\n    if model then\n        -- The formula is satisfiable!\n        print(\"Satisfiable:\")\n        for key, assignment in pairs(model) do\n            print(key, \"=\u003e\", assignment)\n        end\n    else\n        -- The formula is NOT satisfiable (every possible assignment results in\n        -- at least one clause being unsatisfied)\n        print(\"Unsatisfiable\")\n    end\n\n## License\n\nThis project is licensed under the LGPL-3.0 license. See\n[LICENSE.txt](LICENSE.txt) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurtisfenner%2Fcnf-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurtisfenner%2Fcnf-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurtisfenner%2Fcnf-solver/lists"}