spot  1.2.1a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bunop.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2010, 2011, 2012, 2013 Laboratoire de Recherche et
3 // Développement de l'Epita (LRDE).
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
22 #ifndef SPOT_LTLAST_BUNOP_HH
23 # define SPOT_LTLAST_BUNOP_HH
24 
25 #include "refformula.hh"
26 #include <map>
27 #include <iosfwd>
28 #include "constant.hh"
29 
30 namespace spot
31 {
32  namespace ltl
33  {
34 
37  class SPOT_API bunop : public ref_formula
38  {
39  public:
40  enum type { Star };
41 
42  static const unsigned unbounded = -1U;
43 
59  static const formula* instance(type op,
60  const formula* child,
61  unsigned min = 0,
62  unsigned max = unbounded);
63 
73  static const formula* sugar_goto(const formula* child,
74  unsigned min = 1,
75  unsigned max = unbounded);
76 
83  static const formula* sugar_equal(const formula* child,
84  unsigned min = 0,
85  unsigned max = unbounded);
86 
87  virtual void accept(visitor& v) const;
88 
90  const formula* child() const;
91 
93  unsigned min() const;
95  unsigned max() const;
96 
100  std::string format() const;
101 
103  type op() const;
105  const char* op_name() const;
106 
108  virtual std::string dump() const;
109 
111  static unsigned instance_count();
112 
114  static std::ostream& dump_instances(std::ostream& os);
115 
121  static const formula* one_star()
122  {
123  if (!one_star_)
124  one_star_ = instance(Star, constant::true_instance());
125  return one_star_;
126  }
127 
128  protected:
129  typedef std::pair<unsigned, unsigned> pairu;
130  typedef std::pair<type, const formula*> pairo;
131  typedef std::pair<pairo, pairu> pair;
132  typedef std::map<pair, const bunop*> map;
133  static map instances;
134 
135  bunop(type op, const formula* child, unsigned min, unsigned max);
136  virtual ~bunop();
137 
138  private:
139  type op_;
140  const formula* child_;
141  unsigned min_;
142  unsigned max_;
143  static const formula* one_star_;
144  };
145 
150  inline
151  const bunop*
152  is_bunop(const formula* f)
153  {
154  if (f->kind() != formula::BUnOp)
155  return 0;
156  return static_cast<const bunop*>(f);
157  }
158 
163  inline
164  const bunop*
165  is_bunop(const formula* f, bunop::type op)
166  {
167  if (const bunop* bo = is_bunop(f))
168  if (bo->op() == op)
169  return bo;
170  return 0;
171  }
172 
176  inline
177  const bunop*
178  is_Star(const formula* f)
179  {
180  return is_bunop(f, bunop::Star);
181  }
182 
186  inline
187  const bunop*
188  is_KleenStar(const formula* f)
189  {
190  if (const bunop* b = is_Star(f))
191  if (b->min() == 0 && b->max() == bunop::unbounded)
192  return b;
193  return 0;
194  }
195 
196  }
197 }
198 #endif // SPOT_LTLAST_BUNOP_HH
LTL constants.
Formula visitor.
Definition: visitor.hh:41
static const formula * one_star()
Return a formula for 1[*].
Definition: bunop.hh:121
A reference-counted LTL formula.
Definition: refformula.hh:37
Bounded unary operator.
Definition: bunop.hh:37
SPOT_API std::ostream & dump(std::ostream &os, const formula *f)
Dump a formula tree.
static constant * true_instance()
Get the sole instance of spot::ltl::constant::constant(True).
Definition: constant.hh:49
opkind kind() const
Return the kind of the top-level operator.
Definition: formula.hh:114
An LTL formula.
Definition: formula.hh:72
Reference-counted LTL formulae.

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Jan 21 2014 16:52:01 for spot by doxygen 1.8.5