mCRL2
Loading...
Searching...
No Matches
remove_equations.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_PBES_REMOVE_EQUATIONS_H
13#define MCRL2_PBES_REMOVE_EQUATIONS_H
14
15#include "mcrl2/pbes/pbes.h"
16
17namespace mcrl2 {
18
19namespace pbes_system {
20
21namespace detail {
22
23inline
24std::string print_removed_equations(const std::vector<propositional_variable>& removed)
25{
26 std::ostringstream out;
27 out << "\nremoved the following equations:" << std::endl;
28 for (const propositional_variable& v: removed)
29 {
30 out << " " << pbes_system::pp(v) << std::endl;
31 }
32 return out.str();
33}
34
35} // namespace detail
36
37inline
38std::set<propositional_variable> reachable_variables(const pbes& p)
39{
40 typedef std::vector<pbes_equation>::const_iterator iterator;
41
42 // create a mapping from variable names to iterators
43 std::map<core::identifier_string, iterator> index;
44 for (auto i = p.equations().begin(); i != p.equations().end(); ++i)
45 {
46 // index[i->variable().name()] = i; <-- This leads to a attempt to copy-
47 // construct an iterator from a singular iterator when the toolset
48 // is compiled in maintainer mode.
49 index.insert(std::pair<core::identifier_string, iterator>(i->variable().name(),i));
50 }
51
52 std::set<core::identifier_string> visited;
53 std::set<core::identifier_string> explored;
54 visited.insert(p.initial_state().name());
55 while (!visited.empty())
56 {
57 core::identifier_string X = *visited.begin();
58 visited.erase(visited.begin());
59 explored.insert(X);
60 pbes_expression phi = index[X]->formula();
61 std::set<propositional_variable_instantiation> iocc = pbes_system::find_propositional_variable_instantiations(phi);
62 for (const propositional_variable_instantiation& i: iocc)
63 {
64 if (explored.find(i.name()) == explored.end())
65 {
66 visited.insert(i.name());
67 }
68 }
69 }
70
71 std::set<propositional_variable> result;
72 for (const core::identifier_string& i: explored)
73 {
74 result.insert(index[i]->variable());
75 }
76 return result;
77}
78
81inline
82std::vector<propositional_variable> remove_unreachable_variables(pbes& p)
83{
84 std::vector<propositional_variable> result;
85
86 std::set<propositional_variable> V = reachable_variables(p);
87 std::vector<pbes_equation> equations;
88 for (pbes_equation& eqn: p.equations())
89 {
90 if (V.find(eqn.variable()) != V.end())
91 {
92 equations.push_back(eqn);
93 }
94 else
95 {
96 result.push_back(eqn.variable());
97 }
98 }
99 p.equations() = equations;
100 return result;
101}
102
103} // namespace pbes_system
104
105} // namespace mcrl2
106
107#endif // MCRL2_PBES_REMOVE_EQUATIONS_H
Term containing a string.
const_iterator begin() const
Returns an iterator pointing to the first argument.
Definition aterm.h:165
parameterized boolean equation system
Definition pbes.h:58
const propositional_variable_instantiation & initial_state() const
Returns the initial state.
Definition pbes.h:192
const std::vector< pbes_equation > & equations() const
Returns the equations.
Definition pbes.h:164
\brief A propositional variable instantiation
\brief A propositional variable declaration
std::string print_removed_equations(const std::vector< propositional_variable > &removed)
std::set< propositional_variable > reachable_variables(const pbes &p)
std::vector< propositional_variable > remove_unreachable_variables(pbes &p)
Removes equations that are not (syntactically) reachable from the initial state of a PBES.
std::string pp(const fixpoint_symbol &x)
Definition pbes.cpp:37
void find_propositional_variable_instantiations(Container const &container, OutputIterator o)
Returns all data variables that occur in a range of expressions.
Definition find.h:196
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
The class pbes.