mirror of
https://github.com/Z3Prover/z3
synced 2025-08-28 14:08:55 +00:00
Merge branch 'master' of https://github.com/z3prover/z3 into polysat
This commit is contained in:
commit
26893005c7
70 changed files with 843 additions and 1197 deletions
|
@ -1218,15 +1218,11 @@ namespace {
|
|||
linearise_multi_pattern(first_idx);
|
||||
}
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
for (unsigned i = 0; i < m_qa->get_num_decls(); i++) {
|
||||
CTRACE("mam_new_bug", m_vars[i] < 0, tout << mk_ismt2_pp(m_qa, m) << "\ni: " << i << " m_vars[i]: " << m_vars[i] << "\n";
|
||||
tout << "m_mp:\n" << mk_ismt2_pp(m_mp, m) << "\n";
|
||||
tout << "tree:\n" << *m_tree << "\n";
|
||||
);
|
||||
SASSERT(m_vars[i] >= 0);
|
||||
}
|
||||
#endif
|
||||
// check that all variables are captured by pattern.
|
||||
for (unsigned i = 0; i < m_qa->get_num_decls(); i++)
|
||||
if (m_vars[i] == -1)
|
||||
return;
|
||||
|
||||
SASSERT(head->m_next == 0);
|
||||
m_seq.push_back(m_ct_manager.mk_yield(m_qa, m_mp, m_qa->get_num_decls(), reinterpret_cast<unsigned*>(m_vars.begin())));
|
||||
|
||||
|
@ -1843,7 +1839,7 @@ namespace {
|
|||
enode_vector m_bindings;
|
||||
enode_vector m_args;
|
||||
backtrack_stack m_backtrack_stack;
|
||||
unsigned m_top;
|
||||
unsigned m_top { 0 };
|
||||
const instruction * m_pc;
|
||||
|
||||
// auxiliary temporary variables
|
||||
|
@ -2210,8 +2206,13 @@ namespace {
|
|||
if (curr->get_num_args() == expected_num_args && m_context.is_relevant(curr))
|
||||
break;
|
||||
}
|
||||
if (bp.m_it == bp.m_end)
|
||||
if (bp.m_it == bp.m_end) {
|
||||
if (best_v) {
|
||||
bp.m_to_recycle = nullptr;
|
||||
recycle_enode_vector(best_v);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
m_top++;
|
||||
update_max_generation(*(bp.m_it), nullptr);
|
||||
return *(bp.m_it);
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace smt {
|
|||
out << "(clause";
|
||||
for (unsigned i = 0; i < m_num_literals; i++) {
|
||||
out << " ";
|
||||
m_lits[i].display(out, m, bool_var2expr_map);
|
||||
smt::display(out, m_lits[i], m, bool_var2expr_map);
|
||||
}
|
||||
return out << ")";
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ namespace smt {
|
|||
out << "(clause";
|
||||
for (unsigned i = 0; i < m_num_literals; i++) {
|
||||
out << " ";
|
||||
m_lits[i].display_compact(out, bool_var2expr_map);
|
||||
smt::display_compact(out, m_lits[i], bool_var2expr_map);
|
||||
}
|
||||
return out << ")";
|
||||
}
|
||||
|
|
|
@ -385,10 +385,10 @@ namespace smt {
|
|||
expr* e = kv.m_key;
|
||||
expr* val = kv.m_value;
|
||||
literal lit = mk_diseq(e, val);
|
||||
mark_as_relevant(lit);
|
||||
if (get_assignment(lit) != l_undef) {
|
||||
continue;
|
||||
}
|
||||
mark_as_relevant(lit);
|
||||
++num_vars;
|
||||
push_scope();
|
||||
assign(lit, b_justification::mk_axiom(), true);
|
||||
|
|
|
@ -3081,7 +3081,7 @@ namespace smt {
|
|||
literal l2 = *set_it;
|
||||
if (l2 != l) {
|
||||
b_justification js(l);
|
||||
TRACE("theory_case_split", tout << "case split literal "; l2.display(tout, m, m_bool_var2expr.data()); tout << std::endl;);
|
||||
TRACE("theory_case_split", tout << "case split literal "; smt::display(tout, l2, m, m_bool_var2expr.data()); tout << std::endl;);
|
||||
if (l2 == true_literal || l2 == false_literal || l2 == null_literal) continue;
|
||||
assign(~l2, js);
|
||||
if (inconsistent()) {
|
||||
|
@ -4188,7 +4188,7 @@ namespace smt {
|
|||
for (unsigned i = 0; i < num_lits; i++) {
|
||||
display_literal(tout, v[i]);
|
||||
tout << "\n";
|
||||
v[i].display(tout, m, m_bool_var2expr.data());
|
||||
smt::display(tout, v[i], m, m_bool_var2expr.data());
|
||||
tout << "\n\n";
|
||||
}
|
||||
tout << "\n";);
|
||||
|
|
|
@ -1357,7 +1357,7 @@ namespace smt {
|
|||
|
||||
std::ostream& display_literal(std::ostream & out, literal l) const;
|
||||
|
||||
std::ostream& display_detailed_literal(std::ostream & out, literal l) const { l.display(out, m, m_bool_var2expr.data()); return out; }
|
||||
std::ostream& display_detailed_literal(std::ostream & out, literal l) const { return smt::display(out, l, m, m_bool_var2expr.data()); }
|
||||
|
||||
void display_literal_info(std::ostream & out, literal l) const;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
std::ostream& context::display_literal(std::ostream & out, literal l) const {
|
||||
l.display_compact(out, m_bool_var2expr.data()); return out;
|
||||
smt::display_compact(out, l, m_bool_var2expr.data()); return out;
|
||||
}
|
||||
|
||||
std::ostream& context::display_literals(std::ostream & out, unsigned num_lits, literal const * lits) const {
|
||||
|
@ -120,7 +120,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
void context::display_literal_info(std::ostream & out, literal l) const {
|
||||
l.display_compact(out, m_bool_var2expr.data());
|
||||
smt::display_compact(out, l, m_bool_var2expr.data());
|
||||
display_literal_smt2(out, l);
|
||||
out << "relevant: " << is_relevant(bool_var2expr(l.var())) << ", val: " << get_assignment(l) << "\n";
|
||||
}
|
||||
|
|
|
@ -22,41 +22,44 @@ Revision History:
|
|||
|
||||
namespace smt {
|
||||
|
||||
void literal::display(std::ostream & out, ast_manager & m, expr * const * bool_var2expr_map) const {
|
||||
if (*this == true_literal)
|
||||
std::ostream& display(std::ostream & out, literal lit, ast_manager & m, expr * const * bool_var2expr_map) {
|
||||
if (lit == true_literal)
|
||||
out << "true";
|
||||
else if (*this == false_literal)
|
||||
else if (lit == false_literal)
|
||||
out << "false";
|
||||
else if (*this == null_literal)
|
||||
else if (lit == null_literal)
|
||||
out << "null";
|
||||
else if (sign())
|
||||
out << "(not " << mk_bounded_pp(bool_var2expr_map[var()], m, 3) << ")";
|
||||
else if (lit.sign())
|
||||
out << "(not " << mk_bounded_pp(bool_var2expr_map[lit.var()], m, 3) << ")";
|
||||
else
|
||||
out << mk_bounded_pp(bool_var2expr_map[var()], m, 3);
|
||||
out << mk_bounded_pp(bool_var2expr_map[lit.var()], m, 3);
|
||||
return out;
|
||||
}
|
||||
|
||||
void literal::display_smt2(std::ostream & out, ast_manager & m, expr * const * bool_var2expr_map) const {
|
||||
if (*this == true_literal)
|
||||
std::ostream& display_smt2(std::ostream & out, literal lit, ast_manager & m, expr * const * bool_var2expr_map) {
|
||||
if (lit == true_literal)
|
||||
out << "true";
|
||||
else if (*this == false_literal)
|
||||
else if (lit == false_literal)
|
||||
out << "false";
|
||||
else if (*this == null_literal)
|
||||
else if (lit == null_literal)
|
||||
out << "null";
|
||||
else if (sign())
|
||||
out << "(not " << mk_pp(bool_var2expr_map[var()], m, 3) << ")";
|
||||
else if (lit.sign())
|
||||
out << "(not " << mk_pp(bool_var2expr_map[lit.var()], m, 3) << ")";
|
||||
else
|
||||
out << mk_pp(bool_var2expr_map[var()], m, 3);
|
||||
out << mk_pp(bool_var2expr_map[lit.var()], m, 3);
|
||||
return out;
|
||||
}
|
||||
|
||||
void literal::display_compact(std::ostream & out, expr * const * bool_var2expr_map) const {
|
||||
if (*this == true_literal)
|
||||
std::ostream& display_compact(std::ostream & out, literal lit, expr * const * bool_var2expr_map) {
|
||||
if (lit == true_literal)
|
||||
out << "true";
|
||||
else if (*this == false_literal)
|
||||
else if (lit == false_literal)
|
||||
out << "false";
|
||||
else if (sign())
|
||||
out << "(not #" << bool_var2expr_map[var()]->get_id() << ")";
|
||||
else if (lit.sign())
|
||||
out << "(not #" << bool_var2expr_map[lit.var()]->get_id() << ")";
|
||||
else
|
||||
out << "#" << bool_var2expr_map[var()]->get_id();
|
||||
out << "#" << bool_var2expr_map[lit.var()]->get_id();
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, literal l) {
|
||||
|
@ -72,24 +75,26 @@ namespace smt {
|
|||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, const literal_vector & v) {
|
||||
display(out, v.begin(), v.end());
|
||||
::display(out, v.begin(), v.end());
|
||||
return out;
|
||||
}
|
||||
|
||||
void display_compact(std::ostream & out, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map) {
|
||||
std::ostream& display_compact(std::ostream & out, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map) {
|
||||
for (unsigned i = 0; i < num_lits; i++) {
|
||||
if (i > 0)
|
||||
out << " ";
|
||||
lits[i].display_compact(out, bool_var2expr_map);
|
||||
display_compact(out, lits[i], bool_var2expr_map);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void display_verbose(std::ostream & out, ast_manager& m, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map, char const* sep) {
|
||||
std::ostream& display_verbose(std::ostream & out, ast_manager& m, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map, char const* sep) {
|
||||
for (unsigned i = 0; i < num_lits; i++) {
|
||||
if (i > 0)
|
||||
out << sep;
|
||||
lits[i].display(out, m, bool_var2expr_map);
|
||||
display(out, lits[i], m, bool_var2expr_map);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,90 +21,30 @@ Revision History:
|
|||
#include "ast/ast.h"
|
||||
#include "smt/smt_types.h"
|
||||
#include "util/approx_set.h"
|
||||
#include "util/sat_literal.h"
|
||||
|
||||
namespace smt {
|
||||
/**
|
||||
\brief The literal b is represented by the value 2*b, and
|
||||
the literal (not b) by the value 2*b + 1
|
||||
|
||||
*/
|
||||
class literal {
|
||||
int m_val;
|
||||
|
||||
public:
|
||||
literal():m_val(-2) {
|
||||
SASSERT(var() == null_bool_var && !sign());
|
||||
}
|
||||
|
||||
explicit literal(bool_var v, bool sign = false):
|
||||
m_val((v << 1) + static_cast<int>(sign)) {
|
||||
}
|
||||
|
||||
bool_var var() const {
|
||||
return m_val >> 1;
|
||||
}
|
||||
|
||||
bool sign() const {
|
||||
return m_val & 1;
|
||||
}
|
||||
|
||||
int index() const {
|
||||
return m_val;
|
||||
}
|
||||
|
||||
void neg() {
|
||||
m_val = m_val ^ 1;
|
||||
}
|
||||
|
||||
friend literal operator~(literal l);
|
||||
|
||||
friend literal to_literal(int x);
|
||||
|
||||
void display(std::ostream & out, ast_manager & m, expr * const * bool_var2expr_map) const;
|
||||
typedef sat::literal literal;
|
||||
|
||||
inline literal to_literal(int x) { return sat::to_literal(x); }
|
||||
|
||||
void display_smt2(std::ostream & out, ast_manager & m, expr * const * bool_var2expr_map) const;
|
||||
|
||||
void display_compact(std::ostream & out, expr * const * bool_var2expr_map) const;
|
||||
|
||||
unsigned hash() const { return m_val; }
|
||||
};
|
||||
|
||||
inline bool operator==(literal l1, literal l2) {
|
||||
return l1.index() == l2.index();
|
||||
}
|
||||
|
||||
inline bool operator!=(literal l1, literal l2) {
|
||||
return l1.index() != l2.index();
|
||||
}
|
||||
|
||||
inline bool operator<(literal l1, literal l2) {
|
||||
return l1.index() < l2.index();
|
||||
}
|
||||
|
||||
inline literal operator~(literal l) {
|
||||
literal r;
|
||||
r.m_val = l.m_val ^ 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline literal to_literal(int x) {
|
||||
literal l;
|
||||
l.m_val = x;
|
||||
return l;
|
||||
}
|
||||
|
||||
const literal null_literal;
|
||||
const literal true_literal(true_bool_var, false);
|
||||
const literal false_literal(true_bool_var, true);
|
||||
|
||||
typedef svector<literal> literal_vector;
|
||||
typedef sbuffer<literal> literal_buffer;
|
||||
std::ostream & operator<<(std::ostream & out, literal l);
|
||||
std::ostream & operator<<(std::ostream & out, const literal_vector & v);
|
||||
|
||||
void display_compact(std::ostream & out, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map);
|
||||
std::ostream& display(std::ostream & out, literal lit, ast_manager & m, expr * const * bool_var2expr_map);
|
||||
|
||||
std::ostream& display_smt2(std::ostream & out, literal lit, ast_manager & m, expr * const * bool_var2expr_map);
|
||||
|
||||
std::ostream& display_compact(std::ostream & out, literal lit, expr * const * bool_var2expr_map);
|
||||
|
||||
void display_verbose(std::ostream & out, ast_manager& m, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map, char const* sep = "\n");
|
||||
std::ostream& display_compact(std::ostream & out, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map);
|
||||
|
||||
std::ostream& display_verbose(std::ostream & out, ast_manager& m, unsigned num_lits, literal const * lits, expr * const * bool_var2expr_map, char const* sep = "\n");
|
||||
|
||||
template<typename T>
|
||||
void neg_literals(unsigned num_lits, literal const * lits, T & result) {
|
||||
|
@ -112,9 +52,6 @@ namespace smt {
|
|||
result.push_back(~lits[i]);
|
||||
}
|
||||
|
||||
struct literal2unsigned { unsigned operator()(literal l) const { return l.index(); } };
|
||||
|
||||
typedef approx_set_tpl<literal, literal2unsigned> literal_approx_set;
|
||||
|
||||
bool backward_subsumption(unsigned num_lits1, literal const * lits1, unsigned num_lits2, literal const * lits2);
|
||||
};
|
||||
|
|
|
@ -319,7 +319,14 @@ namespace smt {
|
|||
struct scoped_ctx_push {
|
||||
context* c;
|
||||
scoped_ctx_push(context* c): c(c) { c->push(); }
|
||||
~scoped_ctx_push() { c->pop(1); }
|
||||
~scoped_ctx_push() {
|
||||
try {
|
||||
c->pop(1);
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,14 +193,25 @@ namespace smt {
|
|||
|
||||
}
|
||||
catch (z3_error & err) {
|
||||
error_code = err.error_code();
|
||||
ex_kind = ERROR_EX;
|
||||
done = true;
|
||||
if (finished_id == UINT_MAX) {
|
||||
error_code = err.error_code();
|
||||
ex_kind = ERROR_EX;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
ex_msg = ex.msg();
|
||||
ex_kind = DEFAULT_EX;
|
||||
done = true;
|
||||
if (finished_id == UINT_MAX) {
|
||||
ex_msg = ex.msg();
|
||||
ex_kind = DEFAULT_EX;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
if (finished_id == UINT_MAX) {
|
||||
ex_msg = "unknown exception";
|
||||
ex_kind = ERROR_EX;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -333,7 +333,8 @@ namespace smt {
|
|||
if (e != nullptr) {
|
||||
enode * curr = e;
|
||||
do {
|
||||
set_relevant(curr->get_expr());
|
||||
if (!is_relevant_core(curr->get_expr()))
|
||||
set_relevant(curr->get_expr());
|
||||
curr = curr->get_next();
|
||||
}
|
||||
while (curr != e);
|
||||
|
|
|
@ -190,6 +190,8 @@ protected:
|
|||
parent_pos = todo.back().m_parent;
|
||||
self_idx = todo.back().m_idx;
|
||||
n = names.back();
|
||||
bool found = false;
|
||||
|
||||
|
||||
if (cache.contains(e)) {
|
||||
goto done;
|
||||
|
@ -213,37 +215,50 @@ protected:
|
|||
sz = a->get_num_args();
|
||||
n2 = nullptr;
|
||||
|
||||
|
||||
//
|
||||
// This is a single traversal version of the context
|
||||
// simplifier. It simplifies only the first occurrence of
|
||||
// a sub-term with respect to the context.
|
||||
//
|
||||
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
expr* arg = a->get_arg(i);
|
||||
if (cache.find(arg, path_r)) {
|
||||
//
|
||||
// This is a single traversal version of the context
|
||||
// simplifier. It simplifies only the first occurrence of
|
||||
// a sub-term with respect to the context.
|
||||
//
|
||||
|
||||
if (path_r.m_parent == self_pos && path_r.m_idx == i) {
|
||||
args.push_back(path_r.m_expr);
|
||||
if (cache.find(arg, path_r) &&
|
||||
path_r.m_parent == self_pos && path_r.m_idx == i) {
|
||||
args.push_back(path_r.m_expr);
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
args.push_back(arg);
|
||||
}
|
||||
|
||||
//
|
||||
// the context is not equivalent to top-level
|
||||
// if it is already simplified.
|
||||
// Bug exposes such a scenario #5256
|
||||
//
|
||||
if (!found) {
|
||||
args.reset();
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
expr* arg = a->get_arg(i);
|
||||
if (!n2 && !m.is_value(arg)) {
|
||||
n2 = mk_fresh(id, arg->get_sort());
|
||||
trail.push_back(n2);
|
||||
todo.push_back(expr_pos(self_pos, ++child_id, i, arg));
|
||||
names.push_back(n2);
|
||||
args.push_back(n2);
|
||||
}
|
||||
else {
|
||||
args.push_back(arg);
|
||||
}
|
||||
}
|
||||
else if (!n2 && !m.is_value(arg)) {
|
||||
n2 = mk_fresh(id, arg->get_sort());
|
||||
trail.push_back(n2);
|
||||
todo.push_back(expr_pos(self_pos, ++child_id, i, arg));
|
||||
names.push_back(n2);
|
||||
args.push_back(n2);
|
||||
}
|
||||
else {
|
||||
args.push_back(arg);
|
||||
}
|
||||
}
|
||||
m_mk_app(a->get_decl(), args.size(), args.data(), res);
|
||||
trail.push_back(res);
|
||||
// child needs to be visited.
|
||||
if (n2) {
|
||||
SASSERT(!found);
|
||||
m_solver.push();
|
||||
tmp = m.mk_eq(res, n);
|
||||
m_solver.assert_expr(tmp);
|
||||
|
|
|
@ -976,16 +976,13 @@ public:
|
|||
}
|
||||
|
||||
void internalize_eq_eh(app * atom, bool_var) {
|
||||
if (!ctx().get_fparams().m_arith_eager_eq_axioms)
|
||||
return;
|
||||
expr* lhs = nullptr, *rhs = nullptr;
|
||||
VERIFY(m.is_eq(atom, lhs, rhs));
|
||||
enode * n1 = get_enode(lhs);
|
||||
enode * n2 = get_enode(rhs);
|
||||
TRACE("arith_verbose", tout << mk_pp(atom, m) << " " << is_arith(n1) << " " << is_arith(n2) << "\n";);
|
||||
if (is_arith(n1) && is_arith(n2) && n1 != n2) {
|
||||
if (is_arith(n1) && is_arith(n2) && n1 != n2)
|
||||
m_arith_eq_adapter.mk_axioms(n1, n2);
|
||||
}
|
||||
}
|
||||
|
||||
void assign_eh(bool_var v, bool is_true) {
|
||||
|
@ -1085,7 +1082,6 @@ public:
|
|||
}
|
||||
|
||||
void relevant_eh(app* n) {
|
||||
TRACE("arith", tout << mk_pp(n, m) << "\n";);
|
||||
expr* n1, *n2;
|
||||
if (a.is_mod(n, n1, n2))
|
||||
mk_idiv_mod_axioms(n1, n2);
|
||||
|
@ -2083,7 +2079,7 @@ public:
|
|||
bool is_true = m_asserted_atoms[m_asserted_qhead].m_is_true;
|
||||
m_to_check.push_back(bv);
|
||||
api_bound* b = nullptr;
|
||||
TRACE("arith", tout << "propagate: " << bv << "\n";);
|
||||
TRACE("arith", tout << "propagate: " << literal(bv, !is_true) << "\n";);
|
||||
if (m_bool_var2bound.find(bv, b)) {
|
||||
assert_bound(bv, is_true, *b);
|
||||
}
|
||||
|
@ -2642,14 +2638,14 @@ public:
|
|||
if (sign)
|
||||
lit2.neg();
|
||||
}
|
||||
TRACE("arith",
|
||||
ctx().display_literal_verbose(tout, lit1);
|
||||
ctx().display_literal_verbose(tout << " => ", lit2);
|
||||
tout << "\n";);
|
||||
updt_unassigned_bounds(v, -1);
|
||||
++m_stats.m_bound_propagations2;
|
||||
reset_evidence();
|
||||
m_core.push_back(lit1);
|
||||
TRACE("arith",
|
||||
ctx().display_literals_verbose(tout, m_core);
|
||||
ctx().display_literal_verbose(tout << " => ", lit2);
|
||||
tout << "\n";);
|
||||
m_params.push_back(parameter(m_farkas));
|
||||
m_params.push_back(parameter(rational(1)));
|
||||
m_params.push_back(parameter(rational(1)));
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -107,54 +107,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct c_hash { unsigned operator()(char u) const { return (unsigned)u; } };
|
||||
struct c_eq { bool operator()(char u1, char u2) const { return u1 == u2; } };
|
||||
|
||||
class nfa {
|
||||
protected:
|
||||
bool m_valid;
|
||||
unsigned m_next_id;
|
||||
|
||||
unsigned next_id() {
|
||||
unsigned retval = m_next_id;
|
||||
++m_next_id;
|
||||
return retval;
|
||||
}
|
||||
|
||||
unsigned m_start_state;
|
||||
unsigned m_end_state;
|
||||
|
||||
std::map<unsigned, std::map<char, unsigned> > transition_map;
|
||||
std::map<unsigned, std::set<unsigned> > epsilon_map;
|
||||
|
||||
void make_transition(unsigned start, char symbol, unsigned end) {
|
||||
transition_map[start][symbol] = end;
|
||||
}
|
||||
|
||||
void make_epsilon_move(unsigned start, unsigned end) {
|
||||
epsilon_map[start].insert(end);
|
||||
}
|
||||
|
||||
// Convert a regular expression to an e-NFA using Thompson's construction
|
||||
void convert_re(expr * e, unsigned & start, unsigned & end, seq_util & u);
|
||||
|
||||
public:
|
||||
nfa(seq_util & u, expr * e)
|
||||
: m_valid(true), m_next_id(0), m_start_state(0), m_end_state(0) {
|
||||
convert_re(e, m_start_state, m_end_state, u);
|
||||
}
|
||||
|
||||
nfa() : m_valid(false), m_next_id(0), m_start_state(0), m_end_state(0) {}
|
||||
|
||||
bool is_valid() const {
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
void epsilon_closure(unsigned start, std::set<unsigned> & closure);
|
||||
|
||||
bool matches(zstring input);
|
||||
};
|
||||
|
||||
class regex_automaton_under_assumptions {
|
||||
protected:
|
||||
expr * re_term;
|
||||
|
@ -489,7 +441,6 @@ protected:
|
|||
obj_hashtable<expr> regex_terms;
|
||||
obj_map<expr, ptr_vector<expr> > regex_terms_by_string; // S --> [ (str.in.re S *) ]
|
||||
obj_map<expr, svector<regex_automaton_under_assumptions> > regex_automaton_assumptions; // RegEx --> [ aut+assumptions ]
|
||||
obj_map<expr, nfa> regex_nfa_cache; // Regex term --> NFA
|
||||
obj_hashtable<expr> regex_terms_with_path_constraints; // set of string terms which have had path constraints asserted in the current scope
|
||||
obj_hashtable<expr> regex_terms_with_length_constraints; // set of regex terms which had had length constraints asserted in the current scope
|
||||
obj_map<expr, expr*> regex_term_to_length_constraint; // (str.in.re S R) -> (length constraint over S wrt. R)
|
||||
|
@ -718,15 +669,14 @@ protected:
|
|||
void check_consistency_contains(expr * e, bool is_true);
|
||||
|
||||
int ctx_dep_analysis(std::map<expr*, int> & strVarMap, std::map<expr*, int> & freeVarMap,
|
||||
std::map<expr*, std::set<expr*> > & unrollGroupMap, std::map<expr*, std::map<expr*, int> > & var_eq_concat_map);
|
||||
std::map<expr*, std::map<expr*, int> > & var_eq_concat_map);
|
||||
void trace_ctx_dep(std::ofstream & tout,
|
||||
std::map<expr*, expr*> & aliasIndexMap,
|
||||
std::map<expr*, expr*> & var_eq_constStr_map,
|
||||
std::map<expr*, std::map<expr*, int> > & var_eq_concat_map,
|
||||
std::map<expr*, std::map<expr*, int> > & var_eq_unroll_map,
|
||||
std::map<expr*, expr*> & concat_eq_constStr_map,
|
||||
std::map<expr*, std::map<expr*, int> > & concat_eq_concat_map,
|
||||
std::map<expr*, std::set<expr*> > & unrollGroupMap);
|
||||
std::map<expr*, std::map<expr*, int> > & concat_eq_concat_map);
|
||||
|
||||
bool term_appears_as_subterm(expr * needle, expr * haystack);
|
||||
void classify_ast_by_type(expr * node, std::map<expr*, int> & varMap,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue