{"id":21260133,"url":"https://github.com/sdiehl/haskell-picosat","last_synced_at":"2025-07-16T18:32:57.602Z","repository":{"id":12711050,"uuid":"15383576","full_name":"sdiehl/haskell-picosat","owner":"sdiehl","description":"Haskell bindings for PicoSAT solver","archived":false,"fork":false,"pushed_at":"2020-05-06T07:46:12.000Z","size":90,"stargazers_count":17,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-11T06:43:01.183Z","etag":null,"topics":["haskell","haskell-library","logic","logic-programming","picosat","picosat-solver","sat-solver"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sdiehl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-22T23:03:20.000Z","updated_at":"2025-04-23T17:55:30.000Z","dependencies_parsed_at":"2022-09-05T17:31:13.041Z","dependency_job_id":null,"html_url":"https://github.com/sdiehl/haskell-picosat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sdiehl/haskell-picosat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fhaskell-picosat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fhaskell-picosat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fhaskell-picosat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fhaskell-picosat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sdiehl","download_url":"https://codeload.github.com/sdiehl/haskell-picosat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fhaskell-picosat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265530661,"owners_count":23783128,"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":["haskell","haskell-library","logic","logic-programming","picosat","picosat-solver","sat-solver"],"created_at":"2024-11-21T04:16:57.709Z","updated_at":"2025-07-16T18:32:57.563Z","avatar_url":"https://github.com/sdiehl.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Haskell PicoSAT\n---------------\n\n[![Build Status](https://travis-ci.org/sdiehl/haskell-picosat.svg)](https://travis-ci.org/sdiehl/haskell-picosat)\n[![Hackage](https://img.shields.io/hackage/v/picosat.svg)](https://hackage.haskell.org/package/picosat)\n\nhaskell-picosat are Haskell bindings to the PicoSAT solver, written in C. It reads in clauses in CNF (\nConjunctive-Normal Form ) and returns a solution which satisfies the clauses.\n\nThe most notable distinction of this binding is that the SAT solver library is included with the cabal package\nso you shouldn't need to install anything but this package to get going. It's also notably faster than a pure\nHaskell solution at solving very large constraint problems.\n\nInstalling\n----------\n\n```bash\n$ cabal install picosat\n```\n\nUsage\n-----\n\nIf we have a table of variables representing logical statements we can enumerate them with integers.\n\n```text\nA  1\nB  2\nC  3\nD  4\nE  5\nF  6\n```\n\nThen the clause can be written as sequences of positive integers\n(assertion) and negative integers (negation):\n\n```text\n(A v ¬B v C)\n1 -2 3 0\n```\n\n```text\n(B v D v E)\n2 4 5 0\n```\n\n```text\n(D V F)\n4 6 0\n```\n\nSolutions to a statement of the form:\n\n```text\n(A v ¬B v C) ∧ (B v D v E) ∧ (D v F)\n```\n\nCan be written as zero-terminated lists of integers:\n\n```text\n1 -2 3 0\n2 4 5 0\n4 6 0\n```\n\nTo use the Haskell bindings simply pass a list of clauses to\nthe ``solve`` function, this will return either the solution or\n``Unsatisfiable`` or ``Unknown``.\n\n```haskell\nimport Picosat\n\nmain :: IO [Int]\nmain = do\n  solve [[1, -2, 3], [2,4,5], [4,6]]\n  -- Solution [1,-2,3,4,5,6]\n```\n\nThe solution given we can interpret as:\n\n```text\n1   A \n-2 ¬B \n3   C\n4   D\n5   E\n6   F\n```\n\nTo generate all possible solutions we repeatedly feed the negated solution to the solver yielding which is\nimplemented with the ``solveAll`` function which yields a sequence of solutions.\n\n```haskell\nimport Picosat\n\nmain :: IO [Int]\nmain = solveAll [[1,2]]\n  -- [Solution [1,2],Solution [-1,2],Solution [1,-2]]\n```\n\nFor a more complicated example a Sudoku solver is included as an example.\n\nLicense\n-------\n\nPicoSAT itself is included and is also licensed the MIT license.\nCopyright (c) 2006 - 2012, Armin Biere, Johannes Kepler University.\n\nReleased under the MIT License.\nCopyright (c) 2013-2020, Stephen Diehl\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdiehl%2Fhaskell-picosat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdiehl%2Fhaskell-picosat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdiehl%2Fhaskell-picosat/lists"}