tgbaproduct.hh 2.96 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
14
15
16
17
18
19
20
21
  ///
  /// This state is in fact a pair of state: the state from the left
  /// automaton and that of the right.
  class state_bdd_product : public state_bdd
  {
  public:
    /// \brief Constructor
    /// \param left The state from the left automaton.
    /// \param right The state from the right automaton.
    /// These state are acquired by spot::state_bdd_product, and will
    /// be deleted on destruction.
22
23
24
    state_bdd_product(state* left, state* right)
      : state_bdd(left->as_bdd() & right->as_bdd()),
	left_(left),
25
26
27
	right_(right)
    {
    }
28

29
30
31
    /// Copy constructor
    state_bdd_product(const state_bdd_product& o);

32
33
    virtual ~state_bdd_product();

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

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

    virtual int compare(const state* other) const;
47
    virtual state_bdd_product* clone() const;
48
49

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


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

63
    virtual ~tgba_product_succ_iterator();
64

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

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

  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_;
86
87
    bdd left_neg_;
    bdd right_neg_;
88
  };
89

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

100
    virtual ~tgba_product();
101

102
103
    virtual state* get_init_state() const;

104
    virtual tgba_product_succ_iterator*
105
106
107
108
109
110
    succ_iter(const state* state) const;

    virtual const tgba_bdd_dict& get_dict() const;

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

111
112
113
    virtual bdd all_accepting_conditions() const;
    virtual bdd neg_accepting_conditions() const;

114
115
116
117
118
119
  private:
    const tgba* left_;
    bool left_should_be_freed_;
    const tgba* right_;
    bool right_should_be_freed_;
    tgba_bdd_dict dict_;
120
121
    bdd all_accepting_conditions_;
    bdd neg_accepting_conditions_;
122
123
124
125
  };

}

126
#endif // SPOT_TGBA_TGBAPRODUCT_HH