tgbabddconcreteproduct.cc 2.21 KB
Newer Older
1
// Copyright (C) 2003, 2004  Laboratoire d'Informatique de Paris 6 (LIP6),
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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
#include <cassert>
23
24
25
26
#include "tgbabddconcreteproduct.hh"

namespace spot
{
27
  namespace
28
  {
29
30
31
32
33
34
    /// \brief Helper class for product().
    ///
    /// As both automata are encoded using BDD, we just have
    /// to homogenize the variable numbers before ANDing the
    /// relations and initial states.
    class tgba_bdd_product_factory: public tgba_bdd_factory
35
    {
36
37
38
39
40
41
42
43
44
45
46
    public:
      tgba_bdd_product_factory(const tgba_bdd_concrete* left,
			       const tgba_bdd_concrete* right)
	: dict_(left->get_dict()),
	  left_(left),
	  right_(right),
	  data_(left_->get_core_data(), right_->get_core_data()),
	  init_(left_->get_init_bdd() & right_->get_init_bdd())
      {
	assert(dict_ == right->get_dict());
      }
47

48
49
50
51
      virtual
      ~tgba_bdd_product_factory()
      {
      }
52

53
54
55
56
57
      const tgba_bdd_core_data&
      get_core_data() const
      {
	return data_;
      }
58

59
60
61
62
63
      bdd
      get_init_state() const
      {
	return init_;
      }
64

65
66
67
68
69
70
71
72
    private:
      bdd_dict* dict_;
      const tgba_bdd_concrete* left_;
      const tgba_bdd_concrete* right_;
      tgba_bdd_core_data data_;
      bdd init_;
    };
  }
73

74
75
  tgba_bdd_concrete*
  product(const tgba_bdd_concrete* left, const tgba_bdd_concrete* right)
76
77
  {
    tgba_bdd_product_factory p(left, right);
78
    return new tgba_bdd_concrete(p, p.get_init_state());
79
80
  }
}