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 |
|
* Simple inst match generator class. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__QUANTIFIERS__INST_MATCH_GENERATOR_SIMPLE_H |
19 |
|
#define CVC5__THEORY__QUANTIFIERS__INST_MATCH_GENERATOR_SIMPLE_H |
20 |
|
|
21 |
|
#include <map> |
22 |
|
#include <vector> |
23 |
|
|
24 |
|
#include "expr/node_trie.h" |
25 |
|
#include "theory/quantifiers/ematching/inst_match_generator.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
namespace theory { |
29 |
|
namespace quantifiers { |
30 |
|
namespace inst { |
31 |
|
|
32 |
|
/** InstMatchGeneratorSimple class |
33 |
|
* |
34 |
|
* This is the default generator class for simple single triggers. |
35 |
|
* For example, { f( x, a ) }, { f( x, x ) } and { f( x, y ) } are simple single |
36 |
|
* triggers. In practice, around 70-90% of triggers are simple single triggers. |
37 |
|
* |
38 |
|
* Notice that simple triggers also can have an attached polarity. |
39 |
|
* For example, { P( x ) = false }, { f( x, y ) = a } and { ~f( a, x ) = b } are |
40 |
|
* simple single triggers. |
41 |
|
* |
42 |
|
* The implementation traverses the term indices in TermDatabase for adding |
43 |
|
* instantiations, which is more efficient than the techniques required for |
44 |
|
* handling non-simple single triggers. |
45 |
|
*/ |
46 |
15292 |
class InstMatchGeneratorSimple : public IMGenerator |
47 |
|
{ |
48 |
|
public: |
49 |
|
/** constructors */ |
50 |
|
InstMatchGeneratorSimple(Trigger* tparent, Node q, Node pat); |
51 |
|
|
52 |
|
/** Reset instantiation round. */ |
53 |
|
void resetInstantiationRound() override; |
54 |
|
/** Add instantiations. */ |
55 |
|
uint64_t addInstantiations(Node q) override; |
56 |
|
/** Get active score. */ |
57 |
|
int getActiveScore() override; |
58 |
|
|
59 |
|
private: |
60 |
|
/** quantified formula for the trigger term */ |
61 |
|
Node d_quant; |
62 |
|
/** the trigger term */ |
63 |
|
Node d_match_pattern; |
64 |
|
/** equivalence class polarity information |
65 |
|
* |
66 |
|
* This stores the required polarity/equivalence class with this trigger. |
67 |
|
* If d_eqc is non-null, we only produce matches { x->t } such that |
68 |
|
* our context does not entail |
69 |
|
* ( d_match_pattern*{ x->t } = d_eqc) if d_pol = true, or |
70 |
|
* ( d_match_pattern*{ x->t } != d_eqc) if d_pol = false. |
71 |
|
* where * denotes application of substitution. |
72 |
|
*/ |
73 |
|
bool d_pol; |
74 |
|
Node d_eqc; |
75 |
|
/** Match pattern arg types. |
76 |
|
* Cached values of d_match_pattern[i].getType(). |
77 |
|
*/ |
78 |
|
std::vector<TypeNode> d_match_pattern_arg_types; |
79 |
|
/** The match operator d_match_pattern (see TermDb::getMatchOperator). */ |
80 |
|
Node d_op; |
81 |
|
/** |
82 |
|
* Map from child number of d_match_pattern to variable index, or -1 if the |
83 |
|
* child is not a variable. |
84 |
|
*/ |
85 |
|
std::map<size_t, int> d_var_num; |
86 |
|
/** add instantiations, helper function. |
87 |
|
* |
88 |
|
* @param m the current match we are building, |
89 |
|
* @param addedLemmas the number of lemmas we have added via calls to |
90 |
|
* Instantiate::addInstantiation(...), |
91 |
|
* @param argIndex the argument index in d_match_pattern we are currently |
92 |
|
* matching, |
93 |
|
* @param tat the term index we are currently traversing. |
94 |
|
*/ |
95 |
|
void addInstantiations(InstMatch& m, |
96 |
|
uint64_t& addedLemmas, |
97 |
|
size_t argIndex, |
98 |
|
TNodeTrie* tat); |
99 |
|
}; |
100 |
|
|
101 |
|
} // namespace inst |
102 |
|
} // namespace quantifiers |
103 |
|
} // namespace theory |
104 |
|
} // namespace cvc5 |
105 |
|
|
106 |
|
#endif |