1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/******************************************************************************
* Top contributors (to current version):
* Kshitij Bansal, Andrew Reynolds, Andres Noetzli
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* Sets theory rewriter.
*/
#include "cvc5_private.h"
#ifndef CVC5__THEORY__SETS__THEORY_SETS_REWRITER_H
#define CVC5__THEORY__SETS__THEORY_SETS_REWRITER_H
#include "theory/rewriter.h"
namespace cvc5 {
namespace theory {
namespace sets {
class TheorySetsRewriter : public TheoryRewriter
{
public:
/**
* Rewrite a node into the normal form for the theory of sets.
* Called in post-order (really reverse-topological order) when
* traversing the expression DAG during rewriting. This is the
* main function of the rewriter, and because of the ordering,
* it can assume its children are all rewritten already.
*
* This function can return one of three rewrite response codes
* along with the rewritten node:
*
* REWRITE_DONE indicates that no more rewriting is needed.
* REWRITE_AGAIN means that the top-level expression should be
* rewritten again, but that its children are in final form.
* REWRITE_AGAIN_FULL means that the entire returned expression
* should be rewritten again (top-down with preRewrite(), then
* bottom-up with postRewrite()).
*
* Even if this function returns REWRITE_DONE, if the returned
* expression belongs to a different theory, it will be fully
* rewritten by that theory's rewriter.
*/
RewriteResponse postRewrite(TNode node) override;
/**
* Rewrite a node into the normal form for the theory of sets
* in pre-order (really topological order)---meaning that the
* children may not be in the normal form. This is an optimization
* for theories with cancelling terms (e.g., 0 * (big-nasty-expression)
* in arithmetic rewrites to 0 without the need to look at the big
* nasty expression). Since it's only an optimization, the
* implementation here can do nothing.
*/
RewriteResponse preRewrite(TNode node) override;
/**
* Rewrite an equality, in case special handling is required.
*/
Node rewriteEquality(TNode equality)
{
// often this will suffice
return postRewrite(equality).d_node;
}
private:
/**
* Returns true if elementTerm is in setTerm, where both terms are constants.
*/
bool checkConstantMembership(TNode elementTerm, TNode setTerm);
/**
* rewrites for n include:
* - (set.map f (as set.empty (Set T1)) = (as set.empty (Set T2))
* - (set.map f (set.singleton x)) = (set.singleton (apply f x))
* - (set.map f (set.union A B)) =
* (set.union (set.map f A) (set.map f B))
* where f: T1 -> T2
*/
RewriteResponse postRewriteMap(TNode n);
}; /* class TheorySetsRewriter */
} // namespace sets
} // namespace theory
} // namespace cvc5
#endif /* CVC5__THEORY__SETS__THEORY_SETS_REWRITER_H */
|