6cf8814a775a8afb459d7a6e65866e4481e271c2
1 /********************* */
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Clark Barrett
6 ** This file is part of the CVC4 project.
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.\endverbatim
12 ** \brief Implementation of type set class
14 #include "theory/type_set.h"
17 using namespace CVC5::kind
;
25 for (it
= d_typeSet
.begin(); it
!= d_typeSet
.end(); ++it
)
29 TypeToTypeEnumMap::iterator it2
;
30 for (it2
= d_teMap
.begin(); it2
!= d_teMap
.end(); ++it2
)
36 void TypeSet::setTypeEnumeratorProperties(TypeEnumeratorProperties
* tep
)
41 void TypeSet::add(TypeNode t
, TNode n
)
43 iterator it
= d_typeSet
.find(t
);
45 if (it
== d_typeSet
.end())
47 s
= new std::set
<Node
>;
57 std::set
<Node
>* TypeSet::getSet(TypeNode t
) const
59 const_iterator it
= d_typeSet
.find(t
);
60 if (it
== d_typeSet
.end())
67 Node
TypeSet::nextTypeEnum(TypeNode t
, bool useBaseType
)
70 TypeToTypeEnumMap::iterator it
= d_teMap
.find(t
);
71 if (it
== d_teMap
.end())
73 te
= new TypeEnumerator(t
, d_tep
);
89 iterator itSet
= d_typeSet
.find(t
);
91 if (itSet
== d_typeSet
.end())
93 s
= new std::set
<Node
>;
101 while (s
->find(n
) != s
->end())
104 if (te
->isFinished())
111 // add all subterms of n to this set as well
112 // this is necessary for parametric types whose values are constructed from
113 // other types to ensure that we do not enumerate subterms of other
114 // previously enumerated values
115 std::unordered_set
<TNode
, TNodeHashFunction
> visited
;
116 addSubTerms(n
, visited
);
121 void TypeSet::addSubTerms(TNode n
,
122 std::unordered_set
<TNode
, TNodeHashFunction
>& visited
,
125 if (visited
.find(n
) == visited
.end())
132 for (unsigned i
= 0; i
< n
.getNumChildren(); i
++)
134 addSubTerms(n
[i
], visited
, false);
139 } // namespace theory