{"id":21260138,"url":"https://github.com/sdiehl/picologic","last_synced_at":"2025-07-11T03:30:54.104Z","repository":{"id":17857295,"uuid":"20781161","full_name":"sdiehl/picologic","owner":"sdiehl","description":"Symbolic logic expressions","archived":false,"fork":false,"pushed_at":"2020-07-01T09:18:46.000Z","size":43,"stargazers_count":14,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-29T20:05:43.563Z","etag":null,"topics":["haskell","haskell-library","logic","picosat","sat-solver"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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":"2014-06-12T20:02:46.000Z","updated_at":"2023-12-05T10:49:13.000Z","dependencies_parsed_at":"2022-08-20T10:11:06.113Z","dependency_job_id":null,"html_url":"https://github.com/sdiehl/picologic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sdiehl/picologic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fpicologic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fpicologic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fpicologic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fpicologic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sdiehl","download_url":"https://codeload.github.com/sdiehl/picologic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdiehl%2Fpicologic/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264721295,"owners_count":23653915,"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","picosat","sat-solver"],"created_at":"2024-11-21T04:17:04.092Z","updated_at":"2025-07-11T03:30:53.808Z","avatar_url":"https://github.com/sdiehl.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Picologic\n---------\n\n[![Build Status](https://travis-ci.org/sdiehl/picologic.svg?branch=master)](https://travis-ci.org/sdiehl/picologic)\n\nPicologic is a lightweight library for working with symbolic logic expressions.\nIt is built against the picosat Haskell library which bundles the SAT solver\nwith the Haskell package so no external solver or dependencies are necessary.\n\nPicologic provides the logic expressions, parser and normal form conversion, and\nTseytin transformations to express the logic expressions in equational form and\ngenerate constraint sets for use in SAT/SMT solvers.\n\nInstalling\n----------\n\nTo use the library using Stack use:\n\n```bash\n$ git clone git@github.com:sdiehl/picologic.git\n$ cd picologic\n$ stack build\n$ stack test\n```\n\nOr using Cabal:\n\n```bash\n$ cabal install picologic\n```\n\nTo build the interactive shell compile with the ``-fshell``  flag:\n\n```bash\n$ cabal get picologic\n$ cd picologic-0.2.0\n$ cabal configure -fshell\n$ cabal install\n```\n\nUsage\n-----\n\nTo use the API import the ``Picologic`` module.\n\n```haskell\nimport Picologic\n\np, q, r :: Expr\np = readExpr \"~(A | B)\"\nq = readExpr \"(A | ~B | C) \u0026 (B | D | E) \u0026 (D | F)\"\nr = readExpr \"(φ \u003c-\u003e ψ)\"\ns = readExpr \"(0 | A) -\u003e (A \u0026 1)\"\n\nps = ppExprU p\n-- ¬(A ∨ B)\nqs = ppExprU q\n-- ((((A ∨ ¬B) ∨ C) ∧ ((B ∨ D) ∨ E)) ∧ (D ∨ F))\nrs = ppExprU (cnf r)\n-- ((φ ∧ (φ ∨ ¬ψ)) ∧ ((ψ ∨ ¬φ) ∧ ψ))\nss = ppExprU s\n-- ((⊥ ∨ A) → (A ∧ ⊤))\nss1 = ppExprU (cnf s)\n-- ⊤\n\nmain :: IO ()\nmain = solveProp p \u003e\u003e= putStrLn . ppSolutions\n-- ¬A ¬B\n-- ¬A B\n-- A ¬B\n```\n\nThe expression AST consists just of the logical connectives or constants. \n\n```haskell\nnewtype Ident = Ident String\n  deriving (Eq, Ord, Show, Data, Typeable)\n\ndata Expr\n  = Var       Ident      -- ^ Variable\n  | Neg       Expr       -- ^ Logical negation\n  | Conj      Expr Expr  -- ^ Logical conjunction\n  | Disj      Expr Expr  -- ^ Logical disjunction\n  | Iff       Expr Expr  -- ^ Logical biconditional\n  | Implies   Expr Expr  -- ^ Material implication\n  | Top                  -- ^ Constant true\n  | Bottom               -- ^ Constant false\n  deriving (Eq, Ord, Show, Data, Typeable)\n```\n\nTo use the interactive shell when compiled with with ``-fshell`` invoke\n`picologic` at the shell.\n\n```bash\n$ picologic\nPicologic 0.1\nType :help for help\n\nLogic\u003e p | q\n(p ∨ q)\nSolutions:\np q\n¬p q\np ¬q\n\nLogic\u003e ~(a -\u003e (b \u003c-\u003e c))\n(a ∧ ((b ∨ c) ∧ (¬b ∨ ¬c)))\nSolutions:\n¬a ¬b c\na b ¬c\n¬a b ¬c\na ¬b c\n\nLogic\u003e :clauses\n[[2,3],[-2,-3],[2,3,-2,-3],[1,2,3,-2,-3]]\n```\n\nLicense\n-------\n\nReleased under the MIT License.\nCopyright (c) 2014-2020, Stephen Diehl\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdiehl%2Fpicologic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdiehl%2Fpicologic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdiehl%2Fpicologic/lists"}