1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Abdalrhman Mohamed, 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 |
|
* Reconstruct Type Info class implementation. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/quantifiers/sygus/rcons_type_info.h" |
17 |
|
|
18 |
|
#include "expr/skolem_manager.h" |
19 |
|
#include "theory/datatypes/sygus_datatype_utils.h" |
20 |
|
#include "theory/quantifiers/sygus/rcons_obligation.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
namespace theory { |
24 |
|
namespace quantifiers { |
25 |
|
|
26 |
53 |
void RConsTypeInfo::initialize(TermDbSygus* tds, |
27 |
|
SygusStatistics& s, |
28 |
|
TypeNode stn, |
29 |
|
const std::vector<Node>& builtinVars) |
30 |
|
{ |
31 |
53 |
NodeManager* nm = NodeManager::currentNM(); |
32 |
53 |
SkolemManager* sm = nm->getSkolemManager(); |
33 |
|
|
34 |
53 |
d_enumerator.reset(new SygusEnumerator(tds, nullptr, &s, true)); |
35 |
53 |
d_enumerator->initialize(sm->mkDummySkolem("sygus_rcons", stn)); |
36 |
53 |
d_crd.reset(new CandidateRewriteDatabase(true, false, true, false)); |
37 |
|
// since initial samples are not always useful for equivalence checks, set |
38 |
|
// their number to 0 |
39 |
53 |
d_sygusSampler.initialize(stn, builtinVars, 0); |
40 |
53 |
d_crd->initialize(builtinVars, &d_sygusSampler); |
41 |
53 |
} |
42 |
|
|
43 |
11508 |
Node RConsTypeInfo::nextEnum() |
44 |
|
{ |
45 |
11508 |
if (!d_enumerator->increment()) |
46 |
|
{ |
47 |
656 |
Trace("sygus-rcons") << "no increment" << std::endl; |
48 |
656 |
return Node::null(); |
49 |
|
} |
50 |
|
|
51 |
21704 |
Node sz = d_enumerator->getCurrent(); |
52 |
|
|
53 |
21704 |
Trace("sygus-rcons") << (sz == Node::null() |
54 |
21704 |
? sz |
55 |
10852 |
: datatypes::utils::sygusToBuiltin(sz)) |
56 |
10852 |
<< std::endl; |
57 |
|
|
58 |
10852 |
return sz; |
59 |
|
} |
60 |
|
|
61 |
768 |
Node RConsTypeInfo::addTerm(Node n) |
62 |
|
{ |
63 |
1536 |
std::stringstream out; |
64 |
1536 |
return d_crd->addTerm(n, false, out); |
65 |
|
} |
66 |
|
|
67 |
699 |
void RConsTypeInfo::setBuiltinToOb(Node t, RConsObligation* ob) |
68 |
|
{ |
69 |
699 |
d_ob.emplace(t, ob); |
70 |
699 |
} |
71 |
|
|
72 |
15640 |
RConsObligation* RConsTypeInfo::builtinToOb(Node t) |
73 |
|
{ |
74 |
15640 |
auto it = d_ob.find(t); |
75 |
15640 |
if (it != d_ob.cend()) |
76 |
|
{ |
77 |
14966 |
return it->second; |
78 |
|
} |
79 |
674 |
return nullptr; |
80 |
|
} |
81 |
|
|
82 |
|
} // namespace quantifiers |
83 |
|
} // namespace theory |
84 |
29286 |
} // namespace cvc5 |