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/pres/algorithms.h"
14#include "mcrl2/pres/detail/pres_io.h"
15#include "mcrl2/pres/io.h"
16#include "mcrl2/pres/parse.h"
26 static std::vector<utilities::file_format> result;
29 result.push_back(utilities::file_format(
"pres",
"PRES in internal format",
false));
30 result.back().add_extension(
"pres");
31 result.push_back(utilities::file_format(
"text",
"PRES in textual (mCRL2) format",
true));
32 result.back().add_extension(
"txt");
54 atermpp::binary_aterm_ostream
(stream
) << pres;
82 atermpp::binary_aterm_istream
(stream
) >> pres;
106 bool welltypedness_check)
108 if (welltypedness_check)
117 if (filename.empty() || filename ==
"-")
124 if (!filestream.good())
126 throw mcrl2::runtime_error(
"Could not open file " + filename);
140 const std::string& filename,
147 if (filename.empty() || filename ==
"-")
154 if (!filestream.good())
156 throw mcrl2::runtime_error(
"Could not open file " + filename);
207 fixpoint_symbol symbol;
208 propositional_variable var;
213 stream
>> expression;
222 return atermpp::
aterm(atermpp::function_symbol(
"parameterised_boolean_equation_system", 0));
231 stream << pres.data();
232 stream << pres.global_variables();
233 stream << pres.equations();
250 throw mcrl2::runtime_error(
"Stream does not contain a parameterised boolean equation system (PRES).");
254 std::set<data::variable> global_variables;
255 std::vector<pres_equation> equations;
259 stream >> global_variables;
261 stream
>> initial_state;
263 pres = pres_system::pres(data, global_variables, equations, initial_state);
271 catch (
std::exception& ex)
274 throw mcrl2::
runtime_error(std::string(
"Error reading parameterised boolean equation system (PRES)."));
286 if (filename.empty() || filename ==
"-")
292 std::ifstream from(filename, std::ifstream::in | std::ifstream::binary);
293 atermpp::binary_aterm_istream
(from
) >> result;
300 if (filename.empty() || filename ==
"-")
306 std::ofstream to(filename, std::ofstream::out | std::ofstream::binary);
309 throw mcrl2::runtime_error(
"Could not write to filename " + filename);
311 atermpp::binary_aterm_ostream
(to
) << presspec;
323 p.global_variables().end()));
326 const std::vector<pres_equation>& eqn = p.equations();
327 for (std::vector<pres_equation>::const_reverse_iterator i = eqn.rbegin(); i != eqn.rend(); ++i)
329 atermpp::aterm a = pres_equation_to_aterm(*i);
330 eqn_list.push_front(a);
332 atermpp::
aterm equations = atermpp::aterm(core::detail::function_symbol_PREqnSpec(), 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 propositional_variable & variable() const
Returns the pres variable of the equation.
pres_equation(const fixpoint_symbol &symbol, const propositional_variable &variable, const pres_expression &expr)
Constructor.
const pres_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
const fixpoint_symbol & symbol() const
Returns the fixpoint symbol 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 PRES is well typed.
\brief A propositional variable instantiation
const core::identifier_string & name() const
propositional_variable_instantiation(const core::identifier_string &name, const data::data_expression_list ¶meters)
Constructor.
const data::data_expression_list & parameters() const
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_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_PRES()
const atermpp::function_symbol & function_symbol_PRInit()
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
void save_pres(const pres &presspec, const std::string &filename)
Saves an PRES to filename, or to stdout if filename equals "".
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.
void load_pres(pres &pres, std::istream &stream, utilities::file_format format, const std::string &)
Load a PRES from file.
const utilities::file_format guess_format(const std::string &filename)
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, pres_equation &equation)
static atermpp::aterm remove_index_impl(const atermpp::aterm &x)
const utilities::file_format & pres_format_internal()
std::istream & operator>>(std::istream &from, pres &result)
Reads a PRES from an input stream.
void save_pres(const pres &pres, std::ostream &stream, utilities::file_format format)
Save a PRES in the format specified.
const utilities::file_format & pres_format_text()
void load_pres(pres &pres, const std::string &filename, utilities::file_format format)
Load pres from file.
atermpp::aterm pres_marker()
void save_pres(const pres &pres, const std::string &filename, utilities::file_format format, bool welltypedness_check)
save_pres Saves a PRES to a file.
const std::vector< utilities::file_format > & pres_file_formats()
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, pres &pres)
Reads a pres from a stream.
atermpp::aterm pres_to_aterm(const pres &p)
Conversion to atermappl.
std::string pp(const pres_system::pres &x)
static atermpp::aterm add_index_impl(const atermpp::aterm &x)
void complete_data_specification(pres &)
Adds all sorts that appear in the PRES p to the data specification of p.
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