spot  1.2.1a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dve2.hh
1 // Copyright (C) 2011 Laboratoire de Recherche et Developpement
2 // de l'Epita (LRDE)
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SPOT_IFACE_DVE2FASTTGBA_DVE2_HH
20 # define SPOT_IFACE_DVE2FASTTGBA_DVE2_HH
21 
22 #include "tgbaalgos/degen.hh"
23 #include "tgba/sba.hh"
24 
25 
26 #include "fasttgba/fasttgba.hh"
27 #include "fasttgba/fasttgba_product.hh"
28 
29 #include "tgba/tgba.hh"
30 
31 // This is for creating Wrappers
32 #include "fasttgbaalgos/ec/ec.hh"
33 #include "fasttgbaalgos/tgba2fasttgba.hh"
34 
35 
36 #include <mutex>
37 
38 namespace spot
39 {
40  class SPOT_API fasttgba_kripke_product : public fasttgba_product
41  {
42  public:
44  const fasttgba *a2,
45  bool verbose = true)
46  : fasttgba_product(a1, a2, true),
47  verbose_(verbose)
48  {
49  if (verbose_)
50  match_formula_ap();
51  }
52 
56  void match_formula_ap ();
57 
58  private:
59  bool verbose_;
60  };
61 
62 
63  // \brief Load a DVE model.
64  //
65  // The filename given can be either a *.dve source or a *.dve2C
66  // dynamic library compiled with "divine compile --ltsmin file".
67  // When the *.dve source is supplied, the *.dve2C will be updated
68  // only if it is not newer.
69  //
70  // The dead parameter is used to control the behavior of the model
71  // on dead states (i.e. the final states of finite sequences).
72  // If DEAD is "false", it means we are not
73  // interested in finite sequences of the system, and dead state
74  // will have no successor. If DEAD is
75  // "true", we want to check finite sequences as well as infinite
76  // sequences, but do not need to distinguish them. In that case
77  // dead state will have a loop labeled by true. If DEAD is any
78  // other string, this is the name a property that should be true
79  // when looping on a dead state, and false otherwise.
80  //
81  // This function returns 0 on error.
82  //
83  // \a file the name of the *.dve source file or of the *.dve2C
84  // dynamic library
85  // \a to_observe the list of atomic propositions that should be observed
86  // in the model
87  // \a dict the BDD dictionary to use
88  // \a dead an atomic proposition or constant to use for looping on
89  // dead states
90  // \a verbose whether to output verbose messages
91  SPOT_API const spot::fasttgba* load_dve2fast(const std::string& file,
92  spot::ap_dict& aps,
93  spot::acc_dict& accs,
94  bool verbose = true);
95 
96 
97 
98  // A mutex to protect Buddy access
99  std::mutex mutex_load_dve;
100 
104  {
105  public:
107 
109  std::string filename):
110  tgba_(tgba), filename_(filename)
111  {
112  std::lock_guard<std::mutex> lk(mutex_load_dve);
113 
114  //ba_ = spot::degeneralize(tgba_);
115 
116  // Instanciate dictionnaries
117  aps_ = new spot::ap_dict();
118  accs_ = new spot::acc_dict();
119 
120  // Instanciate kripke
121  kripke = spot::load_dve2fast(filename, *aps_, *accs_, true);
122 
123  // Instanciate
124  ftgba1 = spot::tgba_2_fasttgba(tgba_, *aps_, *accs_);
125 
126  prod = new spot::fasttgba_kripke_product (kripke, ftgba1);
127 
128 
129  ba_prod = 0;
130  ba_ftgba = 0;
131  ba_kripke = 0;
132  ba_accs_ = 0;
133  ba_aps_ = 0;
134 
135  return;
136  // -------------------------------------------------------------
137  // Sometimes we need to work on BA, in this case the product
138  // must be done with BA
139  // -------------------------------------------------------------
140  if (ftgba1->number_of_acceptance_marks() <= 1)
141  {
142  ba_prod = prod;
143  return;
144  }
145  // // ba_ = spot::degeneralize(tgba_);
146 
147 
148  // // Instanciate dictionnaries
149  // ba_aps_ = new spot::ap_dict();
150  // ba_accs_ = new spot::acc_dict();
151 
152  // // Instanciate kripke
153  // ba_kripke = spot::load_dve2fast(filename, *ba_aps_, *ba_accs_, true);
154 
155  // // Instanciate
156  // ba_ftgba = spot::tgba_2_fasttgba(ba_, *ba_aps_, *ba_accs_);
157 
158  // ba_prod = new spot::fasttgba_kripke_product (ba_kripke, ba_ftgba);
159  }
160 
161 
162  virtual ~dve2product_instance()
163  {
164  std::lock_guard<std::mutex> lk(mutex_load_dve);
165  //bool is_ba = prod->number_of_acceptance_marks() <= 1;
166 
167  // Clean up for Tgba
168  delete prod;
169  delete ftgba1;
170  delete kripke;
171  delete accs_;
172  delete aps_;
173  prod = 0;
174  ftgba1 = 0;
175  kripke = 0;
176  accs_ = 0;
177  aps_ = 0;
178 
179  // // Clean up for BA
180  // if (!is_ba)
181  // {
182  // delete ba_;
183  // delete ba_prod;
184  // delete ba_ftgba;
185  // delete ba_kripke;
186  // delete ba_accs_;
187  // delete ba_aps_;
188  // ba_prod = 0;
189  // ba_ftgba = 0;
190  // ba_kripke = 0;
191  // ba_accs_ = 0;
192  // ba_aps_ = 0;
193  // }
194  }
195 
196  // The automaton to check
197  const fasttgba* get_automaton () const
198  {
199  return prod;
200  }
201 
202  const fasttgba* get_formula_automaton () const
203  {
204  return ftgba1;
205  }
206 
207  // Sometimes the product need to be with a number
208  // acceptance set less or equal to 1
209  const fasttgba* get_ba_automaton () const
210  {
211  return ba_prod;
212  }
213 
214  private:
215  //
216  const spot::tgba* tgba_;
217  std::string filename_;
218  const spot::fasttgba* ftgba1;
219  const spot::fasttgba* kripke;
220  const spot::fasttgba_kripke_product *prod;
221  spot::ap_dict* aps_;
222  spot::acc_dict* accs_;
223 
224 
225  const spot::tgba* ba_;
226  const spot::fasttgba* ba_ftgba;
227  const spot::fasttgba* ba_kripke;
228  const spot::fasttgba_kripke_product *ba_prod;
229  spot::ap_dict* ba_aps_;
230  spot::acc_dict* ba_accs_;
231  };
232 
233 
238  class SPOT_API dve2product_instanciator: public instanciator
239  {
240  private:
241  const spot::tgba* tgba_;
242  std::string filename_;
243 
244  public:
246  std::string filename):
247  tgba_(tgba), filename_(filename)
248  {
249  }
250 
252  {
253  return new dve2product_instance(tgba_, filename_);
254  }
255  };
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 }
270 
271 #endif // SPOT_IFACE_DVE2FASTTGBA_DVE2_HH
SPOT_API const fasttgba * tgba_2_fasttgba(const spot::tgba *t, spot::ap_dict &aps, spot::acc_dict &accs)
Perform a translation from a Tgba to a Fasttgba.
Definition: dve2.hh:103
Definition: fasttgba.hh:33
Interface for a Kripke structure.
Definition: kripke.hh:83
Definition: dve2.hh:238
Definition: ec.hh:64
A simple wrapper for an automaton.
Definition: ec.hh:40
const fasttgba * get_ba_automaton() const
return the automaton as a B\¨uchi Automaton. Warning ! You don&#39;t have to delete the ...
Definition: dve2.hh:209
This class is used to create a dictionary that will contain all atomic propositions that are needed b...
Definition: ap_dict.hh:41
This class allows to do a synchronized product between two fast tgba.
Definition: fasttgba_product.hh:124
Definition: dve2.hh:40
const instance_automaton * new_instance()
return a new instance of the automaton
Definition: dve2.hh:251
A Transition-based Generalized Büchi Automaton.
Definition: tgba.hh:67
virtual unsigned int number_of_acceptance_marks() const =0
The number of acceptance marks.
Definition: acc_dict.hh:31
const fasttgba * get_automaton() const
return the automaton. Warning ! You don&#39;t have to delete the
Definition: dve2.hh:197

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Jan 21 2014 16:52:01 for spot by doxygen 1.8.5