1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer, Aina Niemetz |
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 |
|
* Datatypes inference. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/datatypes/inference.h" |
17 |
|
|
18 |
|
#include "expr/dtype.h" |
19 |
|
#include "options/datatypes_options.h" |
20 |
|
#include "theory/datatypes/inference_manager.h" |
21 |
|
#include "theory/theory.h" |
22 |
|
|
23 |
|
using namespace cvc5::kind; |
24 |
|
|
25 |
|
namespace cvc5 { |
26 |
|
namespace theory { |
27 |
|
namespace datatypes { |
28 |
|
|
29 |
335848 |
DatatypesInference::DatatypesInference(InferenceManager* im, |
30 |
|
Node conc, |
31 |
|
Node exp, |
32 |
335848 |
InferenceId i) |
33 |
335848 |
: SimpleTheoryInternalFact(i, conc, exp, nullptr), d_im(im) |
34 |
|
{ |
35 |
|
// false is not a valid explanation |
36 |
335848 |
Assert(d_exp.isNull() || !d_exp.isConst() || d_exp.getConst<bool>()); |
37 |
335848 |
} |
38 |
|
|
39 |
296090 |
bool DatatypesInference::mustCommunicateFact(Node n, Node exp) |
40 |
|
{ |
41 |
296090 |
Trace("dt-lemma-debug") << "Compute for " << exp << " => " << n << std::endl; |
42 |
|
// Force lemmas if option is set |
43 |
592180 |
if (options::dtInferAsLemmas()) |
44 |
|
{ |
45 |
|
Trace("dt-lemma-debug") |
46 |
|
<< "Communicate " << n << " due to option" << std::endl; |
47 |
|
return true; |
48 |
|
} |
49 |
|
// Note that equalities due to instantiate are forced as lemmas if |
50 |
|
// necessary as they are created. This ensures that terms are shared with |
51 |
|
// external theories when necessary. We send the lemma here only if the |
52 |
|
// conclusion has kind LEQ (for datatypes size) or OR. Notice that |
53 |
|
// all equalities are kept internal, apart from those forced as lemmas |
54 |
|
// via instantiate. |
55 |
296090 |
else if (n.getKind() == LEQ || n.getKind() == OR) |
56 |
|
{ |
57 |
|
Trace("dt-lemma-debug") |
58 |
|
<< "Communicate " << n << " due to kind" << std::endl; |
59 |
|
return true; |
60 |
|
} |
61 |
296090 |
Trace("dt-lemma-debug") << "Do not communicate " << n << std::endl; |
62 |
296090 |
return false; |
63 |
|
} |
64 |
|
|
65 |
25445 |
TrustNode DatatypesInference::processLemma(LemmaProperty& p) |
66 |
|
{ |
67 |
|
// we don't pass lemma property p currently, as it is always default |
68 |
25445 |
return d_im->processDtLemma(d_conc, d_exp, getId()); |
69 |
|
} |
70 |
|
|
71 |
292238 |
Node DatatypesInference::processFact(std::vector<Node>& exp, |
72 |
|
ProofGenerator*& pg) |
73 |
|
{ |
74 |
|
// add to the explanation vector if applicable (when non-trivial) |
75 |
292238 |
if (!d_exp.isNull() && !d_exp.isConst()) |
76 |
|
{ |
77 |
260848 |
exp.push_back(d_exp); |
78 |
|
} |
79 |
292238 |
return d_im->processDtFact(d_conc, d_exp, getId(), pg); |
80 |
|
} |
81 |
|
|
82 |
|
} // namespace datatypes |
83 |
|
} // namespace theory |
84 |
325376 |
} // namespace cvc5 |