* 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:
Alexandre Duret-Lutz 2004-10-18 13:56:31 +00:00
parent 5176caf4d2
commit 7d27fd3796
28 changed files with 3128 additions and 3025 deletions

View file

@ -1,4 +1,4 @@
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
@ -30,125 +30,161 @@ namespace spot
{
using namespace ltl;
class formula_to_bdd_visitor : public ltl::const_visitor
namespace
{
public:
formula_to_bdd_visitor(bdd_dict* d, void* owner)
: d_(d), owner_(owner)
class formula_to_bdd_visitor: public ltl::const_visitor
{
}
public:
formula_to_bdd_visitor(bdd_dict* d, void* owner)
: d_(d), owner_(owner)
{
}
virtual
~formula_to_bdd_visitor()
{
}
virtual
~formula_to_bdd_visitor()
{
}
virtual void
visit(const atomic_prop* node)
{
res_ = bdd_ithvar(d_->register_proposition(node, owner_));
}
virtual void
visit(const atomic_prop* node)
{
res_ = bdd_ithvar(d_->register_proposition(node, owner_));
}
virtual void
visit(const constant* node)
{
switch (node->val())
{
case constant::True:
res_ = bddtrue;
return;
case constant::False:
res_ = bddfalse;
return;
}
/* Unreachable code. */
assert(0);
}
virtual void
visit(const unop* node)
{
switch (node->op())
{
case unop::F:
case unop::G:
case unop::X:
assert(!"unsupported operator");
case unop::Not:
virtual void
visit(const constant* node)
{
switch (node->val())
{
res_ = bdd_not(recurse(node->child()));
case constant::True:
res_ = bddtrue;
return;
case constant::False:
res_ = bddfalse;
return;
}
}
/* Unreachable code. */
assert(0);
}
/* Unreachable code. */
assert(0);
}
virtual void
visit(const binop* node)
virtual void
visit(const unop* node)
{
switch (node->op())
{
case unop::F:
case unop::G:
case unop::X:
assert(!"unsupported operator");
case unop::Not:
{
res_ = bdd_not(recurse(node->child()));
return;
}
}
/* Unreachable code. */
assert(0);
}
virtual void
visit(const binop* node)
{
bdd f1 = recurse(node->first());
bdd f2 = recurse(node->second());
switch (node->op())
{
case binop::Xor:
res_ = bdd_apply(f1, f2, bddop_xor);
return;
case binop::Implies:
res_ = bdd_apply(f1, f2, bddop_imp);
return;
case binop::Equiv:
res_ = bdd_apply(f1, f2, bddop_biimp);
return;
case binop::U:
case binop::R:
assert(!"unsupported operator");
}
/* Unreachable code. */
assert(0);
}
virtual void
visit(const multop* node)
{
int op = -1;
switch (node->op())
{
case multop::And:
op = bddop_and;
res_ = bddtrue;
break;
case multop::Or:
op = bddop_or;
res_ = bddfalse;
break;
}
assert(op != -1);
unsigned s = node->size();
for (unsigned n = 0; n < s; ++n)
{
res_ = bdd_apply(res_, recurse(node->nth(n)), op);
}
}
bdd
result() const
{
return res_;
}
bdd
recurse(const formula* f) const
{
return formula_to_bdd(f, d_, owner_);
}
private:
bdd_dict* d_;
void* owner_;
bdd res_;
};
// Convert a BDD which is known to be a conjonction into a formula.
static ltl::formula*
conj_to_formula(bdd b, const bdd_dict* d)
{
bdd f1 = recurse(node->first());
bdd f2 = recurse(node->second());
switch (node->op())
if (b == bddfalse)
return constant::false_instance();
multop::vec* v = new multop::vec;
while (b != bddtrue)
{
case binop::Xor:
res_ = bdd_apply(f1, f2, bddop_xor);
return;
case binop::Implies:
res_ = bdd_apply(f1, f2, bddop_imp);
return;
case binop::Equiv:
res_ = bdd_apply(f1, f2, bddop_biimp);
return;
case binop::U:
case binop::R:
assert(!"unsupported operator");
int var = bdd_var(b);
bdd_dict::vf_map::const_iterator isi = d->var_formula_map.find(var);
assert(isi != d->var_formula_map.end());
formula* res = clone(isi->second);
bdd high = bdd_high(b);
if (high == bddfalse)
{
res = unop::instance(unop::Not, res);
b = bdd_low(b);
}
else
{
// If bdd_low is not false, then b was not a conjunction.
assert(bdd_low(b) == bddfalse);
b = high;
}
assert(b != bddfalse);
v->push_back(res);
}
/* Unreachable code. */
assert(0);
return multop::instance(multop::And, v);
}
virtual void
visit(const multop* node)
{
int op = -1;
switch (node->op())
{
case multop::And:
op = bddop_and;
res_ = bddtrue;
break;
case multop::Or:
op = bddop_or;
res_ = bddfalse;
break;
}
assert(op != -1);
unsigned s = node->size();
for (unsigned n = 0; n < s; ++n)
{
res_ = bdd_apply(res_, recurse(node->nth(n)), op);
}
}
bdd
result() const
{
return res_;
}
bdd
recurse(const formula* f) const
{
return formula_to_bdd(f, d_, owner_);
}
private:
bdd_dict* d_;
void* owner_;
bdd res_;
};
} // anonymous
bdd
formula_to_bdd(const formula* f, bdd_dict* d, void* for_me)
@ -158,38 +194,6 @@ namespace spot
return v.result();
}
// Convert a BDD which is known to be a conjonction into a formula.
static ltl::formula*
conj_to_formula(bdd b, const bdd_dict* d)
{
if (b == bddfalse)
return constant::false_instance();
multop::vec* v = new multop::vec;
while (b != bddtrue)
{
int var = bdd_var(b);
bdd_dict::vf_map::const_iterator isi = d->var_formula_map.find(var);
assert(isi != d->var_formula_map.end());
formula* res = clone(isi->second);
bdd high = bdd_high(b);
if (high == bddfalse)
{
res = unop::instance(unop::Not, res);
b = bdd_low(b);
}
else
{
// If bdd_low is not false, then b was not a conjunction.
assert(bdd_low(b) == bddfalse);
b = high;
}
assert(b != bddfalse);
v->push_back(res);
}
return multop::instance(multop::And, v);
}
const formula*
bdd_to_formula(bdd f, const bdd_dict* d)
{

View file

@ -1,4 +1,4 @@
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
@ -24,55 +24,58 @@
namespace spot
{
/// \brief Helper class for product().
///
/// As both automata are encoded using BDD, we just have
/// to homogenize the variable numbers before ANDing the
/// relations and initial states.
class tgba_bdd_product_factory: public tgba_bdd_factory
namespace
{
public:
tgba_bdd_product_factory(const tgba_bdd_concrete* left,
const tgba_bdd_concrete* right)
: dict_(left->get_dict()),
left_(left),
right_(right),
data_(left_->get_core_data(), right_->get_core_data()),
init_(left_->get_init_bdd() & right_->get_init_bdd())
/// \brief Helper class for product().
///
/// As both automata are encoded using BDD, we just have
/// to homogenize the variable numbers before ANDing the
/// relations and initial states.
class tgba_bdd_product_factory: public tgba_bdd_factory
{
assert(dict_ == right->get_dict());
}
public:
tgba_bdd_product_factory(const tgba_bdd_concrete* left,
const tgba_bdd_concrete* right)
: dict_(left->get_dict()),
left_(left),
right_(right),
data_(left_->get_core_data(), right_->get_core_data()),
init_(left_->get_init_bdd() & right_->get_init_bdd())
{
assert(dict_ == right->get_dict());
}
virtual
~tgba_bdd_product_factory()
{
}
virtual
~tgba_bdd_product_factory()
{
}
const tgba_bdd_core_data&
get_core_data() const
{
return data_;
}
const tgba_bdd_core_data&
get_core_data() const
{
return data_;
}
bdd_dict*
get_dict() const
{
return dict_;
}
bdd_dict*
get_dict() const
{
return dict_;
}
bdd
get_init_state() const
{
return init_;
}
bdd
get_init_state() const
{
return init_;
}
private:
bdd_dict* dict_;
const tgba_bdd_concrete* left_;
const tgba_bdd_concrete* right_;
tgba_bdd_core_data data_;
bdd init_;
};
private:
bdd_dict* dict_;
const tgba_bdd_concrete* left_;
const tgba_bdd_concrete* right_;
tgba_bdd_core_data data_;
bdd init_;
};
}
tgba_bdd_concrete*
product(const tgba_bdd_concrete* left, const tgba_bdd_concrete* right)

