mCRL2
Loading...
Searching...
No Matches
pbesinst_structure_graph.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/pbesinst_structure_graph.h
10/// \brief A variant of the lazy algorithm for instantiating a PBES, that produces a structure_graph.
11
12#ifndef MCRL2_PBES_PBESINST_STRUCTURE_GRAPH_H
13#define MCRL2_PBES_PBESINST_STRUCTURE_GRAPH_H
14
15#include <iomanip>
16
17#include "mcrl2/pbes/algorithms.h"
18#include "mcrl2/pbes/join.h"
19#include "mcrl2/pbes/pbesinst_lazy.h"
20#include "mcrl2/pbes/structure_graph_builder.h"
21#include "mcrl2/utilities/logger.h"
22
23
24
25namespace mcrl2::pbes_system {
26
27/// \brief Variant of pbesinst that will compute a structure graph for a PBES.
28/// The result will be put in the structure graph that is passed in the constructor.
30{
31 protected:
33
34 void SG0(const propositional_variable_instantiation& X, const pbes_expression& psi, std::size_t k)
35 {
36 auto vertex_phi = m_graph_builder.insert_variable(X, psi, k);
37 if (is_true(psi))
38 {
39 // skip
40 }
41 else if (is_false(psi))
42 {
43 // skip
44 }
46 {
47 auto vertex_psi = m_graph_builder.insert_variable(psi);
48 m_graph_builder.insert_edge(vertex_phi, vertex_psi);
49 }
50 else if (is_and(psi))
51 {
52 for (const pbes_expression& psi_i: split_and(psi))
53 {
54 auto vertex_psi_i = SG1(psi_i);
55 m_graph_builder.insert_edge(vertex_phi, vertex_psi_i);
56 }
57 }
58 else if (is_or(psi))
59 {
60 for (const pbes_expression& psi_i: split_or(psi))
61 {
62 auto vertex_psi_i = SG1(psi_i);
63 m_graph_builder.insert_edge(vertex_phi, vertex_psi_i);
64 }
65 }
66 }
67
68 structure_graph::index_type SG1(const pbes_expression& psi)
69 {
70 auto vertex_psi = m_graph_builder.insert_vertex(psi);
71 if (is_true(psi))
72 {
73 // skip
74 }
75 else if (is_false(psi))
76 {
77 // skip
78 }
80 {
81 // skip
82 }
83 else if (is_and(psi))
84 {
85 for (const pbes_expression& psi_i: split_and(psi))
86 {
87 auto vertex_psi_i = SG1(psi_i);
88 m_graph_builder.insert_edge(vertex_psi, vertex_psi_i);
89 }
90 }
91 else if (is_or(psi))
92 {
93 for (const pbes_expression& psi_i: split_or(psi))
94 {
95 auto vertex_psi_i = SG1(psi_i);
96 m_graph_builder.insert_edge(vertex_psi, vertex_psi_i);
97 }
98 }
99 return vertex_psi;
100 }
101
103 {
104 if (equation_count > 0 && equation_count % 1000 == 0)
105 {
106 std::ostringstream out;
107 out << "Generated " << equation_count << " BES equations (" << std::fixed << std::setprecision(2) <<
108 ((100.0 * static_cast<double>(equation_count)) / static_cast<double>(m_graph_builder.extent())) << "% explored)" << std::endl;
109 return out.str();
110 }
111
112 return std::nullopt;
113 }
114
115 public:
117 const pbessolve_options& options,
118 const pbes& p,
120 std::optional<data::rewriter> rewriter = std::nullopt
121 )
124 {}
125
126 void on_report_equation(const std::size_t /* thread_index */,
128 const pbes_expression& psi,
129 std::size_t k
130 ) override
131 {
132 // the body of this if statement will only be executed for the first equation
134 {
136 }
137 SG0(X, psi, k);
138 }
139
140 void run() override
141 {
144 }
145};
146
147} // namespace mcrl2::pbes_system
148
149
150
151#endif // MCRL2_PBES_PBESINST_STRUCTURE_GRAPH_H
parameterized boolean equation system
Definition pbes.h:54
A PBES instantiation algorithm that uses a lazy strategy.
virtual void run()
Runs the algorithm. The result is obtained by calling the function get_result.
Variant of pbesinst that will compute a structure graph for a PBES. The result will be put in the str...
pbesinst_structure_graph_algorithm(const pbessolve_options &options, const pbes &p, structure_graph &G, std::optional< data::rewriter > rewriter=std::nullopt)
void run() override
Runs the algorithm. The result is obtained by calling the function get_result.
structure_graph::index_type SG1(const pbes_expression &psi)
void on_report_equation(const std::size_t, const propositional_variable_instantiation &X, const pbes_expression &psi, std::size_t k) override
Reports BES equations that are produced by the algorithm. This function is called for every BES equat...
std::optional< std::string > status_message(std::size_t equation_count) override
void SG0(const propositional_variable_instantiation &X, const pbes_expression &psi, std::size_t k)
\brief A propositional variable instantiation
const data::data_expression & undefined_data_expression()
Returns a data expression that corresponds to 'undefined'.
Definition undefined.h:58
bool is_or(const atermpp::aterm &x)
bool is_false(const pbes_expression &t)
Test for the value false.
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
bool is_true(const pbes_expression &t)
Test for the value true.
void set_initial_state(const propositional_variable_instantiation &x)