ltl_simplifier: add a boolean_to_isop option and method

* src/ltlvisit/simplify.hh (ltl_simplifier_options): add
a boolean_to_isop option
(ltl_simplifier::boolean_to_isop): New method.
* src/ltlvisit/simplify.cc: Implement these.
* src/bin/ltlfilt.cc: Add a --boolean-to-isop option.
* src/ltltest/isop.test: New file.
* src/ltltest/Makefile.am: Add it.
* NEWS: Mention it.
This commit is contained in:
Alexandre Duret-Lutz 2013-03-05 23:23:45 +01:00
parent c17f3b8656
commit c6406995fb
6 changed files with 139 additions and 12 deletions

View file

@ -32,6 +32,7 @@
#include "ltlvisit/contain.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/snf.hh"
#include "tgba/formula2bdd.hh"
#include <cassert>
namespace spot
@ -105,6 +106,16 @@ namespace spot
old->first->destroy();
}
}
{
f2f_map::iterator i = bool_isop_.begin();
f2f_map::iterator end = bool_isop_.end();
while (i != end)
{
f2f_map::iterator old = i++;
old->second->destroy();
old->first->destroy();
}
}
dict->unregister_all_my_variables(this);
}
@ -127,7 +138,8 @@ namespace spot
<< "negative normal form: " << nenoform_.size() << " entries\n"
<< "syntactic implications: " << syntimpl_.size() << " entries\n"
<< "boolean to bdd: " << as_bdd_.size() << " entries\n"
<< "star normal form: " << snf_cache_.size() << " entries\n";
<< "star normal form: " << snf_cache_.size() << " entries\n"
<< "boolean isop: " << bool_isop_.size() << " entries\n";
}
void
@ -374,12 +386,26 @@ namespace spot
return ltl::star_normal_form(f, &snf_cache_);
}
const formula*
boolean_to_isop(const formula* f)
{
f2f_map::const_iterator it = bool_isop_.find(f);
if (it != bool_isop_.end())
return it->second->clone();
assert(f->is_boolean());
const formula* res = bdd_to_formula(as_bdd(f), dict);
bool_isop_[f->clone()] = res->clone();
return res;
}
private:
f2b_map as_bdd_;
f2f_map simplified_;
f2f_map nenoform_;
syntimpl_cache_t syntimpl_;
snf_cache snf_cache_;
f2f_map bool_isop_;
};
@ -3976,9 +4002,16 @@ namespace spot
trace << " miss" << std::endl;
}
simplify_visitor v(c);
f->accept(v);
result = v.result();
if (f->is_boolean() && c->options.boolean_to_isop)
{
result = c->boolean_to_isop(f);
}
else
{
simplify_visitor v(c);
f->accept(v);
result = v.result();
}
trace << "** simplify_recursively(" << to_string(f) << ") result: "
<< to_string(result) << std::endl;
@ -4459,6 +4492,12 @@ namespace spot
return cache_->star_normal_form(f);
}
const formula*
ltl_simplifier::boolean_to_isop(const formula* f)
{
return cache_->boolean_to_isop(f);
}
bdd_dict*
ltl_simplifier::get_dict() const
{
@ -4477,6 +4516,5 @@ namespace spot
cache_->clear_as_bdd_cache();
cache_->lcc.clear();
}
}
}

View file

@ -1,5 +1,5 @@
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE).
// Copyright (C) 2011, 2012, 2013 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -37,14 +37,16 @@ namespace spot
bool containment_checks = false,
bool containment_checks_stronger = false,
bool nenoform_stop_on_boolean = false,
bool reduce_size_strictly = false)
bool reduce_size_strictly = false,
bool boolean_to_isop = false)
: reduce_basics(basics),
synt_impl(synt_impl),
event_univ(event_univ),
containment_checks(containment_checks),
containment_checks_stronger(containment_checks_stronger),
nenoform_stop_on_boolean(nenoform_stop_on_boolean),
reduce_size_strictly(reduce_size_strictly)
reduce_size_strictly(reduce_size_strictly),
boolean_to_isop(boolean_to_isop)
{
}
@ -60,6 +62,8 @@ namespace spot
// will be disabled. Those larger formulae are normally easier
// to translate, so we recommend to set this to false.
bool reduce_size_strictly;
// If true, Boolean subformulae will be rewritten in ISOP form.
bool boolean_to_isop;
};
// fwd declaration to hide technical details.
@ -154,6 +158,13 @@ namespace spot
/// Cached version of spot::ltl::star_normal_form().
const formula* star_normal_form(const formula* f);
/// \brief Rewrite a Boolean formula \a f into as an irredundant
/// sum of product.
///
/// This uses a cache, so it is OK to call this with identical
/// arguments.
const formula* boolean_to_isop(const formula* f);
/// Dump statistics about the caches.
void print_stats(std::ostream& os) const;