Debian Codegraph @

src/prop/minisat/CVC4-README

raw
1 ================ CHANGES TO THE ORIGINAL CODE ==================================
2
3 The only cvc5 connections passed to minisat are the proxy (defined in sat.h) and
4 the context. The context is obtained from the SolverEngine, and the proxy is an
5 intermediary class that has all-access to the SatSolver so as to simplify the
6 interface to (possible) other sat solvers. These two are passed to minisat at
7 construction time and some additional flags are set. We use the SimpSolver
8 solver with simplifications.
9
10 To compare with original minisat code in SVN you can compare to revision 6 on
11 the trunk.
12
13 The PropEngine then uses the following
14
15 // Create the sat solver (this is the proxy, which will create minisat)
16 d_satSolver = new SatSolver(this, d_theoryEngine, d_context);
17 // Add some clauses
18 d_cnfStream->convertAndAssert(node);
19 // Check for satisfiabilty
20 bool result = d_satSolver->solve();
21
22 * Adding theory literals:
23
24 The newVar method has been changed from
25 Var Solver::newVar(bool sign, bool dvar)
26 to
27 Var Solver::newVar(bool sign, bool dvar, bool theoryAtom)
28 in order to mark the variables as theory literals. For that purpose there is a
29 new boolean array called "theory" that is true or false if the variables is for
30 a theory literal.
31
32 * Backtracking/Pushing
33
34 Backtracking in minisat is performed through the cancelUntil() method, which is
35 now modified to pop the context the appropriate number of times.
36
37 Minisat pushes the scope in the newDecisionLevel() method where we appropriately
38 also push the cvc5 context.
39
40 * Phase caching
41
42 In order to implement phase-caching (RSAT paper) we
43 (1) flag minisat to use the user-provided polarities first by setting the
44 minisat::SimpSolver::polarity_user flag when initializing the solver (in sat.h)
45 (2) when a variable is set (in uncheckedEnqueue()) we remember the value in the
46 "polarity" table.
47
48 * Asserting the theory literals
49
50 In the uncheckedEnqueue() method, if the literal is a theory literal (looking
51 in the "theory" table), it is passed to the prop engine thorough the proxy.
52
53 * Theory propagation (checking)
54
55 The BCP propagation method was changed from propagate to propagateBool and
56 another method propagateTheory is defined to do the theory propagation. The
57 propagate method now looks like
58
59 Clause* Solver::propagate()
60 {
61 Clause* confl = NULL;
62
63 while(qhead < trail.size()) {
64 confl = propagateBool();
65 if (confl != NULL) break;
66 confl = propagateTheory();
67 if (confl != NULL) break;
68 }
69
70 return confl;
71 }
72
73 The propagateBool method will perform the BCP on the newly assigned variables
74 in the trail, and if a conflict is found it will break. Otherwise, the theory
75 propagation is given a chance to check for satisfiability and maybe enqueue some
76 additional propagated literals.
77
78 * Conflict resolution
79
80 If a conflict is detected during theory propagation we can rely on the minisat
81 conflict resolution with a twist. Since a theory can return a conflict where
82 all literals are assigned at a level lower than the current level, we must
83 backtrack to the highest level of any literal in the conflict. This is done
84 already in the propagateTheory().
85
86 * Clause simplification
87
88 Minisat performs some simplifications on the clause database:
89 (1) variable elimination
90 (2) subsumtion
91
92 Subsumtion is complete even with theory reasoning, but eliminating theory
93 literals by resolution might be incomplete:
94
95 (x = 0 \vee x = 1) \wedge (x != 1 \vee y = 1) \wedge x = y
96 ^^^^^ ^^^^^^
97 v ~v
98
99 would, after eliminating v, simplify to
100 (x = 0) wedge (y = 1) wedge (x = y) which is unsatisfiable
101
102 while x = 1, y = 1 is a satisfying assignment for the above.
103
104 Minisat does not perform variable elimination on the variables that are marked
105 as frozen (in the "frozen", SimSolver.h) table. We put all the theory literals
106 in the frozen table, which solves the incompleteness problem.
107
108 ================ NOTES =========================================================
109
110 * Accessing the internals of the SAT solver
111
112 The non-public parts of the SAT solver are accessed via the static methods in
113 the SatSolver class. SatSolverProxy is declared as a friend of the
114 SatSolver and has all-privileges access to the internals -- use with care!!!
115
116 * Clause Database and CNF
117
118 The clause database consists of two parts:
119
120 vec<Clause*> clauses; // List of problem clauses.
121 vec<Clause*> learnts; // List of learnt clauses.
122
123 Clauses is the original problem clauses, and learnts are the clauses learned
124 during the search. I have disabled removal of satisfied problem clauses by
125 setting the remove_satisfied flag to false.
126
127 The learnt clauses get removed every once in a while by removing the half of
128 clauses with the low activity (reduceDB())
129
130 Since the clause database backtracks with the SMT solver, the CNF cache should
131 be context dependent and everything will be in sync.
132
133 * Adding a Clause
134
135 The only method in the interface that allows addition of clauses in MiniSAT is
136
137 bool Solver::addClause(vec<Lit>& ps),
138
139 but it only adds the problem clauses.
140
141 In order to add the clauses to the removable database the interface is now
142
143 bool Solver::addClause(vec<Lit>& ps, bool removable).
144
145 Clauses added with removable=true might get removed by the SAT solver when
146 compacting the database.
147
148 The question is whether to add the propagation/conflict lemmas as removable or
149 not?
150
151 * Literal Activities
152
153 We do not backtrack literal activities. This does not semantically change the
154 equivalence of the context, but does change solve times if the same problem is
155 run several times.
156
157 * Do we need to assign literals that only appear in satisfied clauses?