mCRL2
Loading...
Searching...
No Matches
with_prover.h
Go to the documentation of this file.
1// Author(s): Muck van Weerdenburg
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/data/detail/rewrite/with_prover.h
10/// \brief Rewriting combined with semantic simplification using a prover
11
12#ifndef MCRL2_DATA_DETAIL_REWR_PROVER_H
13#define MCRL2_DATA_DETAIL_REWR_PROVER_H
14
15#include "mcrl2/data/detail/prover/bdd_prover.h"
16
17namespace mcrl2::data::detail
18{
19
21{
22 public:
24
26
27 public:
28 RewriterProver(const data_specification& data_spec, mcrl2::data::rewriter::strategy strat,
29 const used_data_equation_selector& equations_selector)
30 : Rewriter(data_spec, equations_selector),
32 {
34 }
35
36 ~RewriterProver() override = default;
37
38 rewrite_strategy getStrategy() override
39 {
40 switch (prover_obj.rewriter_strategy())
41 {
42 case data::rewrite_strategy::jitty:
43 return data::rewrite_strategy::jitty_prover;
44#ifdef MCRL2_ENABLE_JITTYC
45 case data::rewrite_strategy::jitty_compiling:
46 return data::rewrite_strategy::jitty_compiling_prover;
47#endif
48 default:
49 throw mcrl2::runtime_error("invalid rewrite strategy");
50 }
51 }
52
53 void rewrite(data_expression& result, const data_expression& t, substitution_type& sigma) override
54 {
55 // The prover rewriter should also work on terms with other types than Bool.
56 // Up till 14/5/2020 this was not the case. The old code is left here, to
57 // restore it easily, in case it turns out that the jittyp rewriter cannot
58 // fruitfully be applied on expressions, other than those of type bool.
59 //
60 // if (mcrl2::data::data_expression(t).sort() == mcrl2::data::sort_bool::bool_())
61 // {
62 prover_obj.set_substitution(sigma);
63 prover_obj.set_formula(t);
64 result=prover_obj.get_bdd();
65 return;
66 }
67
68 data_expression rewrite(const data_expression& t, substitution_type& sigma) override
69 {
70 data_expression result;
71 rewrite(result,t,sigma);
72 return result;
73 }
74
75 void thread_initialise() override
76 {
78 prover_obj.thread_initialise();
79 }
80
81 protected:
82
83 // Protected copy constructor.
84 public:
85 RewriterProver(const RewriterProver& other) = delete;
86
87 // Copy constructor intended for cloning.
89 BDD_Prover prover_obj_)
90 : Rewriter(rewr),
92 {
94 }
95
96 std::shared_ptr<Rewriter> clone() override
97 {
98 return std::shared_ptr<Rewriter>(new RewriterProver(*this,prover_obj.clone()));
99 }
100};
101
102}
103
104#endif
A unordered_map class in which aterms can be stored.
An abstraction expression.
Definition abstraction.h:23
const variable_list & variables() const
Definition abstraction.h:60
const data_expression & body() const
Definition abstraction.h:65
\brief A data equation
const data_expression & lhs() const
const variable_list & variables() const
data_expression & operator=(const data_expression &) noexcept=default
RewriterProver(const data_specification &data_spec, mcrl2::data::rewriter::strategy strat, const used_data_equation_selector &equations_selector)
Definition with_prover.h:28
RewriterProver(const RewriterProver &other)=delete
data_expression rewrite(const data_expression &t, substitution_type &sigma) override
Rewrite an mCRL2 data term.
Definition with_prover.h:68
rewrite_strategy getStrategy() override
Get rewriter strategy that is used.
Definition with_prover.h:38
void rewrite(data_expression &result, const data_expression &t, substitution_type &sigma) override
Rewrite an mCRL2 data term.
Definition with_prover.h:53
RewriterProver(const RewriterProver &rewr, BDD_Prover prover_obj_)
Definition with_prover.h:88
std::shared_ptr< Rewriter > clone() override
Clone a rewriter.
Definition with_prover.h:96
Rewriter interface class.
Definition rewrite.h:39
void rewrite_where(data_expression &result, const where_clause &term, substitution_type &sigma)
Definition rewrite.cpp:61
virtual void thread_initialise()
Definition rewrite.h:164
Rewriter(const data_specification &data_spec, const used_data_equation_selector &eq_selector)
Constructor. Do not use directly; use createRewriter() function instead.
Definition rewrite.h:60
An enumerator algorithm that generates solutions of a condition.
Definition enumerator.h:599
The default element for the todo list of the enumerator.
Definition enumerator.h:229
Component for selecting a subset of equations that are actually used in an encompassing specification...
Definition selection.h:36
\brief A data variable
Definition variable.h:25
variable(const variable &) noexcept=default
Move semantics.
\brief A where expression
const assignment_list & assignments() const
const data_expression & body() const
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:435
void CheckRewriteRule(const data_equation &data_eqn)
Check that an mCRL2 data equation is a valid rewrite rule. If not, an runtime_error is thrown indicat...
Definition rewrite.cpp:582
static void checkPattern(const data_expression &p)
Definition rewrite.cpp:567
static void check_vars(application::const_iterator begin, const application::const_iterator &end, const std::set< variable > &vars, std::set< variable > &used_vars)
Definition rewrite.cpp:524
void set_enumerator_iteration_limit(std::size_t size)
bool isValidRewriteRule(const data_equation &data_eqn)
Check whether or not an mCRL2 data equation is a valid rewrite rule.
Definition rewrite.cpp:640
static bool occur_check(const variable &v, const atermpp::aterm &e)
Definition rewrite.cpp:44
static void checkPattern(application::const_iterator begin, const application::const_iterator &end)
Definition rewrite.cpp:558
static void check_vars(const data_expression &expr, const std::set< variable > &vars, std::set< variable > &used_vars)
Definition rewrite.cpp:535
bool is_application(const data_expression &t)
Returns true if the term t is an application.
bool is_forall(const atermpp::aterm &x)
Returns true if the term t is a universal quantification.
bool is_exists(const atermpp::aterm &x)
Returns true if the term t is an existential quantification.
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
bool operator()(const atermpp::aterm &t) const
Definition rewrite.cpp:37