12#ifndef MCRL2_MODAL_FORMULA_MAXIMAL_CLOSED_SUBFORMULA_H
13#define MCRL2_MODAL_FORMULA_MAXIMAL_CLOSED_SUBFORMULA_H
15#include "mcrl2/modal_formula/traverser.h"
43 throw mcrl2::runtime_error(
"child_count: unknown argument");
47template <
template <
class>
class Traverser,
class Node,
class Derived>
50 using super = Traverser<Derived>;
56 return static_cast<Derived&>(*
this);
64 void push(
const Node& node)
66 node_stack.push_back(node);
67 mCRL2log(log::debug) <<
"<push>" << node << std::endl;
73 Node result = node_stack.back();
74 node_stack.pop_back();
81 return node_stack.back();
85 const Node&
top()
const
87 return node_stack.back();
100 std::size_t n = child_count(atermpp::down_cast<state_formula>(x));
101 derived().join(x, node_stack.end() - n, node_stack.end(), result);
102 node_stack.erase(node_stack.end() - n, node_stack.end());
137 out <<
"<node>variables = ";
138 for (
const data::variable& v: node.variables)
142 out <<
" formulas = ";
143 for (
const state_formula& f: node.formulas)
150template <
typename Derived>
166 return static_cast<Derived&>(*
this);
169 template <
typename T>
175 data::find_free_variables(x, std::inserter(result.variables, result.variables.end()));
180 for (
const data::variable& v: x.variables())
182 result.variables.erase(v);
188 for (
const data::variable& v: x.variables())
190 result.variables.erase(v);
196 for (
const data::data_expression& e: x.arguments())
198 data::find_free_variables(e, std::inserter(result.variables, result.variables.end()));
202 template <
typename T>
205 if (result.variables.empty())
207 result.formulas.clear();
208 result.formulas.insert(x);
212 template <
typename T>
215 for (node_iterator i = first; i != last; ++i)
217 result.variables.insert(i->variables.begin(), i->variables.end());
219 update_free_variables(x, result);
220 if (result.variables.empty())
222 result.formulas.insert(atermpp::down_cast<state_formula>(x));
226 for (node_iterator i = first; i != last; ++i)
228 result.formulas.insert(i->formulas.begin(), i->formulas.end());
250 return f.top().formulas;
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.