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