Promote use of shared_ptr
* spot/kripke/kripke.hh, spot/ltsmin/ltsmin.cc, spot/ltsmin/ltsmin.hh, spot/mc/ec.hh, spot/mc/intersect.hh, spot/mc/utils.hh, spot/twacube/Makefile.am, spot/twacube/fwd.hh, spot/twacube/twacube.hh, spot/twacube_algos/convert.cc, spot/twacube_algos/convert.hh, tests/core/twacube.cc, tests/ltsmin/modelcheck.cc: here.
This commit is contained in:
parent
7d2abe229b
commit
765bb8a7c4
13 changed files with 64 additions and 31 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <spot/kripke/fairkripke.hh>
|
#include <spot/kripke/fairkripke.hh>
|
||||||
#include <spot/twacube/cube.hh>
|
#include <spot/twacube/cube.hh>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +34,8 @@ namespace spot
|
||||||
/// are provided by this template class. Specialisations
|
/// are provided by this template class. Specialisations
|
||||||
/// will handle it.
|
/// will handle it.
|
||||||
template<typename State, typename SuccIterator>
|
template<typename State, typename SuccIterator>
|
||||||
class SPOT_API kripkecube
|
class SPOT_API kripkecube:
|
||||||
|
public std::enable_shared_from_this<kripkecube<State, SuccIterator>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \brief Returns the initial State of the System
|
/// \brief Returns the initial State of the System
|
||||||
|
|
|
||||||
|
|
@ -1938,7 +1938,7 @@ namespace spot
|
||||||
throw std::runtime_error(err.str());
|
throw std::runtime_error(err.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
spot::kripkecube<spot::cspins_state, spot::cspins_iterator>*
|
ltsmin_kripkecube_ptr
|
||||||
ltsmin_model::kripkecube(const atomic_prop_set* to_observe,
|
ltsmin_model::kripkecube(const atomic_prop_set* to_observe,
|
||||||
const formula dead, int compress) const
|
const formula dead, int compress) const
|
||||||
{
|
{
|
||||||
|
|
@ -1975,7 +1975,8 @@ namespace spot
|
||||||
observed.push_back(dead_ap);
|
observed.push_back(dead_ap);
|
||||||
|
|
||||||
// Finally build the system.
|
// Finally build the system.
|
||||||
return new spot::kripkecube<spot::cspins_state, spot::cspins_iterator>
|
return std::make_shared<spot::kripkecube<spot::cspins_state,
|
||||||
|
spot::cspins_iterator>>
|
||||||
(iface, compress, observed, selfloopize, dead_ap);
|
(iface, compress, observed, selfloopize, dead_ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2012,9 +2013,8 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<bool, std::string, istats>
|
std::tuple<bool, std::string, istats>
|
||||||
ltsmin_model::modelcheck(spot::kripkecube<spot::cspins_state,
|
ltsmin_model::modelcheck(ltsmin_kripkecube_ptr sys,
|
||||||
spot::cspins_iterator>* sys,
|
spot::twacube_ptr twa, bool compute_ctrx)
|
||||||
spot::twacube* twa, bool compute_ctrx)
|
|
||||||
{
|
{
|
||||||
ec_renault13lpar<cspins_state, cspins_iterator,
|
ec_renault13lpar<cspins_state, cspins_iterator,
|
||||||
cspins_state_hash, cspins_state_equal> ec(*sys, twa);
|
cspins_state_hash, cspins_state_equal> ec(*sys, twa);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ namespace spot
|
||||||
class cspins_iterator;
|
class cspins_iterator;
|
||||||
typedef int* cspins_state;
|
typedef int* cspins_state;
|
||||||
|
|
||||||
|
typedef std::shared_ptr<spot::kripkecube<spot::cspins_state,
|
||||||
|
spot::cspins_iterator>>
|
||||||
|
ltsmin_kripkecube_ptr;
|
||||||
|
|
||||||
class SPOT_API ltsmin_model final
|
class SPOT_API ltsmin_model final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -79,7 +83,7 @@ namespace spot
|
||||||
// \brief The same as above but returns a kripkecube, i.e. a kripke
|
// \brief The same as above but returns a kripkecube, i.e. a kripke
|
||||||
// that can be use in parallel. Moreover, it support more ellaborated
|
// that can be use in parallel. Moreover, it support more ellaborated
|
||||||
// atomic propositions such as "P.a == P.c"
|
// atomic propositions such as "P.a == P.c"
|
||||||
spot::kripkecube<spot::cspins_state, spot::cspins_iterator>*
|
ltsmin_kripkecube_ptr
|
||||||
kripkecube(const atomic_prop_set* to_observe,
|
kripkecube(const atomic_prop_set* to_observe,
|
||||||
formula dead = formula::tt(),
|
formula dead = formula::tt(),
|
||||||
int compress = 0) const;
|
int compress = 0) const;
|
||||||
|
|
@ -89,8 +93,8 @@ namespace spot
|
||||||
/// has been found and a string representing the counterexample if the
|
/// has been found and a string representing the counterexample if the
|
||||||
/// computation have been required
|
/// computation have been required
|
||||||
static std::tuple<bool, std::string, istats>
|
static std::tuple<bool, std::string, istats>
|
||||||
modelcheck(spot::kripkecube<spot::cspins_state, spot::cspins_iterator>* sys,
|
modelcheck(ltsmin_kripkecube_ptr sys,
|
||||||
spot::twacube* twa, bool compute_ctrx = false);
|
spot::twacube_ptr twa, bool compute_ctrx = false);
|
||||||
|
|
||||||
/// Number of variables in a state
|
/// Number of variables in a state
|
||||||
int state_size() const;
|
int state_size() const;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace spot
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ec_renault13lpar(kripkecube<State, SuccIterator>& sys,
|
ec_renault13lpar(kripkecube<State, SuccIterator>& sys,
|
||||||
twacube* twa)
|
twacube_ptr twa)
|
||||||
: intersect<State, SuccIterator, StateHash, StateEqual,
|
: intersect<State, SuccIterator, StateHash, StateEqual,
|
||||||
ec_renault13lpar<State, SuccIterator,
|
ec_renault13lpar<State, SuccIterator,
|
||||||
StateHash, StateEqual>>(sys, twa),
|
StateHash, StateEqual>>(sys, twa),
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
intersect(kripkecube<State, SuccIterator>& sys,
|
intersect(kripkecube<State, SuccIterator>& sys,
|
||||||
twacube* twa):
|
twacube_ptr twa):
|
||||||
sys_(sys), twa_(twa)
|
sys_(sys), twa_(twa)
|
||||||
{
|
{
|
||||||
assert(is_a_kripkecube(sys));
|
assert(is_a_kripkecube(sys));
|
||||||
|
|
@ -254,7 +254,7 @@ namespace spot
|
||||||
std::shared_ptr<trans_index> it_prop;
|
std::shared_ptr<trans_index> it_prop;
|
||||||
};
|
};
|
||||||
kripkecube<State, SuccIterator>& sys_;
|
kripkecube<State, SuccIterator>& sys_;
|
||||||
twacube* twa_;
|
twacube_ptr twa_;
|
||||||
std::vector<todo_element> todo;
|
std::vector<todo_element> todo;
|
||||||
typedef std::unordered_map<const product_state, int,
|
typedef std::unordered_map<const product_state, int,
|
||||||
product_state_hash,
|
product_state_hash,
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ namespace spot
|
||||||
std::vector<std::string>* names_;
|
std::vector<std::string>* names_;
|
||||||
bdd_dict_ptr dict_;
|
bdd_dict_ptr dict_;
|
||||||
std::unordered_map<int, int> reverse_binder_;
|
std::unordered_map<int, int> reverse_binder_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -116,7 +115,7 @@ namespace spot
|
||||||
|
|
||||||
public:
|
public:
|
||||||
product_to_twa(kripkecube<State, SuccIterator>& sys,
|
product_to_twa(kripkecube<State, SuccIterator>& sys,
|
||||||
twacube* twa)
|
twacube_ptr twa)
|
||||||
: intersect<State, SuccIterator, StateHash, StateEqual,
|
: intersect<State, SuccIterator, StateHash, StateEqual,
|
||||||
product_to_twa<State, SuccIterator,
|
product_to_twa<State, SuccIterator,
|
||||||
StateHash, StateEqual>>(sys, twa)
|
StateHash, StateEqual>>(sys, twa)
|
||||||
|
|
@ -143,7 +142,6 @@ namespace spot
|
||||||
for (auto ap : this->twa_->get_ap())
|
for (auto ap : this->twa_->get_ap())
|
||||||
{
|
{
|
||||||
auto idx = res_->register_ap(ap);
|
auto idx = res_->register_ap(ap);
|
||||||
std::cout << ap << idx << std::endl;
|
|
||||||
reverse_binder_[i++] = idx;
|
reverse_binder_[i++] = idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS)
|
||||||
|
|
||||||
twacubedir = $(pkgincludedir)/twacube
|
twacubedir = $(pkgincludedir)/twacube
|
||||||
|
|
||||||
twacube_HEADERS = cube.hh twacube.hh
|
twacube_HEADERS = cube.hh twacube.hh fwd.hh
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libtwacube.la
|
noinst_LTLIBRARIES = libtwacube.la
|
||||||
libtwacube_la_SOURCES = \
|
libtwacube_la_SOURCES = \
|
||||||
|
|
|
||||||
29
spot/twacube/fwd.hh
Normal file
29
spot/twacube/fwd.hh
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// -*- coding: utf-8 -*-
|
||||||
|
// Copyright (C) 2016 Laboratoire de Recherche
|
||||||
|
// et Développement de l'Epita (LRDE).
|
||||||
|
//
|
||||||
|
// 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 3 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace spot
|
||||||
|
{
|
||||||
|
class twacube;
|
||||||
|
typedef std::shared_ptr<twacube> twacube_ptr;
|
||||||
|
typedef std::shared_ptr<const twacube> const_twacube_ptr;
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <spot/graph/graph.hh>
|
#include <spot/graph/graph.hh>
|
||||||
#include <spot/twa/acc.hh>
|
#include <spot/twa/acc.hh>
|
||||||
#include <spot/twacube/cube.hh>
|
#include <spot/twacube/cube.hh>
|
||||||
|
#include <spot/twacube/fwd.hh>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -101,7 +102,7 @@ namespace spot
|
||||||
const graph_t::state_storage_t& st_;
|
const graph_t::state_storage_t& st_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SPOT_API twacube final
|
class SPOT_API twacube final: public std::enable_shared_from_this<twacube>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
twacube() = delete;
|
twacube() = delete;
|
||||||
|
|
@ -150,4 +151,9 @@ namespace spot
|
||||||
graph_t theg_;
|
graph_t theg_;
|
||||||
cubeset cubeset_;
|
cubeset cubeset_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline twacube_ptr make_twacube(const std::vector<std::string> aps)
|
||||||
|
{
|
||||||
|
return std::make_shared<twacube>(aps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,14 +59,14 @@ namespace spot
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
spot::twacube* twa_to_twacube(const spot::const_twa_graph_ptr aut)
|
spot::twacube_ptr twa_to_twacube(const spot::const_twa_graph_ptr aut)
|
||||||
{
|
{
|
||||||
// Compute the necessary binder and extract atomic propositions
|
// Compute the necessary binder and extract atomic propositions
|
||||||
std::unordered_map<int, int> ap_binder;
|
std::unordered_map<int, int> ap_binder;
|
||||||
std::vector<std::string>* aps = extract_aps(aut, ap_binder);
|
std::vector<std::string>* aps = extract_aps(aut, ap_binder);
|
||||||
|
|
||||||
// Declare the twa cube
|
// Declare the twa cube
|
||||||
spot::twacube* tg = new spot::twacube(*aps);
|
auto tg = spot::make_twacube(*aps);
|
||||||
|
|
||||||
// Fix acceptance
|
// Fix acceptance
|
||||||
tg->acc() = aut->acc();
|
tg->acc() = aut->acc();
|
||||||
|
|
@ -135,7 +135,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
spot::twa_graph_ptr
|
spot::twa_graph_ptr
|
||||||
twacube_to_twa(spot::twacube* twacube)
|
twacube_to_twa(spot::twacube_ptr twacube)
|
||||||
{
|
{
|
||||||
// Grab necessary variables
|
// Grab necessary variables
|
||||||
auto& theg = twacube->get_graph();
|
auto& theg = twacube->get_graph();
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ namespace spot
|
||||||
std::unordered_map<int, int>& ap_binder);
|
std::unordered_map<int, int>& ap_binder);
|
||||||
|
|
||||||
/// \brief Convert a twa into a twacube
|
/// \brief Convert a twa into a twacube
|
||||||
SPOT_API spot::twacube*
|
SPOT_API twacube_ptr
|
||||||
twa_to_twacube(spot::const_twa_graph_ptr aut);
|
twa_to_twacube(spot::const_twa_graph_ptr aut);
|
||||||
|
|
||||||
/// \brief Convert a twacube into a twa
|
/// \brief Convert a twacube into a twa
|
||||||
SPOT_API spot::twa_graph_ptr
|
SPOT_API spot::twa_graph_ptr
|
||||||
twacube_to_twa(spot::twacube* twacube);
|
twacube_to_twa(spot::twacube_ptr twacube);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ int main()
|
||||||
tg->new_edge(s3, s3, bddtrue, spot::acc_cond::mark_t({0, 1}));
|
tg->new_edge(s3, s3, bddtrue, spot::acc_cond::mark_t({0, 1}));
|
||||||
|
|
||||||
// Test translation
|
// Test translation
|
||||||
auto* aut = twa_to_twacube(tg);
|
auto aut = twa_to_twacube(tg);
|
||||||
spot::print_dot(std::cout, tg);
|
spot::print_dot(std::cout, tg);
|
||||||
std::cout << "-----------\n" << *aut << "-----------\n";
|
std::cout << "-----------\n" << *aut << "-----------\n";
|
||||||
|
|
||||||
|
|
@ -62,7 +62,5 @@ int main()
|
||||||
<< ' ' << d.acc_
|
<< ' ' << d.acc_
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
spot::print_dot(std::cout, spot::twacube_to_twa(aut));
|
spot::print_dot(std::cout, spot::twacube_to_twa(aut));
|
||||||
delete aut;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -371,12 +371,11 @@ static int checked_main()
|
||||||
<< ". This could slow down parallel algorithms.\n";
|
<< ". This could slow down parallel algorithms.\n";
|
||||||
|
|
||||||
tm.start("twa to twacube");
|
tm.start("twa to twacube");
|
||||||
auto* propcube = spot::twa_to_twacube(prop);
|
auto propcube = spot::twa_to_twacube(prop);
|
||||||
tm.stop("twa to twacube");
|
tm.stop("twa to twacube");
|
||||||
|
|
||||||
tm.start("load kripkecube");
|
tm.start("load kripkecube");
|
||||||
spot::kripkecube<spot::cspins_state,
|
spot::ltsmin_kripkecube_ptr modelcube = nullptr;
|
||||||
spot::cspins_iterator>* modelcube = nullptr;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
modelcube = spot::ltsmin_model::load(mc_options.model)
|
modelcube = spot::ltsmin_model::load(mc_options.model)
|
||||||
|
|
@ -397,7 +396,6 @@ static int checked_main()
|
||||||
|
|
||||||
if (!modelcube)
|
if (!modelcube)
|
||||||
{
|
{
|
||||||
delete propcube;
|
|
||||||
exit_code = 2;
|
exit_code = 2;
|
||||||
goto safe_exit;
|
goto safe_exit;
|
||||||
}
|
}
|
||||||
|
|
@ -423,8 +421,6 @@ static int checked_main()
|
||||||
else
|
else
|
||||||
std::cout << "an accepting run exists!\n" << std::get<1>(res)
|
std::cout << "an accepting run exists!\n" << std::get<1>(res)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
delete modelcube;
|
|
||||||
delete propcube;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_exit:
|
safe_exit:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue