Skip to content

Commit

Permalink
fix #2643 - fuzzers are here to get you @lorisdanton
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Oct 13, 2019
1 parent cc26d49 commit a921b4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ast/rewriter/seq_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ eautomaton* re2automaton::operator()(expr* e) {
if (r) {
r->compress();
bool_rewriter br(m);
TRACE("seq", display_expr1 disp(m); r->display(tout, disp););
TRACE("seq", display_expr1 disp(m); r->display(tout << mk_pp(e, m) << " -->\n", disp););
}
return r;
}
Expand Down Expand Up @@ -348,7 +348,9 @@ eautomaton* re2automaton::re2aut(expr* e) {
return a.detach();
}
else if (u.re.is_intersection(e, e1, e2) && m_sa && (a = re2aut(e1)) && (b = re2aut(e2))) {
return m_sa->mk_product(*a, *b);
eautomaton* r = m_sa->mk_product(*a, *b);
TRACE("seq", display_expr1 disp(m); a->display(tout << "a:", disp); b->display(tout << "b:", disp); r->display(tout << "intersection:", disp););
return r;
}
else {
TRACE("seq", tout << "not handled " << mk_pp(e, m) << "\n";);
Expand Down
9 changes: 6 additions & 3 deletions src/math/automata/symbolic_automata_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,14 @@ typename symbolic_automata<T, M>::automaton_t* symbolic_automata<T, M>::mk_produ
unsigned_vector final;
unsigned_vector a_init, b_init;
a.get_epsilon_closure(a.init(), a_init);
bool a_init_is_final = false, b_init_is_final = false;
for (unsigned ia : a_init) {
if (a.is_final_state(ia)) {
a_init_is_final = true;
b.get_epsilon_closure(b.init(), b_init);
for (unsigned ib : b_init) {
if (b.is_final_state(ib)) {
b_init_is_final = true;
final.push_back(0);
break;
}
Expand Down Expand Up @@ -438,8 +441,8 @@ typename symbolic_automata<T, M>::automaton_t* symbolic_automata<T, M>::mk_produ
}

svector<bool> back_reachable(n, false);
for (unsigned i = 0; i < final.size(); ++i) {
back_reachable[final[i]] = true;
for (unsigned f : final) {
back_reachable[f] = true;
}

unsigned_vector stack(final);
Expand All @@ -464,7 +467,7 @@ typename symbolic_automata<T, M>::automaton_t* symbolic_automata<T, M>::mk_produ
}
}
if (mvs1.empty()) {
if (a.is_final_state(a.init()) && b.is_final_state(b.init())) {
if (a_init_is_final && b_init_is_final) {
// special case: automaton has no moves, but the initial state is final on both sides
// this results in the automaton which accepts the empty sequence and nothing else
final.clear();
Expand Down

0 comments on commit a921b4f

Please sign in to comment.