1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Haniel Barbosa, Dejan Jovanovic |
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 |
|
* [[ Add one-line brief description here ]] |
14 |
|
* |
15 |
|
* [[ Add lengthier description here ]] |
16 |
|
* \todo document this file |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "cvc5_private.h" |
20 |
|
|
21 |
|
#ifndef CVC5__THEORY__UF__THEORY_UF_REWRITER_H |
22 |
|
#define CVC5__THEORY__UF__THEORY_UF_REWRITER_H |
23 |
|
|
24 |
|
#include "expr/node_algorithm.h" |
25 |
|
#include "options/uf_options.h" |
26 |
|
#include "theory/rewriter.h" |
27 |
|
#include "theory/substitutions.h" |
28 |
|
#include "theory/theory_rewriter.h" |
29 |
|
|
30 |
|
namespace cvc5 { |
31 |
|
namespace theory { |
32 |
|
namespace uf { |
33 |
|
|
34 |
15266 |
class TheoryUfRewriter : public TheoryRewriter |
35 |
|
{ |
36 |
|
public: |
37 |
|
TheoryUfRewriter(bool isHigherOrder = false); |
38 |
|
RewriteResponse postRewrite(TNode node) override; |
39 |
|
|
40 |
|
RewriteResponse preRewrite(TNode node) override; |
41 |
|
|
42 |
|
public: // conversion between HO_APPLY AND APPLY_UF |
43 |
|
// converts an APPLY_UF to a curried HO_APPLY e.g. (f a b) becomes (@ (@ f a) |
44 |
|
// b) |
45 |
|
static Node getHoApplyForApplyUf(TNode n); |
46 |
|
// converts a curried HO_APPLY into an APPLY_UF e.g. (@ (@ f a) b) becomes (f a b) |
47 |
|
static Node getApplyUfForHoApply(TNode n); |
48 |
|
/** |
49 |
|
* Given a curried HO_APPLY term n, this method adds its arguments into args |
50 |
|
* and returns its operator. If the argument opInArgs is true, then we add |
51 |
|
* its operator to args. |
52 |
|
*/ |
53 |
|
static Node decomposeHoApply(TNode n, |
54 |
|
std::vector<TNode>& args, |
55 |
|
bool opInArgs = false); |
56 |
|
/** returns true if this node can be used as an operator of an APPLY_UF node. In higher-order logic, |
57 |
|
* terms can have function types and not just variables. |
58 |
|
* Currently, we want only free variables to be used as operators of APPLY_UF nodes. This is motivated by |
59 |
|
* E-matching, ite-lifting among other things. For example: |
60 |
|
* f: Int -> Int, g : Int -> Int |
61 |
|
* forall x : ( Int -> Int ), y : Int. (x y) = (f 0) |
62 |
|
* Then, f and g can be used as APPLY_UF operators, but (ite C f g), (lambda x1. (f x1)) as well as the variable x above are not. |
63 |
|
*/ |
64 |
|
static bool canUseAsApplyUfOperator(TNode n); |
65 |
|
/** Is the logic higher-order? */ |
66 |
|
bool d_isHigherOrder; |
67 |
|
}; /* class TheoryUfRewriter */ |
68 |
|
|
69 |
|
} // namespace uf |
70 |
|
} // namespace theory |
71 |
|
} // namespace cvc5 |
72 |
|
|
73 |
|
#endif /* CVC5__THEORY__UF__THEORY_UF_REWRITER_H */ |