-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathltl2ba.h
253 lines (223 loc) · 6.83 KB
/
ltl2ba.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/***** ltl2ba : ltl2ba.h *****/
/* Written by Denis Oddoux, LIAFA, France */
/* Copyright (c) 2001 Denis Oddoux */
/* Modified by Paul Gastin, LSV, France */
/* Copyright (c) 2007 Paul Gastin */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
/* */
/* Based on the translation algorithm by Gastin and Oddoux, */
/* presented at the 13th International Conference on Computer Aided */
/* Verification, CAV 2001, Paris, France. */
/* Proceedings - LNCS 2102, pp. 53-65 */
/* */
/* Send bug-reports and/or questions to Paul Gastin */
/* http://www.lsv.ens-cachan.fr/~gastin */
/* */
/* Some of the code in this file was taken from the Spin software */
/* Written by Gerard J. Holzmann, Bell Laboratories, U.S.A. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
typedef struct Symbol {
char *name;
struct Symbol *next; /* linked list, symbol table */
} Symbol;
typedef struct Node {
short ntyp; /* node type */
struct Symbol *sym;
struct Node *lft; /* tree */
struct Node *rgt; /* tree */
struct Node *nxt; /* if linked list */
} Node;
typedef struct Graph {
Symbol *name;
Symbol *incoming;
Symbol *outgoing;
Symbol *oldstring;
Symbol *nxtstring;
Node *New;
Node *Old;
Node *Other;
Node *Next;
unsigned char isred[64], isgrn[64];
unsigned char redcnt, grncnt;
unsigned char reachable;
struct Graph *nxt;
} Graph;
typedef struct Mapping {
char *from;
Graph *to;
struct Mapping *nxt;
} Mapping;
typedef struct ATrans {
int *to;
int *pos;
int *neg;
struct ATrans *nxt;
} ATrans;
typedef struct AProd {
int astate;
struct ATrans *prod;
struct ATrans *trans;
struct AProd *nxt;
struct AProd *prv;
} AProd;
typedef struct GTrans {
int *pos;
int *neg;
struct GState *to;
int *final;
struct GTrans *nxt;
} GTrans;
typedef struct GState {
int id;
int incoming;
int *nodes_set;
struct GTrans *trans;
struct GState *nxt;
struct GState *prv;
} GState;
typedef struct BTrans {
struct BState *to;
int *pos;
int *neg;
struct BTrans *nxt;
} BTrans;
typedef struct BState {
struct GState *gstate;
int id;
int incoming;
int final;
struct BTrans *trans;
struct BState *nxt;
struct BState *prv;
int label; /* State name for printing */
} BState;
typedef struct GScc {
struct GState *gstate;
int rank;
int theta;
struct GScc *nxt;
} GScc;
typedef struct BScc {
struct BState *bstate;
int rank;
int theta;
struct BScc *nxt;
} BScc;
enum {
ALWAYS=257,
AND, /* 258 */
EQUIV, /* 259 */
EVENTUALLY, /* 260 */
FALSE, /* 261 */
IMPLIES, /* 262 */
NOT, /* 263 */
OR, /* 264 */
PREDICATE, /* 265 */
TRUE, /* 266 */
U_OPER, /* 267 */
V_OPER /* 268 */
#ifdef NXT
, NEXT /* 269 */
#endif
};
Node *Canonical(Node *);
Node *canonical(Node *);
Node *cached(Node *);
Node *dupnode(Node *);
Node *getnode(Node *);
Node *in_cache(Node *);
Node *push_negation(Node *);
Node *right_linked(Node *);
Node *tl_nn(int, Node *, Node *);
Symbol *tl_lookup(char *);
Symbol *getsym(Symbol *);
Symbol *DoDump(Node *);
char *emalloc(int);
int anywhere(int, Node *, Node *);
int dump_cond(Node *, Node *, int);
int isequal(Node *, Node *);
int tl_Getchar(void);
void *tl_emalloc(int);
ATrans *emalloc_atrans();
void free_atrans(ATrans *, int);
void free_all_atrans();
GTrans *emalloc_gtrans();
void free_gtrans(GTrans *, GTrans *, int);
BTrans *emalloc_btrans();
void free_btrans(BTrans *, BTrans *, int);
void a_stats(void);
void addtrans(Graph *, char *, Node *, char *);
void cache_stats(void);
void dump(Node *);
void exit(int);
void Fatal(char *, char *);
void fatal(char *, char *);
void fsm_print(void);
void releasenode(int, Node *);
void tfree(void *);
void tl_explain(int);
void tl_UnGetchar(void);
void tl_parse(void);
void tl_yyerror(char *);
void trans(Node *);
void mk_alternating(Node *);
void mk_generalized();
void mk_buchi();
ATrans *dup_trans(ATrans *);
ATrans *merge_trans(ATrans *, ATrans *);
void do_merge_trans(ATrans **, ATrans *, ATrans *);
int *new_set(int);
int *clear_set(int *, int);
int *make_set(int , int);
void copy_set(int *, int *, int);
int *dup_set(int *, int);
void merge_sets(int *, int *, int);
void do_merge_sets(int *, int *, int *, int);
int *intersect_sets(int *, int *, int);
void add_set(int *, int);
void rem_set(int *, int);
void spin_print_set(int *, int*);
void print_set(int *, int);
int empty_set(int *, int);
int empty_intersect_sets(int *, int *, int);
int same_sets(int *, int *, int);
int included_set(int *, int *, int);
int in_set(int *, int);
int *list_set(int *, int);
int timeval_subtract (struct timeval *, struct timeval *, struct timeval *);
#define ZN (Node *)0
#define ZS (Symbol *)0
#define Nhash 255
#define True tl_nn(TRUE, ZN, ZN)
#define False tl_nn(FALSE, ZN, ZN)
#define Not(a) push_negation(tl_nn(NOT, a, ZN))
#define rewrite(n) canonical(right_linked(n))
typedef Node *Nodeptr;
#define YYSTYPE Nodeptr
#define Debug(x) { if (0) printf(x); }
#define Debug2(x,y) { if (tl_verbose) printf(x,y); }
#define Dump(x) { if (0) dump(x); }
#define Explain(x) { if (tl_verbose) tl_explain(x); }
#define Assert(x, y) { if (!(x)) { tl_explain(y); \
Fatal(": assertion failed\n",(char *)0); } }
#define min(x,y) ((x<y)?x:y)
#define max(x,y) ((x>y)?x:y)
/* Type for output type option */
typedef enum output_type {OT_SPIN, OT_C, OT_JSON} output_type;