1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Andres Noetzli, Gereon Kremer |
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 |
|
* Rewrite rules for string-specific operators in theory of strings. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__STRINGS__STRINGS_REWRITER_H |
19 |
|
#define CVC5__THEORY__STRINGS__STRINGS_REWRITER_H |
20 |
|
|
21 |
|
#include "expr/node.h" |
22 |
|
#include "theory/strings/sequences_rewriter.h" |
23 |
|
|
24 |
|
namespace cvc5 { |
25 |
|
namespace theory { |
26 |
|
namespace strings { |
27 |
|
|
28 |
|
/** |
29 |
|
* An extension of SequencesRewriter that handles operators that |
30 |
|
* are specific to strings (and cannot be applied to sequences). |
31 |
|
*/ |
32 |
15269 |
class StringsRewriter : public SequencesRewriter |
33 |
|
{ |
34 |
|
public: |
35 |
|
StringsRewriter(Rewriter* r, |
36 |
|
HistogramStat<Rewrite>* statistics, |
37 |
|
uint32_t alphaCard = 196608); |
38 |
|
|
39 |
|
RewriteResponse postRewrite(TNode node) override; |
40 |
|
|
41 |
|
/** rewrite string to integer |
42 |
|
* |
43 |
|
* This is the entry point for post-rewriting terms n of the form |
44 |
|
* str.to_int( s ) |
45 |
|
* Returns the rewritten form of n. |
46 |
|
*/ |
47 |
|
Node rewriteStrToInt(Node n); |
48 |
|
|
49 |
|
/** rewrite integer to string |
50 |
|
* |
51 |
|
* This is the entry point for post-rewriting terms n of the form |
52 |
|
* str.from_int( i ) |
53 |
|
* Returns the rewritten form of n. |
54 |
|
*/ |
55 |
|
Node rewriteIntToStr(Node n); |
56 |
|
|
57 |
|
/** rewrite string convert |
58 |
|
* |
59 |
|
* This is the entry point for post-rewriting terms n of the form |
60 |
|
* str.tolower( s ) and str.toupper( s ) |
61 |
|
* Returns the rewritten form of n. |
62 |
|
*/ |
63 |
|
Node rewriteStrConvert(Node n); |
64 |
|
|
65 |
|
/** rewrite string less than |
66 |
|
* |
67 |
|
* This is the entry point for post-rewriting terms n of the form |
68 |
|
* str.<( t, s ) |
69 |
|
* Returns the rewritten form of n. |
70 |
|
*/ |
71 |
|
Node rewriteStringLt(Node n); |
72 |
|
|
73 |
|
/** rewrite string less than or equal |
74 |
|
* |
75 |
|
* This is the entry point for post-rewriting terms n of the form |
76 |
|
* str.<=( t, s ) |
77 |
|
* Returns the rewritten form of n. |
78 |
|
*/ |
79 |
|
Node rewriteStringLeq(Node n); |
80 |
|
|
81 |
|
/** rewrite str.from_code |
82 |
|
* |
83 |
|
* This is the entry point for post-rewriting terms n of the form |
84 |
|
* str.from_code( t ) |
85 |
|
* Returns the rewritten form of n. |
86 |
|
*/ |
87 |
|
Node rewriteStringFromCode(Node n); |
88 |
|
|
89 |
|
/** rewrite str.to_code |
90 |
|
* |
91 |
|
* This is the entry point for post-rewriting terms n of the form |
92 |
|
* str.to_code( t ) |
93 |
|
* Returns the rewritten form of n. |
94 |
|
*/ |
95 |
|
Node rewriteStringToCode(Node n); |
96 |
|
|
97 |
|
/** rewrite is digit |
98 |
|
* |
99 |
|
* This is the entry point for post-rewriting terms n of the form |
100 |
|
* str.is_digit( t ) |
101 |
|
* Returns the rewritten form of n. |
102 |
|
*/ |
103 |
|
Node rewriteStringIsDigit(Node n); |
104 |
|
|
105 |
|
private: |
106 |
|
/** The cardinality of the alphabet */ |
107 |
|
uint32_t d_alphaCard; |
108 |
|
}; |
109 |
|
|
110 |
|
} // namespace strings |
111 |
|
} // namespace theory |
112 |
|
} // namespace cvc5 |
113 |
|
|
114 |
|
#endif /* CVC5__THEORY__STRINGS__STRINGS_REWRITER_H */ |