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 |
|
* Methods for counterexample-guided quantifier instantiation |
14 |
|
* based on nested quantifier elimination. |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "cvc5_private.h" |
18 |
|
|
19 |
|
#ifndef CVC5__THEORY__QUANTIFIERS__CEQGI__NESTED_QE_H |
20 |
|
#define CVC5__THEORY__QUANTIFIERS__CEQGI__NESTED_QE_H |
21 |
|
|
22 |
|
#include <unordered_set> |
23 |
|
|
24 |
|
#include "context/cdhashmap.h" |
25 |
|
#include "expr/node.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
|
29 |
|
class Env; |
30 |
|
|
31 |
|
namespace theory { |
32 |
|
namespace quantifiers { |
33 |
|
|
34 |
|
class NestedQe |
35 |
|
{ |
36 |
|
using NodeNodeMap = context::CDHashMap<Node, Node>; |
37 |
|
|
38 |
|
public: |
39 |
|
NestedQe(Env& env); |
40 |
12 |
~NestedQe() {} |
41 |
|
/** |
42 |
|
* Process quantified formula. If this returns true, then q was processed |
43 |
|
* via nested quantifier elimination (either during this call or previously |
44 |
|
* in this user context). If q was processed in this call, the lemma: |
45 |
|
* (= q qqe) |
46 |
|
* is added to lem, where qqe is the result of nested quantifier elimination |
47 |
|
* on q. |
48 |
|
*/ |
49 |
|
bool process(Node q, std::vector<Node>& lems); |
50 |
|
/** |
51 |
|
* Have we processed q using the above method? |
52 |
|
*/ |
53 |
|
bool hasProcessed(Node q) const; |
54 |
|
|
55 |
|
/** |
56 |
|
* Get nested quantification. Returns true if q has nested quantifiers. |
57 |
|
* Adds each nested quantifier in the body of q to nqs. |
58 |
|
*/ |
59 |
|
static bool getNestedQuantification(Node q, std::unordered_set<Node>& nqs); |
60 |
|
/** |
61 |
|
* Does quantified formula q have nested quantification? |
62 |
|
*/ |
63 |
|
static bool hasNestedQuantification(Node q); |
64 |
|
/** |
65 |
|
* Do nested quantifier elimination. Returns a formula that is equivalent to |
66 |
|
* q and has no nested quantification. If keepTopLevel is false, then the |
67 |
|
* returned formula is quantifier-free. Otherwise, it is a quantified formula |
68 |
|
* with no nested quantification. |
69 |
|
*/ |
70 |
|
static Node doNestedQe(Env& env, Node q, bool keepTopLevel = false); |
71 |
|
/** |
72 |
|
* Run quantifier elimination on quantified formula q, where q has no nested |
73 |
|
* quantification. This method invokes a subsolver for performing quantifier |
74 |
|
* elimination. |
75 |
|
*/ |
76 |
|
static Node doQe(Env& env, Node q); |
77 |
|
|
78 |
|
private: |
79 |
|
/** Reference to the env */ |
80 |
|
Env& d_env; |
81 |
|
/** |
82 |
|
* Mapping from quantified formulas q to the result of doNestedQe(q, true). |
83 |
|
*/ |
84 |
|
NodeNodeMap d_qnqe; |
85 |
|
}; |
86 |
|
|
87 |
|
} // namespace quantifiers |
88 |
|
} // namespace theory |
89 |
|
} // namespace cvc5 |
90 |
|
|
91 |
|
#endif |