9 BiermannMethod::BiermannMethod(
const std::set<std::string> &SpSet,
const std::set<std::string> &SmSet,
const std::set<std::string> &SSet,
const std::set<std::string> &prefixesSet,
const std::set<char> &alphabetSet,
unsigned int n) :
10 SMTMethod(SpSet, SmSet, SSet, prefixesSet, alphabetSet, n)
39 Expr positive =
m_exprManager.mkExpr(kind::GEQ, m_stateName[u], zero);
40 Expr lowerN =
m_exprManager.mkExpr(kind::LEQ, m_stateName[u], n);
41 Expr between = positive.andExpr(lowerN);
42 if (formula.isNull()) {
46 formula = formula.andExpr(between);
51 for (
const auto &ua : m_prefixes) {
53 const char &a = ua.at(ua.size() - 1);
54 const std::string &u = ua.substr(0, ua.size() - 1);
55 for (
const auto &va : m_prefixes) {
56 if(va.size() > 0 && va.at(va.size() - 1) == a) {
57 const std::string &v = va.substr(0, va.size() - 1);
59 Expr premise =
m_exprManager.mkExpr(kind::EQUAL, m_stateName[u], m_stateName[v]);
60 Expr conclusion =
m_exprManager.mkExpr(kind::EQUAL, m_stateName[ua], m_stateName[va]);
62 Expr implication =
m_exprManager.mkExpr(kind::IMPLIES, premise, conclusion);
64 formula = formula.andExpr(implication);
71 for (
const auto &u :
m_Sp) {
72 for (
const auto &v :
m_Sm) {
73 Expr diff =
m_exprManager.mkExpr(kind::EQUAL, m_stateName[u], m_stateName[v]).notExpr();
75 formula = formula.andExpr(diff);
84 unsigned int initial =
m_SMTEngine.getValue(m_stateName.find(
"")->second).getConst<Rational>().getNumerator().toUnsignedInt();
86 std::unique_ptr<DFA<char>> dfa = std::make_unique<DFA<char>>(initial,
m_Sp.find(
"") !=
m_Sp.end());
91 bool accepting =
false;
92 for (
const auto &u :
m_Sp) {
93 Expr expr = m_stateName.find(u)->second;
94 if (
m_SMTEngine.getValue(expr).getConst<Rational>().getNumerator().toUnsignedInt() == q) {
100 dfa->addState(q, accepting);
110 if (ua.size() > 0 && ua.at(ua.size() - 1) == a){
111 std::string u = ua.substr(0, ua.size() - 1);
113 Expr uState = m_stateName.find(u)->second;
114 Expr uaState = m_stateName.find(ua)->second;
116 if (
m_SMTEngine.getValue(uState).getConst<Rational>().getNumerator().toUnsignedInt() == i &&
m_SMTEngine.getValue(uaState).getConst<Rational>().getNumerator().toUnsignedInt() == j) {
118 dfa->addTransition(i, a, j);
125 dfa->addTransition(i, a, i);
const std::set< char > m_alphabet
The namespace of the library.
const std::set< std::string > m_Sm
The set of words to reject .
const std::set< std::string > m_prefixes
static bool s_registered
Useful to make sure the template is correctly used by the compiler.
The base class for every SMT-based method.
const unsigned int m_numberStates
The number of states in the DFA to construct.
void createVariables() override
Creates all needed variables for the method.
CVC4::ExprManager m_exprManager
This must be used to create new variables, constants and expressions.
const std::set< std::string > m_Sp
The set of words to accept .
std::unique_ptr< DFA< char > > toDFA()
Effectively creates the DFA from the values of the variables in the SMT solver (see SMTMethod::m_SMTE...
CVC4::Expr createConstraints() override
Creates an unique expression describing the constraints of this method.
static std::string getFactoryName()
CVC4::SmtEngine m_SMTEngine
This computes acceptable values for the variables and allows to retrieve them.