* src/ltlast/multop.cc, src/ltlast/multop.hh: Declare AndNML
operator.
* src/ltlparse/ltlscan.ll: Distinguish "&" and "&&".
* src/ltlparse/ltlparse.yy: Handle them both as "And" for LTL
formula, use AndNML or And for rational expressions.
* src/ltlvisit/tostring.cc: Adjust to distinguish "&" and "&&" in
rational expressions. Also use {braces} to group rational
expressions.
* src/tgbaalgos/ltl2tgba_fm.cc
(ratexp_trad_visitor::ratexp_trad_visitor): Remove the possibility
to select the empty_word should act like true, and fix the rules
for Closure and NegClosure to rely on constant_term instead.
(ratexp_trad_visitor::visit) Adjust the And translation to also
support AndNML.
(ratexp_trad_visitor::recurse_and_concat): Introduce this new
method to simplify some calls to recurse(f, to_concat_).
* src/tgbatest/ltl2tgba.test: Add more test cases.
* src/ltlvisit/basicreduce.cc, src/ltlvisit/consterm.cc,
src/ltlvisit/contain.cc, src/ltlvisit/mark.cc,
src/ltlvisit/nenoform.cc, src/ltlvisit/syntimpl.cc,
src/tgba/formula2bdd.cc, src/tgbaalgos/eltl2tgba_lacim.cc,
src/tgbaalgos/ltl2taa.cc, src/tgbaalgos/ltl2tgba_lacim.cc: Add
missing cases in switches.
158 lines
5.5 KiB
C++
158 lines
5.5 KiB
C++
// Copyright (C) 2009, 2010 Laboratoire de Recherche et D<>veloppement
|
||
// de l'Epita (LRDE).
|
||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris
|
||
// 6 (LIP6), d<>partement Syst<73>mes R<>partis Coop<6F>ratifs (SRC),
|
||
// Universit<69> 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.
|
||
|
||
/// \file ltlast/multop.hh
|
||
/// \brief LTL multi-operand operators
|
||
#ifndef SPOT_LTLAST_MULTOP_HH
|
||
# define SPOT_LTLAST_MULTOP_HH
|
||
|
||
#include <vector>
|
||
#include <map>
|
||
#include <iosfwd>
|
||
#include "refformula.hh"
|
||
|
||
namespace spot
|
||
{
|
||
namespace ltl
|
||
{
|
||
|
||
/// \brief Multi-operand operators.
|
||
/// \ingroup ltl_ast
|
||
class multop : public ref_formula
|
||
{
|
||
public:
|
||
enum type { Or, And, AndNLM, Concat, Fusion };
|
||
|
||
/// List of formulae.
|
||
typedef std::vector<formula*> vec;
|
||
|
||
/// \brief Build a spot::ltl::multop with two children.
|
||
///
|
||
/// If one of the children itself is a spot::ltl::multop
|
||
/// with the same type, it will be inlined. I.e., children
|
||
/// of that child will be added, and that child itself will
|
||
/// be destroyed. This allows incremental building of
|
||
/// n-ary ltl::multop.
|
||
///
|
||
/// This functions can perform slight optimizations and
|
||
/// may not return an ltl::multop object. See the other
|
||
/// instance function for the list of rewritings.
|
||
static formula* instance(type op, formula* first, formula* second);
|
||
|
||
/// \brief Build a spot::ltl::multop with many children.
|
||
///
|
||
/// Same as the other instance() function, but take a vector of
|
||
/// formulae as argument. This vector is acquired by the
|
||
/// spot::ltl::multop class, the caller should allocate it with
|
||
/// \c new, but not use it (especially not destroy it) after it
|
||
/// has been passed to spot::ltl::multop.
|
||
///
|
||
/// All operators (Or, And, Concat) are associative, and are
|
||
/// automatically inlined. Or and And are commutative, so their
|
||
/// argument are also sorted, to ensure that "a & b" is equal to
|
||
/// "b & a". For Or and And, duplicate arguments are also
|
||
/// removed.
|
||
///
|
||
/// Furthermore this function can perform slight optimizations
|
||
/// and may not return an ltl::multop object. For instance if
|
||
/// the vector contains only one unique element, this this
|
||
/// formula will be returned as-is. Neutral and absorbent element
|
||
/// are also taken care of. The following rewriting are performed
|
||
/// (the left patterns are rewritten as shown on the right):
|
||
///
|
||
/// - And(Exps1...,1,Exps2...) = And(Exps1...,Exps2...)
|
||
/// - And(Exps1...,0,Exps2...) = 0
|
||
/// - And(Exps1...,[*0],Exps2...) = [*0] if no Expi is 0.
|
||
/// - And(Exp) = Exp
|
||
/// - AndNLM(Exps1...,1,Exps2...) = AndNLM(Exps1...,Exps2...)
|
||
/// - AndNLM(Exps1...,0,Exps2...) = 0
|
||
/// - AndNLM(Exps1...,[*0],Exps2...) = AndNLM(Exps1...,Exps2...)
|
||
/// - AndNLM(Exp) = Exp
|
||
/// - Or(Exps1...,1,Exps2...) = 1
|
||
/// - Or(Exps1...,0,Exps2...) = And(Exps1...,Exps2...)
|
||
/// - Or(Exp) = Exp
|
||
/// - Concat(Exps1...,[*0],Exps2...) = Concat(Exps1...,Exps2...)
|
||
/// - Concat(Exps1...,0,Exps2...) = 0
|
||
/// - Concat(Exp) = Exp
|
||
/// - Fusion(Exps1...,1,Exps2...) = Concat(Exps1...,Exps2...)
|
||
/// - Fusion(Exps1...,0,Exps2...) = 0
|
||
/// - Fusion(Exps1...,[*0],Exps2...) = 0
|
||
/// - Fusion(Exp) = Exp
|
||
static formula* instance(type op, vec* v);
|
||
|
||
virtual void accept(visitor& v);
|
||
virtual void accept(const_visitor& v) const;
|
||
|
||
/// Get the number of children.
|
||
unsigned size() const;
|
||
/// \brief Get the nth children.
|
||
///
|
||
/// Starting with \a n = 0.
|
||
const formula* nth(unsigned n) const;
|
||
/// \brief Get the nth children.
|
||
///
|
||
/// Starting with \a n = 0.
|
||
formula* nth(unsigned n);
|
||
|
||
/// Get the type of this operator.
|
||
type op() const;
|
||
/// Get the type of this operator, as a string.
|
||
const char* op_name() const;
|
||
|
||
/// Return a canonic representation of the atomic proposition
|
||
virtual std::string dump() const;
|
||
|
||
/// Number of instantiated multi-operand operators. For debugging.
|
||
static unsigned instance_count();
|
||
|
||
/// Dump all instances. For debugging.
|
||
static std::ostream& dump_instances(std::ostream& os);
|
||
|
||
protected:
|
||
typedef std::pair<type, vec*> pair;
|
||
/// Comparison functor used internally by ltl::multop.
|
||
struct paircmp
|
||
{
|
||
bool
|
||
operator () (const pair& p1, const pair& p2) const
|
||
{
|
||
if (p1.first != p2.first)
|
||
return p1.first < p2.first;
|
||
return *p1.second < *p2.second;
|
||
}
|
||
};
|
||
typedef std::map<pair, multop*, paircmp> map;
|
||
static map instances;
|
||
|
||
multop(type op, vec* v);
|
||
virtual ~multop();
|
||
|
||
private:
|
||
type op_;
|
||
vec* children_;
|
||
};
|
||
|
||
}
|
||
}
|
||
|
||
#endif // SPOT_LTLAST_MULTOP_HH
|