1 /********************* */
4 ** Original author: dejan
5 ** Major contributors: mdeters
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
14 ** \brief The Rewriter class
16 ** The Rewriter class.
19 #include "cvc4_private.h"
23 #include "expr/node.h"
24 #include "expr/attribute.h"
30 * Theory rewriters signal whether more rewriting is needed (or not)
31 * by using a member of this enumeration. See RewriteResponse, below.
37 };/* enum RewriteStatus */
40 * Instances of this class serve as response codes from
41 * Theory::preRewrite() and Theory::postRewrite(). Instances of
42 * derived classes RewriteComplete(n), RewriteAgain(n), and
43 * FullRewriteNeeded(n) should be used, giving self-documenting
46 struct RewriteResponse
{
47 const RewriteStatus status
;
49 RewriteResponse(RewriteStatus status
, Node node
) :
50 status(status
), node(node
) {}
51 };/* struct RewriteResponse */
53 class RewriterInitializer
;
56 * The main rewriter class. All functionality is static.
60 friend class RewriterInitializer
;
62 /** Returns the appropriate cache for a node */
63 static Node
getPreRewriteCache(theory::TheoryId theoryId
, TNode node
);
65 /** Returns the appropriate cache for a node */
66 static Node
getPostRewriteCache(theory::TheoryId theoryId
, TNode node
);
68 /** Sets the appropriate cache for a node */
69 static void setPreRewriteCache(theory::TheoryId theoryId
,
70 TNode node
, TNode cache
);
72 /** Sets the appropriate cache for a node */
73 static void setPostRewriteCache(theory::TheoryId theoryId
,
74 TNode node
, TNode cache
);
76 // disable construction of rewriters; all functionality is static
77 Rewriter() CVC4_UNDEFINED
;
78 Rewriter(const Rewriter
&) CVC4_UNDEFINED
;
81 * Rewrites the node using the given theory rewriter.
83 static Node
rewriteTo(theory::TheoryId theoryId
, Node node
);
85 /** Calls the pre-rewriter for the given theory */
86 static RewriteResponse
callPreRewrite(theory::TheoryId theoryId
, TNode node
);
88 /** Calls the post-rewriter for the given theory */
89 static RewriteResponse
callPostRewrite(theory::TheoryId theoryId
, TNode node
);
92 * Calls the equality-rewriter for the given theory.
94 static Node
callRewriteEquality(theory::TheoryId theoryId
, TNode equality
);
97 * Should be called before the rewriter gets used for the first time.
102 * Should be called to clean up any state.
104 static void shutdown();
109 * Rewrites the node using theoryOf() to determine which rewriter to
112 static Node
rewrite(TNode node
);
114 };/* class Rewriter */
116 }/* CVC4::theory namespace */
117 }/* CVC4 namespace */