All Projects → sdiehl → haskell-picosat

sdiehl / haskell-picosat

Licence: MIT license
Haskell bindings for PicoSAT solver

Programming Languages

c
50402 projects - #5 most used programming language
haskell
3896 projects

Projects that are alternatives of or similar to haskell-picosat

discrete-math-python-scripts
Python code snippets from Discrete Mathematics for Computer Science specialization at Coursera
Stars: ✭ 98 (+553.33%)
Mutual labels:  logic, sat-solver
react-json-logic
Build and evaluate JsonLogic with React components
Stars: ✭ 21 (+40%)
Mutual labels:  logic
Leo-III
An Automated Theorem Prover for Classical Higher-Order Logic with Henkin Semantics
Stars: ✭ 29 (+93.33%)
Mutual labels:  logic
gapt
GAPT: General Architecture for Proof Theory
Stars: ✭ 83 (+453.33%)
Mutual labels:  sat-solver
gini
A fast SAT solver
Stars: ✭ 139 (+826.67%)
Mutual labels:  sat-solver
truth-table-generator
truth-table-generator is a tool that allows to generate a truth table
Stars: ✭ 47 (+213.33%)
Mutual labels:  logic
ioBroker.linkeddevices
Create linked objects (datapoints) of your devices with a self-defined structure. This makes it possible to create a structure in ioBroker, where all objects are centralized, e.g. to be used in the vis or scripts.
Stars: ✭ 17 (+13.33%)
Mutual labels:  logic
OpenCircuits
A free, open source, online digital circuit/logic designer.
Stars: ✭ 140 (+833.33%)
Mutual labels:  logic
Awesome-Neural-Logic
Awesome Neural Logic and Causality: MLN, NLRL, NLM, etc. 因果推断,神经逻辑,强人工智能逻辑推理前沿领域。
Stars: ✭ 106 (+606.67%)
Mutual labels:  logic
theolog-ss2017
Notizen zur TheoLog-Vorlesung mit Begriffen aus Formale Systeme. Hinweis: die Unterlagen sind für die VL in 2017 und können Fehler enthalten
Stars: ✭ 18 (+20%)
Mutual labels:  logic
nunchaku
Model finder for higher-order logic
Stars: ✭ 40 (+166.67%)
Mutual labels:  logic
consistency
Implementation of models in our EMNLP 2019 paper: A Logic-Driven Framework for Consistency of Neural Models
Stars: ✭ 26 (+73.33%)
Mutual labels:  logic
ipc solver
O(N log N)-space IPC solver in OCaml
Stars: ✭ 46 (+206.67%)
Mutual labels:  logic
imove
INACTIVE: Move your mouse, generate code from flow chart
Stars: ✭ 3,598 (+23886.67%)
Mutual labels:  logic
SMCDEL
A symbolic model checker for Dynamic Epistemic Logic.
Stars: ✭ 31 (+106.67%)
Mutual labels:  logic
LPL-solutions
Solutions for the book "Language Proof and Logic".
Stars: ✭ 51 (+240%)
Mutual labels:  logic
typedb
TypeDB: a strongly-typed database
Stars: ✭ 3,152 (+20913.33%)
Mutual labels:  logic
fitchjs
Fitch style proof constructor
Stars: ✭ 19 (+26.67%)
Mutual labels:  logic
stanford-introduction-to-mathematical-thinking
Keith Devlin's Introduction to Mathematical Thinking course on Coursera (2017 Spring)
Stars: ✭ 70 (+366.67%)
Mutual labels:  logic
Picosat Horus
Desenvolvimento e produção de um picossatélite para realizações de medições atmosféricas e envio de telemetria por RF.
Stars: ✭ 26 (+73.33%)
Mutual labels:  picosat

Haskell PicoSAT

Build Status Hackage

haskell-picosat are Haskell bindings to the PicoSAT solver, written in C. It reads in clauses in CNF ( Conjunctive-Normal Form ) and returns a solution which satisfies the clauses.

The most notable distinction of this binding is that the SAT solver library is included with the cabal package so you shouldn't need to install anything but this package to get going. It's also notably faster than a pure Haskell solution at solving very large constraint problems.

Installing

$ cabal install picosat

Usage

If we have a table of variables representing logical statements we can enumerate them with integers.

A  1
B  2
C  3
D  4
E  5
F  6

Then the clause can be written as sequences of positive integers (assertion) and negative integers (negation):

(A v ¬B v C)
1 -2 3 0
(B v D v E)
2 4 5 0
(D V F)
4 6 0

Solutions to a statement of the form:

(A v ¬B v C) ∧ (B v D v E) ∧ (D v F)

Can be written as zero-terminated lists of integers:

1 -2 3 0
2 4 5 0
4 6 0

To use the Haskell bindings simply pass a list of clauses to the solve function, this will return either the solution or Unsatisfiable or Unknown.

import Picosat

main :: IO [Int]
main = do
  solve [[1, -2, 3], [2,4,5], [4,6]]
  -- Solution [1,-2,3,4,5,6]

The solution given we can interpret as:

1   A 
-2 ¬B 
3   C
4   D
5   E
6   F

To generate all possible solutions we repeatedly feed the negated solution to the solver yielding which is implemented with the solveAll function which yields a sequence of solutions.

import Picosat

main :: IO [Int]
main = solveAll [[1,2]]
  -- [Solution [1,2],Solution [-1,2],Solution [1,-2]]

For a more complicated example a Sudoku solver is included as an example.

License

PicoSAT itself is included and is also licensed the MIT license. Copyright (c) 2006 - 2012, Armin Biere, Johannes Kepler University.

Released under the MIT License. Copyright (c) 2013-2020, Stephen Diehl

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].