1 /********************* */
2 /*! \file theory_id.cpp
4 ** Top contributors (to current version):
5 ** Aina Niemetz, Tim King, Dejan Jovanovic
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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 [[ Add one-line brief description here ]]
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
18 #include "theory/theory_id.h"
20 #include "base/check.h"
26 TheoryId
& operator++(TheoryId
& id
)
28 return id
= static_cast<TheoryId
>(static_cast<int>(id
) + 1);
31 std::ostream
& operator<<(std::ostream
& out
, TheoryId theoryId
)
35 case THEORY_BUILTIN
: out
<< "THEORY_BUILTIN"; break;
36 case THEORY_BOOL
: out
<< "THEORY_BOOL"; break;
37 case THEORY_UF
: out
<< "THEORY_UF"; break;
38 case THEORY_ARITH
: out
<< "THEORY_ARITH"; break;
39 case THEORY_BV
: out
<< "THEORY_BV"; break;
40 case THEORY_FP
: out
<< "THEORY_FP"; break;
41 case THEORY_ARRAYS
: out
<< "THEORY_ARRAYS"; break;
42 case THEORY_DATATYPES
: out
<< "THEORY_DATATYPES"; break;
43 case THEORY_SAT_SOLVER
: out
<< "THEORY_SAT_SOLVER"; break;
44 case THEORY_SEP
: out
<< "THEORY_SEP"; break;
45 case THEORY_SETS
: out
<< "THEORY_SETS"; break;
46 case THEORY_STRINGS
: out
<< "THEORY_STRINGS"; break;
47 case THEORY_QUANTIFIERS
: out
<< "THEORY_QUANTIFIERS"; break;
49 default: out
<< "UNKNOWN_THEORY"; break;
54 std::string
getStatsPrefix(TheoryId theoryId
)
58 case THEORY_BUILTIN
: return "theory::builtin"; break;
59 case THEORY_BOOL
: return "theory::bool"; break;
60 case THEORY_UF
: return "theory::uf"; break;
61 case THEORY_ARITH
: return "theory::arith"; break;
62 case THEORY_BV
: return "theory::bv"; break;
63 case THEORY_FP
: return "theory::fp"; break;
64 case THEORY_ARRAYS
: return "theory::arrays"; break;
65 case THEORY_DATATYPES
: return "theory::datatypes"; break;
66 case THEORY_SEP
: return "theory::sep"; break;
67 case THEORY_SETS
: return "theory::sets"; break;
68 case THEORY_STRINGS
: return "theory::strings"; break;
69 case THEORY_QUANTIFIERS
: return "theory::quantifiers"; break;
76 TheoryId
TheoryIdSetUtil::setPop(TheoryIdSet
& set
)
78 uint32_t i
= ffs(set
); // Find First Set (bit)
83 TheoryId id
= static_cast<TheoryId
>(i
- 1);
84 set
= setRemove(id
, set
);
88 size_t TheoryIdSetUtil::setSize(TheoryIdSet set
)
91 while (setPop(set
) != THEORY_LAST
)
98 size_t TheoryIdSetUtil::setIndex(TheoryId id
, TheoryIdSet set
)
100 Assert(setContains(id
, set
));
102 while (setPop(set
) != id
)
109 TheoryIdSet
TheoryIdSetUtil::setInsert(TheoryId theory
, TheoryIdSet set
)
111 return set
| (1 << theory
);
114 TheoryIdSet
TheoryIdSetUtil::setRemove(TheoryId theory
, TheoryIdSet set
)
116 return setDifference(set
, setInsert(theory
));
119 bool TheoryIdSetUtil::setContains(TheoryId theory
, TheoryIdSet set
)
121 return set
& (1 << theory
);
124 TheoryIdSet
TheoryIdSetUtil::setComplement(TheoryIdSet a
)
126 return (~a
) & AllTheories
;
129 TheoryIdSet
TheoryIdSetUtil::setIntersection(TheoryIdSet a
, TheoryIdSet b
)
134 TheoryIdSet
TheoryIdSetUtil::setUnion(TheoryIdSet a
, TheoryIdSet b
)
139 TheoryIdSet
TheoryIdSetUtil::setDifference(TheoryIdSet a
, TheoryIdSet b
)
144 std::string
TheoryIdSetUtil::setToString(TheoryIdSet theorySet
)
146 std::stringstream ss
;
148 for (unsigned theoryId
= 0; theoryId
< THEORY_LAST
; ++theoryId
)
150 TheoryId tid
= static_cast<TheoryId
>(theoryId
);
151 if (setContains(tid
, theorySet
))
160 } // namespace theory