acc: Add operators == and != for acc_code

and make sure are_isomorphic does not look only at the number of
acceptance sets

* src/tgba/acc.hh: Here.
* src/tgbaalgos/are_isomorphic.cc: Use it to ensure two automata
have the same acceptance condition.
* src/tgbatest/explpro4.test: Test product between Büchi and co-Büchi,
and make sure the isomorphic check look at the acceptance condition.
This commit is contained in:
Alexandre Duret-Lutz 2015-02-20 13:16:46 +01:00
parent 039274b238
commit 33c496a4bb
3 changed files with 61 additions and 9 deletions

View file

@ -211,6 +211,42 @@ namespace spot
struct acc_code: public std::vector<acc_word>
{
bool operator==(const acc_code& other)
{
unsigned pos = size();
if (other.size() != pos)
return false;
while (pos > 0)
{
auto op = (*this)[pos - 1].op;
auto sz = (*this)[pos - 1].size;
if (other[pos - 1].op != op ||
other[pos - 1].size != sz)
return false;
switch (op)
{
case acc_cond::acc_op::And:
case acc_cond::acc_op::Or:
--pos;
break;
case acc_cond::acc_op::Inf:
case acc_cond::acc_op::InfNeg:
case acc_cond::acc_op::Fin:
case acc_cond::acc_op::FinNeg:
pos -= 2;
if (other[pos].mark != (*this)[pos].mark)
return false;
break;
}
}
return true;
};
bool operator!=(const acc_code& other)
{
return !(*this == other);
}
bool is_true() const
{
unsigned s = size();