Skip to content

Commit 683070a

Browse files
finish encoding of n'th root
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 8555f25 commit 683070a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/nlsat/nlsat_solver.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -3182,10 +3182,24 @@ namespace nlsat {
31823182
std::string y2 = std::string("y") + std::to_string(j+1);
31833183
out << "(< " << y1 << " " << y2 << ")\n";
31843184
}
3185+
3186+
std::string yn = "y" + std::to_string(a.i() - 1);
3187+
31853188
// TODO we need (forall z : z < yn . p(z) => z = y1 or ... z = y_{n-1})
31863189
// to say y1, .., yn are the first n distinct roots.
31873190
//
3188-
std::string yn = "y" + std::to_string(a.i() - 1);
3191+
out << "(forall ((z Real)) (=> (and (< z " << yn << ") "; display_poly_root(out, "z", a, proc) << ") ";
3192+
if (a.i() == 1) {
3193+
out << "false))\n";
3194+
}
3195+
else {
3196+
out << "(or ";
3197+
for (unsigned j = 0; j + 1 < a.i(); ++j) {
3198+
std::string y1 = std::string("y") + std::to_string(j);
3199+
out << "(= z " << y1 << ") ";
3200+
}
3201+
out << ")))\n";
3202+
}
31893203
switch (a.get_kind()) {
31903204
case atom::ROOT_LT: out << "(< "; proc(out, a.x()); out << " " << yn << ")"; break;
31913205
case atom::ROOT_GT: out << "(> "; proc(out, a.x()); out << " " << yn << ")"; break;

0 commit comments

Comments
 (0)