spot
1.1.3
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ltlast
formula.hh
Go to the documentation of this file.
1
// -*- coding: utf-8 -*-
2
// Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
3
// et Développement de l'Epita (LRDE).
4
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de
5
//
6
// This file is part of Spot, a model checking library.
7
//
8
// Spot is free software; you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 3 of the License, or
11
// (at your option) any later version.
12
//
13
// Spot is distributed in the hope that it will be useful, but WITHOUT
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16
// License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with this program. If not, see <http://www.gnu.org/licenses/>.
20
23
#ifndef SPOT_LTLAST_FORMULA_HH
24
# define SPOT_LTLAST_FORMULA_HH
25
26
#include <string>
27
#include <cassert>
28
#include "
predecl.hh
"
29
#include <list>
30
31
namespace
spot
32
{
33
namespace
ltl
34
{
38
41
44
48
51
54
57
60
63
64
71
class
formula
72
{
73
public
:
75
enum
opkind
{
Constant
,
76
AtomicProp
,
77
UnOp
,
78
BinOp
,
79
MultOp
,
80
BUnOp
,
81
AutomatOp
};
82
83
protected
:
84
formula
(
opkind
k) :
count_
(
max_count
++),
kind_
(k)
85
{
86
// If the counter of formulae ever loops, we want to skip the
87
// first three values, because they are permanently associated
88
// to constants, and it is convenient to have constants smaller
89
// than all other formulae.
90
if
(
max_count
== 0)
91
max_count
= 3;
92
}
93
94
public
:
96
virtual
void
accept
(
visitor
& v)
const
= 0;
97
102
const
formula
*
clone
()
const
;
107
void
destroy
()
const
;
108
110
virtual
std::string
dump
()
const
= 0;
111
113
opkind
kind
()
const
114
{
115
return
kind_
;
116
}
117
119
// Properties //
121
123
bool
is_boolean
()
const
124
{
125
return
is
.
boolean
;
126
}
127
129
bool
is_sugar_free_boolean
()
const
130
{
131
return
is
.
sugar_free_boolean
;
132
}
133
138
bool
is_in_nenoform
()
const
139
{
140
return
is
.
in_nenoform
;
141
}
142
144
bool
is_X_free
()
const
145
{
146
return
is
.
X_free
;
147
}
148
150
bool
is_sugar_free_ltl
()
const
151
{
152
return
is
.
sugar_free_ltl
;
153
}
154
156
bool
is_ltl_formula
()
const
157
{
158
return
is
.
ltl_formula
;
159
}
160
162
bool
is_eltl_formula
()
const
163
{
164
return
is
.
eltl_formula
;
165
}
166
168
bool
is_psl_formula
()
const
169
{
170
return
is
.
psl_formula
;
171
}
172
174
bool
is_sere_formula
()
const
175
{
176
return
is
.
sere_formula
;
177
}
178
181
bool
is_finite
()
const
182
{
183
return
is
.
finite
;
184
}
185
189
203
bool
is_eventual
()
const
207
{
208
return
is
.
eventual
;
209
}
210
214
228
bool
is_universal
()
const
232
{
233
return
is
.
universal
;
234
}
235
237
bool
is_syntactic_safety
()
const
238
{
239
return
is
.
syntactic_safety
;
240
}
241
243
bool
is_syntactic_guarantee
()
const
244
{
245
return
is
.
syntactic_guarantee
;
246
}
247
249
bool
is_syntactic_obligation
()
const
250
{
251
return
is
.
syntactic_obligation
;
252
}
253
255
bool
is_syntactic_recurrence
()
const
256
{
257
return
is
.
syntactic_recurrence
;
258
}
259
261
bool
is_syntactic_persistence
()
const
262
{
263
return
is
.
syntactic_persistence
;
264
}
265
267
bool
is_marked
()
const
268
{
269
return
!
is
.
not_marked
;
270
}
271
273
bool
accepts_eword
()
const
274
{
275
return
is
.
accepting_eword
;
276
}
277
278
bool
has_lbt_atomic_props
()
const
279
{
280
return
is
.
lbt_atomic_props
;
281
}
282
284
unsigned
get_props
()
const
285
{
286
return
props
;
287
}
288
290
size_t
291
hash
()
const
292
{
293
return
count_
;
294
}
295
protected
:
296
virtual
~formula
();
297
299
virtual
void
ref_
()
const
;
302
virtual
bool
unref_
()
const
;
303
305
size_t
count_
;
306
307
struct
ltl_prop
308
{
309
// All properties here should be expressed in such a a way
310
// that property(f && g) is just property(f)&property(g).
311
// This allows us to compute all properties of a compound
312
// formula in one operation.
313
//
314
// For instance we do not use a property that says "has
315
// temporal operator", because it would require an OR between
316
// the two arguments. Instead we have a property that
317
// says "no temporal operator", and that one is computed
318
// with an AND between the arguments.
319
//
320
// Also choose a name that makes sense when prefixed with
321
// "the formula is".
322
bool
boolean
:1;
// No temporal operators.
323
bool
sugar_free_boolean
:1;
// Only AND, OR, and NOT operators.
324
bool
in_nenoform
:1;
// Negative Normal Form.
325
bool
X_free
:1;
// No X operators.
326
bool
sugar_free_ltl
:1;
// No F and G operators.
327
bool
ltl_formula
:1;
// Only LTL operators.
328
bool
eltl_formula
:1;
// Only ELTL operators.
329
bool
psl_formula
:1;
// Only PSL operators.
330
bool
sere_formula
:1;
// Only SERE operators.
331
bool
finite
:1;
// Finite SERE formulae, or Bool+X forms.
332
bool
eventual
:1;
// Purely eventual formula.
333
bool
universal
:1;
// Purely universal formula.
334
bool
syntactic_safety
:1;
// Syntactic Safety Property.
335
bool
syntactic_guarantee
:1;
// Syntactic Guarantee Property.
336
bool
syntactic_obligation
:1;
// Syntactic Obligation Property.
337
bool
syntactic_recurrence
:1;
// Syntactic Recurrence Property.
338
bool
syntactic_persistence
:1;
// Syntactic Persistence Property.
339
bool
not_marked
:1;
// No occurrence of EConcatMarked.
340
bool
accepting_eword
:1;
// Accepts the empty word.
341
bool
lbt_atomic_props
:1;
// Use only atomic propositions like p42.
342
};
343
union
344
{
345
// Use an unsigned for fast computation of all properties.
346
unsigned
props
;
347
ltl_prop
is
;
348
};
349
350
private
:
352
static
size_t
max_count
;
353
opkind
kind_
;
354
};
355
369
struct
formula_ptr_less_than
:
370
public
std::binary_function<const formula*, const formula*, bool>
371
{
372
bool
373
operator()
(
const
formula
* left,
const
formula
* right)
const
374
{
375
assert(left);
376
assert(right);
377
if
(left == right)
378
return
false
;
379
size_t
l = left->
hash
();
380
size_t
r = right->
hash
();
381
if
(l != r)
382
return
l < r;
383
// Because the hash code assigned to each formula is the
384
// number of formulae constructed so far, it is very unlikely
385
// that we will ever reach a case were two different formulae
386
// have the same hash. This will happen only ever with have
387
// produced 256**sizeof(size_t) formulae (i.e. max_count has
388
// looped back to 0 and started over). In that case we can
389
// order two formulae by looking at their text representation.
390
// We could be more efficient and look at their AST, but it's
391
// not worth the burden. (Also ordering pointers is ruled out
392
// because it breaks the determinism of the implementation.)
393
return
left->
dump
() < right->
dump
();
394
}
395
};
396
411
struct
formula_ptr_hash
:
412
public
std::unary_function<const formula*, size_t>
413
{
414
size_t
415
operator()
(
const
formula
* that)
const
416
{
417
assert(that);
418
return
that->
hash
();
419
}
420
};
421
423
std::ostream&
print_formula_props
(std::ostream& out,
424
const
formula
* f,
425
bool
abbreviated =
false
);
426
428
std::list<std::string>
list_formula_props
(
const
formula
* f);
429
}
430
}
431
432
#endif // SPOT_LTLAST_FORMULA_HH
Please direct any
question
,
comment
, or
bug report
to the Spot mailing list at
spot@lrde.epita.fr
.
Generated on Tue Jul 9 2013 14:04:33 for spot by
1.8.4