Downcase a couple of misnamed class names.

* src/misc/acccompl.hh, src/misc/acccompl.cc (AccCompl): Rename to
acc_compl.
* src/tgbaalgos/simulation.cc (AccComplAutomaton, Simulation): Rename
to acc_compl_automaton and direct_simulation.  At the same time,
reindent the whole file.
* src/sanity/style.test: Detect capitalized class names.
* src/kripke/kripkeexplicit.hh (KripkePrint): Remove useless
predeclaration.
* src/tgbaalgos/simulation.hh: Typo in comment.
This commit is contained in:
Alexandre Duret-Lutz 2012-05-02 17:57:38 +02:00
parent dadfbdad9d
commit db4693b303
6 changed files with 329 additions and 326 deletions

View file

@ -1,4 +1,5 @@
// Copyright (C) 2011 Laboratoire de Recherche et Developpement // -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE) // de l'Epita (LRDE)
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
@ -29,10 +30,7 @@
namespace spot namespace spot
{ {
// Define in kripkeprint.hh /// \brief Concrete class for kripke states.
class KripkeVisitor;
/// \brief Concrete class for kripke states.
class state_kripke : public state class state_kripke : public state
{ {
friend class kripke_explicit; friend class kripke_explicit;

View file

@ -34,7 +34,7 @@ namespace spot
// we need to know wich one is go to one when true. So we are looping // we need to know wich one is go to one when true. So we are looping
// through the conditions until bdd_high is true. // through the conditions until bdd_high is true.
// Once found, we keep only it. // Once found, we keep only it.
bdd AccCompl::complement(const bdd acc) bdd acc_compl::complement(const bdd acc)
{ {
bdd_cache_t::const_iterator it = cache_.find(acc); bdd_cache_t::const_iterator it = cache_.find(acc);
if (it != cache_.end()) if (it != cache_.end())
@ -70,7 +70,7 @@ namespace spot
} }
bdd AccCompl::reverse_complement(const bdd acc) bdd acc_compl::reverse_complement(const bdd acc)
{ {
// We are sure that if we have no acceptance condition // We are sure that if we have no acceptance condition
// the result is all_. // the result is all_.

View file

@ -30,14 +30,14 @@
namespace spot namespace spot
{ {
/// \brief Help class to convert a bdd of an automaton into /// \brief Helper class to convert acceptance conditions into promises
/// its complement. ///
/// This is used when you need to complement all the acceptance /// A set of acceptance conditions represented by the sum "à la Spot",
/// conditions in an automaton. For example in the simulation. /// is converted into a product of promises.
class AccCompl class acc_compl
{ {
public: public:
AccCompl(bdd all, bdd neg) acc_compl(bdd all, bdd neg)
: all_(all), : all_(all),
neg_(neg) neg_(neg)
{ {

View file

@ -67,6 +67,9 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do
case $file in case $file in
*.test);; *.test);;
*) *)
grep -E '[^<]class[ \t]+[A-Z]' $tmp &&
diag 'Use lower case class names.'
grep '[ ]if(' $tmp && grep '[ ]if(' $tmp &&
diag 'Missing space after "if"' diag 'Missing space after "if"'

View file

@ -60,7 +60,7 @@
// state. This function is `update_sig'. // state. This function is `update_sig'.
// - Enter in a double loop to adapt the partial order, and set // - Enter in a double loop to adapt the partial order, and set
// 'relation_' accordingly. This function is `update_po'. // 'relation_' accordingly. This function is `update_po'.
// 3. Rename the class (to actualize the name in the previous_it_class and // 3. Rename the class (to actualize the name in the previous_class and
// in relation_). // in relation_).
// 4. Building an automaton with the result, with the condition: // 4. Building an automaton with the result, with the condition:
// "a transition in the original automaton appears in the simulated one // "a transition in the original automaton appears in the simulated one
@ -101,11 +101,11 @@ namespace spot
// This class takes an automaton and creates a copy with all // This class takes an automaton and creates a copy with all
// acceptance conditions complemented. // acceptance conditions complemented.
class AccComplAutomaton: class acc_compl_automaton:
public tgba_reachable_iterator_depth_first public tgba_reachable_iterator_depth_first
{ {
public: public:
AccComplAutomaton(const tgba* a) acc_compl_automaton(const tgba* a)
: tgba_reachable_iterator_depth_first(a), : tgba_reachable_iterator_depth_first(a),
size(0), size(0),
out_(new tgba_explicit_number(a->get_dict())), out_(new tgba_explicit_number(a->get_dict())),
@ -124,7 +124,7 @@ namespace spot
if (state2int.find(s) == state2int.end()) if (state2int.find(s) == state2int.end())
{ {
state2int[s] = ++current_max; state2int[s] = ++current_max;
previous_it_class_[out_->add_state(current_max)] = bddfalse; previous_class_[out_->add_state(current_max)] = bddfalse;
} }
return state2int[s]; return state2int[s];
@ -155,7 +155,7 @@ namespace spot
++size; ++size;
} }
~AccComplAutomaton() ~acc_compl_automaton()
{ {
init_->destroy(); init_->destroy();
} }
@ -163,28 +163,28 @@ namespace spot
public: public:
size_t size; size_t size;
tgba_explicit_number* out_; tgba_explicit_number* out_;
map_state_bdd previous_it_class_; map_state_bdd previous_class_;
private: private:
const tgba* ea_; const tgba* ea_;
AccCompl ac_; acc_compl ac_;
map_state_unsigned state2int; map_state_unsigned state2int;
unsigned current_max; unsigned current_max;
state* init_; state* init_;
}; };
class Simulation class direct_simulation
{ {
// Shortcut used in update_po and go_to_next_it. // Shortcut used in update_po and go_to_next_it.
typedef std::map<bdd, bdd, bdd_less_than> map_bdd_bdd; typedef std::map<bdd, bdd, bdd_less_than> map_bdd_bdd;
public: public:
Simulation(const tgba* t) direct_simulation(const tgba* t)
: a_(0), : a_(0),
po_size_(0), po_size_(0),
all_class_var_(bddtrue) all_class_var_(bddtrue)
{ {
AccComplAutomaton acc_compl_automaton
acc_compl(t); acc_compl(t);
// We'll start our work by replacing all the acceptance // We'll start our work by replacing all the acceptance
@ -195,7 +195,7 @@ namespace spot
// We use the previous run to know the size of the // We use the previous run to know the size of the
// automaton, and to class all the reachable states in the // automaton, and to class all the reachable states in the
// map previous_it_class_. // map previous_class_.
size_a_ = acc_compl.size; size_a_ = acc_compl.size;
// Now, we have to get the bdd which will represent the // Now, we have to get the bdd which will represent the
@ -211,15 +211,15 @@ namespace spot
used_var_.push_back(init); used_var_.push_back(init);
all_class_var_ = init; all_class_var_ = init;
// We fetch the result the run of AccComplAutomaton which // We fetch the result the run of acc_compl_automaton which
// has recorded all the state in a hash table, and we set all // has recorded all the state in a hash table, and we set all
// to init. // to init.
for (map_state_bdd::iterator it for (map_state_bdd::iterator it
= acc_compl.previous_it_class_.begin(); = acc_compl.previous_class_.begin();
it != acc_compl.previous_it_class_.end(); it != acc_compl.previous_class_.end();
++it) ++it)
{ {
previous_it_class_[it->first] = init; previous_class_[it->first] = init;
} }
// Put all the anonymous variable in a queue, and record all // Put all the anonymous variable in a queue, and record all
@ -239,19 +239,19 @@ namespace spot
// Reverse all the acceptance condition at the destruction of // Reverse all the acceptance condition at the destruction of
// this object, because it occurs after the return of the // this object, because it occurs after the return of the
// function simulation. // function simulation.
~Simulation() ~direct_simulation()
{ {
delete a_; delete a_;
} }
// We update the name of the class. // We update the name of the class.
void update_previous_it_class() void update_previous_class()
{ {
std::list<bdd>::iterator it_bdd = used_var_.begin(); std::list<bdd>::iterator it_bdd = used_var_.begin();
// We run through the map bdd/list<state>, and we update // We run through the map bdd/list<state>, and we update
// the previous_it_class_ with the new data. // the previous_class_ with the new data.
it_bdd = used_var_.begin(); it_bdd = used_var_.begin();
for (map_bdd_lstate::iterator it = bdd_lstate_.begin(); for (map_bdd_lstate::iterator it = bdd_lstate_.begin();
it != bdd_lstate_.end(); it != bdd_lstate_.end();
@ -268,9 +268,9 @@ namespace spot
// by removing a transition which has as a destination a // by removing a transition which has as a destination a
// state with no outgoing transition. // state with no outgoing transition.
if (it->first == bddfalse) if (it->first == bddfalse)
previous_it_class_[*it_s] = bddfalse; previous_class_[*it_s] = bddfalse;
else else
previous_it_class_[*it_s] = *it_bdd; previous_class_[*it_s] = *it_bdd;
} }
++it_bdd; ++it_bdd;
} }
@ -284,7 +284,7 @@ namespace spot
while (nb_partition_before != bdd_lstate_.size() while (nb_partition_before != bdd_lstate_.size()
|| nb_po_before != po_size_) || nb_po_before != po_size_)
{ {
update_previous_it_class(); update_previous_class();
nb_partition_before = bdd_lstate_.size(); nb_partition_before = bdd_lstate_.size();
bdd_lstate_.clear(); bdd_lstate_.clear();
nb_po_before = po_size_; nb_po_before = po_size_;
@ -293,7 +293,7 @@ namespace spot
go_to_next_it(); go_to_next_it();
} }
update_previous_it_class(); update_previous_class();
return build_result(); return build_result();
} }
@ -312,7 +312,7 @@ namespace spot
// the label of the transition and the class of the // the label of the transition and the class of the
// destination and all the class it implies. // destination and all the class it implies.
bdd to_add = acc & sit->current_condition() bdd to_add = acc & sit->current_condition()
& relation_[previous_it_class_[dst]]; & relation_[previous_class_[dst]];
res |= to_add; res |= to_add;
dst->destroy(); dst->destroy();
@ -325,16 +325,16 @@ namespace spot
void update_sig() void update_sig()
{ {
// At this time, current_class_ must be empty. It implies // At this time, current_class_ must be empty. It implies
// that the "previous_it_class_ = current_class_" must be // that the "previous_class_ = current_class_" must be
// done before. // done before.
assert(current_class_.empty()); assert(current_class_.empty());
// Here we suppose that previous_it_class_ always contains // Here we suppose that previous_class_ always contains
// all the reachable states of this automaton. We do not // all the reachable states of this automaton. We do not
// have to make (again) a traversal. We just have to run // have to make (again) a traversal. We just have to run
// through this map. // through this map.
for (map_state_bdd::iterator it = previous_it_class_.begin(); for (map_state_bdd::iterator it = previous_class_.begin();
it != previous_it_class_.end(); it != previous_class_.end();
++it) ++it)
{ {
const state* src = it->first; const state* src = it->first;
@ -388,7 +388,7 @@ namespace spot
update_po(now_to_next); update_po(now_to_next);
} }
// This function computes the new po with previous_it_class_ // This function computes the new po with previous_class_
// and the argument. `now_to_next' contains the relation // and the argument. `now_to_next' contains the relation
// between the signature and the future name of the class. // between the signature and the future name of the class.
void update_po(const map_bdd_bdd& now_to_next) void update_po(const map_bdd_bdd& now_to_next)
@ -445,7 +445,7 @@ namespace spot
// transition. We *must* keep the complemented because it // transition. We *must* keep the complemented because it
// is easy to know if an acceptance condition is maximal or // is easy to know if an acceptance condition is maximal or
// not. // not.
AccCompl reverser(all_acceptance_conditions, acc_compl reverser(all_acceptance_conditions,
a_->neg_acceptance_conditions()); a_->neg_acceptance_conditions());
typedef tgba_explicit_number::transition trs; typedef tgba_explicit_number::transition trs;
@ -463,7 +463,7 @@ namespace spot
it != bdd_lstate_.end(); ++it) it != bdd_lstate_.end(); ++it)
{ {
res->add_state(++current_max); res->add_state(++current_max);
bdd part = previous_it_class_[*it->second.begin()]; bdd part = previous_class_[*it->second.begin()];
// The difference between the two next lines is: // The difference between the two next lines is:
// the first says "if you see A", the second "if you // the first says "if you see A", the second "if you
@ -523,21 +523,23 @@ namespace spot
bdd acc = bdd_existcomp(cond_acc_dest, sup_all_acc); bdd acc = bdd_existcomp(cond_acc_dest, sup_all_acc);
// Keep the other ! // Keep the other !
bdd cond = bdd_existcomp(cond_acc_dest, sup_all_atomic_prop); bdd cond = bdd_existcomp(cond_acc_dest,
sup_all_atomic_prop);
// Because we have complemented all the acceptance condition // Because we have complemented all the acceptance
// on the input automaton, we must re invert them to create // condition on the input automaton, we must re
// a new transition. // invert them to create a new transition.
acc = reverser.reverse_complement(acc); acc = reverser.reverse_complement(acc);
// Take the id of the source and destination. // Take the id of the source and destination. To
// To know the source, we must take a random state in the // know the source, we must take a random state in
// list which is in the class we currently work on. // the list which is in the class we currently
int src = bdd2state[previous_it_class_[*it->second.begin()]]; // work on.
int src = bdd2state[previous_class_[*it->second.begin()]];
int dst = bdd2state[dest]; int dst = bdd2state[dest];
// src or dst == 0 means "dest" or "prev..." isn't in the map. // src or dst == 0 means "dest" or "prev..." isn't
// so it is a bug. // in the map. so it is a bug.
assert(src != 0); assert(src != 0);
assert(dst != 0); assert(dst != 0);
@ -551,7 +553,7 @@ namespace spot
} }
} }
res->set_init_state(bdd2state[previous_it_class_ res->set_init_state(bdd2state[previous_class_
[a_->get_init_state()]]); [a_->get_init_state()]]);
res->merge_transitions(); res->merge_transitions();
return res; return res;
@ -583,8 +585,8 @@ namespace spot
std::cerr << "\nPrevious iteration\n" << std::endl; std::cerr << "\nPrevious iteration\n" << std::endl;
for (map_state_bdd::const_iterator it = previous_it_class_.begin(); for (map_state_bdd::const_iterator it = previous_class_.begin();
it != previous_it_class_.end(); it != previous_class_.end();
++it) ++it)
{ {
std::cerr << a_->format_state(it->first) std::cerr << a_->format_state(it->first)
@ -607,7 +609,7 @@ namespace spot
map_bdd_bdd relation_; map_bdd_bdd relation_;
// Represent the class of each state at the previous iteration. // Represent the class of each state at the previous iteration.
map_state_bdd previous_it_class_; map_state_bdd previous_class_;
// The class at the current iteration. // The class at the current iteration.
map_state_bdd current_class_; map_state_bdd current_class_;
@ -638,7 +640,7 @@ namespace spot
tgba* tgba*
simulation(const tgba* t) simulation(const tgba* t)
{ {
Simulation simul(t); direct_simulation simul(t);
return simul.run(); return simul.run();
} }

View file

@ -35,7 +35,7 @@ namespace spot
/// When the language recognized by one state is included in the /// When the language recognized by one state is included in the
/// language recognized by an another one, the first one is merged /// language recognized by an another one, the first one is merged
/// with the second. The algorithm is based on the following /// with the second. The algorithm is based on the following
/// paper, but generalized to handled TGBA directly. /// paper, but generalized to handle TGBA directly.
/// ///
/// \verbatim /// \verbatim
/// @InProceedings{ etessami.00.concur, /// @InProceedings{ etessami.00.concur,