mCRL2
Loading...
Searching...
No Matches
pbes_rewriter_tool.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/pbes_rewriter_tool.h
10/// \brief Base class for tools that use a pbes rewriter.
11
12#ifndef MCRL2_PBES_PBES_REWRITER_TOOL_H
13#define MCRL2_PBES_PBES_REWRITER_TOOL_H
14
15#include <set>
16#include "mcrl2/utilities/command_line_interface.h"
17#include "mcrl2/pbes/pbes_rewriter_type.h"
18
19namespace mcrl2::pbes_system::tools
20{
21
22/// \brief Base class for filter tools that use a pbes rewriter.
23template <typename Tool>
24class pbes_rewriter_tool: public Tool
25{
26 protected:
27 /// \brief The type of the pbes rewriter
28 pbes_system::pbes_rewriter_type m_pbes_rewriter_type;
29
30 /// \brief Returns the types of rewriters that are available for this tool.
31 /// Override this method to change the standard behavior.
32 /// \return The set { simplify, quantifier_all, quantifier_finite }
34 {
35 std::set<pbes_system::pbes_rewriter_type> result;
36 result.insert(pbes_system::pbes_rewriter_type::simplify);
37 result.insert(pbes_system::pbes_rewriter_type::quantifier_all);
38 result.insert(pbes_system::pbes_rewriter_type::quantifier_finite);
39 result.insert(pbes_system::pbes_rewriter_type::quantifier_inside);
40 result.insert(pbes_system::pbes_rewriter_type::quantifier_one_point);
41 result.insert(pbes_system::pbes_rewriter_type::pfnf);
42 result.insert(pbes_system::pbes_rewriter_type::ppg);
43 result.insert(pbes_system::pbes_rewriter_type::srf);
44 result.insert(pbes_system::pbes_rewriter_type::pre_srf);
45 result.insert(pbes_system::pbes_rewriter_type::prune_dataspec);
46 result.insert(pbes_system::pbes_rewriter_type::bqnf_quantifier);
47 result.insert(pbes_system::pbes_rewriter_type::remove_cex_variables);
48 return result;
49 }
50
51 /// \brief Returns the default pbes rewriter.
52 /// Override this method to change the standard behavior.
53 /// \return The string "simplify"
54 virtual pbes_system::pbes_rewriter_type default_rewriter() const
55 {
56 return pbes_system::pbes_rewriter_type::simplify;
57 }
58
59 /// \brief Add options to an interface description. Also includes
60 /// rewriter options.
61 /// \param desc An interface description
62 void add_options(utilities::interface_description& desc) override
63 {
64 Tool::add_options(desc);
65
66 utilities::interface_description::enum_argument<pbes_system::pbes_rewriter_type> arg(utilities::make_enum_argument<pbes_system::pbes_rewriter_type>("NAME"));
67
68 // Compute the available rewriters, and add the approriate arguments
69 std::set<pbes_system::pbes_rewriter_type> types = available_rewriters();
70 for (auto type : types)
71 {
72 arg.add_value(type, type==default_rewriter());
73 }
74
75 desc.add_option(
76 "pbes-rewriter",
77 arg,
78 "use pbes rewrite strategy NAME:",
79 'p'
80 );
81 }
82
83 /// \brief Parse non-standard options
84 /// \param parser A command line parser
85 void parse_options(const utilities::command_line_parser& parser) override
86 {
87 Tool::parse_options(parser);
88 m_pbes_rewriter_type = parser.option_argument_as<pbes_system::pbes_rewriter_type>("pbes-rewriter");
89 }
90
91
92 public:
93 /// \brief Constructor.
94 /// \param name The name of the tool
95 /// \param author The author(s) of the tool
96 /// \param what_is One-line "what is" description of the tool
97 /// \param tool_description The description of the tool
98 /// \param known_issues Known issues with the tool
99 pbes_rewriter_tool(const std::string& name,
100 const std::string& author,
101 const std::string& what_is,
102 const std::string& tool_description,
103 std::string known_issues = ""
104 )
106 {}
107
108 /// \brief Destructor.
109 ~pbes_rewriter_tool() override = default;
110
111 /// \brief Returns the rewriter type
112 /// \return The rewriter type
113 pbes_system::pbes_rewriter_type rewriter_type() const
114 {
116 }
117};
118
119} // namespace mcrl2::pbes_system::tools
120
121
122
123
124
125#endif // MCRL2_PBES_PBES_REWRITER_TOOL_H
Base class for filter tools that use a pbes rewriter.
virtual std::set< pbes_system::pbes_rewriter_type > available_rewriters() const
Returns the types of rewriters that are available for this tool. Override this method to change the s...
virtual pbes_system::pbes_rewriter_type default_rewriter() const
Returns the default pbes rewriter. Override this method to change the standard behavior.
~pbes_rewriter_tool() override=default
Destructor.
void parse_options(const utilities::command_line_parser &parser) override
Parse non-standard options.
void add_options(utilities::interface_description &desc) override
Add options to an interface description. Also includes rewriter options.
pbes_rewriter_tool(const std::string &name, const std::string &author, const std::string &what_is, const std::string &tool_description, std::string known_issues="")
Constructor.
pbes_system::pbes_rewriter_type m_pbes_rewriter_type
The type of the pbes rewriter.
pbes_system::pbes_rewriter_type rewriter_type() const
Returns the rewriter type.