Skip to content

Commit 3fcd9e6

Browse files
logging
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent f4fd947 commit 3fcd9e6

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

src/nlsat/nlsat_explain.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ namespace nlsat {
188188
unsigned lidx = l.index();
189189
if (m_already_added_literal.get(lidx, false))
190190
return;
191-
TRACE("nlsat_explain", tout << "adding literal: " << lidx << "\n"; m_solver.display(tout, l); tout << "\n";);
191+
TRACE("nlsat_explain", tout << "adding literal: " << lidx << "\n"; m_solver.display(tout, l) << "\n";);
192192
m_already_added_literal.setx(lidx, true, false);
193193
m_result->push_back(l);
194194
}
@@ -619,10 +619,15 @@ namespace nlsat {
619619
void psc(polynomial_ref & p, polynomial_ref & q, var x) {
620620
polynomial_ref_vector & S = m_psc_tmp;
621621
polynomial_ref s(m_pm);
622-
TRACE("nlsat_explain", tout << "computing psc of\n"; display(tout, p); tout << "\n"; display(tout, q); tout << "\n";);
623622

624623
psc_chain(p, q, x, S);
625624
unsigned sz = S.size();
625+
TRACE("nlsat_explain", tout << "computing psc of\n"; display(tout, p); tout << "\n"; display(tout, q); tout << "\n";
626+
for (unsigned i = 0; i < sz; ++i) {
627+
s = S.get(i);
628+
tout << "psc: " << s << "\n";
629+
});
630+
626631
for (unsigned i = 0; i < sz; i++) {
627632
s = S.get(i);
628633
TRACE("nlsat_explain", tout << "processing psc(" << i << ")\n"; display(tout, s); tout << "\n";);
@@ -634,7 +639,7 @@ namespace nlsat {
634639
TRACE("nlsat_explain", tout << "done, psc is a constant\n";);
635640
return;
636641
}
637-
if (sign(s) == 0) {
642+
if (sign(s) == polynomial::sign_zero) {
638643
TRACE("nlsat_explain", tout << "psc vanished, adding zero assumption\n";);
639644
add_zero_assumption(s);
640645
continue;
@@ -825,6 +830,7 @@ namespace nlsat {
825830
#else
826831
int s = sign(p);
827832
if (!is_const(p)) {
833+
TRACE("nlsat_explain", tout << p << "\n";);
828834
add_simple_assumption(s == 0 ? atom::EQ : (s < 0 ? atom::LT : atom::GT), p);
829835
}
830836
return s;
@@ -833,6 +839,11 @@ namespace nlsat {
833839

834840
/**
835841
Auxiliary function to linear roots.
842+
y > root[1](-2*y - z)
843+
y > -z/2
844+
y + z/2 > 0
845+
2y + z > 0
846+
836847
*/
837848
void mk_linear_root(atom::kind k, var y, unsigned i, poly * p, bool mk_neg) {
838849
polynomial_ref p_prime(m_pm);
@@ -898,8 +909,13 @@ namespace nlsat {
898909
m_am.isolate_roots(p, undef_var_assignment(m_assignment, y), roots);
899910
unsigned num_roots = roots.size();
900911
for (unsigned i = 0; i < num_roots; i++) {
901-
TRACE("nlsat_explain", tout << "comparing root: "; m_am.display_decimal(tout, roots[i]); tout << "\n";);
902912
int s = m_am.compare(y_val, roots[i]);
913+
TRACE("nlsat_explain",
914+
m_am.display_decimal(tout << "comparing root: ", roots[i]); tout << "\n";
915+
m_am.display_decimal(tout << "with y_val:", y_val);
916+
tout << "\nsign " << s << "\n";
917+
tout << "poly: " << p << "\n";
918+
);
903919
if (s == 0) {
904920
// y_val == roots[i]
905921
// add literal
@@ -931,11 +947,15 @@ namespace nlsat {
931947
}
932948
}
933949
}
934-
935-
if (!lower_inf)
950+
951+
if (!lower_inf) {
952+
TRACE("nlsat_explain", tout << "lower_inf: " << lower_inf << " upper_inf: " << upper_inf << " " << p_lower << "\n";);
936953
add_root_literal(m_full_dimensional ? atom::ROOT_GE : atom::ROOT_GT, y, i_lower, p_lower);
937-
if (!upper_inf)
954+
}
955+
if (!upper_inf) {
956+
TRACE("nlsat_explain", tout << "lower_inf: " << lower_inf << " upper_inf: " << upper_inf << " " << p_upper << "\n";);
938957
add_root_literal(m_full_dimensional ? atom::ROOT_LE : atom::ROOT_LT, y, i_upper, p_upper);
958+
}
939959
}
940960

941961
/**
@@ -1076,7 +1096,7 @@ namespace nlsat {
10761096
new_lit = l;
10771097
return;
10781098
}
1079-
TRACE("nlsat_simplify_core", tout << "trying to simplify literal\n"; display(tout, l); tout << "\nusing equation\n";
1099+
TRACE("nlsat_simplify_core", display(tout << "trying to simplify literal\n", l) << "\nusing equation\n";
10801100
m_pm.display(tout, info.m_eq, m_solver.display_proc()); tout << "\n";);
10811101
int atom_sign = 1;
10821102
bool modified_lit = false;
@@ -1348,7 +1368,9 @@ namespace nlsat {
13481368
var max_x = max_var(m_ps);
13491369
TRACE("nlsat_explain", tout << "polynomials in the conflict:\n"; display(tout, m_ps); tout << "\n";);
13501370
elim_vanishing(m_ps);
1371+
TRACE("nlsat_explain", tout << "elim vanishing\n"; display(tout, m_ps); tout << "\n";);
13511372
project(m_ps, max_x);
1373+
TRACE("nlsat_explain", tout << "after projection\n"; display(tout, m_ps); tout << "\n";);
13521374
}
13531375

13541376
void process2(unsigned num, literal const * ls) {

src/nlsat/nlsat_solver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,11 @@ namespace nlsat {
652652
SASSERT(i > 0);
653653
SASSERT(x >= max_var(p));
654654
SASSERT(k == atom::ROOT_LT || k == atom::ROOT_GT || k == atom::ROOT_EQ || k == atom::ROOT_LE || k == atom::ROOT_GE);
655-
polynomial_ref p1(m_pm);
655+
polynomial_ref p1(m_pm), uniq_p(m_pm);
656656
p1 = m_pm.flip_sign_if_lm_neg(p); // flipping the sign of the polynomial will not change its roots.
657-
poly * uniq_p = m_cache.mk_unique(p1);
657+
uniq_p = m_cache.mk_unique(p1);
658+
TRACE("nlsat_solver", tout << p1 << " " << uniq_p << "\n";);
659+
658660
void * mem = m_allocator.allocate(sizeof(root_atom));
659661
root_atom * new_atom = new (mem) root_atom(k, x, i, uniq_p);
660662
root_atom * old_atom = m_root_atoms.insert_if_not_there(new_atom);

0 commit comments

Comments
 (0)