1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Morgan Deters |
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 |
|
* Utility for constructing and maintaining abstract values. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "smt/abstract_values.h" |
17 |
|
|
18 |
|
#include "options/smt_options.h" |
19 |
|
|
20 |
|
namespace cvc5 { |
21 |
|
namespace smt { |
22 |
|
|
23 |
10093 |
AbstractValues::AbstractValues(NodeManager* nm) |
24 |
|
: d_nm(nm), |
25 |
|
d_fakeContext(), |
26 |
|
d_abstractValueMap(&d_fakeContext), |
27 |
10093 |
d_abstractValues() |
28 |
|
{ |
29 |
10093 |
} |
30 |
10093 |
AbstractValues::~AbstractValues() {} |
31 |
|
|
32 |
100860 |
Node AbstractValues::substituteAbstractValues(TNode n) |
33 |
|
{ |
34 |
|
// We need to do this even if options::abstractValues() is off, |
35 |
|
// since the setting might have changed after we already gave out |
36 |
|
// some abstract values. |
37 |
100860 |
return d_abstractValueMap.apply(n); |
38 |
|
} |
39 |
|
|
40 |
8 |
Node AbstractValues::mkAbstractValue(TNode n) |
41 |
|
{ |
42 |
2074 |
Assert(options::abstractValues()); |
43 |
8 |
Node& val = d_abstractValues[n]; |
44 |
8 |
if (val.isNull()) |
45 |
|
{ |
46 |
8 |
val = d_nm->mkAbstractValue(n.getType()); |
47 |
8 |
d_abstractValueMap.addSubstitution(val, n); |
48 |
|
} |
49 |
|
// We are supposed to ascribe types to all abstract values that go out. |
50 |
16 |
Node ascription = d_nm->mkConst(AscriptionType(n.getType())); |
51 |
8 |
Node retval = d_nm->mkNode(kind::APPLY_TYPE_ASCRIPTION, ascription, val); |
52 |
16 |
return retval; |
53 |
|
} |
54 |
|
|
55 |
|
} // namespace smt |
56 |
30257 |
} // namespace cvc5 |