{"id":21028500,"url":"https://github.com/dirkschumacher/rpicosat","last_synced_at":"2025-05-15T10:33:28.932Z","repository":{"id":44826100,"uuid":"97214775","full_name":"dirkschumacher/rpicosat","owner":"dirkschumacher","description":"PicoSAT bindings for R","archived":false,"fork":false,"pushed_at":"2022-01-22T11:34:28.000Z","size":93,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-23T04:47:42.333Z","etag":null,"topics":["logic","logic-programming","picosat","r","sat","sat-solver","satisfiability"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirkschumacher.png","metadata":{"files":{"readme":"README.Rmd","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":"2017-07-14T09:02:26.000Z","updated_at":"2022-01-22T11:28:58.000Z","dependencies_parsed_at":"2022-09-19T07:00:27.649Z","dependency_job_id":null,"html_url":"https://github.com/dirkschumacher/rpicosat","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Frpicosat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Frpicosat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Frpicosat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkschumacher%2Frpicosat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirkschumacher","download_url":"https://codeload.github.com/dirkschumacher/rpicosat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225346440,"owners_count":17459982,"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":["logic","logic-programming","picosat","r","sat","sat-solver","satisfiability"],"created_at":"2024-11-19T11:55:50.510Z","updated_at":"2024-11-19T11:55:51.847Z","avatar_url":"https://github.com/dirkschumacher.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput:\n  md_document:\n    variant: gfm\n---\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/dirkschumacher/rpicosat/workflows/R-CMD-check/badge.svg)](https://github.com/dirkschumacher/rpicosat/actions)\n[![CRAN Status](http://www.r-pkg.org/badges/version/rpicosat)](https://CRAN.R-project.org/package=rpicosat)\n[![Codecov test coverage](https://codecov.io/gh/dirkschumacher/rpicosat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/dirkschumacher/rpicosat?branch=master)\n\u003c!-- badges: end --\u003e\n\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\n```\n\n# rpicosat\n\nR bindings to the [PicoSAT solver release 965](http://fmv.jku.at/picosat/) by Armin Biere. The PicoSAT C code is distributed under a MIT style license and is bundled with this package.\n\n## Install\n\n### Install development version\n\n```{r, eval=FALSE}\ndevtools::install_github(\"dirkschumacher/rpicosat\")\n```\n\n### Install stable version from CRAN\n\n```{r, eval = FALSE}\ninstall.packages(\"rpicosat\")\n```\n\n\n## API\n\n* `picosat_sat` can solve a SAT problem. The result is a `data.frame` + meta data, so you can use it with `dplyr` et al.\n* `picosat_solution_status` applied to the result of `picosat_sat` returns either *PICOSAT_SATISFIABLE*, *PICOSAT_UNSATISFIABLE* or *PICOSAT_UNKNOWN*\n\nThe following functions can be applied to solutions and make available some statistics generated by the `PicoSAT` solver:\n\n* `picosat_added_original_clauses` #clauses\n* `picosat_decisions` #decisions\n* `picosat_propagations` #propagations\n* `picosat_seconds` seconds spent in the C function `picosat_sat`\n* `picosat_variables` #variables\n* `picosat_visits` #visits\n\n## Example\n\nSuppose we want to test the following formula for satisfiability:\n\n\n$$\n(A \\Rightarrow B)  \\wedge (B \\Rightarrow C) \\wedge (C \\Rightarrow A)\n$$\n\nThis can be formulated as a CNF (conjunctive normal form):\n\n$$\n(\\neg A \\vee B)  \\wedge (\\neg B \\vee C) \\wedge (\\neg C \\vee A)\n$$\n\nIn `rpicosat` the problem is encoded as a list of integer vectors.\n\n```{r}\nformula \u003c- list(\n  c(-1, 2),\n  c(-2, 3),\n  c(-3, 1)\n)\n```\n\n\n```{r example}\nlibrary(rpicosat)\nres \u003c- picosat_sat(formula)\nres\n```\n\nEvery result is also a `data.frame` so you can process the results with packages like `dplyr`.\n\n```{r}\nas.data.frame(res)\n```\n\n\nWe can also test for satisfiability if we assume that a certain literal is `TRUE` or `FALSE`\n\n```{r}\npicosat_sat(formula, c(1)) # assume A is TRUE\n```\n\n```{r}\npicosat_sat(formula, c(1, -3)) # assume A is TRUE, but C is FALSE\n```\n\n## License\n\nThis R package is licensed under MIT. The PicoSAT solver bundled in this package is licensed MIT as well: Copyright (c) Armin Biere, Johannes Kepler University.\n\n## Other packages\n\nThere are [numerous other packages](https://github.com/search?utf8=✓\u0026q=picosat) providing bindings to PicoSAT. After writing this package I discovered [another package](https://github.com/dtimes6/Rpicosat) on github providing bindings to PicoSAT in R.\n\n## Tests\n\n```{r}\ncovr::package_coverage()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirkschumacher%2Frpicosat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirkschumacher%2Frpicosat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirkschumacher%2Frpicosat/lists"}