mirror of
https://github.com/Z3Prover/z3
synced 2025-08-11 21:50:52 +00:00
Merge branch 'master' of https://github.com/z3prover/z3 into polysat
This commit is contained in:
commit
57df45dc16
162 changed files with 2885 additions and 1941 deletions
|
@ -92,8 +92,6 @@ public:
|
|||
bool operator!=(row_iterator const& other) const { return m_index != other.m_index; }
|
||||
};
|
||||
|
||||
bit_matrix() {}
|
||||
~bit_matrix() {}
|
||||
void reset(unsigned num_columns);
|
||||
|
||||
row_iterator begin() { return row_iterator(*this, true); }
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace opt {
|
|||
return true;
|
||||
}
|
||||
|
||||
#define PASSERT(_e_) if (!(_e_)) { TRACE("opt1", display(tout, r); display(tout);); SASSERT(_e_); }
|
||||
#define PASSERT(_e_) { CTRACE("qe", !(_e_), display(tout, r); display(tout);); SASSERT(_e_); }
|
||||
|
||||
bool model_based_opt::invariant(unsigned index, row const& r) {
|
||||
vector<var> const& vars = r.m_vars;
|
||||
|
@ -378,7 +378,8 @@ namespace opt {
|
|||
}
|
||||
else if ((value == lub_val && r.m_type == opt::t_lt) ||
|
||||
(is_pos && value < lub_val) ||
|
||||
(!is_pos && value > lub_val)) {
|
||||
|
||||
(!is_pos && value > lub_val)) {
|
||||
m_above.push_back(bound_row_index);
|
||||
lub_val = value;
|
||||
bound_row_index = row_id;
|
||||
|
@ -423,6 +424,13 @@ namespace opt {
|
|||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
rational model_based_opt::eval(vector<var> const& coeffs) const {
|
||||
rational val(0);
|
||||
for (var const& v : coeffs)
|
||||
val += v.m_coeff * eval(v.m_id);
|
||||
return val;
|
||||
}
|
||||
|
||||
rational model_based_opt::get_coefficient(unsigned row_id, unsigned var_id) const {
|
||||
return m_rows[row_id].get_coefficient(var_id);
|
||||
|
@ -787,7 +795,7 @@ namespace opt {
|
|||
}
|
||||
|
||||
std::ostream& model_based_opt::display(std::ostream& out, row const& r) {
|
||||
out << (r.m_alive?"+":"-") << " ";
|
||||
out << (r.m_alive?"a":"d") << " ";
|
||||
display(out, r.m_vars, r.m_coeff);
|
||||
if (r.m_type == opt::t_mod) {
|
||||
out << r.m_type << " " << r.m_mod << " = 0; value: " << r.m_value << "\n";
|
||||
|
@ -1002,8 +1010,7 @@ namespace opt {
|
|||
result = solve_for(glb_index, x, true);
|
||||
}
|
||||
else {
|
||||
result = def();
|
||||
m_var2value[x] = rational::zero();
|
||||
result = def() + m_var2value[x];
|
||||
}
|
||||
SASSERT(eval(result) == eval(x));
|
||||
}
|
||||
|
@ -1123,9 +1130,8 @@ namespace opt {
|
|||
}
|
||||
TRACE("opt1", display(tout << "tableau after replace x by y := v" << y << "\n"););
|
||||
def result = project(y, compute_def);
|
||||
if (compute_def) {
|
||||
if (compute_def)
|
||||
result = (result * D) + u;
|
||||
}
|
||||
SASSERT(!compute_def || eval(result) == eval(x));
|
||||
return result;
|
||||
}
|
||||
|
@ -1187,13 +1193,15 @@ namespace opt {
|
|||
SASSERT(a.is_pos());
|
||||
if (ty == t_lt) {
|
||||
SASSERT(compute_def);
|
||||
m_rows[row_id1].m_coeff += a;
|
||||
m_rows[row_id1].m_coeff += a;
|
||||
m_rows[row_id1].m_type = t_le;
|
||||
m_rows[row_id1].m_value += a;
|
||||
}
|
||||
if (m_var2is_int[x] && !a.is_one()) {
|
||||
row& r1 = m_rows[row_id1];
|
||||
vector<var> coeffs;
|
||||
mk_coeffs_without(coeffs, r1.m_vars, x);
|
||||
rational c = r1.m_coeff;
|
||||
rational c = mod(-eval(coeffs), a);
|
||||
add_divides(coeffs, c, a);
|
||||
}
|
||||
unsigned_vector const& row_ids = m_var2row_ids[x];
|
||||
|
@ -1203,19 +1211,19 @@ namespace opt {
|
|||
if (!visited.contains(row_id2)) {
|
||||
visited.insert(row_id2);
|
||||
b = get_coefficient(row_id2, x);
|
||||
if (!b.is_zero()) {
|
||||
row& dst = m_rows[row_id2];
|
||||
switch (dst.m_type) {
|
||||
case t_eq:
|
||||
case t_lt:
|
||||
case t_le:
|
||||
solve(row_id1, a, row_id2, x);
|
||||
break;
|
||||
case t_mod:
|
||||
// mod reduction already done.
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
if (b.is_zero())
|
||||
continue;
|
||||
row& dst = m_rows[row_id2];
|
||||
switch (dst.m_type) {
|
||||
case t_eq:
|
||||
case t_lt:
|
||||
case t_le:
|
||||
solve(row_id1, a, row_id2, x);
|
||||
break;
|
||||
case t_mod:
|
||||
// mod reduction already done.
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,8 @@ namespace opt {
|
|||
rational eval(unsigned x) const;
|
||||
|
||||
rational eval(def const& d) const;
|
||||
|
||||
rational eval(vector<var> const& coeffs) const;
|
||||
|
||||
void resolve(unsigned row_src, rational const& a1, unsigned row_dst, unsigned x);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue