of these accepting set so that they are really usable. Provide a all_accepting_conditions() method for use in the emptyness check, and a neg_accepting_conditions() for products. Predeclare TGBA accepting conditions is the i/o. * src/tgba/bddprint.cc (want_prom): Rename as ... (want_prom): ... this. (print_handler): Adjust to display Acc[]. (print_acc_handler, bdd_print_acc): New functions. * src/tgba/bddprint.hh (print_acc_handler, bdd_print_acc): New functions. * src/tgba/succiter.hh (current_promise): Rename as ... (current_accepting_conditions): ... this. * src/tgba/succiterconcrete.cc (current_state): Rename next to now. (current_promise): Rename as ... (current_accepting_conditions): ... this, and compute the accepting conditions. * src/tgba/dictunion.cc, src/tgba/ltl2tgba.cc, src/tgba/succiterconcrete.hh, src/tgba/tgbabddconcretefactory.cc, src/tgba/tgbabddcoredata.cc, src/tgba/tgbabddcoredata.hh, src/tgba/tgbabdddict.hh, src/tgba/tgbabdddict.cc, src/tgba/tgbabddtranslatefactory.cc, src/tgbaalgos/dotty.cc: Adjust to new names. * src/tgba/tgba.hh (all_accepting_conditions, neg_accepting_conditions): New functions. * src/tgba/tgbabddconcretefactory.cc: Adjust to new names, and record accepting conditions instead of promises. * src/tgba/tgbabddcoredata.hh (accepting_conditions, all_accepting_conditions, negacc_set): New variables. (notnow_set, notprom_set, declare_promise): Rename as ... (notnext_set, notacc_set, declare_accepting_condition): ... these. * src/tgba/tgbaexplicit.hh (tgba_explicit_succ_iterator::current_promise): Rename as ... (tgba_explicit_succ_iterator::current_accepting_conditions): ... this. (tgba_explicit::add_promise): Rename as ... (tgba_explicit::add_accepting_condition): ... this. (tgba_explicit::declare_accepting_condition, tgba_explicit::has_accepting_condition): New variables. (tgba_explicit::get_promise): Rename as ... (tgba_explicit::get_accepting_condition): ... this. (tgba_explicit::all_accepting_conditions, tgba_explicit::neg_accepting_conditions): Implement them. (all_accepting_conditions, neg_accepting_conditions, all_accepting_conditions): New variables. (tgba_explicit_succ_iterator): Embed all_accepting_conditions_. * src/tgba/tgbaexplicit.cc: Likewise. * src/tgba/tgbaproduct.hh (tgba_product_succ_uterator): Embed left_neg_ and right_neg_. (tgba_product::all_accepting_conditions, tgba_product::neg_accepting_conditions): Implement them. * src/tgba/tgbatranslateproxy.hh: (tgba_translate_proxy::all_accepting_conditions, tgba_translate_proxy::neg_accepting_conditions): Implement them. * src/tgba/tgbatranslateproxy.cc: Likewise. * src/tgbaalgos/save.cc (save_rec): Call bdd_print (tgba_save_reachable): Output the `acc =' line. * src/tgbaparse/tgbaparse.yy: Support the for accepting conditions definitions using an "acc =" line at the start. Later, use has_accepting_condition while parsing accepting conditions to ensure they were declared. Disallow !cond in accepting conditions. * src/tgbaparse/tgbascan.ll (ACC_DEF): New token. * src/tgbatest/explicit.cc (main): Declare accepting conditions. * src/tgbatest/ltl2tgba.cc (main): Add support for the -a, -A, and -R new options. * src/tgbatest/tgbaread.cc (main): Really exit on parse error. * src/tgbatest/explicit.test, src/tgbatest/explprod.test, src/tgbatest/mixprod.test, src/tgbatest/readsave.test, src/tgbatest/tgbaread.test, src/tgbatest/tripprod.test: Reflect recent changes.
122 lines
3 KiB
C++
122 lines
3 KiB
C++
#include "ltlvisit/clone.hh"
|
|
#include "ltlvisit/destroy.hh"
|
|
#include "tgbabddconcretefactory.hh"
|
|
namespace spot
|
|
{
|
|
tgba_bdd_concrete_factory::~tgba_bdd_concrete_factory()
|
|
{
|
|
acc_map_::iterator ai;
|
|
for (ai = acc_.begin(); ai != acc_.end(); ++ai)
|
|
destroy(ai->first);
|
|
}
|
|
|
|
int
|
|
tgba_bdd_concrete_factory::create_state(const ltl::formula* f)
|
|
{
|
|
// Do not build a state that already exists.
|
|
tgba_bdd_dict::fv_map::iterator sii = dict_.now_map.find(f);
|
|
if (sii != dict_.now_map.end())
|
|
return sii->second;
|
|
|
|
f = clone(f);
|
|
|
|
int num = create_pair();
|
|
dict_.now_map[f] = num;
|
|
dict_.now_formula_map[num] = f;
|
|
|
|
// Record that num+1 should be renamed as num when
|
|
// the next state becomes current.
|
|
bdd_setpair(data_.next_to_now, num + 1, num);
|
|
|
|
// Keep track of all "Now" variables for easy
|
|
// existential quantification.
|
|
data_.declare_now_next (ithvar(num), ithvar(num + 1));
|
|
return num;
|
|
}
|
|
|
|
int
|
|
tgba_bdd_concrete_factory::create_atomic_prop(const ltl::formula* f)
|
|
{
|
|
// Do not build a variable that already exists.
|
|
tgba_bdd_dict::fv_map::iterator sii = dict_.var_map.find(f);
|
|
if (sii != dict_.var_map.end())
|
|
return sii->second;
|
|
|
|
f = clone(f);
|
|
|
|
int num = create_node();
|
|
dict_.var_map[f] = num;
|
|
dict_.var_formula_map[num] = f;
|
|
|
|
// Keep track of all atomic proposition for easy
|
|
// existential quantification.
|
|
data_.declare_atomic_prop(ithvar(num));
|
|
return num;
|
|
}
|
|
|
|
void
|
|
tgba_bdd_concrete_factory::declare_accepting_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 accepting condition.
|
|
int a = create_node();
|
|
const ltl::formula* f = clone(ai->first); // The associated formula.
|
|
dict_.acc_map[f] = a;
|
|
dict_.acc_formula_map[a] = f;
|
|
bdd acc = ithvar(a);
|
|
// Keep track of all accepting conditions for easy
|
|
// existential quantification.
|
|
data_.declare_accepting_condition(acc);
|
|
}
|
|
for (ai = acc_.begin(); ai != acc_.end(); ++ai)
|
|
{
|
|
bdd acc = ithvar(dict_.acc_map[ai->first]);
|
|
|
|
// Complete acc with all the other accepting conditions negated.
|
|
acc &= bdd_exist(data_.negacc_set, acc);
|
|
|
|
// Any state matching the BDD formulae registered is part
|
|
// of this accepting set.
|
|
data_.accepting_conditions |= ai->second & acc;
|
|
}
|
|
}
|
|
|
|
const tgba_bdd_core_data&
|
|
tgba_bdd_concrete_factory::get_core_data() const
|
|
{
|
|
return data_;
|
|
}
|
|
|
|
const tgba_bdd_dict&
|
|
tgba_bdd_concrete_factory::get_dict() const
|
|
{
|
|
return dict_;
|
|
}
|
|
|
|
void
|
|
tgba_bdd_concrete_factory::add_relation(bdd new_rel)
|
|
{
|
|
data_.relation &= new_rel;
|
|
}
|
|
}
|