Questions tagged [clpb]

CLP(B) stands for Constraint Logic Programming over Boolean variables. It extends Prolog with specialized reasoning for propositional formulas.

CLP(B), Constraint Logic Programming over Boolean variables, extends Prolog with specialized reasoning for propositional logic. Like SAT solvers, CLP(B) solvers allow to test for satisfiability, tautologies and other properties of SAT formulas.

Many Prolog systems ship with dedicated libraries or predicates for CLP(B). For example, SICStus Prolog and SWI ship with library(clpb), and GNU Prolog provides many predicates to express relations between Boolean formulas.

Generally, CLP(B) systems are more algebraically oriented than SAT solvers. Among the supported operations that go beyond typical SAT solvers are: variable quantification, unification, and symbolic residual goals.

Implementation methods for CLP(B) systems include BDD-based and approximation-based approaches. BDD-based systems are complete and provide some algebraic virtues like existential and universal quantification of variables which can be efficiently implemented with BDDs. Approximation-based approaches use other formalisms like CLP(FD) constraints or indexicals to express CLP(B) constraints. They are easy to implement and very efficient on many benchmarks, though typically incomplete and require explicit enumeration to test satisfiability.

28 questions
36
votes
5 answers

Prolog Constraint Processing : Packing Squares

I'm trying to solve a constraint processing problem in prolog. I need to pack 4 squares of 5x5,4x4,3x3 and 2x2 in a grid of 10x10. They may not overlap. My variables look like this: Name: SqX(i), i=1..10, domain: 1..10 Where X is either 5,4,3 or 2.…
Sven
  • 1,133
  • 1
  • 11
  • 22
15
votes
4 answers

Prolog SAT Solver

I'm trying to build a simple Prolog SAT solver. My idea is that the user should enter the boolean formula to be solved in CNF (Conjuctive Normal Form) using Prolog lists, for example (A or B) and (B or C) should be presented as sat([[A, B], [B, C]])…
Diego Allen
  • 4,623
  • 5
  • 30
  • 33
5
votes
5 answers

What is the most elegant way to find 16-bit numbers which satisfy some conditions?

I need to find all triples of 16-bit numbers (x, y, z) (well, actually only bits which perfectly match up in different triples with bits on same positions), such that y | x = 0x49ab (y >> 2) ^ x = 0x530b (z >> 1) & y = 0x0883 (x << 2) | z =…
5
votes
3 answers

Brute-force Prolog SAT solver for boolean formulas

I'm trying to write an algorithm that naively looks for models of a boolean formula (NNF, but not CNF). The code I have can check an existing model, but it'll fail (or not finish) when asked to find models, seemingly because it generates infinitely…
Christoph Burschka
  • 4,467
  • 3
  • 16
  • 31
4
votes
3 answers

Solving CNF using Prolog

While learning Prolog, I tried to write a program solving CNF problem (the performance is not an issue), so I ended up with the following code to solve (!x||y||!z)&&(x||!y||z)&&(x||y||z)&&(!x||!y||z): vx(t). vx(f). vy(t). vy(f). vz(t). vz(f). x(X)…
banx
  • 4,376
  • 4
  • 30
  • 34
4
votes
2 answers

Undesirable properties of CLPB

library(clpb) is currently available in SICStus (original version), and SWI (by mat). Let me come to the essence quite rapidly: ?- X = 1+1, sat(X), X = 1+1. X = 1+1. ?- sat(X), X = 1+1. false. So this is a similar problem as it exists in…
false
  • 10,264
  • 13
  • 101
  • 209
4
votes
2 answers

Prolog implement and/2, or/2, nand/2, nor/2, xor/2

I want to implement the following predicates in prolog and use them for truth-tables: and/2, or/2, nand/2, nor/2, xor/2 Maybe someone can show me how to implement and/2 for example so I can do the others myself and post them here.
PROLOGik
  • 68
  • 1
  • 1
  • 8
3
votes
1 answer

CLP(B) weighted sat_count/3 in Prolog

For the CLP(B) library of SWI-Prolog, I want to implement a weighted version of sat_count/2 sat_count(Sat0, N) :- catch((parse_sat(Sat0, Sat), sat_bdd(Sat, BDD), sat_roots(Sat, Roots), …
GinoC
  • 442
  • 4
  • 16
3
votes
1 answer

Creating a Groebner Basis SAT Solver in Prolog

I am trying to create a SAT solver which converts from Conjunctive Normal Form (CNF) with an implementation of Boolean Grobner Bases: a) Negation of a particular variable, e.g. -x will be converted to 1+x. b) Adding the same variable will results…
piyo_kuro
  • 105
  • 9
3
votes
2 answers

Prolog: deduction given that items can be in exactly one of two sets, with set sizes known

I have 5 people in a room. I'll be writing rules to determine whether the people are happy or sad. However, before I even start with that, I have the overlying knowledge that - of the 5 - exactly 3 are happy and 2 are sad (and none can be both). It…
Charlie
  • 31
  • 1
3
votes
4 answers

Constraint programming boolean solver

Huey, Dewey and Louie are being questioned by their uncle. These are the statements they make: • Huey: “Dewey and Louie had equal share in it; if one is guilty, so is the other.” • Dewey: “If Huey is guilty, then so am I.” • Louie: “Dewey and I are…
user2975699
  • 585
  • 1
  • 9
  • 22
2
votes
1 answer

Unknown procedure card/2 in knights and knaves puzzle

I'm programming some knight and knaves puzzles using both sat/1 and a more natural language approach using the custom propositions A says B and false(). Question 3 is stated as follows: You meet three inhabitants, A, B and C. A says: "All three of…
Luiz
  • 99
  • 5
2
votes
0 answers

SICStus Prolog weighted_maximum/3 replacement?

SWI-Prolog CLP(B) has a weighted_maximum/2 predicate. What would be the replacement for this in SICStus Prolog CLP(B)? Here is an example what it does: ?- sat(A#B), weighted_maximum([1,2,1], [A,B,C], Maximum). A = 0, B = C, C = 1, Maximum = 3. I…
user502187
2
votes
0 answers

SICStus Prolog sat_count/2 replacement?

SWI-Prolog CLP(B) has a sat_count/2 predicate. What would be the replacement for this in SICStus Prolog CLP(B)? So far I went with: sat_count(+[1|L], N) :- aggregate_all(count, L^labeling(L), N). But the above is just using labeling brute force,…
user502187
2
votes
1 answer

Print the results in a txt file with prolog

I'm using Prolog with clpd to solve boolean problems. I have rules like this one below: :- use_module(library(clpb)). fun(A, B, C, D, E) :- sat(A + B + C, D), sat(E), labeling([A, B, C, D, E]); Is possible to print the results in a…
NxA
  • 159
  • 1
  • 12
1
2