View file

@ -39,8 +39,12 @@ namespace spot
typedef Sgi::vector<state_couple*> delayed_simulation_relation;
*/
class direct_simulation_relation : public simulation_relation{};
class delayed_simulation_relation : public simulation_relation{};
class direct_simulation_relation: public simulation_relation
{
};
class delayed_simulation_relation: public simulation_relation
{
};
class tgba_reduc: public tgba_explicit,

View file

@ -26,171 +26,174 @@
namespace spot
{
/// \brief A state for spot::tgba_tba_proxy.
///
/// This state is in fact a pair of state: the state from the tgba
/// automaton, and a state of the "counter" (we use a pointer
/// to the position in the cycle_acc_ list).
class state_tba_proxy : public state
namespace
{
typedef tgba_tba_proxy::cycle_list::const_iterator iterator;
public:
state_tba_proxy(state* s, iterator acc)
: s_(s), acc_(acc)
/// \brief A state for spot::tgba_tba_proxy.
///
/// This state is in fact a pair of state: the state from the tgba
/// automaton, and a state of the "counter" (we use a pointer
/// to the position in the cycle_acc_ list).
class state_tba_proxy: public state
{
}
typedef tgba_tba_proxy::cycle_list::const_iterator iterator;
public:
state_tba_proxy(state* s, iterator acc)
: s_(s), acc_(acc)
{
}
/// Copy constructor
state_tba_proxy(const state_tba_proxy& o)
: state(),
s_(o.real_state()->clone()),
acc_(o.acceptance_iterator())
/// Copy constructor
state_tba_proxy(const state_tba_proxy& o)
: state(),
s_(o.real_state()->clone()),
acc_(o.acceptance_iterator())
{
}
virtual
~state_tba_proxy()
{
delete s_;
}
state*
real_state() const
{
return s_;
}
bdd
acceptance_cond() const
{
return *acc_;
}
iterator
acceptance_iterator() const
{
return acc_;
}
virtual int
compare(const state* other) const
{
const state_tba_proxy* o = dynamic_cast<const state_tba_proxy*>(other);
assert(o);
int res = s_->compare(o->real_state());
if (res != 0)
return res;
return acc_->id() - o->acceptance_cond().id();
}
virtual size_t
hash() const
{
// We expect to have many more states than acceptance conditions.
// Hence we keep only 8 bits for acceptance conditions.
return (s_->hash() << 8) + (acc_->id() & 0xFF);
}
virtual
state_tba_proxy* clone() const
{
return new state_tba_proxy(*this);
}
private:
state* s_;
iterator acc_;
};
/// \brief Iterate over the successors of tgba_tba_proxy computed
/// on the fly.
class tgba_tba_proxy_succ_iterator: public tgba_succ_iterator
{
}
typedef tgba_tba_proxy::cycle_list list;
typedef tgba_tba_proxy::cycle_list::const_iterator iterator;
public:
tgba_tba_proxy_succ_iterator(tgba_succ_iterator* it,
iterator expected, iterator end,
bdd the_acceptance_cond)
: it_(it), expected_(expected), end_(end),
the_acceptance_cond_(the_acceptance_cond)
{
}
virtual
~state_tba_proxy()
{
delete s_;
}
virtual
~tgba_tba_proxy_succ_iterator()
{
delete it_;
}
state*
real_state() const
{
return s_;
}
// iteration
bdd
acceptance_cond() const
{
return *acc_;
}
void
first()
{
it_->first();
}
iterator
acceptance_iterator() const
{
return acc_;
}
void
next()
{
it_->next();
}
virtual int
compare(const state* other) const
{
const state_tba_proxy* o = dynamic_cast<const state_tba_proxy*>(other);
assert(o);
int res = s_->compare(o->real_state());
if (res != 0)
return res;
return acc_->id() - o->acceptance_cond().id();
}
bool
done() const
{
return it_->done();
}
virtual size_t
hash() const
{
// We expect to have many more states than acceptance conditions.
// Hence we keep only 8 bits for acceptance conditions.
return (s_->hash() << 8) + (acc_->id() & 0xFF);
}
// inspection
virtual
state_tba_proxy* clone() const
{
return new state_tba_proxy(*this);
}
state_tba_proxy*
current_state() const
{
// A transition in the *EXPECTED acceptance set should be directed
// to the next acceptance set. If the current transition is also
// in the next acceptance set, then go the one after, etc.
//
// See Denis Oddoux's PhD thesis for a nice explanation (in French).
// @PhDThesis{ oddoux.03.phd,
// author = {Denis Oddoux},
// title = {Utilisation des automates alternants pour un
// model-checking efficace des logiques temporelles
// lin{\'e}aires.},
// school = {Universit{\'e}e Paris 7},
// year = {2003},
// address = {Paris, France},
// month = {December}
// }
//
iterator next = expected_;
bdd acc = it_->current_acceptance_conditions();
while ((acc & *next) == *next && next != end_)
++next;
return new state_tba_proxy(it_->current_state(), next);
}
private:
state* s_;
iterator acc_;
};
bdd
current_condition() const
{
return it_->current_condition();
}
bdd
current_acceptance_conditions() const
{
return the_acceptance_cond_;
}
/// \brief Iterate over the successors of tgba_tba_proxy computed on the fly.
class tgba_tba_proxy_succ_iterator: public tgba_succ_iterator
{
typedef tgba_tba_proxy::cycle_list list;
typedef tgba_tba_proxy::cycle_list::const_iterator iterator;
public:
tgba_tba_proxy_succ_iterator(tgba_succ_iterator* it,
iterator expected, iterator end,
bdd the_acceptance_cond)
: it_(it), expected_(expected), end_(end),
the_acceptance_cond_(the_acceptance_cond)
{
}
virtual
~tgba_tba_proxy_succ_iterator()
{
delete it_;
}
// iteration
void
first()
{
it_->first();
}
void
next()
{
it_->next();
}
bool
done() const
{
return it_->done();
}
// inspection
state_tba_proxy*
current_state() const
{
// A transition in the *EXPECTED acceptance set should be directed
// to the next acceptance set. If the current transition is also
// in the next acceptance set, then go the one after, etc.
//
// See Denis Oddoux's PhD thesis for a nice explanation (in French).
// @PhDThesis{ oddoux.03.phd,
// author = {Denis Oddoux},
// title = {Utilisation des automates alternants pour un
// model-checking efficace des logiques temporelles
// lin{\'e}aires.},
// school = {Universit{\'e}e Paris 7},
// year = {2003},
// address = {Paris, France},
// month = {December}
// }
//
iterator next = expected_;
bdd acc = it_->current_acceptance_conditions();
while ((acc & *next) == *next && next != end_)
++next;
return new state_tba_proxy(it_->current_state(), next);
}
bdd
current_condition() const
{
return it_->current_condition();
}
bdd
current_acceptance_conditions() const
{
return the_acceptance_cond_;
}
protected:
tgba_succ_iterator* it_;
const iterator expected_;
const iterator end_;
const bdd the_acceptance_cond_;
};
protected:
tgba_succ_iterator* it_;
const iterator expected_;
const iterator end_;
const bdd the_acceptance_cond_;
};
} // anonymous
tgba_tba_proxy::tgba_tba_proxy(const tgba* a)
: a_(a)