tgbaexplicit.hh 3.58 KB
Newer Older
1
2
3
#ifndef SPOT_TGBA_TGBAEXPLICIT_HH
# define SPOT_TGBA_TGBAEXPLICIT_HH

4
#include "misc/hash.hh"
5
6
7
8
9
10
11
12
13
14
15
#include <list>
#include "tgba.hh"
#include "ltlast/formula.hh"

namespace spot
{
  // Forward declarations.  See below.
  class state_explicit;
  class tgba_explicit_succ_iterator;

  /// Explicit representation of a spot::tgba.
16
  class tgba_explicit: public tgba
17
18
  {
  public:
19
    tgba_explicit(bdd_dict* dict);
20
21
22

    struct transition;
    typedef std::list<transition*> state;
23
24

    /// Explicit transitions (used by spot::tgba_explicit).
25
26
27
    struct transition
    {
      bdd condition;
28
      bdd accepting_conditions;
29
30
31
      state* dest;
    };

32
33
    void set_init_state(const std::string& state);

34
35
36
37
    transition*
    create_transition(const std::string& source, const std::string& dest);

    void add_condition(transition* t, ltl::formula* f);
38
    void add_neg_condition(transition* t, ltl::formula* f);
39
40
41
    void declare_accepting_condition(ltl::formula* f);
    bool has_accepting_condition(ltl::formula* f) const;
    void add_accepting_condition(transition* t, ltl::formula* f);
42
    void complement_all_accepting_conditions();
43
44
45
46
47

    // tgba interface
    virtual ~tgba_explicit();
    virtual spot::state* get_init_state() const;
    virtual tgba_succ_iterator*
48
49
50
    succ_iter(const spot::state* local_state,
	      const spot::state* global_state = 0,
	      const tgba* global_automaton = 0) const;
51
    virtual bdd_dict* get_dict() const;
52
53
    virtual std::string format_state(const spot::state* state) const;

54
55
56
    virtual bdd all_accepting_conditions() const;
    virtual bdd neg_accepting_conditions() const;

57
  protected:
58
59
60
    virtual bdd compute_support_conditions(const spot::state* state) const;
    virtual bdd compute_support_variables(const spot::state* state) const;

61
    state* add_state(const std::string& name);
62
63
    bdd get_condition(ltl::formula* f);
    bdd get_accepting_condition(ltl::formula* f);
64

65
66
67
68
    typedef Sgi::hash_map<const std::string, tgba_explicit::state*,
			  string_hash> ns_map;
    typedef Sgi::hash_map<const tgba_explicit::state*, std::string,
			  ptr_hash<tgba_explicit::state> > sn_map;
69
70
    ns_map name_state_map_;
    sn_map state_name_map_;
71
    bdd_dict* dict_;
72
    tgba_explicit::state* init_;
73
74
75
    mutable bdd all_accepting_conditions_;
    bdd neg_accepting_conditions_;
    mutable bool all_accepting_conditions_computed_;
76
77
78
79
80

  private:
    // Disallow copy.
    tgba_explicit(const tgba_explicit& other);
    tgba_explicit& tgba_explicit::operator=(const tgba_explicit& other);
81
82
83
  };


84
  /// States used by spot::tgba_explicit.
85
86
87
88
89
90
91
92
93
  class state_explicit : public spot::state
  {
  public:
    state_explicit(const tgba_explicit::state* s)
      : state_(s)
    {
    }

    virtual int compare(const spot::state* other) const;
94
    virtual size_t hash() const;
95
96
    virtual state_explicit* clone() const;

97
98
99
100
101
102
103
104
105
106
    virtual ~state_explicit()
    {
    }

    const tgba_explicit::state* get_state() const;
  private:
    const tgba_explicit::state* state_;
  };


107
  /// Successor iterators used by spot::tgba_explicit.
108
  class tgba_explicit_succ_iterator: public tgba_succ_iterator
109
110
  {
  public:
111
    tgba_explicit_succ_iterator(const tgba_explicit::state* s, bdd all_acc);
112
113
114
115
116
117
118
119

    virtual
    ~tgba_explicit_succ_iterator()
    {
    }

    virtual void first();
    virtual void next();
120
    virtual bool done() const;
121

122
123
124
    virtual state_explicit* current_state() const;
    virtual bdd current_condition() const;
    virtual bdd current_accepting_conditions() const;
125
126
127
128

  private:
    const tgba_explicit::state* s_;
    tgba_explicit::state::const_iterator i_;
129
    bdd all_accepting_conditions_;
130
131
132
133
134
  };

}

#endif // SPOT_TGBA_TGBAEXPLICIT_HH