We had two options on how to combine KSP with MiniSat. For the first one, we would have to interact with the public interface of MiniSat as an integrated part of KSP. The second one is to make an external call to MiniSat from KSP, which requires less interference on KSP. The required effort to adapt the source code of MiniSat for both approaches
would be pretty much the same, but we believe that the first approach probably would result in less overall overhead of time, once every external call from KSP to MiniSat requires a translation from the internal representation of clauses of the first to the internal representation of the other, and vice versa. Hence, it would present a better performance. We think, however, that the second approach is more viable, at least at a first moment, as it demands less changes on the source code of KSP, because we are more interested in a proof of concept to verify that our approach does not affect the correctness of the prover. Implementing MiniSat as an integrated part of KSP is left as a possible future work. Thus, our implementation changes KSP to externally invoke a minimally modified version of MiniSat. After a thorough study of MiniSat’s source code, we only found two necessary changes. As we are only interested in the final answer, satisfiable or not, and the clauses learned from the proof search procedure, we modified MiniSat to output even less information than the default triggered by the lowest level of verbosity of the solver. Additionally, we had to force MiniSat to output the learnt clauses as soon as they are produced. Algorithm 6: KSP-Proof-Search-With-SAT-Solver 1 input_processing 2 snf_transformation 3 clause_preprocessing 4 M ODD ← modal_clauses_translation(Λmod) 5 sat_skip ← 0 6 while (Γlit 6= ∅) do 7 if (!sat_skip) then
8 LITD ← propositional_clauses_translation(Γlit∪ Λlit)
9 Γlit ← Γlit∪ minisat_call(LITD, M ODD) 10 sat_skip ← (sat_skip + 1) % sat_cycles 11 for (all modal levels ml) do
12 clause ← given(ml)
13 if (not redundant(clause)) then 14 GEN1(clause, ml, ml − 1) 15 GEN3(clause, ml, ml − 1) 16 LRES(clause, ml, ml)
17 Λlitml ← Λlitml∪ {clause} 18 Γlitml ← Γlitml\ {clause}
19 if (0 : false ∈ Γlit0 ) then return unsatisfiable 20 Γlit←SΓlitml
21 return satisfiable
Algorithm 1 on Section 3.2.3 presented the proof search procedure of KSP. Now, Al- gorithm 6 shows exactly where, Lines 4, 5 and 7 - 10, we had to modify KSP for our pur-
poses of combination. In the Algorithm 6, let Γlit =S
Γlit
ml be the set of support of literal clauses occurring at every modal level. Analogously, let Λlit =S
Λlit
ml and Λmod= S
Λmod ml be the usable sets of literal and modal clauses.
Lines 7 and 10 represent an additional option when running KSP combined with Min- iSat. For experimental purposes, we let the user define the value of sat_cycles, the variable representing the frequency that the SAT solver is called. If the user, for instance, set the sat_cycles to 100, MiniSat will be invoked every 100 cycles of the outer loop of KSP. The default value of sat_cycles is one, i.e., MiniSat called every iteration of the main loop.
The modal_clauses_translation and literal_clauses_translation procedures, Lines 4 and 8, respectively, correspond to the translation of variables from the internal representation of KSP, which is a signed integer, to the internal representation of MiniSat, based on Dimacs [17], which is also a signed integer. The literal_clauses_translation procedure, shown in Algorithm 7, where LITD,ml represents all clauses at modal level ml already in Dimacs format, is quite straightforward. It translates all literal clauses at every modal level to their specific Dimacs representation, without the modal level annotation.
Algorithm 7: propositional_clauses_translation(Γlit∪ Λlit)
1 for all modal levels ml do
2 LITD,ml ← ∅
3 for all clauses C in Γlitml∪ Λlitml do 4 LITD,ml ← LITD,ml ∪ DIMACS(C)
5 end
6 end
7 returnSLITD,ml
We know that the sets of literal clauses are satisfiable, thus, we are interested in the clauses MiniSat might learn if it eventually finds a conflict. Additionally, we also want to see the effect of adding to the set of literal clauses, unit clauses with the literals on the scope of modal operators at the previous modal level. The intuition behind this addition was discussed in Section 5.1. This information might lead to an early application of GEN1 or GEN3. For that purpose, the modal_clauses_translation builds clauses containing literals in the scope of modal operators, accordingly with Algorithm 8, that will be passed along with the literal clauses to the SAT solver. Algorithm 8 builds, for each negative
a-clause, a set of unit clauses with the literal in the scope of the ♦a operator and all unit
clauses formed by the literals in the scope of the a operator. Then, it translates each of these new unit clauses to Dimacs format. We already know that no modal clauses are generated during the main loop of KSP, that is why we can call this translation prior to the main loop.
Algorithm 8: modal_clauses_translation(Λmod)
1 for all modal levels ml do
2 M ODD,ml ← ∅
3 for all agents a do
4 P OSa,ml ← ∅
5 for all positive a-clauses ml : l ⇒ a m in Λmod ml do
6 P OSa,ml ← P OSa,ml ∪ DIMACS({m})
7 end
8 for all negative a-clauses ml : l ⇒ ♦a m in Λmod
ml do 9 M ODD,ml ← M ODD,ml∪ {P OSa,ml∪ DIMACS({m})} 10 end 11 end 12 end 13 returnSM ODD,ml
The call to MiniSat, illustrated by Algorithm 9, occurs every k iterations of KSP main loop, where k is set by the user trough the sat_cycles configuration. The aim is to feed MiniSat with the set of clauses that contains all literal clauses at a specific modal level with each unit clause built from the modal literals at the previous modal level.
Algorithm 9: minisat_call(LITD, M ODD)
1 Cnew ← ∅
2 for all modal levels ml do
3 for all set of unit clauses ∆ = {m1, . . . , mb, m} in M ODD,ml−1 do 4 while MiniSat (LITD,ml∪ ∆) not finished do
5 if MiniSat learns a new clause CL then 6 Cnew ← Cnew∪ {ml : ¬m ∨ CL}
7 end
8 end
9 if MiniSat returns unsatisfiable then
10 Cnew ← Cnew∪ {ml : ¬m1∨ . . . ¬mb∨ ¬m}
11 end
12 end
13 end
14 return Cnew
Each set of unit clauses ∆ = {m1, . . . , mb, m} ∈ M ODD,ml−1, Line 3, represents the clauses built from a literal m that occurs in a negative clause, at modal level ml − 1, and all literals occurring on the positive clauses at the same level. If MiniSat happens to learn a new clause while reasoning over the set of literal clauses with these additional clauses, we add it to the set of literal clauses of KSP, with a binding to the literal in the possibility operator that was passed along. Moreover, if MiniSat decides that the set is unsatisfiable,
we also add a new clause to the literal clauses of KSP. As shown in Section 5.1, the unsatisfiability of the set means that we cannot place all modal literals, from the previous modal level, at the current one, meaning that at least one of them must be false. The derived clause, Line 10, must be a premise for GEN1 and/or GEN3, as the clause only contains literals in the scope of modal operators in modal clauses at the previous level, therefore, we expect that, once learning this clause, one of the two inference rules could be applied right away. At the current state of the implementation, we do not immediately try to apply either rules, as it would have required further changes on KSP main loop. We leave it, though, as a future work. The minisat_call procedure returns the set of all clauses that must be added to the literal clauses at each corresponding modal level, as given in Line 14 of Algorithm 9.
Example 5.2.1 Consider the initial set of clauses in SNFml, Clauses 1-8, from Figure 5.1. The figure shows a refutation of the set using a call to MiniSat. In this example, MiniSat was called with the set of clauses {a, ¬a ∨ ¬b, a ∨ ¬b ∨ c, ¬a, b} as input, where ¬a and
b are the literals of the modal Clauses 4 and 5, respectively. When MiniSat returns
unsatisfiable, we add Clause 9 to the set of literal clauses at modal level one. This clause allows the application of GEN1 instantly, as showed in Clause 10. Without the call to MiniSat, KSP would have to correctly choose Clauses 6 and 8 to apply LRES, generating clause 1 : ¬b, and then apply GEN3, generating the same Clause 10.
1. 0 : t0 8. 1 : ¬a ∨ ¬b 2. 0 : ¬t0∨ t1 9. 1 : ¬b ∨ a [MSAT, 4, 5, 6, 8] 3. 0 : ¬t0∨ t2 10. 0 : ¬t1∨ ¬t2 [GEN1, 4, 5, 9, a, b] 4. 0 : t1 ⇒ ♦¬a 11. 0 : ¬t0∨ ¬t2 [LRES, 2, 10, t1] 5. 0 : t2 ⇒ b 12. 0 : ¬t0 [LRES, 3, 11, t2] 6. 1 : a 13. 0 : false [LRES, 1, 12, t0] 7. 1 : a ∨ ¬b ∨ c
Figure 5.1: Example of refutation using KSP combined with MiniSat