spot  2.12.1
randomltl.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) by the Spot authors, see the AUTHORS file for details.
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #pragma once
20 
21 #include <spot/tl/apcollect.hh>
22 #include <iosfwd>
23 
24 #include <unordered_set>
25 #include <spot/misc/optionmap.hh>
26 #include <spot/misc/hash.hh>
27 #include <spot/tl/simplify.hh>
28 
29 namespace spot
30 {
33  class SPOT_API random_formula
34  {
35  public:
36  random_formula(unsigned proba_size,
37  const atomic_prop_set* ap):
38  proba_size_(proba_size), proba_(new op_proba[proba_size_]), ap_(ap)
39  {
40  }
41 
42  virtual ~random_formula()
43  {
44  delete[] proba_;
45  }
46 
48  const atomic_prop_set*
49  ap() const
50  {
51  return ap_;
52  }
53 
60  formula generate(int n) const;
61 
64  std::ostream& dump_priorities(std::ostream& os) const;
65 
73  const char* parse_options(char* options);
74 
76  bool has_unary_ops() const
77  {
78  return total_2_ > 0.0;
79  }
80 
81  protected:
82  void update_sums();
83 
84  struct op_proba
85  {
86  const char* name;
87  int min_n;
88  double proba;
89  typedef formula (*builder)(const random_formula* rl, int n);
90  builder build;
91  void setup(const char* name, int min_n, builder build);
92  };
93  unsigned proba_size_;
94  op_proba* proba_;
95  double total_1_;
96  op_proba* proba_2_;
97  double total_2_;
98  op_proba* proba_2_or_more_;
99  double total_2_and_more_;
100  const atomic_prop_set* ap_;
101  };
102 
103 
116  class SPOT_API random_ltl: public random_formula
117  {
118  public:
123 
151 
152  protected:
153  void setup_proba_();
154  random_ltl(int size, const atomic_prop_set* ap);
155  };
156 
166  class SPOT_API random_boolean final: public random_formula
167  {
168  public:
174 
195  };
196 
206  class SPOT_API random_sere final: public random_formula
207  {
208  public:
213 
236 
237  random_boolean rb;
238  };
239 
247  class SPOT_API random_psl: public random_ltl
248  {
249  public:
258 
293 
296  };
297 
298  class SPOT_API randltlgenerator
299  {
300  typedef std::unordered_set<formula> fset_t;
301 
302 
303  public:
304  enum output_type { Bool, LTL, SERE, PSL };
305  static constexpr unsigned MAX_TRIALS = 100000U;
306 
307  randltlgenerator(int aprops_n, const option_map& opts,
308  char* opt_pL = nullptr,
309  char* opt_pS = nullptr,
310  char* opt_pB = nullptr);
311 
312  randltlgenerator(atomic_prop_set aprops, const option_map& opts,
313  char* opt_pL = nullptr,
314  char* opt_pS = nullptr,
315  char* opt_pB = nullptr);
316 
317  ~randltlgenerator();
318 
319  formula next();
320 
321  void dump_ltl_priorities(std::ostream& os);
322  void dump_bool_priorities(std::ostream& os);
323  void dump_psl_priorities(std::ostream& os);
324  void dump_sere_priorities(std::ostream& os);
325  void dump_sere_bool_priorities(std::ostream& os);
326  void remove_some_props(atomic_prop_set& s);
327 
328  formula GF_n();
329 
330  private:
331  fset_t unique_set_;
332  atomic_prop_set aprops_;
333 
334  int opt_seed_;
335  int opt_tree_size_min_;
336  int opt_tree_size_max_;
337  bool opt_unique_;
338  bool opt_wf_;
339  int opt_simpl_level_;
340  tl_simplifier simpl_;
341 
342  int output_;
343 
344  random_formula* rf_ = nullptr;
345  random_psl* rp_ = nullptr;
346  random_sere* rs_ = nullptr;
347  };
348 }
Main class for temporal logic formula.
Definition: formula.hh:732
Manage a map of options.
Definition: optionmap.hh:34
Definition: randomltl.hh:299
Generate random Boolean formulae.
Definition: randomltl.hh:167
random_boolean(const atomic_prop_set *ap)
Base class for random formula generators.
Definition: randomltl.hh:34
std::ostream & dump_priorities(std::ostream &os) const
Print the priorities of each operator, constants, and atomic propositions.
const char * parse_options(char *options)
Update the priorities used to generate the formulae.
bool has_unary_ops() const
whether we can use unary operators
Definition: randomltl.hh:76
const atomic_prop_set * ap() const
Return the set of atomic proposition used to build formulae.
Definition: randomltl.hh:49
formula generate(int n) const
Generate a formula of size n.
Generate random LTL formulae.
Definition: randomltl.hh:117
random_ltl(const atomic_prop_set *ap)
Generate random PSL formulae.
Definition: randomltl.hh:248
random_sere rs
The SERE generator used to generate SERE subformulae.
Definition: randomltl.hh:295
random_psl(const atomic_prop_set *ap)
Generate random SERE.
Definition: randomltl.hh:207
random_sere(const atomic_prop_set *ap)
Rewrite or simplify f in various ways.
Definition: simplify.hh:109
@ ap
Atomic proposition.
std::set< formula > atomic_prop_set
Set of atomic propositions.
Definition: apcollect.hh:33
Definition: automata.hh:26
Definition: randomltl.hh:85

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1