spot  1.99.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
bunop.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 Laboratoire de Recherche
3 // et 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 #pragma once
23 
24 #include "formula.hh"
25 #include <map>
26 #include <iosfwd>
27 #include <tuple>
28 #include "constant.hh"
29 
30 namespace spot
31 {
32  namespace ltl
33  {
34 
37  class SPOT_API bunop final : public formula
38  {
39  public:
40  enum type { Star, FStar };
41 
42  static const unsigned unbounded = -1U;
43 
66  static const formula* instance(type op,
67  const formula* child,
68  unsigned min = 0,
69  unsigned max = unbounded);
70 
80  static const formula* sugar_goto(const formula* child,
81  unsigned min = 1,
82  unsigned max = unbounded);
83 
90  static const formula* sugar_equal(const formula* child,
91  unsigned min = 0,
92  unsigned max = unbounded);
93 
94  virtual void accept(visitor& v) const override;
95 
97  const formula* child() const
98  {
99  return child_;
100  }
101 
103  unsigned min() const
104  {
105  return min_;
106  }
107 
109  unsigned max() const
110  {
111  return max_;
112  }
113 
117  std::string format() const;
118 
120  type op() const
121  {
122  return op_;
123  }
124 
126  const char* op_name() const;
127 
129  virtual std::string dump() const override;
130 
132  static unsigned instance_count();
133 
135  static std::ostream& dump_instances(std::ostream& os);
136 
142  static const formula* one_star()
143  {
144  if (!one_star_)
145  one_star_ = instance(Star, constant::true_instance());
146  return one_star_;
147  }
148 
149  protected:
150  typedef std::tuple<type, const formula*, unsigned, unsigned> key;
151  typedef std::map<key, const bunop*> map;
152  static map instances;
153 
154  bunop(type op, const formula* child, unsigned min, unsigned max);
155  virtual ~bunop();
156 
157  private:
158  type op_;
159  const formula* child_;
160  unsigned min_;
161  unsigned max_;
162  static const formula* one_star_;
163  };
164 
169  inline
170  const bunop*
171  is_bunop(const formula* f)
172  {
173  if (f->kind() != formula::BUnOp)
174  return 0;
175  return static_cast<const bunop*>(f);
176  }
177 
182  inline
183  const bunop*
184  is_bunop(const formula* f, bunop::type op)
185  {
186  if (const bunop* bo = is_bunop(f))
187  if (bo->op() == op)
188  return bo;
189  return 0;
190  }
191 
195  inline
196  const bunop*
197  is_Star(const formula* f)
198  {
199  return is_bunop(f, bunop::Star);
200  }
201 
205  inline
206  const bunop*
207  is_KleenStar(const formula* f)
208  {
209  if (const bunop* b = is_Star(f))
210  if (b->min() == 0 && b->max() == bunop::unbounded)
211  return b;
212  return 0;
213  }
214 
215  }
216 }
Definition: public.hh:31
type op() const
Get the type of this operator.
Definition: bunop.hh:120
const formula * child() const
Get the sole operand of this operator.
Definition: bunop.hh:97
unsigned max() const
Minimum number of repetition.
Definition: bunop.hh:109
LTL constants.
LTL formula interface.
Formula visitor.
Definition: visitor.hh:40
static const formula * one_star()
Return a formula for 1[*].
Definition: bunop.hh:142
unsigned min() const
Minimum number of repetition.
Definition: bunop.hh:103
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:52
An LTL formula.
Definition: formula.hh:71

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Wed Aug 26 2015 08:42:37 for spot by doxygen 1.8.8