spot/src/ltlvisit/tunabbrev.cc
Alexandre Duret-Lutz 20c088a45a Speedup some rewriting by detecting cases where they do nothing.
* src/ltlvisit/nenoform.cc, src/ltlvisit/lunabbrev.cc,
src/ltlvisit/simpfg.cc, src/ltlvisit/tunabbrev.cc: Do not recurse
if the formula properties indicate that it is already in the right
form.
2012-04-28 09:30:36 +02:00

81 lines
2.1 KiB
C++

// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// 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 "ltlast/allnodes.hh"
#include "tunabbrev.hh"
namespace spot
{
namespace ltl
{
unabbreviate_ltl_visitor::unabbreviate_ltl_visitor()
{
}
unabbreviate_ltl_visitor::~unabbreviate_ltl_visitor()
{
}
void
unabbreviate_ltl_visitor::visit(unop* uo)
{
switch (uo->op())
{
case unop::Finish:
case unop::X:
case unop::Not:
case unop::Closure:
case unop::NegClosure:
this->super::visit(uo);
return;
case unop::F:
result_ = binop::instance(binop::U,
constant::true_instance(),
recurse(uo->child()));
return;
case unop::G:
result_ = binop::instance(binop::R,
constant::false_instance(),
recurse(uo->child()));
return;
}
}
formula*
unabbreviate_ltl_visitor::recurse(formula* f)
{
return unabbreviate_ltl(f);
}
formula*
unabbreviate_ltl(const formula* f)
{
if (f->is_sugar_free_boolean() && f->is_sugar_free_ltl())
return f->clone();
unabbreviate_ltl_visitor v;
const_cast<formula*>(f)->accept(v);
return v.result();
}
}
}