1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds |
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 class for mining interesting unsat queries from a stream of generated |
14 |
|
* expressions. |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "cvc5_private.h" |
18 |
|
|
19 |
|
#ifndef CVC5__THEORY__QUANTIFIERS__QUERY_GENERATOR_UNSAT_H |
20 |
|
#define CVC5__THEORY__QUANTIFIERS__QUERY_GENERATOR_UNSAT_H |
21 |
|
|
22 |
|
#include <map> |
23 |
|
#include <unordered_set> |
24 |
|
|
25 |
|
#include "expr/node.h" |
26 |
|
#include "expr/variadic_trie.h" |
27 |
|
#include "options/options.h" |
28 |
|
#include "theory/quantifiers/expr_miner.h" |
29 |
|
#include "theory/quantifiers/lazy_trie.h" |
30 |
|
#include "theory/quantifiers/sygus_sampler.h" |
31 |
|
|
32 |
|
namespace cvc5 { |
33 |
|
namespace theory { |
34 |
|
namespace quantifiers { |
35 |
|
|
36 |
|
/** |
37 |
|
* QueryGeneratorUnsat |
38 |
|
* |
39 |
|
* A module for generating interesting unsatisfiable benchmarks using SyGuS |
40 |
|
* enumeration. At a high level, this is based on conjoining predicates that |
41 |
|
* refine models and avoid previously encountered unsat cores. |
42 |
|
*/ |
43 |
|
class QueryGeneratorUnsat : public ExprMiner |
44 |
|
{ |
45 |
|
public: |
46 |
|
QueryGeneratorUnsat(Env& env); |
47 |
4 |
~QueryGeneratorUnsat() {} |
48 |
|
/** initialize */ |
49 |
|
void initialize(const std::vector<Node>& vars, |
50 |
|
SygusSampler* ss = nullptr) override; |
51 |
|
/** |
52 |
|
* Add term to this module. This may trigger the printing and/or checking of |
53 |
|
* new queries. |
54 |
|
*/ |
55 |
|
bool addTerm(Node n, std::ostream& out) override; |
56 |
|
|
57 |
|
private: |
58 |
|
/** |
59 |
|
* Check current query, given by conjunction activeTerms. The generated |
60 |
|
* query is printed on out. If this is UNSAT, we add its unsat core to |
61 |
|
* d_cores. If it is satisfiable, we add its model to currModel for |
62 |
|
* its free variables (which are ExprMiner::d_skolems). |
63 |
|
*/ |
64 |
|
Result checkCurrent(const std::vector<Node>& activeTerms, |
65 |
|
std::ostream& out, |
66 |
|
std::vector<Node>& currModel); |
67 |
|
/** |
68 |
|
* Get next random index, which returns a random index [0, d_terms.size()-1] |
69 |
|
* that is not already in processed. |
70 |
|
*/ |
71 |
|
size_t getNextRandomIndex(const std::unordered_set<size_t>& processed) const; |
72 |
|
/** Constant nodes */ |
73 |
|
Node d_true; |
74 |
|
Node d_false; |
75 |
|
/** cache of all terms registered to this generator */ |
76 |
|
std::vector<Node> d_terms; |
77 |
|
/** total number of queries generated by this class */ |
78 |
|
size_t d_queryCount; |
79 |
|
/** containing the unsat cores */ |
80 |
|
VariadicTrie d_cores; |
81 |
|
/** The options for subsolver calls */ |
82 |
|
Options d_subOptions; |
83 |
|
}; |
84 |
|
|
85 |
|
} // namespace quantifiers |
86 |
|
} // namespace theory |
87 |
|
} // namespace cvc5 |
88 |
|
|
89 |
|
#endif /* CVC5__THEORY__QUANTIFIERS___H */ |