mCRL2
Loading...
Searching...
No Matches
lps2pbes.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_TOOLS_LPS2PBES_H
13#define MCRL2_PBES_TOOLS_LPS2PBES_H
14
15#include "mcrl2/lps/io.h"
17#include "mcrl2/pbes/io.h"
18#include "mcrl2/pbes/lps2pbes.h"
19
20namespace mcrl2 {
21
22namespace pbes_system {
23
24namespace detail
25{
28{
29 std::set<process::action_label> used_lps_actions = lps::find_action_labels(lpsspec.process());
30 std::set<process::action_label> used_state_formula_actions = state_formulas::find_action_labels(formula);
31 std::set<process::action_label> diff = utilities::detail::set_difference(used_state_formula_actions, used_lps_actions);
32 if (!diff.empty())
33 {
34 mCRL2log(log::warning) << "Warning: the modal formula contains an action "
35 << *diff.begin()
36 << " that does not appear in the LPS!" << std::endl;
37 }
38}
39
40} // namespace detail
41
42void lps2pbes(const std::string& input_filename,
43 const std::string& output_filename,
44 const utilities::file_format& output_format,
45 const std::string& formula_filename,
46 bool timed,
47 bool structured,
48 bool unoptimized,
49 bool preprocess_modal_operators,
50 bool generate_counter_example,
51 bool check_only
52 )
53{
54 if (formula_filename.empty())
55 {
56 throw mcrl2::runtime_error("Option -f is not specified");
57 }
58 if (input_filename.empty())
59 {
60 mCRL2log(log::verbose) << "Reading LPS from stdin..." << std::endl;
61 }
62 else
63 {
64 mCRL2log(log::verbose) << "Reading LPS from file '" << input_filename << "'..." << std::endl;
65 }
66 lps::specification plain_lpsspec;
67 load_lps(plain_lpsspec, input_filename); // Read as a non stochastic lps, because lps2pbes cannot handle stochastic lps's.
68 lps::stochastic_specification lpsspec(plain_lpsspec);
69 mCRL2log(log::verbose) << "Reading input from file '" << formula_filename << "'..." << std::endl;
70 std::ifstream from(formula_filename.c_str(), std::ifstream::in | std::ifstream::binary);
71 if (!from)
72 {
73 throw mcrl2::runtime_error("Cannot open state formula file: " + formula_filename);
74 }
75 std::string text = utilities::read_text(from);
76 const bool formula_is_quantitative = false;
78 detail::check_lps2pbes_actions(formspec.formula(), lpsspec);
79 mCRL2log(log::verbose) << "Converting state formula and LPS to a PBES..." << std::endl;
80 pbes_system::pbes result = pbes_system::lps2pbes(lpsspec, formspec, timed, structured, unoptimized, preprocess_modal_operators, generate_counter_example, check_only);
81
82 if (check_only)
83 {
85 << "The file '" << formula_filename
86 << "' contains a well-formed state formula" << std::endl;
87 return;
88 }
89
90 if (output_filename.empty())
91 {
92 mCRL2log(log::verbose) << "Writing PBES to stdout..." << std::endl;
93 }
94 else
95 {
96 mCRL2log(log::verbose) << "Writing PBES to file '" << output_filename << "'..." << std::endl;
97 }
98 save_pbes(result, output_filename, output_format);
99}
100
101} // namespace pbes_system
102
103} // namespace mcrl2
104
105#endif // MCRL2_PBES_TOOLS_LPS2PBES_H
const LinearProcess & process() const
Returns the linear process of the specification.
Linear process specification.
parameterized boolean equation system
Definition pbes.h:58
Standard exception class for reporting runtime errors.
Definition exception.h:27
const state_formula & formula() const
Returns the formula of the state formula specification.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
Add your file description here.
IO routines for linear process specifications.
add your file description here.
@ warning
Definition logger.h:34
@ verbose
Definition logger.h:37
void find_action_labels(const T &x, OutputIterator o)
Returns all action labels that occur in an object.
Definition find.h:172
void check_lps2pbes_actions(const state_formulas::state_formula &formula, const lps::stochastic_specification &lpsspec)
Prints a warning if formula contains an action that is not used in lpsspec.
Definition lps2pbes.h:27
void save_pbes(const pbes &pbes, std::ostream &stream, utilities::file_format format=utilities::file_format())
Save a PBES in the format specified.
Definition io.cpp:49
pbes lps2pbes(const lps::stochastic_specification &lpsspec, const state_formulas::state_formula &formula, bool timed=false, bool structured=false, bool unoptimized=false, bool preprocess_modal_operators=false, bool generate_counter_example=false, bool check_only=false)
Translates a linear process specification and a state formula to a PBES. If the solution of the PBES ...
Definition lps2pbes.h:158
pbes_expression formula(std::set< identifier_t > const &v, const owner_t owner, const std::string &prefix="X")
Definition pg_parse.h:54
state_formula_specification parse_state_formula_specification(std::istream &in, const bool formula_is_quantitative)
Parses a state formula specification from an input stream.
void find_action_labels(const T &x, OutputIterator o)
Returns all action labels that occur in an object.
Definition find.h:578
std::set< T > set_difference(const std::set< T > &x, const std::set< T > &y)
Returns the difference of two sets.
std::string read_text(const std::string &filename, bool warn=false)
Read text from a file.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
IO routines for boolean equation systems.