spot  1.2.1a
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  const spot::tgba* weak = 0,
111  const spot::tgba* terminal = 0):
112  tgba_(tgba), filename_(filename), weak_(weak), term_(terminal)
113  {
114  std::lock_guard<std::mutex> lk(mutex_load_dve);
115 
116  //ba_ = spot::degeneralize(tgba_);
117  ba_ = 0;
118 
119  // Instanciate dictionnaries
120  aps_ = new spot::ap_dict();
121  accs_ = new spot::acc_dict();
122 
123  // Instanciate kripke
124  kripke = spot::load_dve2fast(filename, *aps_, *accs_, true);
125 
126  // Set Up to Zero !
127  ftgba1 = 0;
128  prod = 0;
129  fweak_ = 0;
130  fweak_prod = 0;
131  fterm_ = 0;
132  fterm_prod = 0;
133 
134  ba_prod = 0;
135  ba_ftgba = 0;
136  ba_kripke = 0;
137  ba_accs_ = 0;
138  ba_aps_ = 0;
139 
140  return;
141  }
142 
143 
144  virtual ~dve2product_instance()
145  {
146  std::lock_guard<std::mutex> lk(mutex_load_dve);
147  //bool is_ba = prod->number_of_acceptance_marks() <= 1;
148 
149  // Clean up for Tgba
150  delete ba_;
151  delete fweak_;
152  delete fweak_prod;
153  delete fterm_;
154  delete fterm_prod;
155  delete prod;
156  delete ftgba1;
157  delete kripke;
158  delete accs_;
159  delete aps_;
160  prod = 0;
161  ftgba1 = 0;
162  kripke = 0;
163  accs_ = 0;
164  aps_ = 0;
165 
166  // // Clean up for BA
167  // if (!is_ba)
168  // {
169  // delete ba_;
170  // delete ba_prod;
171  // delete ba_ftgba;
172  // delete ba_kripke;
173  // delete ba_accs_;
174  // delete ba_aps_;
175  // ba_prod = 0;
176  // ba_ftgba = 0;
177  // ba_kripke = 0;
178  // ba_accs_ = 0;
179  // ba_aps_ = 0;
180  // }
181  }
182 
183  // The automaton to check
184  const fasttgba* get_automaton () const
185  {
186  ftgba1 = spot::tgba_2_fasttgba(tgba_, *aps_, *accs_);
187  prod = new spot::fasttgba_kripke_product (kripke, ftgba1);
188  return prod;
189  }
190 
191 
193  {
194  assert(weak_);
195  fweak_ = spot::tgba_2_fasttgba(weak_, *aps_, *accs_);
196  fweak_prod = new spot::fasttgba_kripke_product (kripke, fweak_);
197  return fweak_prod;
198  }
199 
201  {
202  assert(term_);
203  fterm_ = spot::tgba_2_fasttgba(term_, *aps_, *accs_);
204  fterm_prod = new spot::fasttgba_kripke_product (kripke, fterm_);
205  return fterm_prod;
206  }
207 
208  // Get the kripke
209  const fasttgba* get_kripke () const
210  {
211  assert(kripke);
212  return kripke;
213  }
214 
215  const fasttgba* get_formula_automaton () const
216  {
217  if (!ftgba1)
218  ftgba1 = spot::tgba_2_fasttgba(tgba_, *aps_, *accs_);
219 
220  return ftgba1;
221  }
222 
223  // Sometimes the product need to be with a number
224  // acceptance set less or equal to 1
225  const fasttgba* get_ba_automaton () const
226  {
227  if (tgba_->number_of_acceptance_conditions() <= 1)
228  return get_automaton();
229 
230  ba_ = spot::degeneralize(tgba_);
231  ftgba1 = spot::tgba_2_fasttgba(ba_, *aps_, *accs_);
232  prod = new spot::fasttgba_kripke_product (kripke, ftgba1);
233  return prod;
234  }
235 
236  private:
237  //
238  const spot::tgba* tgba_;
239  mutable spot::tgba* ba_;
240  std::string filename_;
241  const spot::tgba* weak_;
242  const spot::tgba* term_;
243 
244 
245 
246  const spot::fasttgba* kripke;
247 
248  mutable const spot::fasttgba_kripke_product *prod;
249  mutable const spot::fasttgba* ftgba1;
250 
251 
252  mutable const spot::fasttgba *fweak_;
253  mutable const spot::fasttgba_kripke_product *fweak_prod;
254 
255 
256  mutable const spot::fasttgba *fterm_;
257  mutable const spot::fasttgba_kripke_product *fterm_prod;
258 
259  spot::ap_dict* aps_;
260  spot::acc_dict* accs_;
261 
262 
263  //const spot::tgba* ba_;
264  const spot::fasttgba* ba_ftgba;
265  const spot::fasttgba* ba_kripke;
266  const spot::fasttgba_kripke_product *ba_prod;
267  spot::ap_dict* ba_aps_;
268  spot::acc_dict* ba_accs_;
269  };
270 
271 
276  class SPOT_API dve2product_instanciator: public instanciator
277  {
278  private:
279  const spot::tgba* tgba_;
280  std::string filename_;
281  const spot::tgba* weak_;
282  const spot::tgba* terminal_;
283 
284  public:
286  std::string filename,
287  const spot::tgba* weak = 0,
288  const spot::tgba* terminal = 0):
289  tgba_(tgba), filename_(filename), weak_(weak), terminal_(terminal)
290  {
291  }
292 
294  {
295  return new dve2product_instance(tgba_, filename_, weak_, terminal_);
296  }
297 
298  virtual bool have_weak()
299  {
300  return weak_ != 0;
301  }
302 
303  virtual bool have_terminal()
304  {
305  return terminal_ != 0;;
306  }
307 
308  virtual bool have_strong()
309  {
310  return tgba_ != 0;;
311  }
312  };
313 }
314 
315 #endif // SPOT_IFACE_DVE2FASTTGBA_DVE2_HH
SPOT_API sba * degeneralize(const tgba *a, bool use_z_lvl=true, bool use_cust_acc_orders=false, bool use_lvl_cache=true)
Degeneralize a spot::tgba into an equivalent sba with only one acceptance condition.
this class acts like a wrapper to the C code of the open_set.
Definition: public.hh:32
const spot::fasttgba * get_weak_automaton() const
return a weak instance of the automaton
Definition: dve2.hh:192
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:276
Definition: ec.hh:71
virtual unsigned int number_of_acceptance_conditions() const
The number of acceptance conditions.
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't have to delete the ...
Definition: dve2.hh:225
virtual bool have_strong()
Return wether there is a weak instance.
Definition: dve2.hh:308
This class is used to create a dictionary that will contain all atomic propositions that are needed b...
Definition: ap_dict.hh:41
virtual bool have_weak()
Return wether there is a weak instance.
Definition: dve2.hh:298
const spot::fasttgba * get_terminal_automaton() const
return a terminal instance of the automaton
Definition: dve2.hh:200
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:293
virtual bool have_terminal()
Return wether there is a terminal instance.
Definition: dve2.hh:303
A Transition-based Generalized Büchi Automaton.
Definition: tgba.hh:67
Definition: acc_dict.hh:31
const fasttgba * get_automaton() const
return the automaton. Warning ! You don't have to delete the
Definition: dve2.hh:184

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Jun 5 2015 11:31:18 for spot by doxygen 1.8.9.1