1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Techniques for evaluating terms with recursively defined functions. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__QUANTIFIERS_FUN_DEF_EVALUATOR_H |
19 |
|
#define CVC5__QUANTIFIERS_FUN_DEF_EVALUATOR_H |
20 |
|
|
21 |
|
#include <map> |
22 |
|
#include <vector> |
23 |
|
#include "expr/node.h" |
24 |
|
#include "theory/evaluator.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
namespace theory { |
28 |
|
namespace quantifiers { |
29 |
|
|
30 |
|
/** |
31 |
|
* Techniques for evaluating recursively defined functions. |
32 |
|
*/ |
33 |
|
class FunDefEvaluator |
34 |
|
{ |
35 |
|
public: |
36 |
|
FunDefEvaluator(); |
37 |
1151 |
~FunDefEvaluator() {} |
38 |
|
/** |
39 |
|
* Assert definition of a (recursive) function definition given by quantified |
40 |
|
* formula q. |
41 |
|
*/ |
42 |
|
void assertDefinition(Node q); |
43 |
|
/** |
44 |
|
* Simplify node based on the (recursive) function definitions known by this |
45 |
|
* class. If n cannot be simplified to a constant, then this method returns |
46 |
|
* null. |
47 |
|
*/ |
48 |
|
Node evaluate(Node n) const; |
49 |
|
/** |
50 |
|
* Has a call to assertDefinition been made? If this returns false, then |
51 |
|
* the evaluate method is the same as calling the rewriter, and returning |
52 |
|
* false if the result is non-constant. |
53 |
|
*/ |
54 |
|
bool hasDefinitions() const; |
55 |
|
|
56 |
|
/** Get definitions */ |
57 |
|
const std::vector<Node>& getDefinitions() const; |
58 |
|
/** Get definition for function symbol f, if it is cached by this class */ |
59 |
|
Node getDefinitionFor(Node f) const; |
60 |
|
|
61 |
|
private: |
62 |
|
/** information cached per function definition */ |
63 |
66 |
class FunDefInfo |
64 |
|
{ |
65 |
|
public: |
66 |
|
/** the quantified formula */ |
67 |
|
Node d_quant; |
68 |
|
/** the body */ |
69 |
|
Node d_body; |
70 |
|
/** the formal argument list */ |
71 |
|
std::vector<Node> d_args; |
72 |
|
}; |
73 |
|
/** maps functions to the above information */ |
74 |
|
std::map<Node, FunDefInfo> d_funDefMap; |
75 |
|
/** list of all definitions */ |
76 |
|
std::vector<Node> d_funDefs; |
77 |
|
/** evaluator utility */ |
78 |
|
Evaluator d_eval; |
79 |
|
}; |
80 |
|
|
81 |
|
} // namespace quantifiers |
82 |
|
} // namespace theory |
83 |
|
} // namespace cvc5 |
84 |
|
|
85 |
|
#endif |