minato.hh 3.38 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
// département Systèmes Répartis Coopératifs (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
23
24
25
26
27
28
29
30
31
#ifndef SPOT_MISC_MINATO_HH
# define SPOT_MISC_MINATO_HH

# include <bdd.h>
# include <stack>

namespace spot
{
  /// \brief Generate an irredundant sum-of-products (ISOP) form of a
  /// BDD function.
32
  /// \ingroup misc_tools
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  ///
  /// This algorithm implements a derecursived version the Minato-Morreale
  /// algorithm presented in the following paper.
  /// \verbatim
  /// @InProceedings{   minato.92.sasimi,
  ///   author        = {Shin-ichi Minato},
  ///   title         = {Fast Generation of Irredundant Sum-of-Products Forms
  ///                   from Binary Decision Diagrams},
  ///   booktitle     = {Proceedings of the third Synthesis and Simulation
  ///                   and Meeting International Interchange workshop
  ///                   (SASIMI'92)},
  ///   pages         = {64--73},
  ///   year          = {1992},
  ///   address       = {Kobe, Japan},
  ///   month         = {April}
  /// }
  /// \endverbatim
  class minato_isop
  {
  public:
    /// \brief Conctructor.
    /// \arg input The BDD function to translate in ISOP.
    minato_isop(bdd input);
56
57
58
59
    /// \brief Conctructor.
    /// \arg input The BDD function to translate in ISOP.
    /// \arg vars  The set of BDD variables to factorize in \a input.
    minato_isop(bdd input, bdd vars);
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    /// \brief Compute the next sum term of the ISOP form.
    /// Return \c bddfalse when all terms have been output.
    bdd next();

  private:
    /// Internal variables for minato_isop.
    struct local_vars
    {
      // If you are following the paper, f_min and f_max corresponds
      // to the pair of BDD function used to encode the ternary function `f'
      // (see Section 3.4).
      // Also note that f0, f0', and f0'' all share the same _max function.
      // Likewise for f1, f1', and f1''.
      bdd f_min, f_max;
      // Because we need a non-recursive version of the algorithm,
      // we had to split it in four step (each step is separated
      // from the other by a call to ISOP in the original algorithm).
      enum { FirstStep, SecondStep, ThirdStep, FourthStep } step;
78
79
80
      // The list of variable to factorize.  This is an addition to
      // the original algorithm.
      bdd vars;
81
82
83
84
      bdd v1;
      bdd f0_min, f0_max;
      bdd f1_min, f1_max;
      bdd g0, g1;
85
86
      local_vars(bdd f_min, bdd f_max, bdd vars)
	: f_min(f_min), f_max(f_max), step(FirstStep), vars(vars) {}
87
    };
88
89
90
    std::stack<local_vars> todo_;
    std::stack<bdd> cube_;
    bdd ret_;
91
92
93
94
  };
}

#endif // SPOT_MISC_MINATO_HH