* src/ltlvisit/basereduc.cc (spot): Correct some mistakes.

* src/ltlvisit/lunabbrev.cc (spot): Nothing change.
* src/tgbatest/ltl2tgba.cc (main): More option to reduce
formula.
* src/tgbatest/spotlbtt.test: One more test.
This commit is contained in:
martinez 2004-05-14 12:55:13 +00:00
parent 35ef738ff9
commit 9db2b31484
5 changed files with 80 additions and 95 deletions

View file

@ -89,8 +89,8 @@ namespace spot
/* X(f1 | GF(f2)) = X(f1) | GF(F2) */
if (node_type(result_) == (node_type_form_visitor::Multop)) {
if (dynamic_cast<multop*>(result_)->size() == 2) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(0)) ||
is_FG(dynamic_cast<multop*>(result_)->nth(0))) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(0))) {
//|| is_FG(dynamic_cast<multop*>(result_)->nth(0))) {
multop::vec* res = new multop::vec;
res->push_back(unop::instance(unop::F, basic_reduce_form(dynamic_cast<multop*>(result_)->nth(1))));
res->push_back(basic_reduce_form(dynamic_cast<multop*>(result_)->nth(0)));
@ -99,8 +99,8 @@ namespace spot
spot::ltl::destroy(f);
return;
}
if (is_GF(dynamic_cast<multop*>(result_)->nth(1)) ||
is_FG(dynamic_cast<multop*>(result_)->nth(1))) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(1))) {
//|| is_FG(dynamic_cast<multop*>(result_)->nth(1))) {
multop::vec* res = new multop::vec;
res->push_back(unop::instance(unop::F, basic_reduce_form(dynamic_cast<multop*>(result_)->nth(0))));
res->push_back(basic_reduce_form(dynamic_cast<multop*>(result_)->nth(1)));
@ -137,8 +137,8 @@ namespace spot
if (node_type(result_) == (node_type_form_visitor::Multop)) {
if (dynamic_cast<multop*>(result_)->op() == multop::And) {
if (dynamic_cast<multop*>(result_)->size() == 2) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(0)) ||
is_FG(dynamic_cast<multop*>(result_)->nth(0))) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(0))) {
//|| is_FG(dynamic_cast<multop*>(result_)->nth(0))) {
multop::vec* res = new multop::vec;
res->push_back(unop::instance(unop::F, basic_reduce_form(dynamic_cast<multop*>(result_)->nth(1))));
res->push_back(basic_reduce_form(dynamic_cast<multop*>(result_)->nth(0)));
@ -146,8 +146,8 @@ namespace spot
result_ = multop::instance(multop::And, res);
return;
}
if (is_GF(dynamic_cast<multop*>(result_)->nth(1)) ||
is_FG(dynamic_cast<multop*>(result_)->nth(1))) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(1))) {
//|| is_FG(dynamic_cast<multop*>(result_)->nth(1))) {
multop::vec* res = new multop::vec;
res->push_back(unop::instance(unop::F, basic_reduce_form(dynamic_cast<multop*>(result_)->nth(0))));
res->push_back(basic_reduce_form(dynamic_cast<multop*>(result_)->nth(1)));
@ -193,8 +193,8 @@ namespace spot
if (node_type(result_) == (node_type_form_visitor::Multop)) {
if (dynamic_cast<multop*>(f)->op() == multop::Or) {
if (dynamic_cast<multop*>(result_)->size() == 2) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(0)) ||
is_FG(dynamic_cast<multop*>(result_)->nth(0))) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(0))) {
//|| is_FG(dynamic_cast<multop*>(result_)->nth(0))) {
multop::vec* res = new multop::vec;
res->push_back(unop::instance(unop::G, basic_reduce_form(dynamic_cast<multop*>(result_)->nth(1))));
res->push_back(basic_reduce_form(dynamic_cast<multop*>(result_)->nth(0)));
@ -202,8 +202,8 @@ namespace spot
result_ = multop::instance(multop::Or, res);
return;
}
if (is_GF(dynamic_cast<multop*>(result_)->nth(1)) ||
is_FG(dynamic_cast<multop*>(result_)->nth(1))) {
if (is_GF(dynamic_cast<multop*>(result_)->nth(1))) {
//|| is_FG(dynamic_cast<multop*>(result_)->nth(1))) {
multop::vec* res = new multop::vec;
res->push_back(unop::instance(unop::G, basic_reduce_form(dynamic_cast<multop*>(result_)->nth(0))));
res->push_back(basic_reduce_form(dynamic_cast<multop*>(result_)->nth(1)));
@ -450,7 +450,7 @@ namespace spot
break;
}
/* GF(a) & GF(b) = GF(a & b)*/
/* GF(a) | GF(b) = GF(a | b)*/
if (is_GF(*i)) {
tmpGF->push_back(spot::ltl::basic_reduce_form(dynamic_cast<unop*>(dynamic_cast<unop*>(*i)->child())->child()));
break;
@ -553,8 +553,8 @@ namespace spot
multop::instance(mo->op(),tmpGF))));
if (tmpFG != NULL)
if (tmpFG->size())
tmpOther->push_back(unop::instance(unop::G,
unop::instance(unop::F,
tmpOther->push_back(unop::instance(unop::F,
unop::instance(unop::G,
multop::instance(mo->op(),tmpFG))));
result_ = multop::instance(op, tmpOther);

View file

@ -22,58 +22,14 @@
#include "ltlast/allnodes.hh"
#include "ltlvisit/clone.hh"
#include "lunabbrev.hh"
//#include "reducform.hh"
#include "reducform.hh"
#include <cassert>
namespace spot
{
namespace ltl
{
class node_type_form_visitor : public const_visitor
{
public:
enum type { Atom, Const, Unop, Binop, Multop };
node_type_form_visitor(){}
type
result() const { return result_;}
void
visit(const atomic_prop* ap){
if (ap == NULL);
result_ = node_type_form_visitor::Atom;
}
void
visit(const constant* c){
if (c == NULL);
result_ = node_type_form_visitor::Const;
}
void
visit(const unop* uo){
if (uo == NULL);
result_ = node_type_form_visitor::Unop;
}
void
visit(const binop* bo){
if (bo == NULL);
result_ = node_type_form_visitor::Binop;
}
void
visit(const multop* mo){
if (mo == NULL);
result_ = node_type_form_visitor::Multop;
}
protected:
type result_;
};
unabbreviate_logic_visitor::unabbreviate_logic_visitor()
{
}
@ -82,37 +38,11 @@ namespace spot
{
}
/*
void
unabbreviate_logic_visitor::visit(unop* uo)
{
formula* f = uo->child();
switch (uo->op())
{
case unop::Not:
case unop::X:
result_ = unop::instance(uo->op(),recurse(f));
return;
case unop::F:
result_ = binop::instance(binop::U,constant::true_instance(),recurse(f));
return;
case unop::G:
result_ = binop::instance(binop::R,constant::false_instance(),recurse(f));
return;
}
// Unreachable code.
assert(0);
}
*/
void
unabbreviate_logic_visitor::visit(binop* bo)
{
formula* f1 = recurse(bo->first());
formula* f2 = recurse(bo->second());
node_type_form_visitor v;
const_cast<formula*>(f1)->accept(v);
switch (bo->op())
{
@ -145,7 +75,7 @@ namespace spot
/* true U f2 == F(f2) */
case binop::U:
if ( v.result() == node_type_form_visitor::Const )
if ( node_type(f1) == node_type_form_visitor::Const )
if ( ((constant*)f1)->val() == constant::True ) {
result_ = unop::instance(unop::F,f2);
return;
@ -155,7 +85,7 @@ namespace spot
/* false R f2 == G(f2) */
case binop::R:
if ( v.result() == node_type_form_visitor::Const )
if ( node_type(f1) == node_type_form_visitor::Const )
if ( ((constant*)f1)->val() == constant::False ) {
result_ = unop::instance(unop::G,f2);
return;