tgbaproduct.hh 3.24 KB
Newer Older
1
2
#ifndef SPOT_TGBA_TGBAPRODUCT_HH
# define SPOT_TGBA_TGBAPRODUCT_HH
3
4
5
6
7
8
9

#include "tgba.hh"
#include "statebdd.hh"

namespace spot
{

10
  /// \brief A state for spot::tgba_product.
11
12
13
  ///
  /// This state is in fact a pair of state: the state from the left
  /// automaton and that of the right.
14
  class state_product : public state
15
16
17
18
19
  {
  public:
    /// \brief Constructor
    /// \param left The state from the left automaton.
    /// \param right The state from the right automaton.
20
    /// These states are acquired by spot::state_product, and will
21
    /// be deleted on destruction.
22
    state_product(state* left, state* right)
23
      :	left_(left),
24
25
26
	right_(right)
    {
    }
27

28
    /// Copy constructor
29
    state_product(const state_product& o);
30

31
    virtual ~state_product();
32

33
    state*
34
35
36
37
38
    left() const
    {
      return left_;
    }

39
    state*
40
41
42
43
44
45
    right() const
    {
      return right_;
    }

    virtual int compare(const state* other) const;
46
    virtual state_product* clone() const;
47
48

  private:
49
50
    state* left_;		///< State from the left automaton.
    state* right_;		///< State from the right automaton.
51
52
53
54
  };


  /// \brief Iterate over the successors of a product computed on the fly.
55
  class tgba_succ_iterator_product: public tgba_succ_iterator
56
57
  {
  public:
58
    tgba_succ_iterator_product(tgba_succ_iterator* left,
59
60
			       tgba_succ_iterator* right,
			       bdd left_neg, bdd right_neg);
61

62
    virtual ~tgba_succ_iterator_product();
63

64
65
66
    // iteration
    void first();
    void next();
67
    bool done() const;
68
69

    // inspection
70
    state_product* current_state() const;
71
72
    bdd current_condition() const;
    bdd current_accepting_conditions() const;
73
74
75
76
77
78
79
80
81
82
83
84

  private:
    //@{
    /// Internal routines to advance to the next successor.
    void step_();
    void next_non_false_();
    //@}

  protected:
    tgba_succ_iterator* left_;
    tgba_succ_iterator* right_;
    bdd current_cond_;
85
86
    bdd left_neg_;
    bdd right_neg_;
87
  };
88

89
  /// \brief A lazy product.  (States are computed on the fly.)
90
  class tgba_product: public tgba
91
92
93
94
95
  {
  public:
    /// \brief Constructor.
    /// \param left The left automata in the product.
    /// \param right The right automata in the product.
96
    /// Do not be fooled by these arguments: a product is commutative.
97
    tgba_product(const tgba* left, const tgba* right);
98

99
    virtual ~tgba_product();
100

101
102
    virtual state* get_init_state() const;

103
    virtual tgba_succ_iterator_product*
104
105
106
    succ_iter(const state* local_state,
	      const state* global_state = 0,
	      const tgba* global_automaton = 0) const;
107

108
    virtual bdd_dict* get_dict() const;
109
110
111

    virtual std::string format_state(const state* state) const;

112
113
    virtual state* project_state(const state* s, const tgba* t) const;

114
115
116
    virtual bdd all_accepting_conditions() const;
    virtual bdd neg_accepting_conditions() const;

117
118
119
120
  protected:
    virtual bdd compute_support_conditions(const state* state) const;
    virtual bdd compute_support_variables(const state* state) const;

121
  private:
122
    bdd_dict* dict_;
123
124
    const tgba* left_;
    const tgba* right_;
125
126
    bdd all_accepting_conditions_;
    bdd neg_accepting_conditions_;
127
128
129
    // Disallow copy.
    tgba_product(const tgba_product&);
    tgba_product& tgba_product::operator=(const tgba_product&);
130
131
132
133
  };

}

134
#endif // SPOT_TGBA_TGBAPRODUCT_HH