mirror of
https://github.com/Z3Prover/z3
synced 2025-08-26 13:06:05 +00:00
fix write_bound_lemma to include term definitions
This commit is contained in:
parent
76b82318b8
commit
939091e2b5
2 changed files with 63 additions and 21 deletions
|
@ -1848,10 +1848,8 @@ namespace lp {
|
|||
SASSERT((upper && bound < lra.get_upper_bound(j).x) ||
|
||||
(!upper && bound > lra.get_lower_bound(j).x));
|
||||
lconstraint_kind kind = upper ? lconstraint_kind::LE : lconstraint_kind::GE;
|
||||
u_dependency* dep = lra.get_bound_constraint_witnesses_for_column(j);
|
||||
u_dependency* dep = upper ? lra.get_column_upper_bound_witness(j) : lra.get_column_lower_bound_witness(j);
|
||||
dep = lra.join_deps(dep, explain_fixed_in_meta_term(m_lspace.m_data));
|
||||
u_dependency* j_bound_dep = upper ? lra.get_column_upper_bound_witness(j) : lra.get_column_lower_bound_witness(j);
|
||||
dep = lra.join_deps(dep, j_bound_dep);
|
||||
dep = lra.join_deps(dep, explain_fixed(lra.get_term(j)));
|
||||
TRACE("dio", tout << "jterm:";
|
||||
print_lar_term_L(lra.get_term(j), tout) << "\ndep:";
|
||||
|
|
|
@ -2584,7 +2584,6 @@ namespace lp {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Start SMT2 file
|
||||
out << "(set-info : \"generated at " << location;
|
||||
out << " for " << (is_low ? "lower" : "upper") << " bound of variable " << j << ",";
|
||||
|
@ -2594,6 +2593,7 @@ namespace lp {
|
|||
std::unordered_set<unsigned> vars_used;
|
||||
vars_used.insert(j);
|
||||
bool is_int = column_is_int(j);
|
||||
|
||||
// Linearize the dependencies
|
||||
svector<constraint_index> deps;
|
||||
m_dependencies.linearize(bound_dep, deps);
|
||||
|
@ -2608,6 +2608,21 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
|
||||
// Collect variables from terms
|
||||
std::unordered_set<unsigned> term_variables;
|
||||
for (unsigned var : vars_used) {
|
||||
if (column_has_term(var)) {
|
||||
const lar_term& term = get_term(var);
|
||||
for (const auto& p : term) {
|
||||
term_variables.insert(p.j());
|
||||
if (!column_is_int(p.j()))
|
||||
is_int = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add term variables to vars_used
|
||||
vars_used.insert(term_variables.begin(), term_variables.end());
|
||||
|
||||
if (is_int) {
|
||||
out << "(set-logic QF_LIA)\n\n";
|
||||
}
|
||||
|
@ -2619,6 +2634,38 @@ namespace lp {
|
|||
}
|
||||
out << "\n";
|
||||
|
||||
// Define term relationships
|
||||
out << "; Term definitions\n";
|
||||
for (unsigned var : vars_used) {
|
||||
if (column_has_term(var)) {
|
||||
const lar_term& term = get_term(var);
|
||||
out << "(assert (= x" << var << " ";
|
||||
|
||||
if (term.size() == 0) {
|
||||
out << "0";
|
||||
} else {
|
||||
if (term.size() > 1) out << "(+ ";
|
||||
|
||||
bool first = true;
|
||||
for (const auto& p : term) {
|
||||
if (first) first = false;
|
||||
else out << " ";
|
||||
|
||||
if (p.coeff().is_one()) {
|
||||
out << "x" << p.j();
|
||||
} else {
|
||||
out << "(* " << format_smt2_constant(p.coeff()) << " x" << p.j() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
if (term.size() > 1) out << ")";
|
||||
}
|
||||
|
||||
out << "))\n";
|
||||
}
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
// Add assertions for the dependencies
|
||||
out << "; Bound dependencies\n";
|
||||
|
||||
|
@ -2629,9 +2676,6 @@ namespace lp {
|
|||
// Handle the constraint type and expression
|
||||
auto k = c.kind();
|
||||
|
||||
// Handle empty constraint (just constant)
|
||||
SASSERT(c.coeffs().size());
|
||||
|
||||
// Normal constraint with variables
|
||||
switch (k) {
|
||||
case LE: out << "(<= "; break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue