clpb


Simple boolean expression testing

半世苍凉 提交于 2019-12-11 02:53:01
问题 | ?- [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 is to ask is the set of expressions {P or Q, ~P} satisfiable? But the error message is not helping here... PS. The answer should be "yes", this formula is satisfied when P = false and Q = true. 回答1: The reason you get an instantiation error is that

Undesirable properties of CLPB

老子叫甜甜 提交于 2019-12-10 18:14:56
问题 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 the default state of library(clpfd) . What to do in such a situation? Update: In library(clpfd) of mat, there is now the functor # /1 for this purpose. Ideally, accompanied with an operator declaration op(100,fx,#) , we now can write: ?- X = 1+1, #X #= Y.

Prolog SAT Solver

旧巷老猫 提交于 2019-11-30 14:47:37
问题 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]]) and Prolog procedes to find the values for A, B, C. My following code is not working and I'm not understanding why. On this line of the trace Call: (7) sat([[true, true]]) ? I was expecting start_solve_clause([_G609, _G612]]) . Disclaimer: Sorry

Prolog SAT Solver

流过昼夜 提交于 2019-11-30 11:27:29
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]]) and Prolog procedes to find the values for A, B, C. My following code is not working and I'm not understanding why. On this line of the trace Call: (7) sat([[true, true]]) ? I was expecting start_solve_clause([_G609, _G612]]) . Disclaimer: Sorry for the crappy code I didn't even know about Prolog or the SAT problem a few days ago. P.S.: Advice on

Prolog Constraint Processing : Packing Squares

怎甘沉沦 提交于 2019-11-28 09:36:03
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. The index i represents the row, the domain the column in the grid. My first constraints try to define the width and height of the squares. I formulate it as such: Constraint: SqX(i) > SqX(j)-X /\ i>j-X, range: i>0 /\ j>0 So that the possible points are constrained to be within X rows and columns from each other. Prolog however, stops on these

Prolog Constraint Processing : Packing Squares

一世执手 提交于 2019-11-27 03:02:46
问题 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. The index i represents the row, the domain the column in the grid. My first constraints try to define the width and height of the squares. I formulate it as such: Constraint: SqX(i) > SqX(j)-X /\ i>j-X, range: i>0 /\ j>0 So that the possible points

工具导航Map