* src/ltlast/binop.cc, src/ltlast/binop.cc: Add support for these new operators. * src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll: Parse them. * src/ltltest/reduccmp.test: Add new tests for W and M. * src/ltlvisit/basicreduce.cc, src/ltlvisit/contain.cc, src/ltlvisit/lunabbrev.cc, src/ltlvisit/nenoform.cc, src/ltlvisit/randomltl.cc, src/ltlvisit/randomltl.hh, src/ltlvisit/reduce.cc, src/ltlvisite/simpfg.cc, src/ltlvisit/simpfg.hh, src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc, src/tgba/formula2bdd.cc, src/tgbaalgos/eltl2tgba_lacim.cc, src/tgbaalgos/ltl2taa.cc, src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_lacim.cc: Add support for W and M. * src/tgbatest/ltl2neverclaim.test: Test never claim output using LBTT, this is more thorough. Also we cannot use -N any more in the spotlbtt.test. * src/tgbatests/ltl2tgba.cc: Define M and W for ELTL. * src/tgbatest/ltl2neverclaim.test: Test W and M, and use -DS instead of -N, because lbtt-translate does not want to translate these operators for tools that masquerade as Spin.
189 lines
3.8 KiB
C++
189 lines
3.8 KiB
C++
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
|
// de l'Epita (LRDE).
|
|
// Copyright (C) 2003, 2005 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 <cassert>
|
|
#include <utility>
|
|
#include "binop.hh"
|
|
#include "visitor.hh"
|
|
#include <iostream>
|
|
|
|
namespace spot
|
|
{
|
|
namespace ltl
|
|
{
|
|
binop::binop(type op, formula* first, formula* second)
|
|
: op_(op), first_(first), second_(second)
|
|
{
|
|
}
|
|
|
|
binop::~binop()
|
|
{
|
|
// Get this instance out of the instance map.
|
|
pairf pf(first(), second());
|
|
pair p(op(), pf);
|
|
map::iterator i = instances.find(p);
|
|
assert (i != instances.end());
|
|
instances.erase(i);
|
|
|
|
// Dereference children.
|
|
first()->destroy();
|
|
second()->destroy();
|
|
}
|
|
|
|
std::string
|
|
binop::dump() const
|
|
{
|
|
return (std::string("binop(") + op_name()
|
|
+ ", " + first()->dump()
|
|
+ ", " + second()->dump() + ")");
|
|
}
|
|
|
|
void
|
|
binop::accept(visitor& v)
|
|
{
|
|
v.visit(this);
|
|
}
|
|
|
|
void
|
|
binop::accept(const_visitor& v) const
|
|
{
|
|
v.visit(this);
|
|
}
|
|
|
|
const formula*
|
|
binop::first() const
|
|
{
|
|
return first_;
|
|
}
|
|
|
|
formula*
|
|
binop::first()
|
|
{
|
|
return first_;
|
|
}
|
|
|
|
const formula*
|
|
binop::second() const
|
|
{
|
|
return second_;
|
|
}
|
|
|
|
formula*
|
|
binop::second()
|
|
{
|
|
return second_;
|
|
}
|
|
|
|
binop::type
|
|
binop::op() const
|
|
{
|
|
return op_;
|
|
}
|
|
|
|
const char*
|
|
binop::op_name() const
|
|
{
|
|
switch (op_)
|
|
{
|
|
case Xor:
|
|
return "Xor";
|
|
case Implies:
|
|
return "Implies";
|
|
case Equiv:
|
|
return "Equiv";
|
|
case U:
|
|
return "U";
|
|
case R:
|
|
return "R";
|
|
case W:
|
|
return "W";
|
|
case M:
|
|
return "M";
|
|
}
|
|
// Unreachable code.
|
|
assert(0);
|
|
return 0;
|
|
}
|
|
|
|
binop::map binop::instances;
|
|
|
|
binop*
|
|
binop::instance(type op, formula* first, formula* second)
|
|
{
|
|
// Sort the operands of commutative operators, so that for
|
|
// example the formula instance for 'a xor b' is the same as
|
|
// that for 'b xor a'.
|
|
switch (op)
|
|
{
|
|
case Xor:
|
|
case Equiv:
|
|
if (second < first)
|
|
std::swap(first, second);
|
|
break;
|
|
case Implies:
|
|
case U:
|
|
case R:
|
|
case W:
|
|
case M:
|
|
// Non commutative operators.
|
|
break;
|
|
}
|
|
|
|
pairf pf(first, second);
|
|
pair p(op, pf);
|
|
map::iterator i = instances.find(p);
|
|
if (i != instances.end())
|
|
{
|
|
// This instance already exists.
|
|
first->destroy();
|
|
second->destroy();
|
|
return static_cast<binop*>(i->second->clone());
|
|
}
|
|
binop* ap = new binop(op, first, second);
|
|
instances[p] = ap;
|
|
return static_cast<binop*>(ap->clone());
|
|
}
|
|
|
|
unsigned
|
|
binop::instance_count()
|
|
{
|
|
return instances.size();
|
|
}
|
|
|
|
std::ostream&
|
|
binop::dump_instances(std::ostream& os)
|
|
{
|
|
for (map::iterator i = instances.begin(); i != instances.end(); ++i)
|
|
{
|
|
os << i->second << " = "
|
|
<< i->second->ref_count_() << " * "
|
|
<< i->second->dump()
|
|
<< std::endl;
|
|
}
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|