* bench/Makefile.am, bench/gspn-ssp/Makefile.am, bench/gspn-ssp/defs.in, bench/scc-stats/Makefile.am, bench/split-product/Makefile.am, configure.ac, iface/Makefile.am, iface/gspn/Makefile.am, iface/gspn/ssp.hh, iface/nips/Makefile.am, iface/nips/common.cc, iface/nips/common.hh, iface/nips/dottynips.cc, iface/nips/nips.cc, iface/nips/nips.hh, src/Makefile.am, src/eltlparse/Makefile.am, src/eltlparse/eltlparse.yy, src/eltlparse/eltlscan.ll, src/eltlparse/fmterror.cc, src/eltlparse/parsedecl.hh, src/eltltest/Makefile.am, src/eltltest/defs.in, src/eltltest/nfa.cc, src/evtgba/evtgba.hh, src/evtgba/product.cc, src/evtgba/product.hh, src/evtgbaalgos/tgba2evtgba.cc, src/evtgbaparse/Makefile.am, src/evtgbaparse/evtgbaparse.yy, src/evtgbatest/defs.in, src/evtgbatest/explicit.test, src/evtgbatest/ltl2evtgba.cc, src/evtgbatest/ltl2evtgba.test, src/evtgbatest/product.cc, src/evtgbatest/product.test, src/evtgbatest/readsave.cc, src/evtgbatest/readsave.test, src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh, src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/constant.cc, src/ltlast/constant.hh, src/ltlast/formula.cc, src/ltlast/formula.hh, src/ltlast/formula_tree.cc, src/ltlast/formula_tree.hh, src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/nfa.cc, src/ltlast/nfa.hh, src/ltlast/unop.cc, src/ltlast/unop.hh, src/ltlenv/declenv.cc, src/ltlenv/declenv.hh, src/ltlenv/environment.hh, src/ltlparse/Makefile.am, src/ltlparse/ltlparse.yy, src/ltltest/Makefile.am, src/ltltest/defs.in, src/ltltest/equals.cc, src/ltltest/equals.test, src/ltltest/lunabbrev.test, src/ltltest/nenoform.test, src/ltltest/parse.test, src/ltltest/parseerr.test, src/ltltest/randltl.cc, src/ltltest/readltl.cc, src/ltltest/reduccmp.test, src/ltltest/syntimpl.cc, src/ltltest/syntimpl.test, src/ltltest/tostring.cc, src/ltltest/tostring.test, src/ltltest/tunabbrev.test, src/ltltest/tunenoform.test, src/ltlvisit/basicreduce.cc, src/ltlvisit/clone.cc, src/ltlvisit/clone.hh, src/ltlvisit/contain.cc, src/ltlvisit/destroy.cc, src/ltlvisit/destroy.hh, src/ltlvisit/lunabbrev.cc, src/ltlvisit/nenoform.cc, src/ltlvisit/randomltl.cc, src/ltlvisit/reduce.cc, src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc, src/misc/bddalloc.cc, src/misc/bddop.cc, src/misc/bddop.hh, src/misc/freelist.hh, src/misc/hash.hh, src/misc/minato.cc, src/misc/minato.hh, src/misc/optionmap.cc, src/misc/timer.cc, src/misc/timer.hh, src/saba/Makefile.am, src/saba/explicitstateconjunction.cc, src/saba/explicitstateconjunction.hh, src/saba/saba.cc, src/saba/saba.hh, src/saba/sabacomplementtgba.cc, src/saba/sabacomplementtgba.hh, src/saba/sabastate.hh, src/saba/sabasucciter.hh, src/sabaalgos/Makefile.am, src/sabaalgos/sabadotty.cc, src/sabaalgos/sabadotty.hh, src/sabaalgos/sabareachiter.cc, src/sabaalgos/sabareachiter.hh, src/sabatest/Makefile.am, src/sabatest/defs.in, src/sanity/Makefile.am, src/tgba/Makefile.am, src/tgba/bdddict.cc, src/tgba/bddprint.cc, src/tgba/formula2bdd.cc, src/tgba/state.hh, src/tgba/succiterconcrete.cc, src/tgba/taatgba.hh, src/tgba/tgba.hh, src/tgba/tgbabddconcretefactory.cc, src/tgba/tgbabddconcretefactory.hh, src/tgba/tgbacomplement.cc, src/tgba/tgbacomplement.hh, src/tgba/tgbaexplicit.cc, src/tgba/tgbaexplicit.hh, src/tgba/tgbaproduct.cc, src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh, src/tgba/tgbasafracomplement.cc, src/tgba/tgbasgba.cc, src/tgba/tgbasgba.hh, src/tgba/tgbaunion.cc, src/tgba/tgbaunion.hh, src/tgbaalgos/dupexp.cc, src/tgbaalgos/eltl2tgba_lacim.cc, src/tgbaalgos/eltl2tgba_lacim.hh, src/tgbaalgos/emptiness.cc, src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/ltl2taa.cc, src/tgbaalgos/ltl2taa.hh, src/tgbaalgos/ltl2tgba_lacim.cc, src/tgbaalgos/neverclaim.cc, src/tgbaalgos/neverclaim.hh, src/tgbaalgos/powerset.cc, src/tgbaalgos/reachiter.cc, src/tgbaalgos/reachiter.hh, src/tgbaalgos/reductgba_sim.cc, src/tgbaalgos/reductgba_sim.hh, src/tgbaalgos/reductgba_sim_del.cc, src/tgbaalgos/stats.cc, src/tgbaalgos/stats.hh, src/tgbaparse/Makefile.am, src/tgbaparse/tgbaparse.yy, src/tgbatest/Makefile.am, src/tgbatest/bddprod.test, src/tgbatest/complementation.cc, src/tgbatest/complementation.test, src/tgbatest/defs.in, src/tgbatest/dfs.test, src/tgbatest/dupexp.test, src/tgbatest/explicit.cc, src/tgbatest/explicit.test, src/tgbatest/explpro3.test, src/tgbatest/explpro4.test, src/tgbatest/explprod.cc, src/tgbatest/explprod.test, src/tgbatest/ltl2neverclaim.test, src/tgbatest/ltl2tgba.cc, src/tgbatest/ltl2tgba.test, src/tgbatest/ltlprod.cc, src/tgbatest/ltlprod.test, src/tgbatest/mixprod.cc, src/tgbatest/mixprod.test, src/tgbatest/powerset.cc, src/tgbatest/readsave.cc, src/tgbatest/readsave.test, src/tgbatest/reduccmp.test, src/tgbatest/reductgba.cc, src/tgbatest/reductgba.test, src/tgbatest/taatgba.cc, src/tgbatest/tgbaread.cc, src/tgbatest/tgbaread.test, src/tgbatest/tripprod.cc, src/tgbatest/tripprod.test, wrap/python/cgi/ltl2tgba.in, wrap/python/tests/ltl2tgba.py, wrap/python/tests/ltlparse.py, wrap/python/tests/ltlsimple.py: Fix copyrights.
461 lines
9.4 KiB
C++
461 lines
9.4 KiB
C++
// Copyright (C) 2008 Laboratoire de Recherche et Développement
|
|
// de l'Epita (LRDE).
|
|
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
|
// et Marie Curie.
|
|
//
|
|
// This file is part of Spot, a model checking library.
|
|
//
|
|
// Spot is free software; you can redistribute it and/or modify it
|
|
// under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
// License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Spot; see the file COPYING. If not, write to the Free
|
|
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
// 02111-1307, USA.
|
|
|
|
#include "product.hh"
|
|
#include "misc/hashfunc.hh"
|
|
#include "misc/modgray.hh"
|
|
#include <cstdlib>
|
|
#include <set>
|
|
#include <cstring>
|
|
|
|
namespace spot
|
|
{
|
|
namespace
|
|
{
|
|
class evtgba_product_state: public state
|
|
{
|
|
public:
|
|
evtgba_product_state(state const* const* s, int n)
|
|
: s_(s), n_(n)
|
|
{
|
|
}
|
|
|
|
~evtgba_product_state()
|
|
{
|
|
for (int j = 0; j < n_; ++j)
|
|
delete s_[j];
|
|
delete[] s_;
|
|
}
|
|
|
|
state const*
|
|
nth(int n) const
|
|
{
|
|
assert(n < n_);
|
|
return s_[n];
|
|
}
|
|
|
|
state const* const*
|
|
all() const
|
|
{
|
|
return s_;
|
|
}
|
|
|
|
int
|
|
compare(const state* other) const
|
|
{
|
|
const evtgba_product_state* s =
|
|
dynamic_cast<const evtgba_product_state*>(other);
|
|
assert(s);
|
|
assert(s->n_ == n_);
|
|
for (int i = 0; i < n_; ++i)
|
|
{
|
|
int res = s_[i]->compare(s->nth(i));
|
|
if (res)
|
|
return res;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
size_t
|
|
hash() const
|
|
{
|
|
size_t res = 0;
|
|
for (int i = 0; i != n_; ++i)
|
|
res ^= wang32_hash(s_[i]->hash());
|
|
return res;
|
|
}
|
|
|
|
evtgba_product_state*
|
|
clone() const
|
|
{
|
|
state const** s = new state const*[n_];
|
|
memcpy(s, s_, n_ * sizeof(*s_));
|
|
return new evtgba_product_state(s, n_);
|
|
}
|
|
|
|
|
|
private:
|
|
state const* const* s_;
|
|
int n_;
|
|
};
|
|
|
|
|
|
class evtgba_product_init_iterator:
|
|
public evtgba_iterator, private loopless_modular_mixed_radix_gray_code
|
|
{
|
|
public:
|
|
evtgba_product_init_iterator(evtgba_iterator* const* op, int n)
|
|
: loopless_modular_mixed_radix_gray_code(n), op_(op), n_(n), done_(0)
|
|
{
|
|
for (int j = 0; j < n_; ++j)
|
|
{
|
|
op_[j]->first();
|
|
if (op_[j]->done())
|
|
++done_;
|
|
}
|
|
}
|
|
|
|
~evtgba_product_init_iterator()
|
|
{
|
|
for (int j = 0; j < n_; ++j)
|
|
delete op_[j];
|
|
delete[] op_;
|
|
}
|
|
|
|
virtual void
|
|
first()
|
|
{
|
|
loopless_modular_mixed_radix_gray_code::first();
|
|
step_();
|
|
}
|
|
|
|
virtual void
|
|
next()
|
|
{
|
|
loopless_modular_mixed_radix_gray_code::next();
|
|
step_();
|
|
}
|
|
|
|
virtual bool
|
|
done() const
|
|
{
|
|
return loopless_modular_mixed_radix_gray_code::done();
|
|
}
|
|
|
|
virtual const state*
|
|
current_state() const
|
|
{
|
|
state const** s = new state const*[n_];
|
|
for (int j = 0; j < n_; ++j)
|
|
s[j] = op_[j]->current_state();
|
|
return new evtgba_product_state(s, n_);
|
|
}
|
|
|
|
virtual const symbol*
|
|
current_label() const
|
|
{
|
|
assert(0);
|
|
return 0;
|
|
}
|
|
|
|
virtual symbol_set
|
|
current_acceptance_conditions() const
|
|
{
|
|
assert(0);
|
|
symbol_set s;
|
|
return s;
|
|
}
|
|
|
|
private:
|
|
|
|
void
|
|
pre_update(int j)
|
|
{
|
|
if (op_[j]->done())
|
|
--done_;
|
|
}
|
|
|
|
void
|
|
post_update(int j)
|
|
{
|
|
if (op_[j]->done())
|
|
++done_;
|
|
}
|
|
|
|
virtual void
|
|
a_first(int j)
|
|
{
|
|
pre_update(j);
|
|
op_[j]->first();
|
|
post_update(j);
|
|
}
|
|
|
|
virtual void
|
|
a_next(int j)
|
|
{
|
|
pre_update(j);
|
|
op_[j]->next();
|
|
post_update(j);
|
|
}
|
|
|
|
virtual bool
|
|
a_last(int j) const
|
|
{
|
|
return op_[j]->done();
|
|
}
|
|
|
|
void
|
|
step_()
|
|
{
|
|
while (done_ && !loopless_modular_mixed_radix_gray_code::done())
|
|
loopless_modular_mixed_radix_gray_code::next();
|
|
}
|
|
|
|
evtgba_iterator* const* op_;
|
|
const int n_;
|
|
int done_; // number of iterator for which done() is true.
|
|
};
|
|
|
|
class evtgba_product_iterator:
|
|
public evtgba_iterator, private loopless_modular_mixed_radix_gray_code
|
|
{
|
|
public:
|
|
evtgba_product_iterator(evtgba_iterator* const* op, int n,
|
|
state const* const* from,
|
|
const evtgba_product::common_symbol_table& cst)
|
|
: loopless_modular_mixed_radix_gray_code(n), op_(op), n_(n),
|
|
from_(from), cst_(cst)
|
|
{
|
|
count_pointer_ = new int*[n];
|
|
for (int j = 0; j < n; ++j)
|
|
count_pointer_[j] = 0;
|
|
}
|
|
|
|
virtual
|
|
~evtgba_product_iterator()
|
|
{
|
|
delete[] count_pointer_;
|
|
for (int j = 0; j < n_; ++j)
|
|
delete op_[j];
|
|
delete[] op_;
|
|
}
|
|
|
|
virtual void
|
|
first()
|
|
{
|
|
loopless_modular_mixed_radix_gray_code::first();
|
|
step_();
|
|
}
|
|
|
|
virtual void
|
|
next()
|
|
{
|
|
loopless_modular_mixed_radix_gray_code::next();
|
|
step_();
|
|
}
|
|
|
|
virtual bool
|
|
done() const
|
|
{
|
|
return loopless_modular_mixed_radix_gray_code::done();
|
|
}
|
|
|
|
virtual const state*
|
|
current_state() const
|
|
{
|
|
state const** s = new state const*[n_];
|
|
for (int j = 0; j < n_; ++j)
|
|
{
|
|
if (op_[j]->done())
|
|
s[j] = from_[j]->clone();
|
|
else
|
|
s[j] = op_[j]->current_state();
|
|
}
|
|
return new evtgba_product_state(s, n_);
|
|
}
|
|
|
|
virtual const symbol*
|
|
current_label() const
|
|
{
|
|
return lcm_.begin()->first;
|
|
}
|
|
|
|
virtual symbol_set
|
|
current_acceptance_conditions() const
|
|
{
|
|
symbol_set s;
|
|
for (int j = 0; j < n_; ++j)
|
|
if (!op_[j]->done())
|
|
{
|
|
symbol_set t = op_[j]->current_acceptance_conditions();
|
|
s.insert(t.begin(), t.end());
|
|
}
|
|
return s;
|
|
}
|
|
|
|
private:
|
|
|
|
void
|
|
pre_update(int j)
|
|
{
|
|
if (!--*count_pointer_[j])
|
|
lcm_.erase(op_[j]->current_label());
|
|
count_pointer_[j] = 0;
|
|
}
|
|
|
|
void
|
|
post_update(int j)
|
|
{
|
|
if (!op_[j]->done())
|
|
{
|
|
count_pointer_[j] = &lcm_[op_[j]->current_label()];
|
|
++*count_pointer_[j];
|
|
}
|
|
}
|
|
|
|
virtual void
|
|
a_first(int j)
|
|
{
|
|
if (count_pointer_[j])
|
|
pre_update(j);
|
|
op_[j]->first();
|
|
post_update(j);
|
|
}
|
|
|
|
virtual void
|
|
a_next(int j)
|
|
{
|
|
pre_update(j);
|
|
op_[j]->next();
|
|
post_update(j);
|
|
}
|
|
|
|
virtual bool
|
|
a_last(int j) const
|
|
{
|
|
return op_[j]->done();
|
|
}
|
|
|
|
void
|
|
step_()
|
|
{
|
|
while (!loopless_modular_mixed_radix_gray_code::done())
|
|
{
|
|
if (lcm_.size() == 1)
|
|
{
|
|
const symbol* l = lcm_.begin()->first;
|
|
const std::set<int>& s = cst_.find(l)->second;
|
|
std::set<int>::const_iterator i;
|
|
for (i = s.begin(); i != s.end(); ++i)
|
|
if (op_[*i]->done())
|
|
break;
|
|
if (i == s.end())
|
|
return;
|
|
}
|
|
loopless_modular_mixed_radix_gray_code::next();
|
|
}
|
|
}
|
|
|
|
evtgba_iterator* const* op_;
|
|
int n_;
|
|
state const* const* from_;
|
|
const evtgba_product::common_symbol_table& cst_;
|
|
typedef std::map<const symbol*, int> label_count_map;
|
|
label_count_map lcm_;
|
|
int** count_pointer_;
|
|
};
|
|
|
|
} // anonymous
|
|
|
|
|
|
evtgba_product::evtgba_product(const evtgba_product_operands& op)
|
|
: op_(op)
|
|
{
|
|
int n = 0;
|
|
for (evtgba_product_operands::const_iterator i = op.begin();
|
|
i != op.end(); ++i, ++n)
|
|
{
|
|
const symbol_set& al = (*i)->alphabet();
|
|
alphabet_.insert(al.begin(), al.end());
|
|
const symbol_set& ac = (*i)->all_acceptance_conditions();
|
|
all_acc_.insert(ac.begin(), ac.end());
|
|
|
|
for (symbol_set::const_iterator j = al.begin(); j != al.end(); ++j)
|
|
common_symbols_[*j].insert(n);
|
|
}
|
|
}
|
|
|
|
evtgba_product::~evtgba_product()
|
|
{
|
|
}
|
|
|
|
evtgba_iterator*
|
|
evtgba_product::init_iter() const
|
|
{
|
|
int n = op_.size();
|
|
evtgba_iterator** it = new evtgba_iterator *[n];
|
|
for (int i = 0; i < n; ++i)
|
|
it[i] = op_[i]->init_iter();
|
|
|
|
return new evtgba_product_init_iterator(it, n);
|
|
}
|
|
|
|
evtgba_iterator*
|
|
evtgba_product::succ_iter(const state* st) const
|
|
{
|
|
const evtgba_product_state* s =
|
|
dynamic_cast<const evtgba_product_state*>(st);
|
|
assert(s);
|
|
|
|
int n = op_.size();
|
|
|
|
evtgba_iterator** it = new evtgba_iterator *[n];
|
|
for (int i = 0; i < n; ++i)
|
|
it[i] = op_[i]->succ_iter(s->nth(i));
|
|
|
|
return new evtgba_product_iterator(it, n, s->all(), common_symbols_);
|
|
}
|
|
|
|
evtgba_iterator*
|
|
evtgba_product::pred_iter(const state* st) const
|
|
{
|
|
const evtgba_product_state* s =
|
|
dynamic_cast<const evtgba_product_state*>(st);
|
|
assert(s);
|
|
|
|
int n = op_.size();
|
|
|
|
evtgba_iterator** it = new evtgba_iterator *[n];
|
|
for (int i = 0; i < n; ++i)
|
|
it[i] = op_[i]->pred_iter(s->nth(i));
|
|
|
|
return new evtgba_product_iterator(it, n, s->all(), common_symbols_);
|
|
}
|
|
|
|
std::string
|
|
evtgba_product::format_state(const state* st) const
|
|
{
|
|
const evtgba_product_state* s =
|
|
dynamic_cast<const evtgba_product_state*>(st);
|
|
int n = op_.size();
|
|
std::string res = "<" + op_[0]->format_state(s->nth(0));
|
|
|
|
for (int i = 1; i < n; ++i)
|
|
res = res + ", " + op_[i]->format_state(s->nth(i));
|
|
|
|
return res + ">";
|
|
}
|
|
|
|
const symbol_set&
|
|
evtgba_product::all_acceptance_conditions() const
|
|
{
|
|
return all_acc_;
|
|
}
|
|
|
|
const symbol_set&
|
|
evtgba_product::alphabet() const
|
|
{
|
|
return alphabet_;
|
|
}
|
|
|
|
}
|