3

I am new to the topic of propositional logic and boolean expressions. So this is why I need help. Here is my problem:

In the car industry you have thousand of different variants of components available to choose from when you buy a car. Not every component is combinable, so for each car there exist a lot of rules that are expressed in propositional logic. In my case each car has between 2000 and 4000 rules.

They look like this:

  1. A → B ∨ C ∨ D
  2. C → ¬F
  3. F ∧ G → D
  4. ...

where "∧" = "and" / "∨" = "or" / "¬" = "not" / "→" = "implication".

The variables A, B, C, ... are linked to the components in the bill of material. The data I have consists of pairs of components with their linked variables.

Example:

  1. Component_1, Component_2: (A) ∧ (B)
  2. Component_1, Component_3: (A) ∧ (C ∨ F)
  3. Component_3, Component_5: (B ∨ G)
  4. ...

Now, my question is how to solve this problem. Specifically, I would like to know if each combination of the components is possible according to rules above.

  1. Which tool, software and algorithm can solve these type of problems?
  2. Is there a illustrative example?
  3. How can I automate it, so I can check each combination in my list?
  4. Generally, what should I search for in Google to deepen my knowledge in this topic?

Thank you very much for your help! Olaf

Olaf_SQL
  • 55
  • 4
  • 1
    You can look at the list of the past [**SAT competitions**](http://www.satcompetition.org/) to choose a **tool** to solve your own problem. The *Handbook of Satisfiability* is, imho, the most comprehensive introduction on the topic you can start with. Once you encode all the rules, you can use the so called *all-sat* search to list all possible *models* of your formula, each of which corresponds to a specific combination of components. To automate it, use some *script* to generate the *SAT* formula. Try to use the solver *incrementally*, if possible in your use case, for better performance. – Patrick Trentin Nov 26 '17 at 11:31
  • 2
    Ok, Thank you very much. Especially the "all-sat" search will probably help me. – Olaf_SQL Dec 06 '17 at 10:33
  • As for AllSAT I would recommend [sharpCDCL](http://tools.computational-logic.org/content/sharpCDCL.php), I had a great positive experience with it, solving some real-world poblems. If you want more "expressiveness", consider using [clasp](https://potassco.org/clasp/) – CaptainTrunky Dec 13 '17 at 07:53

1 Answers1

0

You might want to try a Prolog system with a SAT Solver, such as SWI-Prolog, Jekejeke Minlog, etc... you can readily play with it in the REPL of the Prolog system. To load the SAT solver just type (you don't need to type the ?- itself):

/* in SWI-Prolog */
?- use_module(library(clpb)).

/* in Jekejeke Minlog */
?- use_module(library(finite/clpb)).

You can then use the top-level to search for solutions of a boolean formula, like this example here an xor:

?- sat(X#Y), labeling([X,Y]).
X = 0,
Y = 1 ;
X = 1,
Y = 0.

Here is an example of a kitchen planner code. The kitchen has 3 places, and we assign a freezer and a stove. The freezer is not allowed to be near to the stove.

The freezer has code 0,1 and the stove has code 1,0. We make use of the card constraint to place the freezer and the stove.

:- use_module(library(finite/clpb)).

freezer([X,Y|L],[(~X)*Y|R]) :-
   freezer(L, R).
freezer([], []).

stove([X,Y|L],[X*(~Y)|R]) :-
   stove(L, R).
stove([], []).

free([X,Y|L],[(~X)*(~Y)|R]) :-
    free(L, R).
free([], []).

allowed([X,Y,Z,T|L]) :-
   sat(~((~X)*Y*Z*(~T))),
   sat(~(X*(~Y)*(~Z)*T)),
   allowed([Z,T|L]).
allowed([_,_]).
allowed([]).

kitchen(L) :-
   freezer(L, F), card(1, F),
   stove(L, G), card(1, G),
   free(L, H), card(1, H),
   allowed(L).

What I want to demonstrate with the Prolog code is the benefit, that problem encoding towards a SAT formulation can be done via Prolog code itself. When the above code is run I get the following result as expected:

?- L=[_,_,_,_,_,_], kitchen(L), labeling(L).
L = [0,1,0,0,1,0] ;
L = [1,0,0,0,0,1] ;
No