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
2
votes
1 answer

Generating random values where a constraint does and does not hold

I have the following: :-use_module(library(clpfd)). list_index_value(List,Index,Value):- nth0(Index,List,Value). length_conindexes_conrandomvector(Length,Conindexs,Randomvector):- length(Randomvector,Length), same_length(Conindexs,Ones), …
user27815
  • 4,767
  • 14
  • 28
2
votes
1 answer

Building a logical expression from structure data for clpb

I have data in the following form: :-use_module(library(clpb)). %inputs are ids that will have an associated boolean value.…
user27815
  • 4,767
  • 14
  • 28
2
votes
2 answers

Prolog boolean equation solve

I have gotten this program to work so far in GNU prolog not(X) :- \+ X. and(X, Y):- X , Y. or(X, Y):- X ; Y. implies(X, Y):- \+ X ; Y. p. q. :- initialization(main). main :- write('Program start'), nl. You can type in and(p,q),…
user3573388
  • 191
  • 1
  • 6
2
votes
3 answers

Simple boolean expression testing

| ?- [user]. compiling user for byte code... formula_0(P, Q):- (P; Q), \+ P. user compiled, 2 lines read - 768 bytes written, 37208 ms yes | ?- formula_0(P, Q). uncaught exception: error(instantiation_error,formula_0/2) All I basically want to do…
user797257
1
vote
1 answer

Circuit Verification using prolog

i have been given functions and predicate to use to verify a 2 bit full adder circuit. This is what I have understood so far:- a function signal(t) where t is terminal and signal takes value 1 or 0. signal(T, V) :- V is 1; V is 0. a function…
daredevil11
  • 107
  • 14
1
vote
2 answers

Prolog: comparing the respective elements in 2 lists

I have 2 lists [x1, x2, ...xn] and [y1, y2, ...yn] of the form {0, 1}^n. I want to generate a new list [a1, a2 ... an] such that ai = xi AND yi for every i from 1 to n (i.e., if x1 = y1 = 1 then a1 = 1 or if x1 = 1, y1 = 0, then a1 = 0) How can I…
1
vote
3 answers

How to construct a list from two lists in prolog

I am a newbie to prolog and I find it hard to think in a recursive manner. Suppose I have two lists: list1[0,0,0,1,1,0,1,1], list2[1,0,1,0,0,0,1,1]. And I want to return a list that has a 1 when either list1 or list 2 has a 1 at a corresponding…
Louis Kuang
  • 727
  • 1
  • 14
  • 30
0
votes
0 answers

Is there a prolog clpb coding which can solve this puzzle involving knights, knave, and spies?

There are three people (Alex, Brook and Cody), one of whom is a knight, one a knave, and one a spy.The knight always tells the truth, the knave always lies, and the spy can either lie or tell the truth. Alex says: "Cody is a knave." Brook says:…
0
votes
1 answer

Count solutions in a CSP

I'm using prolog and I have this code: :- use_module(library(clpb)). fun(A, B, C, D, E) :- sat(A + B + C + D), sat(E), labeling([A, B, C, D, E]). If I want count all the solutions how can I do it? I've read about sat_count(+Expr, -Count)…
NxA
  • 159
  • 1
  • 12
0
votes
2 answers

Can prolog be used to determine invalid inference?

If I have two premises as follows: a -> c (a implies c) b -> c (b implies c) and a derived conclusion: a -> b (a therefore implies b), then the conclusion can be shown to be invalid because: a -> c is valid for statement #1 when a is true and c…
0
votes
3 answers

PROLOG Undefined procedure ERROR (Two parameters recursion)

count([], 0, 0). count([X|T], M, N) :- 1 is X, count(T, MRec, NRec), M is MRec, N is NRec+1. count([X|T], M, N) :- 0 is X, count(T, MRec, NRec), M is MRec+1, N is…
0
votes
3 answers

Bertrand Russell Puzzle

Solve the following Caliban problem, translating each clue 'loyally' into Prolog, i.e. as loyally as possible. As a simple exercise in abstraction suppose that four meaningless symbols a, b, c, and d correspond in one order or another to the …
abc
  • 153
  • 2
  • 12
-2
votes
1 answer

Finding consistent assignments for logical formulas

I am about to implement a prover for logical terms in Prolog. My current code is not really presentable, therefore, I will just state, what I want my program to do and hopefully you can give me some good advice for that :) It should take a list of…
user8060841
1
2