Start the ELTL translation (LACIM).
Merge all eltlast/ files into formula.hh (except automatop.hh).
This commit is contained in:
parent
862302590c
commit
8c0d1003b0
55 changed files with 2000 additions and 422 deletions
|
|
@ -31,6 +31,7 @@ tgbaalgos_HEADERS = \
|
|||
dotty.hh \
|
||||
dottydec.hh \
|
||||
dupexp.hh \
|
||||
eltl2tgba_lacim.hh \
|
||||
emptiness.hh \
|
||||
emptiness_stats.hh \
|
||||
gv04.hh \
|
||||
|
|
@ -60,6 +61,7 @@ libtgbaalgos_la_SOURCES = \
|
|||
dotty.cc \
|
||||
dottydec.cc \
|
||||
dupexp.cc \
|
||||
eltl2tgba_lacim.cc \
|
||||
emptiness.cc \
|
||||
gv04.cc \
|
||||
lbtt.cc \
|
||||
|
|
|
|||
188
src/tgbaalgos/eltl2tgba_lacim.cc
Normal file
188
src/tgbaalgos/eltl2tgba_lacim.cc
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
// Copyright (C) 2008 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 "eltlast/formula.hh"
|
||||
#include "eltlvisit/lunabbrev.hh"
|
||||
#include "eltlvisit/nenoform.hh"
|
||||
#include "eltlvisit/destroy.hh"
|
||||
#include "tgba/tgbabddconcretefactory.hh"
|
||||
#include <cassert>
|
||||
|
||||
#include "eltl2tgba_lacim.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace
|
||||
{
|
||||
using namespace eltl;
|
||||
|
||||
/// \brief Recursively translate a formula into a BDD.
|
||||
class eltl_trad_visitor: public const_visitor
|
||||
{
|
||||
public:
|
||||
eltl_trad_visitor(tgba_bdd_concrete_factory& fact, bool root = false)
|
||||
: fact_(fact), root_(root)
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~eltl_trad_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
bdd
|
||||
result()
|
||||
{
|
||||
return res_;
|
||||
}
|
||||
|
||||
void
|
||||
visit(const atomic_prop* node)
|
||||
{
|
||||
res_ = bdd_ithvar(fact_.create_atomic_prop(node));
|
||||
}
|
||||
|
||||
void
|
||||
visit(const constant* node)
|
||||
{
|
||||
switch (node->val())
|
||||
{
|
||||
case constant::True:
|
||||
res_ = bddtrue;
|
||||
return;
|
||||
case constant::False:
|
||||
res_ = bddfalse;
|
||||
return;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
visit(const unop* node)
|
||||
{
|
||||
switch (node->op())
|
||||
{
|
||||
case unop::Not:
|
||||
{
|
||||
res_ = bdd_not(recurse(node->child()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
/* Unreachable code. */
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
visit(const multop* node)
|
||||
{
|
||||
int op = -1;
|
||||
bool root = false;
|
||||
switch (node->op())
|
||||
{
|
||||
case multop::And:
|
||||
op = bddop_and;
|
||||
res_ = bddtrue;
|
||||
// When the root formula is a conjunction it's ok to
|
||||
// consider all children as root formulae. This allows the
|
||||
// root-G trick to save many more variable. (See the
|
||||
// translation of G.)
|
||||
root = root_;
|
||||
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), root), op);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
visit (const automatop* node)
|
||||
{
|
||||
// FIXME.
|
||||
(void) node;
|
||||
}
|
||||
|
||||
bdd
|
||||
recurse(const formula* f, bool root = false)
|
||||
{
|
||||
eltl_trad_visitor v(fact_, root);
|
||||
f->accept(v);
|
||||
return v.result();
|
||||
}
|
||||
|
||||
private:
|
||||
bdd res_;
|
||||
tgba_bdd_concrete_factory& fact_;
|
||||
bool root_;
|
||||
};
|
||||
} // anonymous
|
||||
|
||||
tgba_bdd_concrete*
|
||||
eltl_to_tgba_lacim(const eltl::formula* f, bdd_dict* dict)
|
||||
{
|
||||
// Normalize the formula. We want all the negations on
|
||||
// the atomic propositions. We also suppress logic
|
||||
// abbreviations such as <=>, =>, or XOR, since they
|
||||
// would involve negations at the BDD level.
|
||||
const eltl::formula* f1 = eltl::unabbreviate_logic(f);
|
||||
const eltl::formula* f2 = eltl::negative_normal_form(f1);
|
||||
eltl::destroy(f1);
|
||||
|
||||
// Traverse the formula and draft the automaton in a factory.
|
||||
tgba_bdd_concrete_factory fact(dict);
|
||||
eltl_trad_visitor v(fact, true);
|
||||
f2->accept(v);
|
||||
eltl::destroy(f2);
|
||||
fact.finish();
|
||||
|
||||
// Finally setup the resulting automaton.
|
||||
return new tgba_bdd_concrete(fact, v.result());
|
||||
}
|
||||
}
|
||||
55
src/tgbaalgos/eltl2tgba_lacim.hh
Normal file
55
src/tgbaalgos/eltl2tgba_lacim.hh
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (C) 2008 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.
|
||||
|
||||
#ifndef SPOT_TGBAALGOS_ELTL2TGBA_LACIM_HH
|
||||
# define SPOT_TGBAALGOS_ELTL2TGBA_LACIM_HH
|
||||
|
||||
#include "eltlast/formula.hh"
|
||||
#include "tgba/tgbabddconcrete.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
/// \brief Build a spot::tgba_bdd_concrete from an ELTL formula.
|
||||
/// \ingroup tgba_eltl
|
||||
///
|
||||
/// This is based on the following paper.
|
||||
/// \verbatim
|
||||
/// @InProceedings{ couvreur.00.lacim,
|
||||
/// author = {Jean-Michel Couvreur},
|
||||
/// title = {Un point de vue symbolique sur la logique temporelle
|
||||
/// lin{\'e}aire},
|
||||
/// booktitle = {Actes du Colloque LaCIM 2000},
|
||||
/// month = {August},
|
||||
/// year = {2000},
|
||||
/// pages = {131--140},
|
||||
/// volume = {27},
|
||||
/// series = {Publications du LaCIM},
|
||||
/// publisher = {Universit{\'e} du Qu{\'e}bec {\`a} Montr{\'e}al},
|
||||
/// editor = {Pierre Leroux}
|
||||
/// }
|
||||
/// \endverbatim
|
||||
/// \param f The formula to translate into an automaton.
|
||||
/// \param dict The spot::bdd_dict the constructed automata should use.
|
||||
/// \return A spot::tgba_bdd_concrete that recognizes the language of \a f.
|
||||
tgba_bdd_concrete* eltl_to_tgba_lacim(const eltl::formula* f, bdd_dict* dict);
|
||||
}
|
||||
|
||||
#endif // SPOT_TGBAALGOS_LTL2TGBA_LACIM_HH
|
||||
|
|
@ -64,7 +64,7 @@ namespace spot
|
|||
{
|
||||
fv_map::iterator i;
|
||||
for (i = next_map.begin(); i != next_map.end(); ++i)
|
||||
destroy(i->first);
|
||||
destroy(dynamic_cast<const ltl::formula*>(i->first));
|
||||
dict->unregister_all_my_variables(this);
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ namespace spot
|
|||
for (fi = next_map.begin(); fi != next_map.end(); ++fi)
|
||||
{
|
||||
os << " " << fi->second << ": Next[";
|
||||
to_string(fi->first, os) << "]" << std::endl;
|
||||
fi->first->to_string(os) << "]" << std::endl;
|
||||
}
|
||||
os << "Shared Dict:" << std::endl;
|
||||
dict->dump(os);
|
||||
|
|
@ -137,13 +137,13 @@ namespace spot
|
|||
{
|
||||
vf_map::const_iterator isi = next_formula_map.find(var);
|
||||
if (isi != next_formula_map.end())
|
||||
return clone(isi->second);
|
||||
return dynamic_cast<ltl::formula*>(isi->second->clone());
|
||||
isi = dict->acc_formula_map.find(var);
|
||||
if (isi != dict->acc_formula_map.end())
|
||||
return clone(isi->second);
|
||||
return dynamic_cast<ltl::formula*>(isi->second->clone());
|
||||
isi = dict->var_formula_map.find(var);
|
||||
if (isi != dict->var_formula_map.end())
|
||||
return clone(isi->second);
|
||||
return dynamic_cast<ltl::formula*>(isi->second->clone());
|
||||
assert(0);
|
||||
// Never reached, but some GCC versions complain about
|
||||
// a missing return otherwise.
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace spot
|
|||
bdd_dict::vf_map::const_iterator vi =
|
||||
d->acc_formula_map.find(v);
|
||||
assert(vi != d->acc_formula_map.end());
|
||||
std::string s = ltl::to_string(vi->second);
|
||||
std::string s = vi->second->to_string();
|
||||
if (dynamic_cast<const ltl::atomic_prop*>(vi->second)
|
||||
&& s[0] == '"')
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue