3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-24 20:16:00 +00:00
This commit is contained in:
Nikolaj Bjorner 2022-12-13 19:35:20 -08:00
parent cd3d38caf7
commit 9054e72920
8 changed files with 51 additions and 46 deletions

View file

@ -1013,28 +1013,31 @@ namespace datalog {
}
}
void rule::display(context & ctx, std::ostream & out) const {
void rule::display(context & ctx, std::ostream & out, bool compact) const {
ast_manager & m = ctx.get_manager();
out << m_name.str () << ":\n";
if (!compact)
out << m_name.str () << ":\n";
output_predicate(ctx, m_head, out);
if (m_tail_size == 0) {
out << ".\n";
out << ".";
if (!compact)
out << "\n";
return;
}
out << " :- ";
for (unsigned i = 0; i < m_tail_size; i++) {
if (i > 0)
out << ",";
out << "\n ";
if (!compact)
out << "\n";
out << " ";
if (is_neg_tail(i))
out << "not ";
app * t = get_tail(i);
if (ctx.is_predicate(t)) {
if (ctx.is_predicate(t))
output_predicate(ctx, t, out);
}
else {
else
out << mk_pp(t, m);
}
}
out << '.';
if (ctx.output_profile()) {
@ -1042,10 +1045,10 @@ namespace datalog {
output_profile(out);
out << '}';
}
out << '\n';
if (m_proof) {
if (!compact)
out << '\n';
if (m_proof)
out << mk_pp(m_proof, m) << '\n';
}
}

View file

@ -365,7 +365,7 @@ namespace datalog {
void get_vars(ast_manager& m, ptr_vector<sort>& sorts) const;
void display(context & ctx, std::ostream & out) const;
void display(context & ctx, std::ostream & out, bool compact = false) const;
/**
\brief Return the name(s) associated with this rule. Plural for preprocessed (e.g. obtained by inlining) rules.

View file

@ -320,32 +320,31 @@ namespace datalog {
unsigned_vector & res, bool & identity);
template<class T>
void permutate_by_cycle(T & container, unsigned cycle_len, const unsigned * permutation_cycle) {
if (cycle_len<2) {
void permute_by_cycle(T& container, unsigned cycle_len, const unsigned * permutation_cycle) {
if (cycle_len < 2)
return;
}
auto aux = container[permutation_cycle[0]];
for (unsigned i=1; i<cycle_len; i++) {
container[permutation_cycle[i-1]]=container[permutation_cycle[i]];
}
container[permutation_cycle[cycle_len-1]]=aux;
verbose_stream() << "xx " << cycle_len << "\n";
for (unsigned i = 1; i < cycle_len; i++)
container[permutation_cycle[i-1]] = container[permutation_cycle[i]];
container[permutation_cycle[cycle_len-1]] = aux;
}
template<class T, class M>
void permutate_by_cycle(ref_vector<T,M> & container, unsigned cycle_len, const unsigned * permutation_cycle) {
void permute_by_cycle(ref_vector<T,M> & container, unsigned cycle_len, const unsigned * permutation_cycle) {
if (cycle_len<2) {
return;
}
verbose_stream() << "ptr\n";
T * aux = container.get(permutation_cycle[0]);
for (unsigned i=1; i<cycle_len; i++) {
for (unsigned i=1; i < cycle_len; i++) {
container.set(permutation_cycle[i-1], container.get(permutation_cycle[i]));
}
container.set(permutation_cycle[cycle_len-1], aux);
}
template<class T>
void permutate_by_cycle(T & container, const unsigned_vector & permutation_cycle) {
permutate_by_cycle(container, permutation_cycle.size(), permutation_cycle.data());
void permute_by_cycle(T & container, const unsigned_vector & permutation_cycle) {
permute_by_cycle(container, permutation_cycle.size(), permutation_cycle.data());
}