* iface/gspn/gspn.cc, src/ltlvisit/basicreduce.cc,
src/ltlvisit/destroy.cc, src/ltlvisit/dotty.cc,
src/ltlvisit/dump.cc, src/ltlvisit/length.cc,
src/ltlvisit/nenoform.cc, src/ltlvisit/reduce.cc,
src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc,
src/tgba/formula2bdd.cc, src/tgba/tgbabddconcreteproduct.cc,
src/tgba/tgbatba.cc, src/tgbaalgos/dotty.cc,
src/tgbaalgos/dupexp.cc, src/tgbaalgos/lbtt.cc,
src/tgbaalgos/ltl2tgba_lacim.cc, src/tgbaalgos/neverclaim.cc,
src/tgbaalgos/save.cc, src/tgbaalgos/stats.cc,
src/tgbaalgos/gtec/nsheap.cc, src/tgbaalgos/gtec/nsheap.hh:
Declare private classes and helper function in anonymous namespaces.
* HACKING, src/sanity/style.test: Document and check this.
Also check for trailing { after namespace or class.
* src/ltlast/predecl.hh, src/ltlast/visitor.hh,
src/tgba/tgbareduc.hh: Fix trailing {.
This commit is contained in:
parent
5176caf4d2
commit
7d27fd3796
28 changed files with 3128 additions and 3025 deletions
|
|
@ -27,166 +27,170 @@ namespace spot
|
|||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class negative_normal_form_visitor : public visitor
|
||||
namespace
|
||||
{
|
||||
public:
|
||||
negative_normal_form_visitor(bool negated)
|
||||
: negated_(negated)
|
||||
class negative_normal_form_visitor: public visitor
|
||||
{
|
||||
}
|
||||
public:
|
||||
negative_normal_form_visitor(bool negated)
|
||||
: negated_(negated)
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~negative_normal_form_visitor()
|
||||
{
|
||||
}
|
||||
virtual
|
||||
~negative_normal_form_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
formula* result() const
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
formula* result() const
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
|
||||
void
|
||||
visit(atomic_prop* ap)
|
||||
{
|
||||
formula* f = ap->ref();
|
||||
if (negated_)
|
||||
result_ = unop::instance(unop::Not, f);
|
||||
else
|
||||
result_ = f;
|
||||
}
|
||||
void
|
||||
visit(atomic_prop* ap)
|
||||
{
|
||||
formula* f = ap->ref();
|
||||
if (negated_)
|
||||
result_ = unop::instance(unop::Not, f);
|
||||
else
|
||||
result_ = f;
|
||||
}
|
||||
|
||||
void
|
||||
visit(constant* c)
|
||||
{
|
||||
if (!negated_)
|
||||
{
|
||||
result_ = c;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (c->val())
|
||||
{
|
||||
case constant::True:
|
||||
result_ = constant::false_instance();
|
||||
return;
|
||||
case constant::False:
|
||||
result_ = constant::true_instance();
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
visit(unop* uo)
|
||||
{
|
||||
formula* f = uo->child();
|
||||
switch (uo->op())
|
||||
{
|
||||
case unop::Not:
|
||||
result_ = recurse_(f, negated_ ^ true);
|
||||
return;
|
||||
case unop::X:
|
||||
/* !Xa == X!a */
|
||||
result_ = unop::instance(unop::X, recurse(f));
|
||||
return;
|
||||
case unop::F:
|
||||
/* !Fa == G!a */
|
||||
result_ = unop::instance(negated_ ? unop::G : unop::F, recurse(f));
|
||||
return;
|
||||
case unop::G:
|
||||
/* !Ga == F!a */
|
||||
result_ = unop::instance(negated_ ? unop::F : unop::G, recurse(f));
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
visit(binop* bo)
|
||||
{
|
||||
formula* f1 = bo->first();
|
||||
formula* f2 = bo->second();
|
||||
switch (bo->op())
|
||||
{
|
||||
case binop::Xor:
|
||||
/* !(a ^ b) == a <=> b */
|
||||
result_ = binop::instance(negated_ ? binop::Equiv : binop::Xor,
|
||||
recurse_(f1, false),
|
||||
recurse_(f2, false));
|
||||
return;
|
||||
case binop::Equiv:
|
||||
/* !(a <=> b) == a ^ b */
|
||||
result_ = binop::instance(negated_ ? binop::Xor : binop::Equiv,
|
||||
recurse_(f1, false),
|
||||
recurse_(f2, false));
|
||||
return;
|
||||
case binop::Implies:
|
||||
if (negated_)
|
||||
/* !(a => b) == a & !b */
|
||||
result_ = multop::instance(multop::And,
|
||||
recurse_(f1, false),
|
||||
recurse_(f2, true));
|
||||
else
|
||||
result_ = binop::instance(binop::Implies,
|
||||
recurse(f1), recurse(f2));
|
||||
return;
|
||||
case binop::U:
|
||||
/* !(a U b) == !a R !b */
|
||||
result_ = binop::instance(negated_ ? binop::R : binop::U,
|
||||
recurse(f1), recurse(f2));
|
||||
return;
|
||||
case binop::R:
|
||||
/* !(a R b) == !a U !b */
|
||||
result_ = binop::instance(negated_ ? binop::U : binop::R,
|
||||
recurse(f1), recurse(f2));
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
visit(multop* mo)
|
||||
{
|
||||
/* !(a & b & c) == !a | !b | !c */
|
||||
/* !(a | b | c) == !a & !b & !c */
|
||||
multop::type op = mo->op();
|
||||
if (negated_)
|
||||
switch (op)
|
||||
void
|
||||
visit(constant* c)
|
||||
{
|
||||
if (!negated_)
|
||||
{
|
||||
case multop::And:
|
||||
op = multop::Or;
|
||||
break;
|
||||
case multop::Or:
|
||||
op = multop::And;
|
||||
break;
|
||||
result_ = c;
|
||||
return;
|
||||
}
|
||||
multop::vec* res = new multop::vec;
|
||||
unsigned mos = mo->size();
|
||||
for (unsigned i = 0; i < mos; ++i)
|
||||
res->push_back(recurse(mo->nth(i)));
|
||||
result_ = multop::instance(op, res);
|
||||
}
|
||||
|
||||
formula*
|
||||
recurse_(formula* f, bool negated)
|
||||
{
|
||||
return negative_normal_form(f, negated);
|
||||
}
|
||||
switch (c->val())
|
||||
{
|
||||
case constant::True:
|
||||
result_ = constant::false_instance();
|
||||
return;
|
||||
case constant::False:
|
||||
result_ = constant::true_instance();
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
formula*
|
||||
recurse(formula* f)
|
||||
{
|
||||
return recurse_(f, negated_);
|
||||
}
|
||||
void
|
||||
visit(unop* uo)
|
||||
{
|
||||
formula* f = uo->child();
|
||||
switch (uo->op())
|
||||
{
|
||||
case unop::Not:
|
||||
result_ = recurse_(f, negated_ ^ true);
|
||||
return;
|
||||
case unop::X:
|
||||
/* !Xa == X!a */
|
||||
result_ = unop::instance(unop::X, recurse(f));
|
||||
return;
|
||||
case unop::F:
|
||||
/* !Fa == G!a */
|
||||
result_ = unop::instance(negated_ ? unop::G : unop::F,
|
||||
recurse(f));
|
||||
return;
|
||||
case unop::G:
|
||||
/* !Ga == F!a */
|
||||
result_ = unop::instance(negated_ ? unop::F : unop::G,
|
||||
recurse(f));
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
protected:
|
||||
formula* result_;
|
||||
bool negated_;
|
||||
};
|
||||
void
|
||||
visit(binop* bo)
|
||||
{
|
||||
formula* f1 = bo->first();
|
||||
formula* f2 = bo->second();
|
||||
switch (bo->op())
|
||||
{
|
||||
case binop::Xor:
|
||||
/* !(a ^ b) == a <=> b */
|
||||
result_ = binop::instance(negated_ ? binop::Equiv : binop::Xor,
|
||||
recurse_(f1, false),
|
||||
recurse_(f2, false));
|
||||
return;
|
||||
case binop::Equiv:
|
||||
/* !(a <=> b) == a ^ b */
|
||||
result_ = binop::instance(negated_ ? binop::Xor : binop::Equiv,
|
||||
recurse_(f1, false),
|
||||
recurse_(f2, false));
|
||||
return;
|
||||
case binop::Implies:
|
||||
if (negated_)
|
||||
/* !(a => b) == a & !b */
|
||||
result_ = multop::instance(multop::And,
|
||||
recurse_(f1, false),
|
||||
recurse_(f2, true));
|
||||
else
|
||||
result_ = binop::instance(binop::Implies,
|
||||
recurse(f1), recurse(f2));
|
||||
return;
|
||||
case binop::U:
|
||||
/* !(a U b) == !a R !b */
|
||||
result_ = binop::instance(negated_ ? binop::R : binop::U,
|
||||
recurse(f1), recurse(f2));
|
||||
return;
|
||||
case binop::R:
|
||||
/* !(a R b) == !a U !b */
|
||||
result_ = binop::instance(negated_ ? binop::U : binop::R,
|
||||
recurse(f1), recurse(f2));
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
visit(multop* mo)
|
||||
{
|
||||
/* !(a & b & c) == !a | !b | !c */
|
||||
/* !(a | b | c) == !a & !b & !c */
|
||||
multop::type op = mo->op();
|
||||
if (negated_)
|
||||
switch (op)
|
||||
{
|
||||
case multop::And:
|
||||
op = multop::Or;
|
||||
break;
|
||||
case multop::Or:
|
||||
op = multop::And;
|
||||
break;
|
||||
}
|
||||
multop::vec* res = new multop::vec;
|
||||
unsigned mos = mo->size();
|
||||
for (unsigned i = 0; i < mos; ++i)
|
||||
res->push_back(recurse(mo->nth(i)));
|
||||
result_ = multop::instance(op, res);
|
||||
}
|
||||
|
||||
formula*
|
||||
recurse_(formula* f, bool negated)
|
||||
{
|
||||
return negative_normal_form(f, negated);
|
||||
}
|
||||
|
||||
formula*
|
||||
recurse(formula* f)
|
||||
{
|
||||
return recurse_(f, negated_);
|
||||
}
|
||||
|
||||
protected:
|
||||
formula* result_;
|
||||
bool negated_;
|
||||
};
|
||||
}
|
||||
|
||||
formula*
|
||||
negative_normal_form(const formula* f, bool negated)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue