1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Mathias Preiner |
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 |
|
* Utility for filtering sygus solutions. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__QUANTIFIERS__SOLUTION_FILTER_H |
19 |
|
#define CVC5__THEORY__QUANTIFIERS__SOLUTION_FILTER_H |
20 |
|
|
21 |
|
#include <map> |
22 |
|
#include <unordered_set> |
23 |
|
#include "expr/node.h" |
24 |
|
#include "theory/quantifiers/expr_miner.h" |
25 |
|
#include "theory/quantifiers/lazy_trie.h" |
26 |
|
#include "theory/quantifiers/sygus_sampler.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
namespace quantifiers { |
31 |
|
|
32 |
|
/** |
33 |
|
* This class is used to filter solutions based on logical strength. |
34 |
|
* |
35 |
|
* Currently, it is used to filter predicate solutions that are collectively |
36 |
|
* entailed by the previous predicate solutions (if we are looking for logically |
37 |
|
* stronger solutions), or to filter predicate solutions that entail any |
38 |
|
* previous predicate (if we are looking for logically weaker solutions). |
39 |
|
*/ |
40 |
|
class SolutionFilterStrength : public ExprMiner |
41 |
|
{ |
42 |
|
public: |
43 |
|
SolutionFilterStrength(); |
44 |
9 |
~SolutionFilterStrength() {} |
45 |
|
/** initialize */ |
46 |
|
void initialize(const std::vector<Node>& vars, |
47 |
|
SygusSampler* ss = nullptr) override; |
48 |
|
/** |
49 |
|
* Add term to this miner. It is expected that n has Boolean type. |
50 |
|
* |
51 |
|
* If d_isStrong is true, then if this method returns false, then the |
52 |
|
* entailment n_1 ^ ... ^ n_m |= n holds, where n_1, ..., n_m are the terms |
53 |
|
* previously registered to this class. |
54 |
|
* |
55 |
|
* Dually, if d_isStrong is false, then if this method returns false, then |
56 |
|
* the entailment n |= n_1 V ... V n_m holds. |
57 |
|
*/ |
58 |
|
bool addTerm(Node n, std::ostream& out) override; |
59 |
|
/** set logically strong */ |
60 |
|
void setLogicallyStrong(bool isStrong); |
61 |
|
|
62 |
|
private: |
63 |
|
/** |
64 |
|
* Set of all (non-filtered) terms registered to this class. We store the |
65 |
|
* negation of these terms if d_isStrong is false. |
66 |
|
*/ |
67 |
|
std::vector<Node> d_curr_sols; |
68 |
|
/** whether we are trying to find the logically strongest solutions */ |
69 |
|
bool d_isStrong; |
70 |
|
}; |
71 |
|
|
72 |
|
} // namespace quantifiers |
73 |
|
} // namespace theory |
74 |
|
} // namespace cvc5 |
75 |
|
|
76 |
|
#endif /* CVC5__THEORY__QUANTIFIERS__SOLUTION_FILTER_H */ |