@@ -122,6 +122,33 @@ namespace nlsat {
122
122
};
123
123
perm_display_var_proc m_display_var;
124
124
125
+ display_assumption_proc const * m_display_assumption;
126
+ struct display_literal_assumption : public display_assumption_proc {
127
+ imp& i;
128
+ literal_vector const & lits;
129
+ display_literal_assumption (imp& i, literal_vector const & lits): i(i), lits(lits) {}
130
+ std::ostream& operator ()(std::ostream& out, assumption a) const override {
131
+ if (lits.begin () <= a && a < lits.end ()) {
132
+ out << *((literal const *)a);
133
+ }
134
+ else if (i.m_display_assumption ) {
135
+ (*i.m_display_assumption )(out, a);
136
+ }
137
+ return out;
138
+ }
139
+
140
+ };
141
+ struct scoped_display_assumptions {
142
+ imp& i;
143
+ display_assumption_proc const * m_save;
144
+ scoped_display_assumptions (imp& i, display_assumption_proc const & p): i(i), m_save(i.m_display_assumption) {
145
+ i.m_display_assumption = &p;
146
+ }
147
+ ~scoped_display_assumptions () {
148
+ i.m_display_assumption = m_save;
149
+ }
150
+ };
151
+
125
152
explain m_explain;
126
153
127
154
bool_var m_bk; // current Boolean variable we are processing
@@ -179,6 +206,7 @@ namespace nlsat {
179
206
m_patch_denom (m_pm),
180
207
m_num_bool_vars (0 ),
181
208
m_display_var (m_perm),
209
+ m_display_assumption (nullptr ),
182
210
m_explain (s, m_assignment, m_cache, m_atoms, m_var2eq, m_evaluator),
183
211
m_scope_lvl (0 ),
184
212
m_lemma (s),
@@ -1035,9 +1063,9 @@ namespace nlsat {
1035
1063
interval_set * xk_set = m_infeasible[m_xk];
1036
1064
save_set_updt_trail (xk_set);
1037
1065
interval_set_ref new_set (m_ism);
1038
- TRACE (" nlsat_inf_set" , tout << " updating infeasible set\n " ; m_ism.display (tout, xk_set); tout << " \n " ; m_ism.display (tout, s); tout << " \n " ;);
1066
+ TRACE (" nlsat_inf_set" , tout << " updating infeasible set\n " ; m_ism.display (tout, xk_set) << " \n " ; m_ism.display (tout, s) << " \n " ;);
1039
1067
new_set = m_ism.mk_union (s, xk_set);
1040
- TRACE (" nlsat_inf_set" , tout << " new infeasible set:\n " ; m_ism.display (tout, new_set); tout << " \n " ;);
1068
+ TRACE (" nlsat_inf_set" , tout << " new infeasible set:\n " ; m_ism.display (tout, new_set) << " \n " ;);
1041
1069
SASSERT (!m_ism.is_full (new_set));
1042
1070
m_ism.inc_ref (new_set);
1043
1071
m_infeasible[m_xk] = new_set;
@@ -1060,7 +1088,7 @@ namespace nlsat {
1060
1088
if (m_var2eq[x] != 0 && degree (m_var2eq[x]) <= degree (a))
1061
1089
return ; // we only update m_var2eq if the new equality has smaller degree
1062
1090
TRACE (" simplify_core" , tout << " Saving equality for " ; m_display_var (tout, x) << " (x" << x << " ) " ;
1063
- tout << " scope-lvl: " << scope_lvl () << " \n " ; display (tout, literal (b, false )); tout << " \n " ;);
1091
+ tout << " scope-lvl: " << scope_lvl () << " \n " ; display (tout, literal (b, false )) << " \n " ;);
1064
1092
save_updt_eq_trail (m_var2eq[x]);
1065
1093
m_var2eq[x] = a;
1066
1094
}
@@ -1094,7 +1122,8 @@ namespace nlsat {
1094
1122
SASSERT (a != nullptr );
1095
1123
interval_set_ref curr_set (m_ism);
1096
1124
curr_set = m_evaluator.infeasible_intervals (a, l.sign ());
1097
- TRACE (" nlsat_inf_set" , tout << " infeasible set for literal: " ; display (tout, l); tout << " \n " ; m_ism.display (tout, curr_set); tout << " \n " ;);
1125
+ TRACE (" nlsat_inf_set" , tout << " infeasible set for literal: " ; display (tout, l); tout << " \n " ; m_ism.display (tout, curr_set); tout << " \n " ;
1126
+ display (tout, cls) << " \n " ;);
1098
1127
if (m_ism.is_empty (curr_set)) {
1099
1128
TRACE (" nlsat_inf_set" , tout << " infeasible set is empty, found literal\n " ;);
1100
1129
R_propagate (l, nullptr );
@@ -1114,7 +1143,8 @@ namespace nlsat {
1114
1143
interval_set_ref tmp (m_ism);
1115
1144
tmp = m_ism.mk_union (curr_set, xk_set);
1116
1145
if (m_ism.is_full (tmp)) {
1117
- TRACE (" nlsat_inf_set" , tout << " infeasible set + current set = R, skip literal\n " ;);
1146
+ TRACE (" nlsat_inf_set" , tout << " infeasible set + current set = R, skip literal\n " ;
1147
+ display (tout, cls) << " \n " ;);
1118
1148
R_propagate (~l, tmp, false );
1119
1149
continue ;
1120
1150
}
@@ -1382,6 +1412,8 @@ namespace nlsat {
1382
1412
for (unsigned i = 0 ; i < sz; ++i) {
1383
1413
mk_clause (1 , ptr+i, (assumption)(ptr+i));
1384
1414
}
1415
+ display_literal_assumption dla (*this , assumptions);
1416
+ scoped_display_assumptions _scoped_display (*this , dla);
1385
1417
lbool r = check ();
1386
1418
1387
1419
if (r == l_false) {
@@ -1393,9 +1425,6 @@ namespace nlsat {
1393
1425
if (ptr <= lp && lp < ptr + sz) {
1394
1426
result.push_back (*lp);
1395
1427
}
1396
- else {
1397
- std::cout << " pointer out of bounds\n " ;
1398
- }
1399
1428
}
1400
1429
}
1401
1430
collect (assumptions, m_clauses);
@@ -1506,7 +1535,7 @@ namespace nlsat {
1506
1535
}
1507
1536
1508
1537
void resolve_clause (bool_var b, unsigned sz, literal const * c) {
1509
- TRACE (" nlsat_proof" , tout << " resolving " ; if (b != null_bool_var) display_atom (tout, b); tout << " \n " ; display (tout, sz, c); tout << " \n " ;);
1538
+ TRACE (" nlsat_proof" , tout << " resolving " ; if (b != null_bool_var) display_atom (tout, b) << " \n " ; display (tout, sz, c); tout << " \n " ;);
1510
1539
TRACE (" nlsat_proof_sk" , tout << " resolving " ; if (b != null_bool_var) tout << " b" << b; tout << " \n " ; display_abst (tout, sz, c); tout << " \n " ;);
1511
1540
1512
1541
bool found_decision = false ;
@@ -1703,7 +1732,7 @@ namespace nlsat {
1703
1732
if (t.m_kind == trail::BVAR_ASSIGNMENT) {
1704
1733
bool_var b = t.m_b ;
1705
1734
if (is_marked (b)) {
1706
- TRACE (" nlsat_resolve" , tout << " found marked bool_var: " << b << " \n " ; display_atom (tout, b); tout << " \n " ;);
1735
+ TRACE (" nlsat_resolve" , tout << " found marked bool_var: " << b << " \n " ; display_atom (tout, b) << " \n " ;);
1707
1736
m_num_marks--;
1708
1737
reset_mark (b);
1709
1738
justification jst = m_justifications[b];
@@ -1812,13 +1841,7 @@ namespace nlsat {
1812
1841
undo_until_level (new_lvl);
1813
1842
}
1814
1843
1815
- bool same = (sz == conflict_clause->size ());
1816
- if (same) {
1817
- for (unsigned i = 0 ; same && i < sz; ++i) {
1818
- same = m_lemma[i] == (*conflict_clause)[i];
1819
- }
1820
- }
1821
- if (same) {
1844
+ if (lemma_is_clause (*conflict_clause)) {
1822
1845
TRACE (" nlsat" , tout << " found decision literal in conflict clause\n " ;);
1823
1846
VERIFY (process_clause (*conflict_clause, true ));
1824
1847
return true ;
@@ -1839,6 +1862,14 @@ namespace nlsat {
1839
1862
return true ;
1840
1863
}
1841
1864
1865
+ bool lemma_is_clause (clause const & cls) const {
1866
+ bool same = (m_lemma.size () == cls.size ());
1867
+ for (unsigned i = 0 ; same && i < m_lemma.size (); ++i) {
1868
+ same = m_lemma[i] == cls[i];
1869
+ }
1870
+ return same;
1871
+ }
1872
+
1842
1873
1843
1874
// -----------------------
1844
1875
//
@@ -2883,10 +2914,11 @@ namespace nlsat {
2883
2914
std::ostream& display_assumptions (std::ostream & out, _assumption_set s) const {
2884
2915
vector<assumption, false > deps;
2885
2916
m_asm.linearize (s, deps);
2917
+ bool first = true ;
2886
2918
for (auto dep : deps) {
2887
- out << *((literal const *)(dep)) << " " ;
2919
+ if (first) first = false ; else out << " " ;
2920
+ if (m_display_assumption) (*m_display_assumption)(out, dep);
2888
2921
}
2889
-
2890
2922
return out;
2891
2923
}
2892
2924
@@ -3154,6 +3186,11 @@ namespace nlsat {
3154
3186
m_imp->m_display_var .m_proc = &proc;
3155
3187
}
3156
3188
3189
+ void solver::set_display_assumption (display_assumption_proc const & proc) {
3190
+ m_imp->m_display_assumption = &proc;
3191
+ }
3192
+
3193
+
3157
3194
unsigned solver::num_vars () const {
3158
3195
return m_imp->num_vars ();
3159
3196
}
0 commit comments