mCRL2
Loading...
Searching...
No Matches
pbes_equation_index.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//
9/// \file mcrl2/pbes/pbes_equation_index.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_PBES_EQUATION_INDEX_H
13#define MCRL2_PBES_PBES_EQUATION_INDEX_H
14
15#include "mcrl2/pbes/pbes.h"
16
17namespace mcrl2::pbes_system {
18
20{
21 // maps the name of an equation to the pair (i, k) with i the corresponding index of the equation, and k the rank
26
27 // PBES can be pbes or srf_pbes
28 template <typename PBES>
29 explicit pbes_equation_index(const PBES& p)
30 {
31 auto const& equations = p.equations();
32 std::size_t rank = 0;
33 std::size_t i = 0;
34 for ( ; i < equations.size(); i++)
35 {
36 const auto& eqn = equations[i];
37 if (i == 0)
38 {
39 rank = equations.front().symbol().is_mu() ? 1 : 0;
40 }
41 else
42 {
43 if (equations[i - 1].symbol() != equations[i].symbol())
44 {
45 rank++;
46 }
47 }
48 equation_index.insert({eqn.variable().name(), std::make_pair(i, rank)});
49 }
50 m_max_rank=rank;
51 m_max_index=i;
52 }
53
54 /// \brief Returns the index of the equation of the variable with the given name
56 {
57 auto i = equation_index.find(name);
58 assert (i != equation_index.end());
59 return i->second.first;
60 }
61
62 /// \brief Returns the rank of the equation of the variable with the given name
64 {
65 auto i = equation_index.find(name);
66 assert (i != equation_index.end());
67 return i->second.second;
68 }
69
70 /// \brief Returns the rank of the equation of the variable with the given name
72 {
73 return m_max_rank;
74 }
75
76 /// \brief Returns the rank of the equation of the variable with the given name
78 {
79 return m_max_index;
80 }
81};
82
83inline
85{
86 for (const auto& p: index.equation_index)
87 {
88 out << p.first << " -> (" << p.second.first << ", " << p.second.second << ")" << std::endl;
89 }
90 return out;
91}
92
93} // namespace mcrl2::pbes_system
94
95
96
97#endif // MCRL2_PBES_PBES_EQUATION_INDEX_H
std::ostream & operator<<(std::ostream &out, const pbes_equation_index &index)
std::size_t max_rank() const
Returns the rank of the equation of the variable with the given name.
std::size_t max_index() const
Returns the rank of the equation of the variable with the given name.
std::size_t index(const core::identifier_string &name) const
Returns the index of the equation of the variable with the given name.
std::size_t rank(const core::identifier_string &name) const
Returns the rank of the equation of the variable with the given name.