dupexp.cc 2.37 KB
Newer Older
1
// -*- coding: utf-8 -*-
2 3
// Copyright (C) 2009, 2011, 2012, 2014, 2015 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
Guillaume Sadegh's avatar
Guillaume Sadegh committed
4
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
5
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
6 7 8 9 10 11
// 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
12
// the Free Software Foundation; either version 3 of the License, or
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
13 14 15 16 17 18 19 20
// (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
21
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
22

23
#include "dupexp.hh"
24
#include "tgba/tgbagraph.hh"
25 26 27 28
#include <sstream>
#include <string>
#include <map>
#include "reachiter.hh"
29
#include "dotty.hh"
30

31 32 33
namespace spot
{
  namespace
34
  {
35 36
    template <class T>
    class dupexp_iter: public T
37
    {
38
    public:
39
      dupexp_iter(const const_tgba_ptr& a, twa::prop_set p)
40
	: T(a), out_(make_tgba_digraph(a->get_dict()))
41
      {
42
	out_->copy_acceptance_of(a);
43
	out_->copy_ap_of(a);
44
	out_->prop_copy(a, p);
45
      }
46

47
      tgba_digraph_ptr
48 49 50 51
      result()
      {
	return out_;
      }
52

53 54 55
      virtual void
      process_state(const state*, int n, tgba_succ_iterator*)
      {
56
	unsigned ns = out_->new_state();
57 58
	assert(ns == static_cast<unsigned>(n) - 1);
	(void)ns;
59
	(void)n;
60 61 62
      }

      virtual void
63 64
      process_link(const state*, int in,
		   const state*, int out,
65
		   const tgba_succ_iterator* si)
66
      {
67 68 69
	out_->new_transition
	  (in - 1, out - 1, si->current_condition(),
	   si->current_acceptance_conditions());
70
      }
71

Thomas Badie's avatar
Thomas Badie committed
72
    protected:
73
      tgba_digraph_ptr out_;
74
    };
75

76
  } // anonymous
77

78
  tgba_digraph_ptr
79
  tgba_dupexp_bfs(const const_tgba_ptr& aut, twa::prop_set p)
80
  {
81
    dupexp_iter<tgba_reachable_iterator_breadth_first> di(aut, p);
82 83 84 85
    di.run();
    return di.result();
  }

86
  tgba_digraph_ptr
87
  tgba_dupexp_dfs(const const_tgba_ptr& aut, twa::prop_set p)
88
  {
89
    dupexp_iter<tgba_reachable_iterator_depth_first> di(aut, p);
90 91 92 93
    di.run();
    return di.result();
  }
}