1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Tim King, Mathias Preiner |
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 |
|
* Typing and cardinality rules for the theory of sep. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/sep/theory_sep_type_rules.h" |
17 |
|
|
18 |
|
namespace cvc5 { |
19 |
|
namespace theory { |
20 |
|
namespace sep { |
21 |
|
|
22 |
51 |
TypeNode SepEmpTypeRule::computeType(NodeManager* nodeManager, |
23 |
|
TNode n, |
24 |
|
bool check) |
25 |
|
{ |
26 |
51 |
Assert(n.getKind() == kind::SEP_EMP); |
27 |
51 |
return nodeManager->booleanType(); |
28 |
|
} |
29 |
|
|
30 |
304 |
TypeNode SepPtoTypeRule::computeType(NodeManager* nodeManager, |
31 |
|
TNode n, |
32 |
|
bool check) |
33 |
|
{ |
34 |
304 |
Assert(n.getKind() == kind::SEP_PTO); |
35 |
304 |
if (check) |
36 |
|
{ |
37 |
608 |
TypeNode refType = n[0].getType(check); |
38 |
304 |
TypeNode ptType = n[1].getType(check); |
39 |
|
} |
40 |
304 |
return nodeManager->booleanType(); |
41 |
|
} |
42 |
|
|
43 |
210 |
TypeNode SepStarTypeRule::computeType(NodeManager* nodeManager, |
44 |
|
TNode n, |
45 |
|
bool check) |
46 |
|
{ |
47 |
210 |
TypeNode btype = nodeManager->booleanType(); |
48 |
210 |
Assert(n.getKind() == kind::SEP_STAR); |
49 |
210 |
if (check) |
50 |
|
{ |
51 |
701 |
for (unsigned i = 0; i < n.getNumChildren(); i++) |
52 |
|
{ |
53 |
982 |
TypeNode ctype = n[i].getType(check); |
54 |
491 |
if (ctype != btype) |
55 |
|
{ |
56 |
|
throw TypeCheckingExceptionPrivate(n, |
57 |
|
"child of sep star is not Boolean"); |
58 |
|
} |
59 |
|
} |
60 |
|
} |
61 |
210 |
return btype; |
62 |
|
} |
63 |
|
|
64 |
30 |
TypeNode SepWandTypeRule::computeType(NodeManager* nodeManager, |
65 |
|
TNode n, |
66 |
|
bool check) |
67 |
|
{ |
68 |
30 |
TypeNode btype = nodeManager->booleanType(); |
69 |
30 |
Assert(n.getKind() == kind::SEP_WAND); |
70 |
30 |
if (check) |
71 |
|
{ |
72 |
90 |
for (unsigned i = 0; i < n.getNumChildren(); i++) |
73 |
|
{ |
74 |
120 |
TypeNode ctype = n[i].getType(check); |
75 |
60 |
if (ctype != btype) |
76 |
|
{ |
77 |
|
throw TypeCheckingExceptionPrivate( |
78 |
|
n, "child of sep magic wand is not Boolean"); |
79 |
|
} |
80 |
|
} |
81 |
|
} |
82 |
30 |
return btype; |
83 |
|
} |
84 |
|
|
85 |
891 |
TypeNode SepLabelTypeRule::computeType(NodeManager* nodeManager, |
86 |
|
TNode n, |
87 |
|
bool check) |
88 |
|
{ |
89 |
891 |
TypeNode btype = nodeManager->booleanType(); |
90 |
891 |
Assert(n.getKind() == kind::SEP_LABEL); |
91 |
891 |
if (check) |
92 |
|
{ |
93 |
1782 |
TypeNode ctype = n[0].getType(check); |
94 |
891 |
if (ctype != btype) |
95 |
|
{ |
96 |
|
throw TypeCheckingExceptionPrivate(n, |
97 |
|
"child of sep label is not Boolean"); |
98 |
|
} |
99 |
1782 |
TypeNode stype = n[1].getType(check); |
100 |
891 |
if (!stype.isSet()) |
101 |
|
{ |
102 |
|
throw TypeCheckingExceptionPrivate(n, "label of sep label is not a set"); |
103 |
|
} |
104 |
|
} |
105 |
891 |
return btype; |
106 |
|
} |
107 |
|
|
108 |
1638 |
TypeNode SepNilTypeRule::computeType(NodeManager* nodeManager, |
109 |
|
TNode n, |
110 |
|
bool check) |
111 |
|
{ |
112 |
1638 |
Assert(n.getKind() == kind::SEP_NIL); |
113 |
1638 |
Assert(check); |
114 |
1638 |
TypeNode type = n.getType(); |
115 |
1638 |
return type; |
116 |
|
} |
117 |
|
|
118 |
|
} // namespace sep |
119 |
|
} // namespace theory |
120 |
29337 |
} // namespace cvc5 |