mirror of
https://github.com/Z3Prover/z3
synced 2025-06-07 06:33:23 +00:00
fixed encoding for order constraints
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
01879ed1ed
commit
705b107846
2 changed files with 15 additions and 9 deletions
|
@ -24,10 +24,12 @@ Revision History:
|
||||||
class stream_buffer {
|
class stream_buffer {
|
||||||
std::istream & m_stream;
|
std::istream & m_stream;
|
||||||
int m_val;
|
int m_val;
|
||||||
|
unsigned m_line;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
stream_buffer(std::istream & s):
|
stream_buffer(std::istream & s):
|
||||||
m_stream(s) {
|
m_stream(s),
|
||||||
|
m_line(0) {
|
||||||
m_val = m_stream.get();
|
m_val = m_stream.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +39,10 @@ public:
|
||||||
|
|
||||||
void operator ++() {
|
void operator ++() {
|
||||||
m_val = m_stream.get();
|
m_val = m_stream.get();
|
||||||
|
if (m_val == '\n') ++m_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned line() const { return m_line; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Buffer>
|
template<typename Buffer>
|
||||||
|
@ -76,7 +81,7 @@ int parse_int(Buffer & in) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*in < '0' || *in > '9') {
|
if (*in < '0' || *in > '9') {
|
||||||
std::cerr << "(error, \"unexpected char: " << *in << "\")\n";
|
std::cerr << "(error, \"unexpected char: " << *in << " line: " << in.line() << "\")\n";
|
||||||
exit(3);
|
exit(3);
|
||||||
exit(ERR_PARSER);
|
exit(ERR_PARSER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,15 +328,15 @@ Notes:
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_implies_and(literal l, literal_vector const& xs) {
|
void add_implies_and(literal l, literal_vector const& xs) {
|
||||||
for (unsigned j = 0; j < xs.size(); ++j) {
|
for (literal const& x : xs) {
|
||||||
add_clause(ctx.mk_not(l), xs[j]);
|
add_clause(ctx.mk_not(l), x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_and_implies(literal l, literal_vector const& xs) {
|
void add_and_implies(literal l, literal_vector const& xs) {
|
||||||
literal_vector lits;
|
literal_vector lits;
|
||||||
for (unsigned j = 0; j < xs.size(); ++j) {
|
for (literal const& x : xs) {
|
||||||
lits.push_back(ctx.mk_not(xs[j]));
|
lits.push_back(ctx.mk_not(x));
|
||||||
}
|
}
|
||||||
lits.push_back(l);
|
lits.push_back(l);
|
||||||
add_clause(lits);
|
add_clause(lits);
|
||||||
|
@ -513,8 +513,9 @@ Notes:
|
||||||
add_clause(ctx.mk_not(r), ctx.mk_not(ys[i]), ctx.mk_not(xs[i + 1]));
|
add_clause(ctx.mk_not(r), ctx.mk_not(ys[i]), ctx.mk_not(xs[i + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_eq) {
|
||||||
add_clause(ctx.mk_not(r), ys[n-2], xs[n-1]);
|
add_clause(ctx.mk_not(r), ys[n-2], xs[n-1]);
|
||||||
add_clause(ctx.mk_not(r), ctx.mk_not(ys[n-2]), ctx.mk_not(xs[n-1]));
|
}
|
||||||
for (unsigned i = 1; i < n - 1; ++i) {
|
for (unsigned i = 1; i < n - 1; ++i) {
|
||||||
add_clause(ctx.mk_not(ys[i]), xs[i], ys[i-1]);
|
add_clause(ctx.mk_not(ys[i]), xs[i], ys[i-1]);
|
||||||
}
|
}
|
||||||
|
@ -583,7 +584,7 @@ Notes:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& pp(std::ostream& out, literal_vector const& lits) {
|
std::ostream& pp(std::ostream& out, literal_vector const& lits) {
|
||||||
for (unsigned i = 0; i < lits.size(); ++i) ctx.pp(out, lits[i]) << " ";
|
for (literal const& l : lits) ctx.pp(out, l) << " ";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue