1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Andres Noetzli, Tianyi Liang |
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 |
|
* A finite model finding decision strategy for strings. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__STRINGS__STRINGS_FMF_H |
19 |
|
#define CVC5__THEORY__STRINGS__STRINGS_FMF_H |
20 |
|
|
21 |
|
#include "context/cdhashset.h" |
22 |
|
#include "context/cdo.h" |
23 |
|
#include "context/context.h" |
24 |
|
#include "expr/node.h" |
25 |
|
#include "theory/decision_strategy.h" |
26 |
|
#include "theory/strings/term_registry.h" |
27 |
|
#include "theory/valuation.h" |
28 |
|
|
29 |
|
namespace cvc5 { |
30 |
|
namespace theory { |
31 |
|
namespace strings { |
32 |
|
|
33 |
|
/** Strings finite model finding |
34 |
|
* |
35 |
|
* This class manages the creation of a decision strategy that bounds the |
36 |
|
* sum of lengths of terms of type string. |
37 |
|
*/ |
38 |
|
class StringsFmf |
39 |
|
{ |
40 |
|
typedef context::CDHashSet<Node> NodeSet; |
41 |
|
|
42 |
|
public: |
43 |
|
StringsFmf(context::Context* c, |
44 |
|
context::UserContext* u, |
45 |
|
Valuation valuation, |
46 |
|
TermRegistry& tr); |
47 |
|
~StringsFmf(); |
48 |
|
/** presolve |
49 |
|
* |
50 |
|
* This initializes a (new copy) of the decision strategy d_sslds. |
51 |
|
*/ |
52 |
|
void presolve(); |
53 |
|
/** |
54 |
|
* Get the decision strategy, valid after a call to presolve in the duration |
55 |
|
* of a check-sat call. |
56 |
|
*/ |
57 |
|
DecisionStrategy* getDecisionStrategy() const; |
58 |
|
|
59 |
|
private: |
60 |
|
/** String sum of lengths decision strategy |
61 |
|
* |
62 |
|
* This decision strategy enforces that len(x_1) + ... + len(x_k) <= n |
63 |
|
* for a minimal natural number n, where x_1, ..., x_n is the list of |
64 |
|
* input variables of the problem of type String. |
65 |
|
* |
66 |
|
* This decision strategy is enabled by option::stringsFmf(). |
67 |
|
*/ |
68 |
156 |
class StringSumLengthDecisionStrategy : public DecisionStrategyFmf |
69 |
|
{ |
70 |
|
public: |
71 |
|
StringSumLengthDecisionStrategy(context::Context* c, |
72 |
|
context::UserContext* u, |
73 |
|
Valuation valuation); |
74 |
|
/** make literal */ |
75 |
|
Node mkLiteral(unsigned i) override; |
76 |
|
/** identify */ |
77 |
|
std::string identify() const override; |
78 |
|
/** is initialized */ |
79 |
|
bool isInitialized(); |
80 |
|
/** initialize */ |
81 |
|
void initialize(const std::vector<Node>& vars); |
82 |
|
|
83 |
|
/* |
84 |
|
* Do not hide the zero-argument version of initialize() inherited from the |
85 |
|
* base class |
86 |
|
*/ |
87 |
|
using DecisionStrategyFmf::initialize; |
88 |
|
|
89 |
|
private: |
90 |
|
/** |
91 |
|
* User-context-dependent node corresponding to the sum of the lengths of |
92 |
|
* input variables of type string |
93 |
|
*/ |
94 |
|
context::CDO<Node> d_inputVarLsum; |
95 |
|
}; |
96 |
|
/** an instance of the above class */ |
97 |
|
std::unique_ptr<StringSumLengthDecisionStrategy> d_sslds; |
98 |
|
/** The SAT search context for the theory of strings. */ |
99 |
|
context::Context* d_satContext; |
100 |
|
/** The user level assertion context for the theory of strings. */ |
101 |
|
context::UserContext* d_userContext; |
102 |
|
/** The valuation object of theory of strings */ |
103 |
|
Valuation d_valuation; |
104 |
|
/** The term registry of theory of strings */ |
105 |
|
TermRegistry& d_termReg; |
106 |
|
}; |
107 |
|
|
108 |
|
} // namespace strings |
109 |
|
} // namespace theory |
110 |
|
} // namespace cvc5 |
111 |
|
|
112 |
|
#endif /* CVC5__THEORY__STRINGS__STRINGS_FMF_H */ |