spot/src/tgba/tgbabddconcretefactory.cc
Damien Lefortier 2fbcd7e52f Add support for ELTL (AST & parser), and an adaptation of LaCIM
for ELTL.  This is a new version of the work started in 2008 with
LTL and ELTL formulae now sharing the same class hierarchy.

* configure.ac: Adjust for src/eltlparse/ and src/eltltest/
directories, and call AX_BOOST_BASE.
* m4/boost.m4: New file defining AX_BOOST_BASE([MINIMUM-VERSION]).
* src/Makefile.am: Add eltlparse and eltltest.
* src/eltlparse/: New directory.  Contains the ELTL parser.
* src/eltltest/: New directory.  Contains tests related to
ELTL (parser and AST).
* src/ltlast/Makefile.am: Adjust for ELTL AST files.
* src/ltlast/automatop.cc, src/ltlast/automatop.hh: New files.
Represent automaton operators nodes used in ELTL ASTs.
* src/ltlast/nfa.cc, src/ltlast/nfa.hh: New files.  Represent
simple NFAs used internally by automatop nodes.
* src/ltlast/allnode.hh, src/ltlast/predecl.hh,
src/ltlast/visitor.hh: Adjust for automatop.
* src/ltlvisit/basicreduce.cc, src/ltlvisit/clone.cc,
src/ltlvisit/clone.hh, src/ltlvisit/contain.cc,
src/ltlvisit/dotty.cc, src/ltlvisit/nenoform.cc,
src/ltlvisit/postfix.cc, src/ltlvisit/postfix.hh,
src/ltlvisit/reduce.cc, src/ltlvisit/syntimpl.cc,
src/ltlvisit/tostring.cc: Because LTL and ELTL formulae share the
same class hierarchy, LTL visitors need to handle automatop nodes
to compile.  When it's meaningful the visitor applies on automatop
nodes or simply assert(0) otherwise.
* src/tgba/tgbabddconcretefactory.cc (create_anonymous_state),
src/tgba/tgbabddconcretefactory.hh (create_anonymous_state): New
function used by the LaCIM translation algorithm for ELTL.
* src/tgbaalgos/Makefile.am: Adjust for eltl2tgba_lacim* files.
* src/tgbaalgos/eltl2tgba_lacim.cc,
src/tgbaalgos/eltl2tgba_lacim.hh: New files.  Implementation of
the LaCIM translation algorithm for ELTL.
* src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_lacim.cc:
Handle automatop nodes in the translation by an assert(0).
* src/tgbatest/Makefile.am: Adjust for eltl2tgba.* files.
* src/src/tgbatest/eltl2tgba.cc, src/tgbatest/eltl2tgba.test: New
files
2009-03-26 12:05:08 +01:00

147 lines
4.5 KiB
C++

// Copyright (C) 2003 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 "ltlvisit/clone.hh"
#include "ltlvisit/destroy.hh"
#include "tgbabddconcretefactory.hh"
namespace spot
{
tgba_bdd_concrete_factory::tgba_bdd_concrete_factory(bdd_dict* dict)
: data_(dict)
{
}
tgba_bdd_concrete_factory::~tgba_bdd_concrete_factory()
{
acc_map_::iterator ai;
for (ai = acc_.begin(); ai != acc_.end(); ++ai)
destroy(ai->first);
get_dict()->unregister_all_my_variables(this);
}
int
tgba_bdd_concrete_factory::create_state(const ltl::formula* f)
{
int num = get_dict()->register_state(f, this);
// Keep track of all "Now" variables for easy
// existential quantification.
data_.declare_now_next (bdd_ithvar(num), bdd_ithvar(num + 1));
return num;
}
int
tgba_bdd_concrete_factory::create_anonymous_state()
{
int num = get_dict()->register_anonymous_variables(2, this);
bdd_setpair(get_dict()->next_to_now, num + 1, num);
bdd_setpair(get_dict()->now_to_next, num, num + 1);
// Keep track of all "Now" variables for easy
// existential quantification.
data_.declare_now_next (bdd_ithvar(num), bdd_ithvar(num + 1));
return num;
}
int
tgba_bdd_concrete_factory::create_atomic_prop(const ltl::formula* f)
{
int num = get_dict()->register_proposition(f, this);
// Keep track of all atomic proposition for easy
// existential quantification.
data_.declare_atomic_prop(bdd_ithvar(num));
return num;
}
void
tgba_bdd_concrete_factory::declare_acceptance_condition(bdd b,
const ltl::formula* a)
{
// Maintain a conjunction of BDDs associated to A. We will latter
// (in tgba_bdd_concrete_factory::finish()) associate this
// conjunction to A.
acc_map_::iterator ai = acc_.find(a);
if (ai == acc_.end())
{
a = clone(a);
acc_[a] = b;
}
else
{
ai->second &= b;
}
}
void
tgba_bdd_concrete_factory::finish()
{
acc_map_::iterator ai;
for (ai = acc_.begin(); ai != acc_.end(); ++ai)
{
// Register a BDD variable for this acceptance condition.
int num = get_dict()->register_acceptance_variable(ai->first, this);
// Keep track of all acceptance conditions for easy
// existential quantification.
data_.declare_acceptance_condition(bdd_ithvar(num));
}
for (ai = acc_.begin(); ai != acc_.end(); ++ai)
{
bdd acc = bdd_ithvar(get_dict()->acc_map[ai->first]);
// Complete acc with all the other acceptance conditions negated.
acc &= bdd_exist(data_.negacc_set, acc);
// Any state matching the BDD formulae registered is part
// of this acceptance set.
data_.acceptance_conditions |= ai->second & acc;
// Keep track of all acceptance conditions, so that we can
// easily check whether a transition satisfies all acceptance
// conditions.
data_.all_acceptance_conditions |= acc;
}
// Any constraint between Now variables also exist between Next
// variables. Doing this limits the quantity of useless
// successors we will have to explore. (By "useless successors"
// I mean a combination of Next variables that represent a cul de sac
// state: the combination exists but won't allow further exploration
// because it fails the constraints.)
data_.relation &= bdd_replace(bdd_exist(data_.relation, data_.notnow_set),
get_dict()->now_to_next);
}
const tgba_bdd_core_data&
tgba_bdd_concrete_factory::get_core_data() const
{
return data_;
}
bdd_dict*
tgba_bdd_concrete_factory::get_dict() const
{
return data_.dict;
}
void
tgba_bdd_concrete_factory::constrain_relation(bdd new_rel)
{
data_.relation &= new_rel;
}
}