1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Mathias Preiner, Tim King |
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 |
|
* ceg_dt_instantiator |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H |
19 |
|
#define CVC5__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H |
20 |
|
|
21 |
|
#include "expr/node.h" |
22 |
|
#include "theory/quantifiers/cegqi/ceg_instantiator.h" |
23 |
|
|
24 |
|
namespace cvc5 { |
25 |
|
namespace theory { |
26 |
|
namespace quantifiers { |
27 |
|
|
28 |
|
/** Datatypes Instantiator |
29 |
|
* |
30 |
|
* This class implements a selection function for datatypes based on solving |
31 |
|
* for occurrences of variables in subfields of datatypes. |
32 |
|
*/ |
33 |
|
class DtInstantiator : public Instantiator |
34 |
|
{ |
35 |
|
public: |
36 |
37 |
DtInstantiator(TypeNode tn) : Instantiator(tn) {} |
37 |
74 |
virtual ~DtInstantiator() {} |
38 |
|
/** reset */ |
39 |
|
void reset(CegInstantiator* ci, |
40 |
|
SolvedForm& sf, |
41 |
|
Node pv, |
42 |
|
CegInstEffort effort) override; |
43 |
|
/** this instantiator implements hasProcessEqualTerm */ |
44 |
|
bool hasProcessEqualTerm(CegInstantiator* ci, |
45 |
|
SolvedForm& sf, |
46 |
|
Node pv, |
47 |
|
CegInstEffort effort) override; |
48 |
|
/** process equal terms |
49 |
|
* |
50 |
|
* This tries to find an equality eqc[i] = eqc[j] such that pv can be solved |
51 |
|
* for (via solve_dt). If a solved form for pv can be found in this way, we |
52 |
|
* add the substitution for pv to sf and recurse. |
53 |
|
*/ |
54 |
|
bool processEqualTerms(CegInstantiator* ci, |
55 |
|
SolvedForm& sf, |
56 |
|
Node pv, |
57 |
|
std::vector<Node>& eqc, |
58 |
|
CegInstEffort effort) override; |
59 |
|
/** this instantiator processes equalities */ |
60 |
|
bool hasProcessEquality(CegInstantiator* ci, |
61 |
|
SolvedForm& sf, |
62 |
|
Node pv, |
63 |
|
CegInstEffort effort) override; |
64 |
|
/** process equality |
65 |
|
* |
66 |
|
* This tries to find a solved form for pv based on the equality |
67 |
|
* terms[0] = terms[1] via solve_dt. If a solved form for pv can be found in |
68 |
|
* this way, we add the substitution for pv to sf and recurse. |
69 |
|
*/ |
70 |
|
bool processEquality(CegInstantiator* ci, |
71 |
|
SolvedForm& sf, |
72 |
|
Node pv, |
73 |
|
std::vector<TermProperties>& term_props, |
74 |
|
std::vector<Node>& terms, |
75 |
|
CegInstEffort effort) override; |
76 |
|
/** identify */ |
77 |
39 |
std::string identify() const override { return "Dt"; } |
78 |
|
|
79 |
|
private: |
80 |
|
/** solve datatype |
81 |
|
* |
82 |
|
* If this method returns a non-null node ret, then v -> ret is a |
83 |
|
* solution for v in the equality a = b and ret does not contain v. |
84 |
|
* |
85 |
|
* For example, if cons( v, nil ) = cons( 5, nil ), this method returns 5. |
86 |
|
* For example, if cons( v, nil ) = L, this method returns head( L ). |
87 |
|
* For example, if cons( v, nil ) = cons( v+1, nil ), this method returns |
88 |
|
* the null node. |
89 |
|
*/ |
90 |
|
Node solve_dt(Node v, Node a, Node b, Node sa, Node sb); |
91 |
|
}; |
92 |
|
|
93 |
|
} // namespace quantifiers |
94 |
|
} // namespace theory |
95 |
|
} // namespace cvc5 |
96 |
|
|
97 |
|
#endif /* CVC5__THEORY__QUANTIFIERS__CEG_DT_INSTANTIATOR_H */ |