fix(library/tactic/rewrite_tactic): rewrite macros did not implement operator==

This problem was affecting the cache
This commit is contained in:
Leonardo de Moura 2015-03-13 19:24:09 -07:00
parent cfeb426cd7
commit f6f2c499ae
2 changed files with 43 additions and 0 deletions

View file

@ -47,6 +47,9 @@ public:
unsigned contains(unsigned occ_idx) const;
friend serializer & operator<<(serializer & s, occurrence const & o);
friend deserializer & operator>>(deserializer & d, occurrence & o);
bool operator==(occurrence const & o) const { return m_kind == o.m_kind && m_occs == o.m_occs; }
bool operator!=(occurrence const & o) const { return !operator==(o); }
};
/** \brief Replace occurrences of \c t in \c e with the free variable #vidx.
@ -83,6 +86,9 @@ public:
optional<occurrence> includes_hypothesis(name const & h) const;
void get_explicit_hypotheses_names(buffer<name> & r) const;
bool operator==(location const & l) const { return m_kind == l.m_kind && m_goal == l.m_goal && m_hyps == l.m_hyps; }
bool operator!=(location const & l) const { return !operator==(l); }
friend serializer & operator<<(serializer & s, location const & loc);
friend deserializer & operator>>(deserializer & d, location & loc);
};

View file

@ -81,6 +81,9 @@ public:
d >> e.m_location;
return d;
}
bool operator==(unfold_info const & i) const { return m_names == i.m_names && m_location == i.m_location; }
bool operator!=(unfold_info const & i) const { return !operator==(i); }
};
class reduce_info {
@ -97,6 +100,9 @@ public:
d >> e.m_location;
return d;
}
bool operator==(reduce_info const & i) const { return m_location == i.m_location; }
bool operator!=(reduce_info const & i) const { return !operator==(i); }
};
class rewrite_info {
@ -132,6 +138,13 @@ public:
return rewrite_info(symm, OneOrMore, optional<unsigned>(), loc);
}
bool operator==(rewrite_info const & i) const {
return
m_symm == i.m_symm && m_multiplicity == i.m_multiplicity &&
m_num == i.m_num && m_location == i.m_location;
}
bool operator!=(rewrite_info const & i) const { return !operator==(i); }
bool symm() const {
return m_symm;
}
@ -199,6 +212,12 @@ public:
s << *g_rewrite_reduce_opcode << m_info;
}
reduce_info const & get_info() const { return m_info; }
virtual bool operator==(macro_definition_cell const & other) const {
if (auto o = dynamic_cast<rewrite_reduce_macro_cell const *>(&other))
return m_info == o->m_info;
return false;
}
};
expr mk_rewrite_reduce(location const & loc) {
@ -231,6 +250,12 @@ public:
s << *g_rewrite_fold_opcode << m_info;
}
fold_info const & get_info() const { return m_info; }
virtual bool operator==(macro_definition_cell const & other) const {
if (auto o = dynamic_cast<rewrite_fold_macro_cell const *>(&other))
return m_info == o->m_info;
return false;
}
};
expr mk_rewrite_fold(expr const & e, location const & loc) {
@ -256,6 +281,12 @@ public:
s << *g_rewrite_unfold_opcode << m_info;
}
unfold_info const & get_info() const { return m_info; }
virtual bool operator==(macro_definition_cell const & other) const {
if (auto o = dynamic_cast<rewrite_unfold_macro_cell const *>(&other))
return m_info == o->m_info;
return false;
}
};
expr mk_rewrite_unfold(list<name> const & ns, location const & loc) {
@ -281,6 +312,12 @@ public:
s << *g_rewrite_elem_opcode << m_info;
}
rewrite_info const & get_info() const { return m_info; }
virtual bool operator==(macro_definition_cell const & other) const {
if (auto o = dynamic_cast<rewrite_element_macro_cell const *>(&other))
return m_info == o->m_info;
return false;
}
};
expr mk_rw_macro(macro_definition const & def, optional<expr> const & pattern, expr const & H) {