spot 2.11.6.dev
Loading...
Searching...
No Matches
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
29namespace 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
75 protected:
76 void update_sums();
77
78 struct op_proba
79 {
80 const char* name;
81 int min_n;
82 double proba;
83 typedef formula (*builder)(const random_formula* rl, int n);
84 builder build;
85 void setup(const char* name, int min_n, builder build);
86 };
87 unsigned proba_size_;
88 op_proba* proba_;
89 double total_1_;
90 op_proba* proba_2_;
91 double total_2_;
92 op_proba* proba_2_or_more_;
93 double total_2_and_more_;
94 const atomic_prop_set* ap_;
95 };
96
97
110 class SPOT_API random_ltl: public random_formula
111 {
112 public:
117
145
146 protected:
147 void setup_proba_();
148 random_ltl(int size, const atomic_prop_set* ap);
149 };
150
160 class SPOT_API random_boolean final: public random_formula
161 {
162 public:
168
189 };
190
200 class SPOT_API random_sere final: public random_formula
201 {
202 public:
207
230
232 };
233
241 class SPOT_API random_psl: public random_ltl
242 {
243 public:
252
287
290 };
291
292 class SPOT_API randltlgenerator
293 {
294 typedef std::unordered_set<formula> fset_t;
295
296
297 public:
298 enum output_type { Bool, LTL, SERE, PSL };
299 static constexpr unsigned MAX_TRIALS = 100000U;
300
301 randltlgenerator(int aprops_n, const option_map& opts,
302 char* opt_pL = nullptr,
303 char* opt_pS = nullptr,
304 char* opt_pB = nullptr);
305
306 randltlgenerator(atomic_prop_set aprops, const option_map& opts,
307 char* opt_pL = nullptr,
308 char* opt_pS = nullptr,
309 char* opt_pB = nullptr);
310
312
313 formula next();
314
315 void dump_ltl_priorities(std::ostream& os);
316 void dump_bool_priorities(std::ostream& os);
317 void dump_psl_priorities(std::ostream& os);
318 void dump_sere_priorities(std::ostream& os);
319 void dump_sere_bool_priorities(std::ostream& os);
320 void remove_some_props(atomic_prop_set& s);
321
322 formula GF_n();
323
324 private:
325 fset_t unique_set_;
326 atomic_prop_set aprops_;
327
328 int opt_seed_;
329 int opt_tree_size_min_;
330 int opt_tree_size_max_;
331 bool opt_unique_;
332 bool opt_wf_;
333 int opt_simpl_level_;
334 tl_simplifier simpl_;
335
336 int output_;
337
338 random_formula* rf_ = nullptr;
339 random_psl* rp_ = nullptr;
340 random_sere* rs_ = nullptr;
341 };
342}
Main class for temporal logic formula.
Definition formula.hh:732
Manage a map of options.
Definition optionmap.hh:34
Definition randomltl.hh:293
Generate random Boolean formulae.
Definition randomltl.hh:161
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.
formula generate(int n) const
Generate a formula of size n.
const atomic_prop_set * ap() const
Return the set of atomic proposition used to build formulae.
Definition randomltl.hh:49
Generate random LTL formulae.
Definition randomltl.hh:111
random_ltl(const atomic_prop_set *ap)
Generate random PSL formulae.
Definition randomltl.hh:242
random_sere rs
The SERE generator used to generate SERE subformulae.
Definition randomltl.hh:289
random_psl(const atomic_prop_set *ap)
Generate random SERE.
Definition randomltl.hh:201
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:79

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.8