10#include "mcrl2/atermpp/aterm_io_binary.h"
11#include "mcrl2/core/load_aterm.h"
12#include "mcrl2/data/data_io.h"
13#include "mcrl2/pbes/algorithms.h"
14#include "mcrl2/pbes/detail/pbes_io.h"
15#include "mcrl2/pbes/io.h"
16#include "mcrl2/pbes/join.h"
17#include "mcrl2/pbes/parse.h"
18#include "mcrl2/pbes/normal_forms.h"
28 static std::vector<utilities::file_format> result;
31 result.push_back(utilities::file_format(
"pbes",
"PBES in internal format",
false));
32 result.back().add_extension(
"pbes");
33 result.push_back(utilities::file_format(
"text",
"PBES in textual (mCRL2) format",
true));
34 result.back().add_extension(
"txt");
35 result.push_back(utilities::file_format(
"bes",
"BES in internal format",
false));
36 result.back().add_extension(
"bes");
37 result.push_back(utilities::file_format(
"pgsolver",
"BES in PGSolver format",
true));
38 result.back().add_extension(
"gm");
39 result.back().add_extension(
"pg");
60 atermpp::binary_aterm_ostream
(stream
) << pbes;
91 atermpp::binary_aterm_istream
(stream
) >> pbes;
115 bool welltypedness_check)
117 if (welltypedness_check)
126 if (filename.empty() || filename ==
"-")
133 if (!filestream.good())
135 throw mcrl2::runtime_error(
"Could not open file " + filename);
149 const std::string& filename,
156 if (filename.empty() || filename ==
"-")
163 if (!filestream.good())
165 throw mcrl2::runtime_error(
"Could not open file " + filename);
222 stream
>> expression;
231 return atermpp::
aterm(atermpp::function_symbol(
"parameterised_boolean_equation_system", 0));
240 stream << pbes.data();
241 stream << pbes.global_variables();
242 stream << pbes.equations();
259 throw mcrl2::runtime_error(
"Stream does not contain a parameterised boolean equation system (PBES).");
263 std::set<data::variable> global_variables;
264 std::vector<pbes_equation> equations;
268 stream >> global_variables;
270 stream
>> initial_state;
272 pbes = pbes_system::pbes(data, global_variables, equations, initial_state);
280 catch (
std::exception& ex)
283 throw mcrl2::
runtime_error(std::string(
"Error reading parameterised boolean equation system (PBES)."));
295 if (filename.empty() || filename ==
"-")
301 std::ifstream from(filename, std::ifstream::in | std::ifstream::binary);
302 atermpp::binary_aterm_istream
(from
) >> result;
309 if (filename.empty() || filename ==
"-")
315 std::ofstream to(filename, std::ofstream::out | std::ofstream::binary);
318 throw mcrl2::runtime_error(
"Could not write to filename " + filename);
320 atermpp::binary_aterm_ostream
(to
) << pbesspec;
332 p.global_variables().end()));
335 const std::vector<pbes_equation>& eqn = p.equations();
336 for (
auto i = eqn.rbegin(); i != eqn.rend(); ++i)
338 atermpp::aterm a = pbes_equation_to_aterm(*i);
339 eqn_list.push_front(a);
341 atermpp::
aterm equations = atermpp::aterm(core::detail::function_symbol_PBEqnSpec(), eqn_list);
The interface for a class that reads aterm from a stream. The default constructed term aterm() indica...
The interface for a class that writes aterm to a stream. Every written term is retrieved by the corre...
A helper class to restore the state of the aterm_{i,o}stream objects upon destruction....
aterm_stream_state(aterm_stream &stream)
const function_symbol & function() const
Returns the function symbol belonging to an aterm.
aterm & operator=(aterm &&other) noexcept=default
binary_aterm_istream(std::istream &is)
Provide the input stream from which terms are read.
binary_aterm_ostream(std::ostream &os)
Provide the output stream to which the terms are written.
bool operator==(const function_symbol &f) const
Equality test.
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
function_symbol(const core::identifier_string &name, const sort_expression &sort)
Constructor.
const core::identifier_string & name() const
const sort_expression & sort() const
const core::identifier_string & name() const
const sort_expression & sort() const
variable(const core::identifier_string &name, const sort_expression &sort)
Constructor.
logger(const log_level_t l)
Default constructor.
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
pbes_equation(const fixpoint_symbol &symbol, const propositional_variable &variable, const pbes_expression &expr)
Constructor.
const fixpoint_symbol & symbol() const
Returns the fixpoint symbol of the equation.
const propositional_variable & variable() const
Returns the pbes variable of the equation.
parameterized boolean equation system
const propositional_variable_instantiation & initial_state() const
Returns the initial state.
bool is_well_typed() const
Checks if the PBES is well typed.
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
propositional_variable_instantiation(const core::identifier_string &name, const data::data_expression_list ¶meters)
Constructor.
const core::identifier_string & name() const
\brief A propositional variable declaration
Standard exception class for reporting runtime errors.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
The main namespace for the aterm++ library.
aterm_istream & operator>>(aterm_istream &stream, aterm &term)
Read the given term from the stream, but for aterm_list we want to use a specific one that performs v...
term_list< aterm > aterm_list
A term_list with elements of type aterm.
aterm_istream & operator>>(aterm_istream &stream, aterm_transformer transformer)
Sets the given transformer to be applied to following reads.
const atermpp::function_symbol & function_symbol_PBES()
const atermpp::function_symbol & function_symbol_OpIdNoIndex()
std::string file_source(const std::string &filename)
const atermpp::function_symbol & function_symbol_GlobVarSpec()
const atermpp::function_symbol & function_symbol_DataVarIdNoIndex()
const atermpp::function_symbol & function_symbol_PropVarInstNoIndex()
const atermpp::function_symbol & function_symbol_PBInit()
const atermpp::function_symbol & function_symbol_OpId()
atermpp::aterm data_specification_to_aterm(const data_specification &s)
Namespace for all data library functionality.
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, data_specification &spec)
Reads a data specification from a stream.
atermpp::term_list< variable > variable_list
\brief list of variables
bool is_bes(const pbes &x)
Returns true if a PBES is in BES form.
pbes load_pbes(const std::string &filename)
Loads a PBES from filename, or from stdin if filename equals "".
void save_pbes(const pbes &pbesspec, const std::string &filename)
Saves an PBES to filename, or to stdout if filename equals "".
The main namespace for the PBES library.
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, pbes &pbes)
Reads a pbes from a stream.
static atermpp::aterm remove_index_impl(const atermpp::aterm &x)
void load_pbes(pbes &pbes, std::istream &stream, utilities::file_format format, const std::string &)
Load a PBES from file.
void save_pbes(const pbes &pbes, const std::string &filename, utilities::file_format format, bool welltypedness_check)
save_pbes Saves a PBES to a file.
const utilities::file_format & pbes_format_internal_bes()
atermpp::aterm pbes_marker()
void load_pbes(pbes &pbes, const std::string &filename, utilities::file_format format)
Load pbes from file.
const utilities::file_format & pbes_format_pgsolver()
std::istream & operator>>(std::istream &from, pbes &result)
Reads a PBES from an input stream.
atermpp::aterm pbes_to_aterm(const pbes &p)
Conversion to atermappl.
const std::vector< utilities::file_format > & pbes_file_formats()
void save_bes_pgsolver(const pbes &bes, std::ostream &stream, bool maxpg)
std::string pp(const pbes_system::pbes &x)
void save_pbes(const pbes &pbes, std::ostream &stream, utilities::file_format format)
Save a PBES in the format specified.
void complete_data_specification(pbes &)
Adds all sorts that appear in the PBES p to the data specification of p.
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, pbes_equation &equation)
const utilities::file_format & pbes_format_internal()
const utilities::file_format & pbes_format_text()
static atermpp::aterm add_index_impl(const atermpp::aterm &x)
const utilities::file_format guess_format(const std::string &filename)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const