mirror of
https://github.com/Z3Prover/z3
synced 2026-04-26 13:53:33 +00:00
Fixed output error
This commit is contained in:
parent
3662b89adc
commit
a873d5cdda
3 changed files with 49 additions and 15 deletions
|
|
@ -20,6 +20,7 @@ Author:
|
||||||
#include "ast/euf/euf_seq_plugin.h"
|
#include "ast/euf/euf_seq_plugin.h"
|
||||||
#include "ast/arith_decl_plugin.h"
|
#include "ast/arith_decl_plugin.h"
|
||||||
#include "ast/ast_pp.h"
|
#include "ast/ast_pp.h"
|
||||||
|
#include "smt/seq/seq_nielsen.h"
|
||||||
|
|
||||||
namespace euf {
|
namespace euf {
|
||||||
|
|
||||||
|
|
@ -528,6 +529,10 @@ namespace euf {
|
||||||
expr* elem_expr = elem->get_expr();
|
expr* elem_expr = elem->get_expr();
|
||||||
if (!re_expr || !elem_expr)
|
if (!re_expr || !elem_expr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
// std::cout << "Derivative of " << seq::snode_label_html(re, m) << "\nwith respect to " << seq::snode_label_html(elem, m) << std::endl;
|
||||||
|
// if (allowed_range)
|
||||||
|
// std::cout << "using " << seq::snode_label_html(allowed_range, m) << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// unwrap str.unit to get the character expression
|
// unwrap str.unit to get the character expression
|
||||||
expr* ch = nullptr;
|
expr* ch = nullptr;
|
||||||
|
|
@ -560,6 +565,7 @@ namespace euf {
|
||||||
}
|
}
|
||||||
// Fallback: If elem itself is a regex predicate, extract representative
|
// Fallback: If elem itself is a regex predicate, extract representative
|
||||||
else if (ele_sort != elem_expr->get_sort()) {
|
else if (ele_sort != elem_expr->get_sort()) {
|
||||||
|
// std::cout << "Different sorts: " << ele_sort->get_name() << " vs " << elem_expr->get_sort()->get_name() << std::endl;
|
||||||
expr* lo = nullptr, *hi = nullptr;
|
expr* lo = nullptr, *hi = nullptr;
|
||||||
if (m_seq.re.is_full_char(elem_expr))
|
if (m_seq.re.is_full_char(elem_expr))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -573,8 +579,8 @@ namespace euf {
|
||||||
else
|
else
|
||||||
elem_expr = lo;
|
elem_expr = lo;
|
||||||
}
|
}
|
||||||
else
|
std::cout << "Unexpected node: " << mk_pp(elem_expr, m) << std::endl;
|
||||||
return nullptr;
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -585,9 +591,10 @@ namespace euf {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sgraph::collect_re_predicates(snode* re, expr_ref_vector& preds) {
|
void sgraph::collect_re_predicates(snode* re, expr_ref_vector& preds) {
|
||||||
if (!re || !re->get_expr())
|
if (!re)
|
||||||
return;
|
return;
|
||||||
expr* e = re->get_expr();
|
expr* e = re->get_expr();
|
||||||
|
SASSERT(e);
|
||||||
expr* lo = nullptr, *hi = nullptr;
|
expr* lo = nullptr, *hi = nullptr;
|
||||||
// leaf regex predicates: character ranges and single characters
|
// leaf regex predicates: character ranges and single characters
|
||||||
if (m_seq.re.is_range(e, lo, hi)) {
|
if (m_seq.re.is_range(e, lo, hi)) {
|
||||||
|
|
|
||||||
|
|
@ -807,14 +807,36 @@ namespace seq {
|
||||||
|
|
||||||
if (seq.re.is_to_re(e, a)) {
|
if (seq.re.is_to_re(e, a)) {
|
||||||
zstring s;
|
zstring s;
|
||||||
if (seq.str.is_string(a, s))
|
bool first = true;
|
||||||
return "\"" + dot_html_escape(s.encode()) + "\"";
|
svector<expr*> args;
|
||||||
unsigned ch_val = 0;
|
args.push_back(a);
|
||||||
if (seq.str.is_unit(a) && seq.is_const_char(to_app(a)->get_arg(0), ch_val)) {
|
// flatten concatenations
|
||||||
return "\"" + dot_html_escape(zstring(ch_val).encode()) + "\"";
|
|
||||||
}
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << mk_pp(a, m);
|
while (!args.empty()) {
|
||||||
|
expr* arg = args.back();
|
||||||
|
args.pop_back();
|
||||||
|
if (seq.str.is_concat(arg)) {
|
||||||
|
args.push_back(to_app(arg)->get_arg(1));
|
||||||
|
args.push_back(to_app(arg)->get_arg(0));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (seq.str.is_string(arg, s)) {
|
||||||
|
if (!first) os << " ";
|
||||||
|
os << "\"" + dot_html_escape(s.encode()) + "\"";
|
||||||
|
first = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
unsigned ch_val = 0;
|
||||||
|
if (seq.str.is_unit(arg) && seq.is_const_char(to_app(arg)->get_arg(0), ch_val)) {
|
||||||
|
if (!first) os << " ";
|
||||||
|
os << "\"" + dot_html_escape(zstring(ch_val).encode()) + "\"";
|
||||||
|
first = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!first) os << " ";
|
||||||
|
os << mk_pp(arg, m);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
return dot_html_escape(os.str());
|
return dot_html_escape(os.str());
|
||||||
}
|
}
|
||||||
if (seq.re.is_concat(e)) {
|
if (seq.re.is_concat(e)) {
|
||||||
|
|
@ -833,9 +855,11 @@ namespace seq {
|
||||||
if (seq.re.is_union(e)) {
|
if (seq.re.is_union(e)) {
|
||||||
app* ap = to_app(e);
|
app* ap = to_app(e);
|
||||||
std::string res;
|
std::string res;
|
||||||
if (ap->get_num_args() == 0) return "∅";
|
if (ap->get_num_args() == 0)
|
||||||
for (unsigned i = 0; i < ap->get_num_args(); ++i) {
|
return "∅";
|
||||||
if (i > 0) res += " | ";
|
res = regex_expr_html(ap->get_arg(1), m, seq);
|
||||||
|
for (unsigned i = 1; i < ap->get_num_args(); ++i) {
|
||||||
|
res += " | ";
|
||||||
res += regex_expr_html(ap->get_arg(i), m, seq);
|
res += regex_expr_html(ap->get_arg(i), m, seq);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -907,7 +931,7 @@ namespace seq {
|
||||||
// shows s_power with superscripts, s_unit by its inner expression,
|
// shows s_power with superscripts, s_unit by its inner expression,
|
||||||
// and falls back to mk_pp (HTML-escaped) for other token kinds.
|
// and falls back to mk_pp (HTML-escaped) for other token kinds.
|
||||||
|
|
||||||
static std::string snode_label_html(euf::snode const* n, ast_manager& m) {
|
std::string snode_label_html(euf::snode const* n, ast_manager& m) {
|
||||||
if (!n) return "null";
|
if (!n) return "null";
|
||||||
seq_util seq(m);
|
seq_util seq(m);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,13 +254,16 @@ namespace smt {
|
||||||
class enode;
|
class enode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace seq {
|
namespace seq {
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
class nielsen_node;
|
class nielsen_node;
|
||||||
class nielsen_edge;
|
class nielsen_edge;
|
||||||
class nielsen_graph;
|
class nielsen_graph;
|
||||||
class seq_parikh; // Parikh image filter (see seq_parikh.h)
|
class seq_parikh;
|
||||||
|
|
||||||
|
std::string snode_label_html(euf::snode const* n, ast_manager& m);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract interface for an incremental solver used by nielsen_graph
|
* Abstract interface for an incremental solver used by nielsen_graph
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue