tgbaexplicit.hh 17.4 KB
Newer Older
Pierre PARUTTO's avatar
Pierre PARUTTO committed
1
2
3
4
5
6
// -*- encoding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
// Développement de l'Epita.
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
// 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.

25
26
27
#ifndef SPOT_TGBA_TGBAEXPLICIT_HH
# define SPOT_TGBA_TGBAEXPLICIT_HH

Pierre PARUTTO's avatar
Pierre PARUTTO committed
28
#include <sstream>
29
#include <list>
Pierre PARUTTO's avatar
Pierre PARUTTO committed
30

31
#include "tgba.hh"
Pierre PARUTTO's avatar
Pierre PARUTTO committed
32
33
34
#include "tgba/formula2bdd.hh"
#include "misc/hash.hh"
#include "misc/bddop.hh"
35
#include "ltlast/formula.hh"
Pierre PARUTTO's avatar
Pierre PARUTTO committed
36
#include "ltlvisit/tostring.hh"
37
38
39

namespace spot
{
Pierre PARUTTO's avatar
Pierre PARUTTO committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  ///misc
  template<typename T>
  struct destroy_key
  {
    void destroy(T t)
    {
      (void) t;
    }
  };

  template<>
  struct destroy_key<const ltl::formula*>
  {
    void destroy(const ltl::formula* t)
    {
      t->destroy();
    }
  };
58

59
  class sba: public tgba
Pierre PARUTTO's avatar
Pierre PARUTTO committed
60
61
  {
  public:
62
    /// A State in an SBA (State-based Buchi Automaton) is accepting
Pierre PARUTTO's avatar
Pierre PARUTTO committed
63
64
65
66
67
    /// iff all outgoing transitions are accepting.
    virtual bool is_accepting(const spot::state* s) = 0;
  };

  /// States used by spot::explicit_graph implementation
68
  /// \ingroup tgba_representation
Pierre PARUTTO's avatar
Pierre PARUTTO committed
69
  template<typename Label, typename label_hash>
70
  class state_explicit: public spot::state
71
72
  {
  public:
73
74
75
76
    state_explicit()
    {
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
77
78
    state_explicit(const Label& l):
      label_(l)
79
80
81
    {
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
82
    virtual ~state_explicit()
83
84
    {
    }
85

86
87
88
    void destroy() const
    {
    }
89

Pierre PARUTTO's avatar
Pierre PARUTTO committed
90
91
92
    typedef Label Label_t;
    typedef label_hash label_hash_t;

93
94
95
    struct transition
    {
      bdd condition;
96
      bdd acceptance_conditions;
Pierre PARUTTO's avatar
Pierre PARUTTO committed
97
      const state_explicit<Label, label_hash>* dest;
98
99
    };

100
101
102
    typedef std::list<transition> transitions_t;
    transitions_t successors;

Pierre PARUTTO's avatar
Pierre PARUTTO committed
103
    const Label& label() const
104
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
105
      return label_;
106
107
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
108
109
110
111
    bool empty() const
    {
      return successors.empty();
    }
112

Pierre PARUTTO's avatar
Pierre PARUTTO committed
113
114
115
116
117
118
119
120
121
122
123
124
125
    virtual int compare(const state* other) const
    {
      const state_explicit<Label, label_hash>* s =
	down_cast<const state_explicit<Label, label_hash>*>(other);
      assert (s);

      // Do not simply return "o - this", it might not fit in an int.
      if (s < this)
	return -1;
      if (s > this)
	return 1;
      return 0;
    }
126

Pierre PARUTTO's avatar
Pierre PARUTTO committed
127
128
129
130
131
    virtual size_t hash() const
    {
      return
	reinterpret_cast<const char*>(this) - static_cast<const char*>(0);
    }
132

Pierre PARUTTO's avatar
Pierre PARUTTO committed
133
134
135
136
137
    virtual state_explicit<Label, label_hash>*
    clone() const
    {
      return const_cast<state_explicit<Label, label_hash>*>(this);
    }
138

Pierre PARUTTO's avatar
Pierre PARUTTO committed
139
140
141
  protected:
    Label label_;
  };
142

Pierre PARUTTO's avatar
Pierre PARUTTO committed
143
144
145
146
147
148
149
150
151
152
  ///states labeled by an int
  /// \ingroup tgba_representation
  class state_explicit_number:
    public state_explicit<int, identity_hash<int> >
  {
  public:
    state_explicit_number()
      : state_explicit<int, identity_hash<int> >()
    {
    }
153

Pierre PARUTTO's avatar
Pierre PARUTTO committed
154
155
156
157
    state_explicit_number(int label)
      : state_explicit<int, identity_hash<int> >(label)
    {
    }
158

Pierre PARUTTO's avatar
Pierre PARUTTO committed
159
160
161
    virtual void destroy()
    {
    }
162

Pierre PARUTTO's avatar
Pierre PARUTTO committed
163
164
165
166
167
168
169
170
    static const int default_val;
    static std::string to_string(int l)
    {
      std::stringstream ss;
      ss << l;
      return ss.str();
    }
  };
171

Pierre PARUTTO's avatar
Pierre PARUTTO committed
172
173
174
175
176
177
178
179
180
181
  /// States labeled by a string
  /// \ingroup tgba_representation
  class state_explicit_string:
    public state_explicit<std::string, string_hash>
  {
  public:
    state_explicit_string():
      state_explicit<std::string, string_hash>()
    {
    }
182

Pierre PARUTTO's avatar
Pierre PARUTTO committed
183
184
185
186
    state_explicit_string(const std::string& label)
      : state_explicit<std::string, string_hash>(label)
    {
    }
187

Pierre PARUTTO's avatar
Pierre PARUTTO committed
188
189
190
    virtual void destroy()
    {
    }
191

Pierre PARUTTO's avatar
Pierre PARUTTO committed
192
193
194
195
196
197
    static const std::string default_val;
    static std::string to_string(const std::string& l)
    {
      return l;
    }
  };
198

Pierre PARUTTO's avatar
Pierre PARUTTO committed
199
200
201
202
203
204
205
206
207
208
  /// States labeled by a formula
  /// \ingroup tgba_representation
  class state_explicit_formula:
    public state_explicit<const ltl::formula*, ltl::formula_ptr_hash>
  {
  public:
    state_explicit_formula():
      state_explicit<const ltl::formula*, ltl::formula_ptr_hash>()
    {
    }
209

Pierre PARUTTO's avatar
Pierre PARUTTO committed
210
211
212
213
    state_explicit_formula(const ltl::formula* label)
      : state_explicit<const ltl::formula*, ltl::formula_ptr_hash>(label)
    {
    }
214

Pierre PARUTTO's avatar
Pierre PARUTTO committed
215
216
217
    virtual void destroy()
    {
    }
218

Pierre PARUTTO's avatar
Pierre PARUTTO committed
219
220
221
222
223
224
    static const ltl::formula* default_val;
    static std::string to_string(const ltl::formula* l)
    {
      return ltl::to_string(l);
    }
  };
225

226
  /// Successor iterators used by spot::tgba_explicit.
227
  /// \ingroup tgba_representation
Pierre PARUTTO's avatar
Pierre PARUTTO committed
228
  template<typename State>
229
  class tgba_explicit_succ_iterator: public tgba_succ_iterator
230
231
  {
  public:
Pierre PARUTTO's avatar
Pierre PARUTTO committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
    tgba_explicit_succ_iterator(const State* start,
				bdd all_acc)
      : start_(start),
	all_acceptance_conditions_(all_acc)
    {
    }

    virtual void first()
    {
      it_ = start_->successors.begin();
    }

    virtual void next()
    {
      ++it_;
    }
248

Pierre PARUTTO's avatar
Pierre PARUTTO committed
249
250
251
252
    virtual bool done() const
    {
      return it_ == start_->successors.end();
    }
253

Pierre PARUTTO's avatar
Pierre PARUTTO committed
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
    virtual State* current_state() const
    {
      assert(!done());

      //ugly but I can't see any other wayout
      const State* res = down_cast<const State*>(it_->dest);
      assert(res);

      return
	const_cast<State*>(res);
    }

    virtual bdd current_condition() const
    {
      assert(!done());
      return it_->condition;
    }

    virtual bdd current_acceptance_conditions() const
    {
      assert(!done());
      return it_->acceptance_conditions & all_acceptance_conditions_;
    }
277

278
279
280
281
282
283
    typename State::transitions_t::const_iterator
    get_iterator() const
    {
      return it_;
    }

284
  private:
Pierre PARUTTO's avatar
Pierre PARUTTO committed
285
286
    const State* start_;
    typename State::transitions_t::const_iterator it_;
287
    bdd all_acceptance_conditions_;
288
289
  };

Pierre PARUTTO's avatar
Pierre PARUTTO committed
290
291
292
293
  /// Graph implementation for automata representation
  /// \ingroup tgba_representation
  template<typename State, typename Type>
  class explicit_graph: public Type
294
295
  {
  protected:
Pierre PARUTTO's avatar
Pierre PARUTTO committed
296
297
298
299
300
    typedef Sgi::hash_map<typename State::Label_t, State,
			  typename State::label_hash_t> ls_map;
    typedef Sgi::hash_map<const State*, typename State::Label_t,
			  ptr_hash<State> > sl_map;

301
  public:
302
303
    typedef typename State::transition transition;

Pierre PARUTTO's avatar
Pierre PARUTTO committed
304
305
306
307
308
309
310
    explicit_graph(bdd_dict* dict)
      : ls_(),
	sl_(),
	init_(0),
	dict_(dict)
    {
    }
311

Pierre PARUTTO's avatar
Pierre PARUTTO committed
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
    State* add_default_init()
    {
      return add_state(State::default_val);
    }

    transition*
    create_transition(State* source, const State* dest)
    {
      transition t;

      t.dest = dest;
      t.condition = bddtrue;
      t.acceptance_conditions = bddfalse;

      typename State::transitions_t::iterator i =
	source->successors.insert(source->successors.end(), t);

      return &*i;
    }

    transition*
    create_transition(const typename State::Label_t& source,
		      const typename State::Label_t& dest)
    {
      // It's important that the source be created before the
      // destination, so the first source encountered becomes the
      // default initial state.
      State* s = add_state(source);
      return create_transition(s, add_state(dest));
    }

    transition*
    get_transition(const tgba_explicit_succ_iterator<State>* si)
    {
346
      return const_cast<transition*>(&(*(si->get_iterator())));
Pierre PARUTTO's avatar
Pierre PARUTTO committed
347
348
349
350
351
352
353
354
355
356
    }

    void add_condition(transition* t, const ltl::formula* f)
    {
      t->condition &= formula_to_bdd(f, dict_, this);
      f->destroy();
    }

    /// This assumes that all variables in \a f are known from dict.
    void add_conditions(transition* t, bdd f)
357
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
358
359
      dict_->register_propositions(f, this);
      t->condition &= f;
360
361
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
362
    bool has_acceptance_condition(const ltl::formula* f) const
363
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
364
365
366
367
368
369
370
371
372
373
374
375
376
      return dict_->is_registered_acceptance_variable(f, this);
    }

    //old tgba explicit labelled interface
    bool has_state(const typename State::Label_t& name)
    {
      return ls_.find(name) != ls_.end();
    }

    const typename State::Label_t& get_label(const State* s) const
    {
      typename sl_map::const_iterator i = sl_.find(s);
      assert(i != sl_.end());
377
378
379
      return i->second;
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
380
    const typename State::Label_t& get_label(const spot::state* s) const
381
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
382
      const State* se = down_cast<const State*>(s);
383
      assert(se);
384
      return get_label(se);
385
386
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
    transition*
    create_trainsition(const typename State::Label_t& source,
		       const typename State::Label_t& dest)
    {
      // It's important that the source be created before the
      // destination, so the first source encountered becomes the
      // default initial state.
      State* s = add_state(source);
      return create_transition(s, add_state(dest));
    }

    void
    complement_all_acceptance_conditions()
    {
      bdd all = this->all_acceptance_conditions();
      typename ls_map::iterator i;
      for (i = ls_.begin(); i != ls_.end(); ++i)
	{
	  typename State::transitions_t::iterator i2;
	  for (i2 = i->second.successors.begin();
	       i2 != i->second.successors.end(); ++i2)
	    i2->acceptance_conditions = all - i2->acceptance_conditions;
	}
    }

    void
    merge_transitions()
    {
      typename ls_map::iterator i;
      for (i = ls_.begin(); i != ls_.end(); ++i)
      {
	typename State::transitions_t::iterator t1;
	for (t1 = i->second.successors.begin();
	     t1 != i->second.successors.end(); ++t1)
	{
	  bdd acc = t1->acceptance_conditions;
	  const state_explicit<typename State::Label_t,
			       typename State::label_hash_t>* dest = t1->dest;

	  // Find another transition with the same destination and
	  // acceptance conditions.
	  typename State::transitions_t::iterator t2 = t1;
	  ++t2;
	  while (t2 != i->second.successors.end())
	  {
	    typename State::transitions_t::iterator t2copy = t2++;
	    if (t2copy->acceptance_conditions == acc && t2copy->dest == dest)
	    {
	      t1->condition |= t2copy->condition;
	      i->second.successors.erase(t2copy);
	    }
	  }
	}
      }
    }

443
    /// Return the state_explicit for \a name, creating the state if
444
    /// it does not exist.
Pierre PARUTTO's avatar
Pierre PARUTTO committed
445
    State* add_state(const typename State::Label_t& name)
446
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
447
448
      typename ls_map::iterator i = ls_.find(name);
      if (i == ls_.end())
449
	{
Pierre PARUTTO's avatar
Pierre PARUTTO committed
450
451
452
	  State s(name);
	  ls_[name] = s;
	  sl_[&ls_[name]] = name;
453
454
455
456

	  // The first state we add is the inititial state.
	  // It can also be overridden with set_init_state().
	  if (!init_)
Pierre PARUTTO's avatar
Pierre PARUTTO committed
457
	    init_ = &ls_[name];
458

Pierre PARUTTO's avatar
Pierre PARUTTO committed
459
	  return &(ls_[name]);
460
	}
Pierre PARUTTO's avatar
Pierre PARUTTO committed
461
      return &(i->second);
462
    }
463

Pierre PARUTTO's avatar
Pierre PARUTTO committed
464
465
    State*
    set_init_state(const typename State::Label_t& state)
466
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
467
      State* s = add_state(state);
468
469
470
471
      init_ = s;
      return s;
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
472
473
474
475
    // tgba interface
    virtual ~explicit_graph()
    {
      typename ls_map::iterator i = ls_.begin();
476

Pierre PARUTTO's avatar
Pierre PARUTTO committed
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
      while (i != ls_.end())
      {
	typename State::Label_t s = i->first;

	// Do not erase the same state twice(Because of possible aliases).
	if (sl_.erase(&(i->second)))
	  i->second.destroy();

	++i;
	destroy_key<typename State::Label_t> dest;
	dest.destroy(s);
      }
    }

    virtual State* get_init_state() const
492
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
493
494
495
496
      if (!init_)
	const_cast<explicit_graph<State, Type>*>(this)->add_default_init();

      return init_;
497
498
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
499
500
501
502
    virtual tgba_explicit_succ_iterator<State>*
    succ_iter(const spot::state* state,
	      const spot::state* global_state = 0,
	      const tgba* global_automaton = 0) const
503
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
504
505
506
507
508
509
510
511
512
513
      const State* s = down_cast<const State*>(state);
      assert(s);

      (void) global_state;
      (void) global_automaton;

      return
	new tgba_explicit_succ_iterator<State>(s,
					       this
					       ->all_acceptance_conditions());
514
515
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
    //no need?
    virtual std::string format_state(const spot::state* state) const
    {
      const State* se = down_cast<const State*>(state);
      assert(se);
      typename sl_map::const_iterator i = sl_.find(se);
      assert(i != sl_.end());
      return State::to_string(i->second);
    }

    /// old implementation in tgba_explicit_string
    /// Create an alias for a state.  Any reference to \a alias_name
    /// will act as a reference to \a real_name.
    void add_state_alias(const typename State::Label_t& alias,
			 const typename State::Label_t& real)
    {
      ls_[alias] = *(add_state(real));
    }

  protected:

    ls_map ls_;
    sl_map sl_;
    State* init_;

    bdd_dict* dict_;
  };

  template <typename State>
  class tgba_explicit: public explicit_graph<State, tgba>
  {
  public:
548
    typedef typename State::transition transition;
Pierre PARUTTO's avatar
Pierre PARUTTO committed
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
    typedef State state;

    tgba_explicit(bdd_dict* dict):
      explicit_graph<State,tgba>(dict),
      all_acceptance_conditions_(bddfalse),
      all_acceptance_conditions_computed_(false),
      neg_acceptance_conditions_(bddtrue)
    {
    }

    /// \brief Copy the acceptance conditions of a tgba.
    ///
    /// If used, this function should be called before creating any
    /// transition.
    void copy_acceptance_conditions_of(const tgba *a)
    {
      assert(neg_acceptance_conditions_ == bddtrue);
      assert(all_acceptance_conditions_computed_ == false);
      bdd f = a->neg_acceptance_conditions();
      this->dict_->register_acceptance_variables(f, this);
      neg_acceptance_conditions_ = f;
    }

    /// The acceptance conditions.
    void set_acceptance_conditions(bdd acc)
    {
      assert(neg_acceptance_conditions_ == bddtrue);
      assert(all_acceptance_conditions_computed_ == false);

      this->dict_->register_acceptance_variables(bdd_support(acc), this);
      neg_acceptance_conditions_ = compute_neg_acceptance_conditions(acc);
      all_acceptance_conditions_computed_ = true;
      all_acceptance_conditions_ = acc;
    }

    void add_acceptance_condition(transition* t, const ltl::formula* f)
585
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
586
587
588
589
590
591
592
593
594
595
596
      bdd c = get_acceptance_condition(f);
      t->acceptance_conditions |= c;
    }

    /// This assumes that all acceptance conditions in \a f are known from
    /// dict.
    void add_acceptance_conditions(transition* t, bdd f)
    {
      bdd sup = bdd_support(f);
      this->dict_->register_acceptance_variables(sup, this);
      while (sup != bddtrue)
597
	{
Pierre PARUTTO's avatar
Pierre PARUTTO committed
598
599
	  neg_acceptance_conditions_ &= bdd_nithvar(bdd_var(sup));
	  sup = bdd_high(sup);
600
	}
Pierre PARUTTO's avatar
Pierre PARUTTO committed
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
      t->acceptance_conditions |= f;
    }

    /// tgba interface
    virtual ~tgba_explicit()
    {
      this->dict_->unregister_all_my_variables(this);
      // These have already been destroyed by subclasses.
      // Prevent destroying by tgba::~tgba.
      this->last_support_conditions_input_ = 0;
      this->last_support_variables_input_ = 0;

    }

    virtual bdd all_acceptance_conditions() const
    {
      if (!all_acceptance_conditions_computed_)
      {
	all_acceptance_conditions_ =
	  compute_all_acceptance_conditions(neg_acceptance_conditions_);
	all_acceptance_conditions_computed_ = true;
      }
      return all_acceptance_conditions_;
    }

    virtual bdd_dict* get_dict() const
    {
      return this->dict_;
    }

    virtual bdd neg_acceptance_conditions() const
    {
      return neg_acceptance_conditions_;
634
635
636
637
638
    }

    void
    declare_acceptance_condition(const ltl::formula* f)
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
639
      int v = this->dict_->register_acceptance_variable(f, this);
640
641
642
643
644
      f->destroy();
      bdd neg = bdd_nithvar(v);
      neg_acceptance_conditions_ &= neg;

      // Append neg to all acceptance conditions.
Pierre PARUTTO's avatar
Pierre PARUTTO committed
645
646
      typename explicit_graph<State, tgba>::ls_map::iterator i;
      for (i = this->ls_.begin(); i != this->ls_.end(); ++i)
647
	{
Pierre PARUTTO's avatar
Pierre PARUTTO committed
648
649
650
	  typename State::transitions_t::iterator i2;
	  for (i2 = i->second.successors.begin();
	       i2 != i->second.successors.end(); ++i2)
651
	    i2->acceptance_conditions &= neg;
652
653
654
655
656
	}

      all_acceptance_conditions_computed_ = false;
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
657
  protected:
658

Pierre PARUTTO's avatar
Pierre PARUTTO committed
659
    bdd get_acceptance_condition(const ltl::formula* f)
660
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
661
662
663
664
665
666
      bdd_dict::fv_map::iterator i = this->dict_->acc_map.find(f);
      assert(this->has_acceptance_condition(f));
      f->destroy();
      bdd v = bdd_ithvar(i->second);
      v &= bdd_exist(neg_acceptance_conditions_, v);
      return v;
667
668
    }

Pierre PARUTTO's avatar
Pierre PARUTTO committed
669
    virtual bdd compute_support_conditions(const spot::state* in) const
670
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
671
672
673
      const State* s = down_cast<const State*>(in);
      assert(s);
      const typename State::transitions_t& st = s->successors;
674

Pierre PARUTTO's avatar
Pierre PARUTTO committed
675
      bdd res = bddfalse;
676

Pierre PARUTTO's avatar
Pierre PARUTTO committed
677
678
679
      typename State::transitions_t::const_iterator i;
      for (i = st.begin(); i != st.end(); ++i)
	res |= i->condition;
680

Pierre PARUTTO's avatar
Pierre PARUTTO committed
681
682
683
684
      return res;
    }

    virtual bdd compute_support_variables(const spot::state* in) const
685
    {
Pierre PARUTTO's avatar
Pierre PARUTTO committed
686
687
688
689
690
691
692
693
694
695
696
      const State* s = down_cast<const State*>(in);
      assert(s);
      const typename State::transitions_t& st = s->successors;

      bdd res = bddtrue;

      typename State::transitions_t::const_iterator i;
      for (i = st.begin(); i != st.end(); ++i)
	res &= bdd_support(i->condition);

      return res;
697
    }
698

Pierre PARUTTO's avatar
Pierre PARUTTO committed
699
700
701
    mutable bdd all_acceptance_conditions_;
    mutable bool all_acceptance_conditions_computed_;
    bdd neg_acceptance_conditions_;
702

Pierre PARUTTO's avatar
Pierre PARUTTO committed
703
704
705
706
  private:
    // Disallow copy.
    tgba_explicit(const tgba_explicit<State>& other);
    tgba_explicit& operator=(const tgba_explicit& other);
707
  };
Pierre PARUTTO's avatar
Pierre PARUTTO committed
708
709
710
711
712


  typedef tgba_explicit<state_explicit_string> tgba_explicit_string;
  typedef tgba_explicit<state_explicit_formula> tgba_explicit_formula;
  typedef tgba_explicit<state_explicit_number> tgba_explicit_number;
713
714
715
}

#endif // SPOT_TGBA_TGBAEXPLICIT_HH