13#ifndef MCRL2_PRES_TOOLS_PRESSOLVE_H
14#define MCRL2_PRES_TOOLS_PRESSOLVE_H
16#include "mcrl2/utilities/input_output_tool.h"
17#include "mcrl2/data/rewriter_tool.h"
19#include "mcrl2/pres/pres_input_tool.h"
20#include "mcrl2/pres/detail/pres_io.h"
21#include "mcrl2/pres/pressolve_options.h"
22#include "mcrl2/pres/normalize.h"
23#include "mcrl2/pres/detail/instantiate_global_variables.h"
24#include "mcrl2/pres/pres2res.h"
25#include "mcrl2/pres/ressolve_gauss_elimination.h"
26#include "mcrl2/pres/ressolve_numerical.h"
27#include "mcrl2/pres/ressolve_numerical_directed.h"
39 std::size_t pos = filename.find_last_of(
'.');
40 if (pos == std::string::npos)
44 return filename.substr(pos + 1);
58 super::add_options(desc);
59 desc.add_hidden_option(
"no-remove-unused-rewrite-rules",
60 "do not remove unused rewrite rules. ",
'u');
61 desc.add_hidden_option(
62 "no-replace-constants-by-variables",
63 "Do not move constant expressions to a substitution.");
68 "select the algorithm NAME to solve the res after it is generated.",
'a');
69 desc.add_option(
"precision",
utilities::make_mandatory_argument(
"NUM"),
70 "provide an answer within precision 10^-precision. [AS IT STANDS THIS IS THE NOW THE DIFFERENCE BETWEEN TWO ITERATIONS]",
'p');
75 super::parse_options(parser);
78 !parser.has_option(
"no-replace-constants-by-variables");
80 !parser.has_option(
"no-remove-unused-rewrite-rules");
81 options.rewrite_strategy = rewrite_strategy();
84 if (parser.has_option(
"file"))
86 std::string filename = parser.option_argument(
"file");
93 if (parser.has_option(
"algorithm"))
98 if (parser.has_option(
"precision"))
102 throw mcrl2::runtime_error(
"Option --precision (-p) can only be used in combination with --algorithm=numerical or --algorithm=numerical_directed.");
110 throw mcrl2::runtime_error(
"The argument of --precision (-p) is not a valid number.");
121 return {pres_system::pres_format_internal()};
126 std::set<data::function_symbol> used_functions = pres_system::find_function_symbols(presspec);
127 used_functions.insert(data::less(data::sort_real::real_()));
128 used_functions.insert(data::sort_real::divides(data::sort_real::real_(),data::sort_real::real_()));
129 used_functions.insert(data::sort_real::times(data::sort_real::real_(),data::sort_real::real_()));
130 used_functions.insert(data::sort_real::plus(data::sort_real::real_(),data::sort_real::real_()));
131 used_functions.insert(data::sort_real::minus(data::sort_real::real_(),data::sort_real::real_()));
132 used_functions.insert(data::sort_real::minimum(data::sort_real::real_(),data::sort_real::real_()));
133 used_functions.insert(data::sort_real::maximum(data::sort_real::real_(),data::sort_real::real_()));
135 return data::rewriter(presspec.data(),
136 data::used_data_equation_selector(presspec.data(), used_functions, presspec.global_variables(), !options.remove_unused_rewrite_rules),
137 options.rewrite_strategy);
145 "Generate a BES from a PRES and solve it. ",
146 "Solves (P)BES from INFILE. "
147 "If INFILE is not present, stdin is used. "
148 "The PRES is first instantiated into a parity game, "
149 "which is then solved using Zielonka's algorithm. "
150 "It supports the generation of a witness or counter "
151 "example for the property encoded by the PRES.")
161 data::mutable_map_substitution<> sigma;
162 sigma = pres_system::detail::instantiate_global_variables(presspec);
163 pres_system::detail::replace_global_variables(presspec, sigma);
169 timer().start(
"instantiation");
172 timer().finish(
"instantiation");
177 timer().start(
"solving");
183 std::cout << result <<
std::endl;
188 double result = solver
.run();
194 double result = solver
.run();
197 timer().finish(
"solving");
Rewriter that operates on data expressions.
logger(const log_level_t l)
Default constructor.
A simple algorithm that takes a pres, instantiates it into a res, without parameterized variables,...
pres2res_algorithm(const pressolve_options &options, const pres &input_pres, enumerate_quantifiers_rewriter &R)
parameterized boolean equation system
An algorithm that takes a res, i.e. a pres with propositional variables without parameters and solves...
ressolve_by_gauss_elimination_algorithm(const pressolve_options &options, const pres &input_pres)
const pres_expression run()
ressolve_by_numerical_iteration_directed(const pressolve_options &options, const pres &input_pres)
ressolve_by_numerical_iteration(const pressolve_options &options, const pres &input_pres)
Standard exception class for reporting runtime errors.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Namespace for all data library functionality.
pres load_pres(const std::string &filename)
Loads a PRES from filename, or from stdin if filename equals "".
The main namespace for the PRES library.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
An attempt for improving the efficiency.
enumerate_quantifiers_rewriter(const data::rewriter &R, const data::data_specification &dataspec, bool enumerate_infinite_sorts=true)
solution_algorithm algorithm
bool replace_constants_by_variables
bool remove_unused_rewrite_rules
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const