ltl2tgba.cc 20.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright (C) 2003, 2004  Laboratoire d'Informatique de Paris 6 (LIP6),
// dpartement Systmes Rpartis Coopratifs (SRC), Universit Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot 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.
//
// Spot 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 Spot; see the file COPYING.  If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.

22
23
#include <iostream>
#include <cassert>
24
25
#include <fstream>
#include <string>
26
#include "ltlvisit/destroy.hh"
27
#include "ltlvisit/reduce.hh"
28
#include "ltlvisit/tostring.hh"
29
#include "ltlvisit/apcollect.hh"
30
31
#include "ltlast/allnodes.hh"
#include "ltlparse/public.hh"
32
#include "tgbaalgos/ltl2tgba_lacim.hh"
33
#include "tgbaalgos/ltl2tgba_fm.hh"
34
#include "tgba/bddprint.hh"
35
#include "tgbaalgos/dotty.hh"
36
#include "tgbaalgos/lbtt.hh"
37
#include "tgba/tgbatba.hh"
38
#include "tgbaalgos/magic.hh"
39
40
#include "tgbaalgos/se05.hh"
#include "tgbaalgos/tau03.hh"
41
#include "tgbaalgos/tau03opt.hh"
42
43
#include "tgbaalgos/gtec/gtec.hh"
#include "tgbaalgos/gtec/ce.hh"
44
#include "tgbaparse/public.hh"
45
#include "tgbaalgos/dupexp.hh"
46
#include "tgbaalgos/neverclaim.hh"
47
#include "tgbaalgos/reductgba_sim.hh"
48
#include "tgbaalgos/replayrun.hh"
49
#include "tgbaalgos/rundotdec.hh"
50

51
52
53
void
syntax(char* prog)
{
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
54
  std::cerr << "Usage: "<< prog << " [OPTIONS...] formula" << std::endl
55
            << "       "<< prog << " -F [OPTIONS...] file" << std::endl
56
            << "       "<< prog << " -X [OPTIONS...] file" << std::endl
Alexandre Duret-Lutz's avatar
spacing    
Alexandre Duret-Lutz committed
57
	    << std::endl
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
58
	    << "Options:" << std::endl
martinez's avatar
martinez committed
59
	    << "  -a    display the acceptance_conditions BDD, not the "
60
	    << "reachability graph"
61
	    << std::endl
martinez's avatar
martinez committed
62
63
	    << "  -A    same as -a, but as a set" << std::endl
	    << "  -d    turn on traces during parsing" << std::endl
64
65
	    << "  -D    degeneralize the automaton as a TBA" << std::endl
	    << "  -DS   degeneralize the automaton as an SBA" << std::endl
66
67
68
	    << "  -e[ALGO]  emptiness-check, expect and compute an "
	    << "accepting run" << std::endl
	    << "  -E[ALGO]  emptiness-check, expect no accepting run"
69
	    << std::endl
martinez's avatar
martinez committed
70
71
72
            << "  -f    use Couvreur's FM algorithm for translation"
	    << std::endl
            << "  -F    read the formula from the file" << std::endl
73
	    << "  -g    graph the accepting run on the automaton (requires -e)"
74
	    << std::endl
martinez's avatar
martinez committed
75
            << "  -L    fair-loop approximation (implies -f)" << std::endl
martinez's avatar
martinez committed
76
77
	    << "  -N    display the never clain for Spin "
	    << "(implies -D)" << std::endl
martinez's avatar
martinez committed
78
79
            << "  -p    branching postponement (implies -f)" << std::endl
	    << "  -r    display the relation BDD, not the reachability graph"
80
	    << std::endl
martinez's avatar
martinez committed
81
82
	    << "  -r1   reduce formula using basic rewriting" << std::endl
	    << "  -r2   reduce formula using class of eventuality and "
83
	    << "and universality" << std::endl
martinez's avatar
martinez committed
84
	    << "  -r3   reduce formula using implication between "
85
	    << "sub-formulae" << std::endl
martinez's avatar
martinez committed
86
87
88
	    << "  -r4   reduce formula using all rules" << std::endl
	    << "  -rd   display the reduce formula" << std::endl
	    << "  -R    same as -r, but as a set" << std::endl
89
	    << "  -R1q  merge states using direct simulation "
martinez's avatar
martinez committed
90
	    << "(use -L for more reduction)"
91
	    << std::endl
92
	    << "  -R1t  remove transitions using direct simulation "
martinez's avatar
martinez committed
93
	    << "(use -L for more reduction)"
94
	    << std::endl
95
96
	    << "  -R2q  merge states using delayed simulation" << std::endl
	    << "  -R2t  remove transitions using delayed simulation"
97
	    << std::endl
98
99
100
	    << "  -R3   use SCC to reduce the automata" << std::endl
	    << "  -Rd   display the simulation relation" << std::endl
	    << "  -RD   display the parity game (dot format)" << std::endl
martinez's avatar
martinez committed
101
	    << "  -s    convert to explicit automata, and number states "
102
	    << "in DFS order" << std::endl
martinez's avatar
martinez committed
103
	    << "  -S    convert to explicit automata, and number states "
104
	    << "in BFS order" << std::endl
martinez's avatar
martinez committed
105
	    << "  -t    display reachable states in LBTT's format" << std::endl
106
107
            << "  -U[PROPS]  consider atomic properties PROPS as exclusive "
	    << "events (implies -f)" << std::endl
martinez's avatar
martinez committed
108
109
110
	    << "  -v    display the BDD variables used by the automaton"
	    << std::endl
            << "  -x    try to produce a more deterministic automata "
111
	    << "(implies -f)" << std::endl
martinez's avatar
martinez committed
112
	    << "  -X    do not compute an automaton, read it from a file"
113
	    << std::endl
martinez's avatar
martinez committed
114
	    << "  -y    do not merge states with same symbolic representation "
115
116
117
	    << "(implies -f)" << std::endl
	    << std::endl
	    << "Where ALGO should be one of:" << std::endl
118
	    << "  couvreur99 (the default)" << std::endl
119
120
	    << "  couvreur99_shy" << std::endl
	    << "  magic_search" << std::endl
121
	    << "  magic_search_repeated" << std::endl
122
123
124
125
	    << "  bsh_magic_search[(heap size in Mo - 10Mo by default)]"
            << std::endl
	    << "  bsh_magic_search_repeated[(heap size in MB - 10MB"
            << " by default)]" << std::endl
126
	    << "  se05_search" << std::endl
127
128
129
130
	    << "  se05_search_repeated" << std::endl
	    << "  bsh_se05_search[(heap size in MB - 10MB by default)]"
            << std::endl
	    << "  bsh_se05_search_repeated[(heap size in MB - 10MB"
131
            << " by default)]" << std::endl
132
133
	    << "  tau03_search" << std::endl
	    << "  tau03_opt_search" << std::endl;
134
135
136
137
138
139
140
141
  exit(2);
}

int
main(int argc, char** argv)
{
  int exit_code = 0;

142
  bool debug_opt = false;
143
  enum { NoDegen, DegenTBA, DegenSBA } degeneralize_opt = NoDegen;
144
  bool degeneralize_maybe = false;
145
  bool fm_opt = false;
146
  bool fm_exprop_opt = false;
147
  bool fm_symb_merge_opt = true;
148
  bool file_opt = false;
149
  int output = 0;
150
  int formula_index = 0;
151
  std::string echeck_algo;
152
153
  enum { None, Couvreur, Couvreur2, MagicSearch, Se05Search,
              Tau03Search, Tau03OptSearch } echeck = None;
154
  enum { NoneDup, BFS, DFS } dupexp = NoneDup;
155
  bool search_many = false;
156
157
  bool bit_state_hashing = false;
  int heap_size = 10*1024*1024;
158
  bool expect_counter_example = false;
159
  bool from_file = false;
160
  int reduc_aut = spot::Reduce_None;
161
  int redopt = spot::ltl::Reduce_None;
162
163
  bool display_reduce_form = false;
  bool display_rel_sim = false;
164
  bool display_parity_game = false;
165
  bool post_branching = false;
166
  bool fair_loop_approx = false;
167
  bool graph_run_opt = false;
168
169
  spot::ltl::environment& env(spot::ltl::default_environment::instance());
  spot::ltl::atomic_prop_set* unobservables = 0;
170

171
  for (;;)
172
    {
173
      if (argc < formula_index + 2)
174
	syntax(argv[0]);
175
176
177

      ++formula_index;

178
179
180
181
182
183
184
185
186
      if (!strcmp(argv[formula_index], "-a"))
	{
	  output = 2;
	}
      else if (!strcmp(argv[formula_index], "-A"))
	{
	  output = 4;
	}
      else if (!strcmp(argv[formula_index], "-d"))
187
188
189
	{
	  debug_opt = true;
	}
190
191
      else if (!strcmp(argv[formula_index], "-D"))
	{
192
193
194
195
196
	  degeneralize_opt = DegenTBA;
	}
      else if (!strcmp(argv[formula_index], "-DS"))
	{
	  degeneralize_opt = DegenSBA;
197
	}
198
      else if (!strncmp(argv[formula_index], "-e", 2))
199
200
201
202
203
204
205
206
207
208
209
210
211
        {
          if (argv[formula_index][2] != 0)
            {
              char *p = strchr(argv[formula_index], '(');
              if (p && sscanf(p+1, "%d)", &heap_size) == 1)
                *p = '\0';
              echeck_algo = argv[formula_index] + 2;
            }
          else
            echeck_algo = "couvreur99";
          expect_counter_example = true;
          output = -1;
        }
212
      else if (!strncmp(argv[formula_index], "-E", 2))
213
214
215
216
217
218
219
220
221
222
223
224
225
        {
          if (argv[formula_index][2] != 0)
            {
              char *p = strchr(argv[formula_index], '(');
              if (p && sscanf(p+1, "%d)", &heap_size) == 1)
                *p = '\0';
              echeck_algo = argv[formula_index] + 2;
            }
          else
            echeck_algo = "couvreur99";
          expect_counter_example = false;
          output = -1;
        }
226
227
228
229
230
231
232
233
      else if (!strcmp(argv[formula_index], "-f"))
	{
	  fm_opt = true;
	}
      else if (!strcmp(argv[formula_index], "-F"))
	{
	  file_opt = true;
	}
234
235
236
237
      else if (!strcmp(argv[formula_index], "-g"))
	{
	  graph_run_opt = true;
	}
238
239
240
241
242
      else if (!strcmp(argv[formula_index], "-L"))
	{
	  fair_loop_approx = true;
	  fm_opt = true;
	}
martinez's avatar
martinez committed
243
244
      else if (!strcmp(argv[formula_index], "-N"))
	{
245
	  degeneralize_opt = DegenSBA;
martinez's avatar
martinez committed
246
247
	  output = 8;
	}
248
249
250
251
252
      else if (!strcmp(argv[formula_index], "-p"))
	{
	  post_branching = true;
	  fm_opt = true;
	}
253
254
      else if (!strcmp(argv[formula_index], "-r"))
	{
255
256
	  output = 1;
	}
257
258
259
260
261
262
      else if (!strcmp(argv[formula_index], "-r1"))
	{
	  redopt |= spot::ltl::Reduce_Basics;
	}
      else if (!strcmp(argv[formula_index], "-r2"))
	{
263
	  redopt |= spot::ltl::Reduce_Eventuality_And_Universality;
264
265
266
	}
      else if (!strcmp(argv[formula_index], "-r3"))
	{
267
	  redopt |= spot::ltl::Reduce_Syntactic_Implications;
268
269
270
271
272
	}
      else if (!strcmp(argv[formula_index], "-r4"))
	{
	  redopt |= spot::ltl::Reduce_All;
	}
273
274
275
      else if (!strcmp(argv[formula_index], "-R"))
	{
	  output = 3;
276
	}
martinez's avatar
martinez committed
277
278
279
280
281
282
283
284
285
      else if (!strcmp(argv[formula_index], "-R1q"))
	{
	  reduc_aut |= spot::Reduce_quotient_Dir_Sim;
	}
      else if (!strcmp(argv[formula_index], "-R1t"))
	{
	  reduc_aut |= spot::Reduce_transition_Dir_Sim;
	}
      else if (!strcmp(argv[formula_index], "-R2q"))
286
	{
martinez's avatar
martinez committed
287
	  reduc_aut |= spot::Reduce_quotient_Del_Sim;
288
	}
martinez's avatar
martinez committed
289
      else if (!strcmp(argv[formula_index], "-R2t"))
290
	{
martinez's avatar
martinez committed
291
	  reduc_aut |= spot::Reduce_transition_Del_Sim;
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
	}
      else if (!strcmp(argv[formula_index], "-R3"))
	{
	  reduc_aut |= spot::Reduce_Scc;
	}
      else if (!strcmp(argv[formula_index], "-rd"))
	{
	  display_reduce_form = true;
	}
      else if (!strcmp(argv[formula_index], "-Rd"))
	{
	  display_rel_sim = true;
	}
      else if (!strcmp(argv[formula_index], "-RD"))
	{
	  display_parity_game = true;
	}
309
310
311
312
313
314
315
316
      else if (!strcmp(argv[formula_index], "-s"))
	{
	  dupexp = DFS;
	}
      else if (!strcmp(argv[formula_index], "-S"))
	{
	  dupexp = BFS;
	}
317
318
319
320
      else if (!strcmp(argv[formula_index], "-t"))
	{
	  output = 6;
	}
321
322
323
324
325
      else if (!strncmp(argv[formula_index], "-U", 2))
	{
	  unobservables = new spot::ltl::atomic_prop_set;
	  fm_opt = true;
	  // Parse -U's argument.
326
	  const char* tok = strtok(argv[formula_index] + 2, ", \t;");
327
328
329
330
	  while (tok)
	    {
	      unobservables->insert
		(static_cast<spot::ltl::atomic_prop*>(env.require(tok)));
331
	      tok = strtok(0, ", \t;");
332
333
	    }
	}
334
335
336
337
      else if (!strcmp(argv[formula_index], "-v"))
	{
	  output = 5;
	}
338
339
340
341
342
      else if (!strcmp(argv[formula_index], "-x"))
	{
	  fm_opt = true;
	  fm_exprop_opt = true;
	}
343
344
345
346
      else if (!strcmp(argv[formula_index], "-X"))
	{
	  from_file = true;
	}
347
348
349
350
351
      else if (!strcmp(argv[formula_index], "-y"))
	{
	  fm_opt = true;
	  fm_symb_merge_opt = false;
	}
352
353
354
355
      else
	{
	  break;
	}
356
357
    }

358
  if (echeck_algo != "")
359
    {
360
361
362
363
364
365
366
367
368
369
370
      if (echeck_algo == "couvreur99")
	{
	  echeck = Couvreur;
	}
      else if (echeck_algo == "couvreur99_shy")
	{
	  echeck = Couvreur2;
	}
      else if (echeck_algo == "magic_search")
	{
	  echeck = MagicSearch;
371
	  degeneralize_maybe = true;
372
373
374
375
	}
      else if (echeck_algo == "magic_search_repeated")
	{
	  echeck = MagicSearch;
376
	  degeneralize_maybe = true;
377
	  search_many = true;
378
	}
379
380
381
      else if (echeck_algo == "bsh_magic_search")
	{
	  echeck = MagicSearch;
382
	  degeneralize_maybe = true;
383
384
385
386
387
          bit_state_hashing = true;
	}
      else if (echeck_algo == "bsh_magic_search_repeated")
	{
	  echeck = MagicSearch;
388
	  degeneralize_maybe = true;
389
          bit_state_hashing = true;
390
	  search_many = true;
391
	}
392
393
      else if (echeck_algo == "se05_search")
	{
394
	  echeck = Se05Search;
395
	  degeneralize_maybe = true;
396
397
398
	}
      else if (echeck_algo == "se05_search_repeated")
	{
399
	  echeck = Se05Search;
400
	  degeneralize_maybe = true;
401
	  search_many = true;
402
403
404
405
	}
      else if (echeck_algo == "bsh_se05_search")
	{
	  echeck = Se05Search;
406
	  degeneralize_maybe = true;
407
408
409
410
411
          bit_state_hashing = true;
	}
      else if (echeck_algo == "bsh_se05_search_repeated")
	{
	  echeck = Se05Search;
412
	  degeneralize_maybe = true;
413
          bit_state_hashing = true;
414
415
416
417
418
	  search_many = true;
	}
      else if (echeck_algo == "tau03_search")
	{
	  echeck = Tau03Search;
419
	}
420
421
422
423
      else if (echeck_algo == "tau03_opt_search")
	{
	  echeck = Tau03OptSearch;
	}
424
425
426
427
428
      else
	{
	  std::cerr << "unknown emptiness-check: " << echeck_algo << std::endl;
	  syntax(argv[0]);
	}
429
430
    }

431
432
433
434
435
436
  if (graph_run_opt && (echeck_algo == "" || !expect_counter_example))
    {
      std::cerr << argv[0] << ": error: -g requires -e." << std::endl;
      exit(1);
    }

437
438
439
440
  std::string input;

  if (file_opt)
    {
441
      if (strcmp(argv[formula_index], "-"))
442
	{
443
	  std::ifstream fin(argv[formula_index]);
444
	  if (!fin)
445
446
447
448
	    {
	      std::cerr << "Cannot open " << argv[formula_index] << std::endl;
	      exit(2);
	    }
449

450
	  if (!std::getline(fin, input, '\0'))
451
452
453
454
455
456
	    {
	      std::cerr << "Cannot read " << argv[formula_index] << std::endl;
	      exit(2);
	    }
	}
      else
457
	{
458
	  std::getline(std::cin, input, '\0');
459
460
461
462
463
464
465
	}
    }
  else
    {
      input = argv[formula_index];
    }

466
  spot::bdd_dict* dict = new spot::bdd_dict();
467
468
469
470
471
472
473
474
475

  spot::ltl::formula* f = 0;
  if (!from_file)
    {
      spot::ltl::parse_error_list pel;
      f = spot::ltl::parse(input, pel, env, debug_opt);
      exit_code = spot::ltl::format_parse_errors(std::cerr, input, pel);
    }
  if (f || from_file)
476
    {
477
478
479
480
      spot::tgba_bdd_concrete* concrete = 0;
      spot::tgba* to_free = 0;
      spot::tgba* a = 0;

481
482
483
      if (from_file)
	{
	  spot::tgba_parse_error_list pel;
484
485
	  spot::tgba_explicit* e;
	  to_free = a = e = spot::tgba_parse(input, pel, dict, env, debug_opt);
486
	  if (spot::format_tgba_parse_errors(std::cerr, pel))
487
488
489
490
491
	    {
	      delete to_free;
	      delete dict;
	      return 2;
	    }
492
	  e->merge_transitions();
493
	}
494
      else
495
	{
496
	  if (redopt != spot::ltl::Reduce_None)
497
	    {
498
499
500
	      spot::ltl::formula* t = spot::ltl::reduce(f, redopt);
	      spot::ltl::destroy(f);
	      f = t;
501
502
	      if (display_reduce_form)
		std::cout << spot::ltl::to_string(f) << std::endl;
503
	    }
504

505
	  if (fm_opt)
506
	    to_free = a = spot::ltl_to_tgba_fm(f, dict, fm_exprop_opt,
507
					       fm_symb_merge_opt,
508
					       post_branching,
509
					       fair_loop_approx, unobservables);
510
511
512
	  else
	    to_free = a = concrete = spot::ltl_to_tgba_lacim(f, dict);
	}
513

514
      spot::tgba_tba_proxy* degeneralized = 0;
515

516
517
518
519
520
      if (degeneralize_maybe
	  && degeneralize_opt == NoDegen
	  && a->number_of_acceptance_conditions() > 1)
	degeneralize_opt = DegenTBA;
      if (degeneralize_opt == DegenTBA)
521
	a = degeneralized = new spot::tgba_tba_proxy(a);
522
523
      else if (degeneralize_opt == DegenSBA)
	a = degeneralized = new spot::tgba_sba_proxy(a);
524

525
526
527
528
      spot::tgba_reduc* aut_red = 0;
      if (reduc_aut != spot::Reduce_None)
	{
	  a = aut_red = new spot::tgba_reduc(a);
529
530
531
532

	  if (reduc_aut & spot::Reduce_Scc)
	    aut_red->prune_scc();

martinez's avatar
martinez committed
533
534
535
536
	  if (reduc_aut & (spot::Reduce_quotient_Dir_Sim |
			   spot::Reduce_transition_Dir_Sim |
			   spot::Reduce_quotient_Del_Sim |
			   spot::Reduce_transition_Del_Sim))
537
	    {
martinez's avatar
martinez committed
538
539
540
541
542
	      spot::direct_simulation_relation* rel_dir = 0;
	      spot::delayed_simulation_relation* rel_del = 0;

	      if (reduc_aut & (spot::Reduce_quotient_Dir_Sim |
			       spot::Reduce_transition_Dir_Sim))
543
544
545
546
		rel_dir =
		  spot::get_direct_relation_simulation(a,
						       std::cout,
						       display_parity_game);
martinez's avatar
martinez committed
547
548
	      else if (reduc_aut & (spot::Reduce_quotient_Del_Sim |
				    spot::Reduce_transition_Del_Sim))
549
550
551
552
		rel_del =
		  spot::get_delayed_relation_simulation(a,
							std::cout,
							display_parity_game);
553
554

	      if (display_rel_sim)
martinez's avatar
martinez committed
555
556
557
558
559
560
		{
		  if (rel_dir)
		    aut_red->display_rel_sim(rel_dir, std::cout);
		  if (rel_del)
		    aut_red->display_rel_sim(rel_del, std::cout);
		}
561

martinez's avatar
martinez committed
562
563
564
565
566
567
568
569
570
571
572
573
574
	      if (reduc_aut & spot::Reduce_quotient_Dir_Sim)
		aut_red->quotient_state(rel_dir);
	      if (reduc_aut & spot::Reduce_transition_Dir_Sim)
		aut_red->delete_transitions(rel_dir);
	      if (reduc_aut & spot::Reduce_quotient_Del_Sim)
		aut_red->quotient_state(rel_del);
	      if (reduc_aut & spot::Reduce_transition_Del_Sim)
		aut_red->delete_transitions(rel_del);

	      if (rel_dir)
		spot::free_relation_simulation(rel_dir);
	      if (rel_del)
		spot::free_relation_simulation(rel_del);
575
576
577
	    }
	}

578
579
580
581
582
583
584
585
586
587
588
589
590
      spot::tgba_explicit* expl = 0;
      switch (dupexp)
	{
	case NoneDup:
	  break;
	case BFS:
	  a = expl = tgba_dupexp_bfs(a);
	  break;
	case DFS:
	  a = expl = tgba_dupexp_dfs(a);
	  break;
	}

591
592
      switch (output)
	{
593
594
595
	case -1:
	  /* No output.  */
	  break;
596
597
598
599
	case 0:
	  spot::dotty_reachable(std::cout, a);
	  break;
	case 1:
600
601
602
	  if (concrete)
	    spot::bdd_print_dot(std::cout, concrete->get_dict(),
				concrete->get_core_data().relation);
603
604
	  break;
	case 2:
605
606
607
	  if (concrete)
	    spot::bdd_print_dot(std::cout, concrete->get_dict(),
				concrete->
608
				get_core_data().acceptance_conditions);
609
610
	  break;
	case 3:
611
612
613
	  if (concrete)
	    spot::bdd_print_set(std::cout, concrete->get_dict(),
				concrete->get_core_data().relation);
614
615
	  break;
	case 4:
616
617
618
	  if (concrete)
	    spot::bdd_print_set(std::cout, concrete->get_dict(),
				concrete->
619
				get_core_data().acceptance_conditions);
620
	  break;
621
	case 5:
622
	  a->get_dict()->dump(std::cout);
623
	  break;
624
625
626
	case 6:
	  spot::lbtt_reachable(std::cout, a);
	  break;
627
	case 8:
628
629
630
631
632
633
634
	  {
	    assert(degeneralize_opt == DegenSBA);
	    const spot::tgba_sba_proxy* s =
	      static_cast<const spot::tgba_sba_proxy*>(degeneralized);
	    spot::never_claim_reachable(std::cout, s, f);
	    break;
	  }
635
636
637
	default:
	  assert(!"unknown output option");
	}
638

639
      spot::emptiness_check* ec = 0;
640
641
642
643
      switch (echeck)
	{
	case None:
	  break;
martinez's avatar
martinez committed
644

645
	case Couvreur:
646
647
648
	  ec = new spot::couvreur99_check(a);
	  break;

649
	case Couvreur2:
650
	  ec = new spot::couvreur99_check_shy(a);
651
	  break;
martinez's avatar
martinez committed
652

653
654
        case MagicSearch:
          if (bit_state_hashing)
655
            ec = spot::bit_state_hashing_magic_search(a, heap_size);
656
          else
657
            ec = spot::explicit_magic_search(a);
658
          break;
659

660
661
        case Se05Search:
          if (bit_state_hashing)
662
            ec = spot::bit_state_hashing_se05_search(a, heap_size);
663
          else
664
            ec = spot::explicit_se05_search(a);
665
          break;
666
667
668
669
670
671
672
673
674
675
676
677

	case Tau03Search:
          if (a->number_of_acceptance_conditions() == 0)
            {
              std::cout << "To apply tau03_search, the automaton must have at "
                        << "least on accepting condition. Try with another "
                        << "algorithm." << std::endl;
            }
          else
            {
              ec = spot::explicit_tau03_search(a);
            }
678
679
680
681
682
683
684
685
686
687
688
689

	case Tau03OptSearch:
          if (a->number_of_acceptance_conditions() == 0)
            {
              std::cout << "To apply tau03_opt_search, the automaton must "
                        << "have at least on accepting condition. "
                        << "Try with another algorithm." << std::endl;
            }
          else
            {
              ec = spot::explicit_tau03_opt_search(a);
            }
690
	  break;
691
	}
martinez's avatar
martinez committed
692

693
694
695
696
697
      if (ec)
	{
	  do
	    {
	      spot::emptiness_check_result* res = ec->check();
698
699
	      if (!graph_run_opt)
		ec->print_stats(std::cout);
700
701
	      if (expect_counter_example != !!res &&
                      (!bit_state_hashing || !expect_counter_example))
702
703
704
705
		exit_code = 1;

	      if (!res)
		{
706
707
708
709
710
711
712
713
714
715
716
                  std::cout << "no accepting run found";
                  if (bit_state_hashing && expect_counter_example)
                    {
                      std::cout << " even if expected" << std::endl;
                      std::cout << "this is maybe due to the use of the bit "
                                << "state hashing technic" << std::endl;
                      std::cout << "you can try to increase the heap size "
                                << "or use an explicit storage" << std::endl;
                    }
                  std::cout << std::endl;
                  break;
717
718
719
720
721
722
723
		}
	      else
		{

		  spot::tgba_run* run = res->accepting_run();
		  if (!run)
		    {
724
		      std::cout << "an accepting run exists" << std::endl;
725
726
727
		    }
		  else
		    {
728
729
730
		      if (graph_run_opt)
			{
			  spot::tgba_run_dotty_decorator deco(run);
731
			  spot::dotty_reachable(std::cout, a, &deco);
732
733
734
			}
		      else
			{
735
736
			  spot::print_tgba_run(std::cout, a, run);
			  if (!spot::replay_tgba_run(std::cout, a, run, true))
737
738
			    exit_code = 1;
			}
739
740
741
742
743
		      delete run;
		    }
		}
	      delete res;
	    }
744
	  while (search_many);
745
	  delete ec;
martinez's avatar
martinez committed
746
747
	}

748
749
      if (f)
        spot::ltl::destroy(f);
750
751
752
      delete expl;
      delete degeneralized;
      delete aut_red;
753
      delete to_free;
754
755
756
757
758
759
760
761
762
763
    }
  else
    {
      exit_code = 1;
    }

  assert(spot::ltl::atomic_prop::instance_count() == 0);
  assert(spot::ltl::unop::instance_count() == 0);
  assert(spot::ltl::binop::instance_count() == 0);
  assert(spot::ltl::multop::instance_count() == 0);
764
  delete dict;
765
766
  return exit_code;
}