From 5d1ada309c721bacc4604d281e04dd38a825d5f6 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sun, 21 Aug 2016 00:53:37 +0200 Subject: [PATCH] and the rest --- acompare2/src/AutomatonCompare.cpp | 1 - aconvert2/src/DotConverter.cpp | 251 +++++++++--------- aconvert2/src/DotConverter.h | 40 +-- aconvert2/src/GasTexConverter.cpp | 118 ++++---- aconvert2/src/GasTexConverter.h | 1 + aconvert2/src/TikZConverter.cpp | 169 ++++++------ aconvert2/src/TikZConverter.h | 40 +-- alib2algo/src/automaton/simplify/Minimize.cpp | 2 +- .../efficient/AllEpsilonClosure.cpp | 77 +++--- .../properties/efficient/AllEpsilonClosure.h | 20 +- .../properties/efficient/ReachableStates.cpp | 56 ++-- .../properties/efficient/ReachableStates.h | 10 +- .../properties/efficient/UsefullStates.cpp | 44 +-- .../properties/efficient/UsefullStates.h | 10 +- .../efficient/EpsilonRemoverIncoming.cpp | 16 +- .../efficient/EpsilonRemoverOutgoing.cpp | 18 +- .../src/automaton/simplify/efficient/Trim.cpp | 1 - .../efficient/UnreachableStatesRemover.cpp | 13 +- .../efficient/UselessStatesRemover.cpp | 7 +- .../automaton/simplify/efficient/trimTest.cpp | 16 +- 20 files changed, 455 insertions(+), 455 deletions(-) diff --git a/acompare2/src/AutomatonCompare.cpp b/acompare2/src/AutomatonCompare.cpp index 5de663f789..0f8133e70f 100644 --- a/acompare2/src/AutomatonCompare.cpp +++ b/acompare2/src/AutomatonCompare.cpp @@ -6,7 +6,6 @@ */ #include "AutomatonCompare.h" -#include "automaton/common/State.h" #include "automaton/Automaton.h" diff --git a/aconvert2/src/DotConverter.cpp b/aconvert2/src/DotConverter.cpp index d3d10c0904..49ea9acfe4 100644 --- a/aconvert2/src/DotConverter.cpp +++ b/aconvert2/src/DotConverter.cpp @@ -6,7 +6,6 @@ */ #include "DotConverter.h" -#include "automaton/common/State.h" #include <automaton/FSM/NFA.h> #include <automaton/FSM/EpsilonNFA.h> @@ -57,20 +56,20 @@ void DotConverter::convert(std::ostream& out, const automaton::EpsilonNFA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -90,26 +89,26 @@ void DotConverter::convert(std::ostream& out, const automaton::MultiInitialState int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } //Mark initial states out << "node [shape = plaintext, label=\"start\"]; 0; \n"; - for (const automaton::State& state : a.getInitialStates()) { + for (const label::Label& state : a.getInitialStates()) { out << "0 -> " << states.find(state)->second << ";\n"; } @@ -125,20 +124,20 @@ void DotConverter::convert(std::ostream& out, const automaton::NFA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -158,20 +157,20 @@ void DotConverter::convert(std::ostream& out, const automaton::DFA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -191,20 +190,20 @@ void DotConverter::convert(std::ostream& out, const automaton::ExtendedNFA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -224,20 +223,20 @@ void DotConverter::convert(std::ostream& out, const automaton::CompactNFA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -257,20 +256,20 @@ void DotConverter::convert(std::ostream& out, const automaton::NFTA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -286,20 +285,20 @@ void DotConverter::convert(std::ostream& out, const automaton::DFTA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -315,20 +314,20 @@ void DotConverter::convert(std::ostream& out, const automaton::DPDA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -348,20 +347,20 @@ void DotConverter::convert(std::ostream& out, const automaton::SinglePopDPDA& a) int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -381,20 +380,20 @@ void DotConverter::convert(std::ostream& out, const automaton::InputDrivenDPDA& int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -414,20 +413,20 @@ void DotConverter::convert(std::ostream& out, const automaton::InputDrivenNPDA& int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -447,20 +446,20 @@ void DotConverter::convert(std::ostream& out, const automaton::VisiblyPushdownDP int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -480,26 +479,26 @@ void DotConverter::convert(std::ostream& out, const automaton::VisiblyPushdownNP int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } //Mark initial states out << "node [shape = plaintext, label=\"start\"]; 0; \n"; - for (const automaton::State& state : a.getInitialStates()) { + for (const label::Label& state : a.getInitialStates()) { out << "0 -> " << states.find(state)->second << ";\n"; } @@ -515,20 +514,20 @@ void DotConverter::convert(std::ostream& out, const automaton::RealTimeHeightDet int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -548,26 +547,26 @@ void DotConverter::convert(std::ostream& out, const automaton::RealTimeHeightDet int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } //Mark initial states out << "node [shape = plaintext, label=\"start\"]; 0; \n"; - for (const automaton::State& state : a.getInitialStates()) { + for (const label::Label& state : a.getInitialStates()) { out << "0 -> " << states.find(state)->second << ";\n"; } @@ -583,20 +582,20 @@ void DotConverter::convert(std::ostream& out, const automaton::NPDA& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -616,20 +615,20 @@ void DotConverter::convert(std::ostream& out, const automaton::SinglePopNPDA& a) int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -649,20 +648,20 @@ void DotConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) { int cnt = 1; //Map states to indices - std::map<automaton::State, int> states; - for (const automaton::State& state : a.getStates()) { + std::map<label::Label, int> states; + for (const label::Label& state : a.getStates()) { states.insert(std::make_pair(state, cnt++)); } //Print final states - for (const automaton::State& state : a.getFinalStates()) { - out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + for (const label::Label& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state) << "\"]; " << states.find(state)->second << ";\n"; } //Print nonfinal states for (const auto& state : states) { if (!a.getFinalStates().count(state.first)) { - out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first) << "\" ]; " << state.second << ";\n"; } } @@ -676,7 +675,7 @@ void DotConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) { auto DotConverterOneTapeDTM = DotConverter::RegistratorWrapper<void, automaton::OneTapeDTM>(DotConverter::convert); -void DotConverter::transitions(const automaton::EpsilonNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::EpsilonNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; //put transitions from automaton to "transitions" @@ -688,7 +687,7 @@ void DotConverter::transitions(const automaton::EpsilonNFA& fsm, const std::map< symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); } - for(const automaton::State& to : transition.second) { + for(const label::Label& to : transition.second) { std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second); std::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key); @@ -715,14 +714,14 @@ void DotConverter::transitions(const automaton::EpsilonNFA& fsm, const std::map< } } -void DotConverter::transitions(const automaton::MultiInitialStateNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::MultiInitialStateNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; //put transitions from automaton to "transitions" for (const auto& transition : fsm.getTransitions()) { std::string symbol = alib::StringDataFactory::toString(transition.first.second); - for(const automaton::State& to : transition.second) { + for(const label::Label& to : transition.second) { std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second); std::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key); @@ -749,14 +748,14 @@ void DotConverter::transitions(const automaton::MultiInitialStateNFA& fsm, const } } -void DotConverter::transitions(const automaton::NFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::NFA& fsm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; //put transitions from automaton to "transitions" for (const auto& transition : fsm.getTransitions()) { std::string symbol = alib::StringDataFactory::toString(transition.first.second); - for(const automaton::State& to : transition.second) { + for(const label::Label& to : transition.second) { std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second); std::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key); @@ -783,7 +782,7 @@ void DotConverter::transitions(const automaton::NFA& fsm, const std::map<automat } } -void DotConverter::transitions(const automaton::DFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::DFA& fsm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; //put transitions from automaton to "transitions" @@ -815,14 +814,14 @@ void DotConverter::transitions(const automaton::DFA& fsm, const std::map<automat } } -void DotConverter::transitions(const automaton::ExtendedNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::ExtendedNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; //put transitions from automaton to "transitions" for (const auto& transition : fsm.getTransitions()) { std::string symbol = alib::StringDataFactory::toString(transition.first.second); - for(const automaton::State& to : transition.second) { + for(const label::Label& to : transition.second) { std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second); std::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key); @@ -849,14 +848,14 @@ void DotConverter::transitions(const automaton::ExtendedNFA& fsm, const std::map } } -void DotConverter::transitions(const automaton::CompactNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::CompactNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; //put transitions from automaton to "transitions" for (const auto& transition : fsm.getTransitions()) { std::string symbol = alib::StringDataFactory::toString(string::String { transition.first.second } ); - for(const automaton::State& to : transition.second) { + for(const label::Label& to : transition.second) { std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second); std::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key); @@ -883,7 +882,7 @@ void DotConverter::transitions(const automaton::CompactNFA& fsm, const std::map< } } -void DotConverter::transitions(const automaton::NFTA& fta, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::NFTA& fta, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, std::vector<int>>, std::string> transitions; //put transitions from automaton to "transitions" @@ -891,9 +890,9 @@ void DotConverter::transitions(const automaton::NFTA& fta, const std::map<automa std::string symbol = alib::StringDataFactory::toString(transition.first.first.getSymbol()); symbol += std::utos(transition.first.first.getRank().getData()); - for(const automaton::State& to : transition.second) { + for(const label::Label& to : transition.second) { std::pair<int, std::vector<int>> key(states.find(to)->second, {}); - for(const automaton::State& state : transition.first.second) { + for(const label::Label& state : transition.first.second) { key.second.push_back(states.find(state)->second); } std::map<std::pair<int, std::vector<int>>, std::string>::iterator mapit = transitions.find(key); @@ -934,7 +933,7 @@ void DotConverter::transitions(const automaton::NFTA& fta, const std::map<automa } } -void DotConverter::transitions(const automaton::DFTA& fta, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::DFTA& fta, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, std::vector<int>>, std::string> transitions; //put transitions from automaton to "transitions" @@ -943,7 +942,7 @@ void DotConverter::transitions(const automaton::DFTA& fta, const std::map<automa symbol += std::utos(transition.first.first.getRank().getData()); std::pair<int, std::vector<int>> key(states.find(transition.second)->second, {}); - for(const automaton::State& state : transition.first.second) { + for(const label::Label& state : transition.first.second) { key.second.push_back(states.find(state)->second); } std::map<std::pair<int, std::vector<int>>, std::string>::iterator mapit = transitions.find(key); @@ -983,7 +982,7 @@ void DotConverter::transitions(const automaton::DFTA& fta, const std::map<automa } } -void DotConverter::transitions(const automaton::DPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::DPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getTransitions()) { @@ -1046,7 +1045,7 @@ void DotConverter::transitions(const automaton::DPDA& pda, const std::map<automa } } -void DotConverter::transitions(const automaton::SinglePopDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::SinglePopDPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getTransitions()) { @@ -1102,7 +1101,7 @@ void DotConverter::transitions(const automaton::SinglePopDPDA& pda, const std::m } } -void DotConverter::transitions(const automaton::InputDrivenDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::InputDrivenDPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; const auto& symbolToPDSOperation = pda.getPushdownStoreOperations(); @@ -1166,7 +1165,7 @@ void DotConverter::transitions(const automaton::InputDrivenDPDA& pda, const std: } } -void DotConverter::transitions(const automaton::InputDrivenNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::InputDrivenNPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; const auto& symbolToPDSOperation = pda.getPushdownStoreOperations(); @@ -1233,7 +1232,7 @@ void DotConverter::transitions(const automaton::InputDrivenNPDA& pda, const std: } } -void DotConverter::transitions(const automaton::VisiblyPushdownDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::VisiblyPushdownDPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getCallTransitions()) { @@ -1340,7 +1339,7 @@ void DotConverter::transitions(const automaton::VisiblyPushdownDPDA& pda, const } } -void DotConverter::transitions(const automaton::VisiblyPushdownNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::VisiblyPushdownNPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getCallTransitions()) { @@ -1459,7 +1458,7 @@ void DotConverter::transitions(const automaton::VisiblyPushdownNPDA& pda, const } } -void DotConverter::transitions(const automaton::RealTimeHeightDeterministicDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::RealTimeHeightDeterministicDPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getCallTransitions()) { @@ -1575,7 +1574,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicDPDA& } } -void DotConverter::transitions(const automaton::RealTimeHeightDeterministicNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::RealTimeHeightDeterministicNPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getCallTransitions()) { @@ -1703,7 +1702,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicNPDA& } } -void DotConverter::transitions(const automaton::NPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::NPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getTransitions()) { @@ -1770,7 +1769,7 @@ void DotConverter::transitions(const automaton::NPDA& pda, const std::map<automa } } -void DotConverter::transitions(const automaton::SinglePopNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::SinglePopNPDA& pda, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : pda.getTransitions()) { @@ -1830,7 +1829,7 @@ void DotConverter::transitions(const automaton::SinglePopNPDA& pda, const std::m } } -void DotConverter::transitions(const automaton::OneTapeDTM& tm, const std::map<automaton::State, int>& states, std::ostream& out) { +void DotConverter::transitions(const automaton::OneTapeDTM& tm, const std::map<label::Label, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; for (const auto& transition : tm.getTransitions()) { std::string symbol; diff --git a/aconvert2/src/DotConverter.h b/aconvert2/src/DotConverter.h index 02e7ce5914..1def7ec4b9 100644 --- a/aconvert2/src/DotConverter.h +++ b/aconvert2/src/DotConverter.h @@ -14,29 +14,31 @@ #include <automaton/Automaton.h> #include <automaton/AutomatonFeatures.h> +#include <label/Label.h> + #include <map> #include <utility> class DotConverter : public std::SingleDispatchFirstStaticParam<DotConverter, void, std::ostream&, automaton::AutomatonBase> { - static void transitions(const automaton::EpsilonNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::MultiInitialStateNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::NFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::DFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::ExtendedNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::CompactNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::NFTA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::DFTA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::DPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::SinglePopDPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::InputDrivenDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::InputDrivenNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::VisiblyPushdownDPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::VisiblyPushdownNPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::RealTimeHeightDeterministicDPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::RealTimeHeightDeterministicNPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::NPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::SinglePopNPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); - static void transitions(const automaton::OneTapeDTM& tm, const std::map<automaton::State, int>& states, std::ostream& out); + static void transitions(const automaton::EpsilonNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::MultiInitialStateNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::NFA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::DFA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::ExtendedNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::CompactNFA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::NFTA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::DFTA& fsm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::DPDA& pda, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::SinglePopDPDA& tm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::InputDrivenDPDA& pda, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::InputDrivenNPDA& pda, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::VisiblyPushdownDPDA& tm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::VisiblyPushdownNPDA& tm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::RealTimeHeightDeterministicDPDA& tm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::RealTimeHeightDeterministicNPDA& tm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::NPDA& pda, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::SinglePopNPDA& tm, const std::map<label::Label, int>& states, std::ostream& out); + static void transitions(const automaton::OneTapeDTM& tm, const std::map<label::Label, int>& states, std::ostream& out); public: static void convert(std::ostream& out, const automaton::Automaton& a); diff --git a/aconvert2/src/GasTexConverter.cpp b/aconvert2/src/GasTexConverter.cpp index 28657c755e..c0912ca943 100644 --- a/aconvert2/src/GasTexConverter.cpp +++ b/aconvert2/src/GasTexConverter.cpp @@ -66,9 +66,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::EpsilonNFA& a) out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -107,9 +107,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::MultiInitialSt out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -148,9 +148,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::NFA& a) { out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -189,9 +189,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::DFA& a) { out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -230,9 +230,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::ExtendedNFA& a out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -271,9 +271,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::CompactNFA& a) out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -324,9 +324,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::DPDA& a) { out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -365,9 +365,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::SinglePopDPDA& out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -406,9 +406,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::InputDrivenDPD out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -447,9 +447,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::InputDrivenNPD out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -488,9 +488,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::VisiblyPushdow out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -529,9 +529,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::VisiblyPushdow out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -570,9 +570,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::RealTimeHeight out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -611,9 +611,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::RealTimeHeight out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -652,9 +652,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::NPDA& a) { out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -693,9 +693,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::SinglePopNPDA& out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -734,9 +734,9 @@ void GasTexConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) out <<"\\node("; } - out << state.getName(); + out << state; out << ")(,){"; - out << state.getName(); + out << state; out << "}\n"; } @@ -792,7 +792,7 @@ void GasTexConverter::transitions(const automaton::EpsilonNFA& fsm, std::ostream std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : fsm.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); std::string symbol; if (transition.first.second.is<string::Epsilon>()) { @@ -816,7 +816,7 @@ void GasTexConverter::transitions(const automaton::MultiInitialStateNFA& fsm, st std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : fsm.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); std::string symbol = (std::string) transition.first.second; @@ -835,7 +835,7 @@ void GasTexConverter::transitions(const automaton::NFA& fsm, std::ostream& out) std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : fsm.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); std::string symbol = (std::string) transition.first.second; @@ -853,7 +853,7 @@ void GasTexConverter::transitions(const automaton::NFA& fsm, std::ostream& out) void GasTexConverter::transitions(const automaton::DFA& fsm, std::ostream& out) { std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : fsm.getTransitions()) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) transition.second.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) transition.second); std::string symbol = (std::string) transition.first.second; @@ -872,7 +872,7 @@ void GasTexConverter::transitions(const automaton::ExtendedNFA& fsm, std::ostrea for (const auto& transition : fsm.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); std::string symbol = alib::StringDataFactory::toString(transition.first.second); @@ -892,7 +892,7 @@ void GasTexConverter::transitions(const automaton::CompactNFA& fsm, std::ostream for (const auto& transition : fsm.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); std::string symbol = alib::StringDataFactory::toString(string::String(transition.first.second)); @@ -919,7 +919,7 @@ void GasTexConverter::transitions(const automaton::DPDA& pda, std::ostream& out) std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : pda.getTransitions()) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) transition.second.first.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) transition.second.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -949,7 +949,7 @@ void GasTexConverter::transitions(const automaton::SinglePopDPDA& pda, std::ostr std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : pda.getTransitions()) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) transition.second.first.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) transition.second.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -984,7 +984,7 @@ void GasTexConverter::transitions(const automaton::InputDrivenDPDA& pda, std::os const auto& push = symbolToPDSOperation.find(std::get<1>(transition.first))->second.second; const auto& to = transition.second; - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); auto mapIterator = transitionMap.find(key); std::string symbol = alib::StringDataFactory::toString(transition.first.second); @@ -1014,7 +1014,7 @@ void GasTexConverter::transitions(const automaton::InputDrivenNPDA& pda, std::os const auto& push = symbolToPDSOperation.find(std::get<1>(transition.first))->second.second; for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); auto mapIterator = transitionMap.find(key); std::string symbol = alib::StringDataFactory::toString(transition.first.second); @@ -1040,7 +1040,7 @@ void GasTexConverter::transitions(const automaton::VisiblyPushdownDPDA& pda, std std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : pda.getCallTransitions()) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) transition.second.first.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) transition.second.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1060,7 +1060,7 @@ void GasTexConverter::transitions(const automaton::VisiblyPushdownDPDA& pda, std } for (const auto& transition : pda.getReturnTransitions()) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) transition.second.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) transition.second); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1080,7 +1080,7 @@ void GasTexConverter::transitions(const automaton::VisiblyPushdownDPDA& pda, std } for (const auto& transition : pda.getLocalTransitions()) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) transition.second.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) transition.second); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1107,7 +1107,7 @@ void GasTexConverter::transitions(const automaton::VisiblyPushdownNPDA& pda, std for (const auto& transition : pda.getCallTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.first.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1129,7 +1129,7 @@ void GasTexConverter::transitions(const automaton::VisiblyPushdownNPDA& pda, std for (const auto& transition : pda.getReturnTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) to); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1151,7 +1151,7 @@ void GasTexConverter::transitions(const automaton::VisiblyPushdownNPDA& pda, std for (const auto& transition : pda.getLocalTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1178,7 +1178,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicDP std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (const auto& transition : pda.getCallTransitions()) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) transition.second.first.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) transition.second.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1201,7 +1201,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicDP } for (const auto& transition : pda.getReturnTransitions()) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) transition.second.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) transition.second); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1224,7 +1224,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicDP } for (const auto& transition : pda.getLocalTransitions()) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) transition.second.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) transition.second); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1254,7 +1254,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicNP for (const auto& transition : pda.getCallTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.first.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1279,7 +1279,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicNP for (const auto& transition : pda.getReturnTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) to); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1304,7 +1304,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicNP for (const auto& transition : pda.getLocalTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1335,7 +1335,7 @@ void GasTexConverter::transitions(const automaton::NPDA& pda, std::ostream& out) for (const auto& transition : pda.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) to.first.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) to.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1367,7 +1367,7 @@ void GasTexConverter::transitions(const automaton::SinglePopNPDA& pda, std::ostr for (const auto& transition : pda.getTransitions()) { for(const auto& to : transition.second) { - std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first).getName(), (std::string) to.first.getName()); + std::pair<std::string, std::string> key((std::string) std::get<0>(transition.first), (std::string) to.first); auto mapIterator = transitionMap.find(key); std::string symbol; @@ -1398,7 +1398,7 @@ void GasTexConverter::transitions(const automaton::OneTapeDTM& tm, std::ostream& std::map<std::pair<std::string, std::string>, std::string> transitionMap; for (auto& transition : tm.getTransitions()) { - std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) std::get<0>(transition.second).getName()); + std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) std::get<0>(transition.second)); auto mapIterator = transitionMap.find(key); std::string symbol = alib::StringDataFactory::toString(transition.first.second); diff --git a/aconvert2/src/GasTexConverter.h b/aconvert2/src/GasTexConverter.h index 11c63a09a6..c054794d03 100644 --- a/aconvert2/src/GasTexConverter.h +++ b/aconvert2/src/GasTexConverter.h @@ -14,6 +14,7 @@ #include <utility> #include <vector> #include "automaton/Automaton.h" +#include <automaton/AutomatonFeatures.h> #include "alphabet/Symbol.h" class GasTexConverter : public std::SingleDispatchFirstStaticParam<GasTexConverter, void, std::ostream&, automaton::AutomatonBase> { diff --git a/aconvert2/src/TikZConverter.cpp b/aconvert2/src/TikZConverter.cpp index eaf4db84a5..1c7b0125ce 100644 --- a/aconvert2/src/TikZConverter.cpp +++ b/aconvert2/src/TikZConverter.cpp @@ -6,7 +6,6 @@ */ #include "TikZConverter.h" -#include "automaton/common/State.h" #include <automaton/FSM/NFA.h> #include <automaton/FSM/EpsilonNFA.h> @@ -57,9 +56,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::EpsilonNFA & int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -72,7 +71,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::EpsilonNFA & if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -86,9 +85,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::MultiInitialS int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -101,7 +100,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::MultiInitialS if ( a.getInitialStates ( ).count ( state.first ) ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -115,9 +114,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NFA & a ) { int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -130,7 +129,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NFA & a ) { if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -144,9 +143,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DFA & a ) { int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -159,7 +158,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DFA & a ) { if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -173,9 +172,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::ExtendedNFA & int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -188,7 +187,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::ExtendedNFA & if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -202,9 +201,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::CompactNFA & int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -217,7 +216,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::CompactNFA & if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -231,9 +230,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NFTA & a ) { int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -243,7 +242,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NFTA & a ) { if ( a.getFinalStates ( ).count ( state.first ) ) mods += ",accepting"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -257,9 +256,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DFTA & a ) { int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -269,7 +268,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DFTA & a ) { if ( a.getFinalStates ( ).count ( state.first ) ) mods += ",accepting"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -283,9 +282,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DPDA & a ) { int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -298,7 +297,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DPDA & a ) { if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -312,9 +311,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopDPDA int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -327,7 +326,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopDPDA if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -341,9 +340,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenDP int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -356,7 +355,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenDP if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -370,9 +369,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenNP int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -385,7 +384,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenNP if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -399,9 +398,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdo int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -414,7 +413,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdo if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -428,9 +427,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdo int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -443,7 +442,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdo if ( a.getInitialStates ( ).count ( state.first ) ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -457,9 +456,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeigh int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -472,7 +471,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeigh if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -486,9 +485,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeigh int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -501,7 +500,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeigh if ( a.getInitialStates ( ).count ( state.first ) ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -515,9 +514,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NPDA & a ) { int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -530,7 +529,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NPDA & a ) { if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -544,9 +543,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopNPDA int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -559,7 +558,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopNPDA if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -573,9 +572,9 @@ void TikZConverter::convert ( std::ostream & out, const automaton::OneTapeDTM & int cnt = 1; // Map states to indices - std::map < automaton::State, int > states; + std::map < label::Label, int > states; - for ( const automaton::State & state : a.getStates ( ) ) + for ( const label::Label & state : a.getStates ( ) ) states.insert ( std::make_pair ( state, cnt++ ) ); // Print states @@ -588,7 +587,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::OneTapeDTM & if ( a.getInitialState ( ) == state.first ) mods += ",initial"; - out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first.getName ( ) ) << "}\n"; + out << "\\node[state" + mods + "] (" << state.second << ") {" << alib::StringDataFactory::toString ( state.first ) << "}\n"; } transitions ( a, states, out ); @@ -597,7 +596,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::OneTapeDTM & auto TikZConverterOneTapeDTM = TikZConverter::RegistratorWrapper < void, automaton::OneTapeDTM > ( TikZConverter::convert ); -void TikZConverter::transitions ( const automaton::EpsilonNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::EpsilonNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; // put transitions from automaton to "transitions" @@ -609,7 +608,7 @@ void TikZConverter::transitions ( const automaton::EpsilonNFA & fsm, const std:: else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); - for ( const automaton::State & to : transition.second ) { + for ( const label::Label & to : transition.second ) { std::pair < int, int > key ( states.find ( transition.first.first )->second, states.find ( to )->second ); std::map < std::pair < int, int >, std::string >::iterator mapit = transitions.find ( key ); @@ -644,14 +643,14 @@ void TikZConverter::transitions ( const automaton::EpsilonNFA & fsm, const std:: } } -void TikZConverter::transitions ( const automaton::MultiInitialStateNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::MultiInitialStateNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; // put transitions from automaton to "transitions" for ( const auto & transition : fsm.getTransitions ( ) ) { std::string symbol = alib::StringDataFactory::toString ( transition.first.second ); - for ( const automaton::State & to : transition.second ) { + for ( const label::Label & to : transition.second ) { std::pair < int, int > key ( states.find ( transition.first.first )->second, states.find ( to )->second ); std::map < std::pair < int, int >, std::string >::iterator mapit = transitions.find ( key ); @@ -686,14 +685,14 @@ void TikZConverter::transitions ( const automaton::MultiInitialStateNFA & fsm, c } } -void TikZConverter::transitions ( const automaton::NFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::NFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; // put transitions from automaton to "transitions" for ( const auto & transition : fsm.getTransitions ( ) ) { std::string symbol = alib::StringDataFactory::toString ( transition.first.second ); - for ( const automaton::State & to : transition.second ) { + for ( const label::Label & to : transition.second ) { std::pair < int, int > key ( states.find ( transition.first.first )->second, states.find ( to )->second ); std::map < std::pair < int, int >, std::string >::iterator mapit = transitions.find ( key ); @@ -728,7 +727,7 @@ void TikZConverter::transitions ( const automaton::NFA & fsm, const std::map < a } } -void TikZConverter::transitions ( const automaton::DFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::DFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; // put transitions from automaton to "transitions" @@ -768,14 +767,14 @@ void TikZConverter::transitions ( const automaton::DFA & fsm, const std::map < a } } -void TikZConverter::transitions ( const automaton::ExtendedNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::ExtendedNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; // put transitions from automaton to "transitions" for ( const auto & transition : fsm.getTransitions ( ) ) { std::string symbol = alib::StringDataFactory::toString ( transition.first.second ); - for ( const automaton::State & to : transition.second ) { + for ( const label::Label & to : transition.second ) { std::pair < int, int > key ( states.find ( transition.first.first )->second, states.find ( to )->second ); std::map < std::pair < int, int >, std::string >::iterator mapit = transitions.find ( key ); @@ -810,14 +809,14 @@ void TikZConverter::transitions ( const automaton::ExtendedNFA & fsm, const std: } } -void TikZConverter::transitions ( const automaton::CompactNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::CompactNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; // put transitions from automaton to "transitions" for ( const auto & transition : fsm.getTransitions ( ) ) { std::string symbol = alib::StringDataFactory::toString ( string::String { transition.first.second } ); - for ( const automaton::State & to : transition.second ) { + for ( const label::Label & to : transition.second ) { std::pair < int, int > key ( states.find ( transition.first.first )->second, states.find ( to )->second ); std::map < std::pair < int, int >, std::string >::iterator mapit = transitions.find ( key ); @@ -852,7 +851,7 @@ void TikZConverter::transitions ( const automaton::CompactNFA & fsm, const std:: } } -void TikZConverter::transitions ( const automaton::NFTA & fta, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::NFTA & fta, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, std::vector < int > >, std::string > transitions; // put transitions from automaton to "transitions" @@ -860,10 +859,10 @@ void TikZConverter::transitions ( const automaton::NFTA & fta, const std::map < std::string symbol = alib::StringDataFactory::toString ( transition.first.first.getSymbol ( ) ); symbol += std::utos ( transition.first.first.getRank ( ).getData ( ) ); - for ( const automaton::State & to : transition.second ) { + for ( const label::Label & to : transition.second ) { std::pair < int, std::vector < int > > key ( states.find ( to )->second, { } ); - for ( const automaton::State & state : transition.first.second ) + for ( const label::Label & state : transition.first.second ) key.second.push_back ( states.find ( state )->second ); std::map < std::pair < int, std::vector < int > >, std::string >::iterator mapit = transitions.find ( key ); @@ -917,7 +916,7 @@ void TikZConverter::transitions ( const automaton::NFTA & fta, const std::map < } } -void TikZConverter::transitions ( const automaton::DFTA & fta, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::DFTA & fta, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, std::vector < int > >, std::string > transitions; // put transitions from automaton to "transitions" @@ -927,7 +926,7 @@ void TikZConverter::transitions ( const automaton::DFTA & fta, const std::map < std::pair < int, std::vector < int > > key ( states.find ( transition.second )->second, { } ); - for ( const automaton::State & state : transition.first.second ) + for ( const label::Label & state : transition.first.second ) key.second.push_back ( states.find ( state )->second ); std::map < std::pair < int, std::vector < int > >, std::string >::iterator mapit = transitions.find ( key ); @@ -980,7 +979,7 @@ void TikZConverter::transitions ( const automaton::DFTA & fta, const std::map < } } -void TikZConverter::transitions ( const automaton::DPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::DPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getTransitions ( ) ) { @@ -1044,7 +1043,7 @@ void TikZConverter::transitions ( const automaton::DPDA & pda, const std::map < } } -void TikZConverter::transitions ( const automaton::SinglePopDPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::SinglePopDPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getTransitions ( ) ) { @@ -1104,7 +1103,7 @@ void TikZConverter::transitions ( const automaton::SinglePopDPDA & pda, const st } } -void TikZConverter::transitions ( const automaton::InputDrivenDPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::InputDrivenDPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; const auto & symbolToPDSOperation = pda.getPushdownStoreOperations ( ); @@ -1172,7 +1171,7 @@ void TikZConverter::transitions ( const automaton::InputDrivenDPDA & pda, const } } -void TikZConverter::transitions ( const automaton::InputDrivenNPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::InputDrivenNPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; const auto & symbolToPDSOperation = pda.getPushdownStoreOperations ( ); @@ -1244,7 +1243,7 @@ void TikZConverter::transitions ( const automaton::InputDrivenNPDA & pda, const } } -void TikZConverter::transitions ( const automaton::VisiblyPushdownDPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::VisiblyPushdownDPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { @@ -1367,7 +1366,7 @@ void TikZConverter::transitions ( const automaton::VisiblyPushdownDPDA & pda, co } } -void TikZConverter::transitions ( const automaton::VisiblyPushdownNPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::VisiblyPushdownNPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { @@ -1505,7 +1504,7 @@ void TikZConverter::transitions ( const automaton::VisiblyPushdownNPDA & pda, co } } -void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicDPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicDPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { @@ -1637,7 +1636,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicDP } } -void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicNPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicNPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { @@ -1784,7 +1783,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicNP } } -void TikZConverter::transitions ( const automaton::NPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::NPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getTransitions ( ) ) { @@ -1854,7 +1853,7 @@ void TikZConverter::transitions ( const automaton::NPDA & pda, const std::map < } } -void TikZConverter::transitions ( const automaton::SinglePopNPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::SinglePopNPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : pda.getTransitions ( ) ) { @@ -1920,7 +1919,7 @@ void TikZConverter::transitions ( const automaton::SinglePopNPDA & pda, const st } } -void TikZConverter::transitions ( const automaton::OneTapeDTM & tm, const std::map < automaton::State, int > & states, std::ostream & out ) { +void TikZConverter::transitions ( const automaton::OneTapeDTM & tm, const std::map < label::Label, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; for ( const auto & transition : tm.getTransitions ( ) ) { diff --git a/aconvert2/src/TikZConverter.h b/aconvert2/src/TikZConverter.h index 7a6304b20c..2cf8187a65 100644 --- a/aconvert2/src/TikZConverter.h +++ b/aconvert2/src/TikZConverter.h @@ -14,29 +14,31 @@ #include <automaton/Automaton.h> #include <automaton/AutomatonFeatures.h> +#include <label/Label.h> + #include <map> #include <utility> class TikZConverter : public std::SingleDispatchFirstStaticParam < TikZConverter, void, std::ostream &, automaton::AutomatonBase > { - static void transitions ( const automaton::EpsilonNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::MultiInitialStateNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::NFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::DFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::ExtendedNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::CompactNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::NFTA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::DFTA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::DPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::SinglePopDPDA & tm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::InputDrivenDPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::InputDrivenNPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::VisiblyPushdownDPDA & tm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::VisiblyPushdownNPDA & tm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::RealTimeHeightDeterministicDPDA & tm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::RealTimeHeightDeterministicNPDA & tm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::NPDA & pda, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::SinglePopNPDA & tm, const std::map < automaton::State, int > & states, std::ostream & out ); - static void transitions ( const automaton::OneTapeDTM & tm, const std::map < automaton::State, int > & states, std::ostream & out ); + static void transitions ( const automaton::EpsilonNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::MultiInitialStateNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::NFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::DFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::ExtendedNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::CompactNFA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::NFTA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::DFTA & fsm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::DPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::SinglePopDPDA & tm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::InputDrivenDPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::InputDrivenNPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::VisiblyPushdownDPDA & tm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::VisiblyPushdownNPDA & tm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::RealTimeHeightDeterministicDPDA & tm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::RealTimeHeightDeterministicNPDA & tm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::NPDA & pda, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::SinglePopNPDA & tm, const std::map < label::Label, int > & states, std::ostream & out ); + static void transitions ( const automaton::OneTapeDTM & tm, const std::map < label::Label, int > & states, std::ostream & out ); public: static void convert ( std::ostream & out, const automaton::Automaton & a ); diff --git a/alib2algo/src/automaton/simplify/Minimize.cpp b/alib2algo/src/automaton/simplify/Minimize.cpp index 73c84e1b42..b4fc6b7c36 100644 --- a/alib2algo/src/automaton/simplify/Minimize.cpp +++ b/alib2algo/src/automaton/simplify/Minimize.cpp @@ -26,7 +26,7 @@ automaton::Automaton Minimize::minimize(const automaton::Automaton& automaton) { automaton::DFA Minimize::minimize(const automaton::DFA& dfa) { if(dfa.getFinalStates().size() == 0) { - automaton::DFA result(label::Label(0)); + automaton::DFA result(label::labelFrom(0)); result.setInputAlphabet(dfa.getInputAlphabet()); return result; } diff --git a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp index edcf29337c..b3429eb5a3 100644 --- a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp +++ b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp @@ -20,14 +20,13 @@ #include <regexp/properties/RegExpEpsilon.h> - namespace automaton { namespace properties { namespace efficient { -void process(const std::map<automaton::State, std::set<automaton::State>>& epsilonTransitions, const automaton::State * state, std::map<automaton::State, std::set<automaton::State>>& closures, std::set<automaton::State>& visited, std::set<automaton::State>& nonvisited) { +void process(const std::map<label::Label, std::set<label::Label>>& epsilonTransitions, const label::Label * state, std::map<label::Label, std::set<label::Label>>& closures, std::set<label::Label>& visited, std::set<label::Label>& nonvisited) { if(visited.count(*state)) return; state = &*visited.insert(*state).first; @@ -36,22 +35,22 @@ void process(const std::map<automaton::State, std::set<automaton::State>>& epsil auto tos = epsilonTransitions.find(*state); if(tos == epsilonTransitions.end()) return; - for(const automaton::State& to : tos->second) { + for(const label::Label& to : tos->second) { process(epsilonTransitions, &to, closures, visited, nonvisited); closures[*state].insert(closures[to].begin(), closures[to].end()); } } -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::EpsilonNFA & fsm) { - std::map<automaton::State, std::set<automaton::State>> res; +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure( const automaton::EpsilonNFA & fsm) { + std::map<label::Label, std::set<label::Label>> res; - for(const automaton::State& state : fsm.getStates()) + for(const label::Label& state : fsm.getStates()) res[state].insert(state); - std::set<automaton::State> visited; - std::set<automaton::State> nonvisited = fsm.getStates(); + std::set<label::Label> visited; + std::set<label::Label> nonvisited = fsm.getStates(); - std::map<automaton::State, std::set<automaton::State>> epsilonTransitions = fsm.getEpsilonTransitions(); + std::map<label::Label, std::set<label::Label>> epsilonTransitions = fsm.getEpsilonTransitions(); while(nonvisited.size()) { process(epsilonTransitions, &*nonvisited.begin(), res, visited, nonvisited); @@ -66,46 +65,46 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureEpsilonNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::EpsilonNFA>(AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureEpsilonNFA = AllEpsilonClosure::RegistratorWrapper<std::map<label::Label, std::set<label::Label>>, automaton::EpsilonNFA>(AllEpsilonClosure::allEpsilonClosure); -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::MultiInitialStateNFA & fsm) { - std::map<automaton::State, std::set<automaton::State>> closure; - for(const automaton::State& state : fsm.getStates()) +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure( const automaton::MultiInitialStateNFA & fsm) { + std::map<label::Label, std::set<label::Label>> closure; + for(const label::Label& state : fsm.getStates()) closure[state].insert(state); return closure; } -auto AllEpsilonClosureMultiInitialStateNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::MultiInitialStateNFA>(AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureMultiInitialStateNFA = AllEpsilonClosure::RegistratorWrapper<std::map<label::Label, std::set<label::Label>>, automaton::MultiInitialStateNFA>(AllEpsilonClosure::allEpsilonClosure); -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::NFA & fsm) { - std::map<automaton::State, std::set<automaton::State>> closure; - for(const automaton::State& state : fsm.getStates()) +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure( const automaton::NFA & fsm) { + std::map<label::Label, std::set<label::Label>> closure; + for(const label::Label& state : fsm.getStates()) closure[state].insert(state); return closure; } -auto AllEpsilonClosureNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::NFA>(AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureNFA = AllEpsilonClosure::RegistratorWrapper<std::map<label::Label, std::set<label::Label>>, automaton::NFA>(AllEpsilonClosure::allEpsilonClosure); -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::DFA & fsm) { - std::map<automaton::State, std::set<automaton::State>> closure; - for(const automaton::State& state : fsm.getStates()) +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure( const automaton::DFA & fsm) { + std::map<label::Label, std::set<label::Label>> closure; + for(const label::Label& state : fsm.getStates()) closure[state].insert(state); return closure; } -auto AllEpsilonClosureDFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::DFA>(AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureDFA = AllEpsilonClosure::RegistratorWrapper<std::map<label::Label, std::set<label::Label>>, automaton::DFA>(AllEpsilonClosure::allEpsilonClosure); -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::ExtendedNFA & fsm) { - std::map<automaton::State, std::set<automaton::State>> res; +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure( const automaton::ExtendedNFA & fsm) { + std::map<label::Label, std::set<label::Label>> res; - for(const automaton::State& state : fsm.getStates()) + for(const label::Label& state : fsm.getStates()) res[state].insert(state); - std::set<automaton::State> visited; - std::set<automaton::State> nonvisited = fsm.getStates(); + std::set<label::Label> visited; + std::set<label::Label> nonvisited = fsm.getStates(); - std::map<automaton::State, std::set<automaton::State>> epsilonTransitions; - for(const std::pair<const std::pair<State, regexp::RegExp>, std::set<State> >& transition : fsm.getTransitions() ) + std::map<label::Label, std::set<label::Label>> epsilonTransitions; + for(const std::pair<const std::pair<label::Label, regexp::RegExp>, std::set<label::Label> >& transition : fsm.getTransitions() ) if( regexp::properties::RegExpEpsilon::languageContainsEpsilon( transition.first.second ) ) epsilonTransitions[transition.first.first].insert(transition.second.begin(), transition.second.end()); @@ -122,19 +121,19 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureExtendedNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::ExtendedNFA>(AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureExtendedNFA = AllEpsilonClosure::RegistratorWrapper<std::map<label::Label, std::set<label::Label>>, automaton::ExtendedNFA>(AllEpsilonClosure::allEpsilonClosure); -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::CompactNFA & fsm) { - std::map<automaton::State, std::set<automaton::State>> res; +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure( const automaton::CompactNFA & fsm) { + std::map<label::Label, std::set<label::Label>> res; - for(const automaton::State& state : fsm.getStates()) + for(const label::Label& state : fsm.getStates()) res[state].insert(state); - std::set<automaton::State> visited; - std::set<automaton::State> nonvisited = fsm.getStates(); + std::set<label::Label> visited; + std::set<label::Label> nonvisited = fsm.getStates(); - std::map<automaton::State, std::set<automaton::State>> epsilonTransitions; - for(const std::pair<const std::pair<State, string::LinearString>, std::set<State> >& transition : fsm.getTransitions() ) + std::map<label::Label, std::set<label::Label>> epsilonTransitions; + for(const std::pair<const std::pair<label::Label, string::LinearString>, std::set<label::Label> >& transition : fsm.getTransitions() ) if( transition.first.second.getContent().size() == 0 ) epsilonTransitions[transition.first.first].insert(transition.second.begin(), transition.second.end()); @@ -151,9 +150,9 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureCompactNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::CompactNFA>(AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureCompactNFA = AllEpsilonClosure::RegistratorWrapper<std::map<label::Label, std::set<label::Label>>, automaton::CompactNFA>(AllEpsilonClosure::allEpsilonClosure); -std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure(const Automaton& automaton) { +std::map<label::Label, std::set<label::Label>> AllEpsilonClosure::allEpsilonClosure(const Automaton& automaton) { return dispatch(automaton.getData()); } diff --git a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h index c0fd91d0a9..7ab595e8bb 100644 --- a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h +++ b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h @@ -13,7 +13,9 @@ #include <map> #include "automaton/Automaton.h" -#include <automaton/common/State.h> +#include "automaton/AutomatonFeatures.h" + +#include <label/Label.h> namespace automaton { @@ -21,19 +23,19 @@ namespace properties { namespace efficient { -class AllEpsilonClosure : public std::SingleDispatch<AllEpsilonClosure, std::map<automaton::State, std::set<automaton::State>>, automaton::AutomatonBase> { +class AllEpsilonClosure : public std::SingleDispatch<AllEpsilonClosure, std::map<label::Label, std::set<label::Label>>, automaton::AutomatonBase> { public: - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::Automaton & automaton); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::Automaton & automaton); /** * Computes allEpsilon closure of a state in allEpsilon nonfree automaton */ - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::EpsilonNFA & fsm); - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::MultiInitialStateNFA & fsm); - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::NFA & fsm); - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::DFA & fsm); - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::ExtendedNFA & fsm); - static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::CompactNFA & fsm); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::EpsilonNFA & fsm); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::MultiInitialStateNFA & fsm); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::NFA & fsm); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::DFA & fsm); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::ExtendedNFA & fsm); + static std::map<label::Label, std::set<label::Label>> allEpsilonClosure( const automaton::CompactNFA & fsm); }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp b/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp index 368b450f8f..f9e14f5492 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp @@ -23,84 +23,84 @@ namespace properties { namespace efficient { -std::set<automaton::State> ReachableStates::reachableStates(const Automaton& automaton) { +std::set<label::Label> ReachableStates::reachableStates(const Automaton& automaton) { return dispatch(automaton.getData()); } template<class T> -std::set<automaton::State> ReachableStates::reachableStates( const T & fsm ) { - std::map<automaton::State, std::set<automaton::State>> transitions; +std::set<label::Label> ReachableStates::reachableStates( const T & fsm ) { + std::map<label::Label, std::set<label::Label>> transitions; for(const auto& transition : fsm.getTransitions()) transitions[transition.first.first].insert(transition.second.begin(), transition.second.end()); - std::deque<automaton::State> queue { fsm.getInitialState( ) }; - std::set<automaton::State> visited { fsm.getInitialState( ) }; + std::deque<label::Label> queue { fsm.getInitialState( ) }; + std::set<label::Label> visited { fsm.getInitialState( ) }; while( !queue.empty() ) { - const std::set<automaton::State>& to = transitions[queue.front()]; + const std::set<label::Label>& to = transitions[queue.front()]; queue.pop_front(); - for(const automaton::State& process : to) + for(const label::Label& process : to) if(visited.insert(process).second) { - queue.push_back(std::move(const_cast<automaton::State&>(process))); + queue.push_back(std::move(const_cast<label::Label&>(process))); } } return visited; } -auto ReachableStatesEpsilonNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(ReachableStates::reachableStates); -auto ReachableStatesNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(ReachableStates::reachableStates); -auto ReachableStatesCompactNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(ReachableStates::reachableStates); -auto ReachableStatesExtendedNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(ReachableStates::reachableStates); +auto ReachableStatesEpsilonNFA = ReachableStates::RegistratorWrapper<std::set<label::Label>, automaton::EpsilonNFA>(ReachableStates::reachableStates); +auto ReachableStatesNFA = ReachableStates::RegistratorWrapper<std::set<label::Label>, automaton::NFA>(ReachableStates::reachableStates); +auto ReachableStatesCompactNFA = ReachableStates::RegistratorWrapper<std::set<label::Label>, automaton::CompactNFA>(ReachableStates::reachableStates); +auto ReachableStatesExtendedNFA = ReachableStates::RegistratorWrapper<std::set<label::Label>, automaton::ExtendedNFA>(ReachableStates::reachableStates); template<> -std::set<automaton::State> ReachableStates::reachableStates( const automaton::MultiInitialStateNFA & fsm ) { - std::map<automaton::State, std::set<automaton::State>> transitions; +std::set<label::Label> ReachableStates::reachableStates( const automaton::MultiInitialStateNFA & fsm ) { + std::map<label::Label, std::set<label::Label>> transitions; for(const auto& transition : fsm.getTransitions()) transitions[transition.first.first].insert(transition.second.begin(), transition.second.end()); - std::deque<automaton::State> queue ( fsm.getInitialStates( ).begin(), fsm.getInitialStates().end() ); - std::set<automaton::State> visited = fsm.getInitialStates( ); + std::deque<label::Label> queue ( fsm.getInitialStates( ).begin(), fsm.getInitialStates().end() ); + std::set<label::Label> visited = fsm.getInitialStates( ); while( !queue.empty() ) { - const std::set<automaton::State>& to = transitions[queue.front()]; + const std::set<label::Label>& to = transitions[queue.front()]; queue.pop_front(); - for(const automaton::State& process : to) + for(const label::Label& process : to) if(visited.insert(process).second) { - queue.push_back(std::move(const_cast<automaton::State&>(process))); + queue.push_back(std::move(const_cast<label::Label&>(process))); } } return visited; } -auto ReachableStatesMultiInitialStateNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(ReachableStates::reachableStates); +auto ReachableStatesMultiInitialStateNFA = ReachableStates::RegistratorWrapper<std::set<label::Label>, automaton::MultiInitialStateNFA>(ReachableStates::reachableStates); template<> -std::set<automaton::State> ReachableStates::reachableStates( const automaton::DFA & fsm ) { - std::map<automaton::State, std::set<automaton::State>> transitions; +std::set<label::Label> ReachableStates::reachableStates( const automaton::DFA & fsm ) { + std::map<label::Label, std::set<label::Label>> transitions; for(const auto& transition : fsm.getTransitions()) transitions[transition.first.first].insert(transition.second); - std::deque<automaton::State> queue { fsm.getInitialState( ) }; - std::set<automaton::State> visited { fsm.getInitialState( ) }; + std::deque<label::Label> queue { fsm.getInitialState( ) }; + std::set<label::Label> visited { fsm.getInitialState( ) }; while( !queue.empty() ) { - const std::set<automaton::State>& to = transitions[queue.front()]; + const std::set<label::Label>& to = transitions[queue.front()]; queue.pop_front(); - for(const automaton::State& process : to) + for(const label::Label& process : to) if(visited.insert(process).second) { - queue.push_back(std::move(const_cast<automaton::State&>(process))); + queue.push_back(std::move(const_cast<label::Label&>(process))); } } return visited; } -auto ReachableStatesDFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(ReachableStates::reachableStates); +auto ReachableStatesDFA = ReachableStates::RegistratorWrapper<std::set<label::Label>, automaton::DFA>(ReachableStates::reachableStates); } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h index abd7a93276..bbf5b56759 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h @@ -13,8 +13,10 @@ #include <deque> #include <set> -#include <automaton/common/State.h> #include <automaton/Automaton.h> +#include <automaton/AutomatonFeatures.h> + +#include <label/Label.h> namespace automaton { @@ -22,15 +24,15 @@ namespace properties { namespace efficient { -class ReachableStates : public std::SingleDispatch<ReachableStates, std::set<automaton::State>, automaton::AutomatonBase> { +class ReachableStates : public std::SingleDispatch<ReachableStates, std::set<label::Label>, automaton::AutomatonBase> { public: - static std::set<automaton::State> reachableStates( const automaton::Automaton & automaton ); + static std::set<label::Label> reachableStates( const automaton::Automaton & automaton ); /** * Removes dead states from FSM. Melichar 2.29 */ template<class T> - static std::set<automaton::State> reachableStates( const T & fsm ); + static std::set<label::Label> reachableStates( const T & fsm ); }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp b/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp index 18128c4b73..d7b919241f 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp @@ -23,62 +23,62 @@ namespace properties { namespace efficient { -std::set<automaton::State> UsefullStates::usefullStates(const Automaton& automaton) { +std::set<label::Label> UsefullStates::usefullStates(const Automaton& automaton) { return dispatch(automaton.getData()); } template<class T> -std::set<automaton::State> UsefullStates::usefullStates( const T & fsm ) { - std::map<automaton::State, std::set<automaton::State>> reversedTransitions; +std::set<label::Label> UsefullStates::usefullStates( const T & fsm ) { + std::map<label::Label, std::set<label::Label>> reversedTransitions; for(const auto& transition : fsm.getTransitions()) - for(const automaton::State& to : transition.second) + for(const label::Label& to : transition.second) reversedTransitions[to].insert(transition.first.first); - std::deque<automaton::State> queue ( fsm.getFinalStates( ).begin(), fsm.getFinalStates().end() ); - std::set<automaton::State> visited = fsm.getFinalStates( ); + std::deque<label::Label> queue ( fsm.getFinalStates( ).begin(), fsm.getFinalStates().end() ); + std::set<label::Label> visited = fsm.getFinalStates( ); while( !queue.empty() ) { - const std::set<automaton::State>& to = reversedTransitions[queue.front()]; + const std::set<label::Label>& to = reversedTransitions[queue.front()]; queue.pop_front(); - for(const automaton::State& process : to) + for(const label::Label& process : to) if(visited.insert(process).second) { - queue.push_back(std::move(const_cast<automaton::State&>(process))); + queue.push_back(std::move(const_cast<label::Label&>(process))); } } return visited; } -auto UsefullStatesEpsilonNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(UsefullStates::usefullStates); -auto UsefullStatesNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(UsefullStates::usefullStates); -auto UsefullStatesCompactNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(UsefullStates::usefullStates); -auto UsefullStatesExtendedNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(UsefullStates::usefullStates); -auto UsefullStatesMultiInitialStateNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(UsefullStates::usefullStates); +auto UsefullStatesEpsilonNFA = UsefullStates::RegistratorWrapper<std::set<label::Label>, automaton::EpsilonNFA>(UsefullStates::usefullStates); +auto UsefullStatesNFA = UsefullStates::RegistratorWrapper<std::set<label::Label>, automaton::NFA>(UsefullStates::usefullStates); +auto UsefullStatesCompactNFA = UsefullStates::RegistratorWrapper<std::set<label::Label>, automaton::CompactNFA>(UsefullStates::usefullStates); +auto UsefullStatesExtendedNFA = UsefullStates::RegistratorWrapper<std::set<label::Label>, automaton::ExtendedNFA>(UsefullStates::usefullStates); +auto UsefullStatesMultiInitialStateNFA = UsefullStates::RegistratorWrapper<std::set<label::Label>, automaton::MultiInitialStateNFA>(UsefullStates::usefullStates); template<> -std::set<automaton::State> UsefullStates::usefullStates( const automaton::DFA & fsm ) { - std::map<automaton::State, std::set<automaton::State>> reversedTransitions; +std::set<label::Label> UsefullStates::usefullStates( const automaton::DFA & fsm ) { + std::map<label::Label, std::set<label::Label>> reversedTransitions; for(const auto& transition : fsm.getTransitions()) reversedTransitions[transition.second].insert(transition.first.first); - std::deque<automaton::State> queue ( fsm.getFinalStates( ).begin(), fsm.getFinalStates().end() ); - std::set<automaton::State> visited = fsm.getFinalStates( ); + std::deque<label::Label> queue ( fsm.getFinalStates( ).begin(), fsm.getFinalStates().end() ); + std::set<label::Label> visited = fsm.getFinalStates( ); while( !queue.empty() ) { - const std::set<automaton::State>& to = reversedTransitions[queue.front()]; + const std::set<label::Label>& to = reversedTransitions[queue.front()]; queue.pop_front(); - for(const automaton::State& process : to) + for(const label::Label& process : to) if(visited.insert(process).second) { - queue.push_back(std::move(const_cast<automaton::State&>(process))); + queue.push_back(std::move(const_cast<label::Label&>(process))); } } return visited; } -auto UsefullStatesDFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(UsefullStates::usefullStates); +auto UsefullStatesDFA = UsefullStates::RegistratorWrapper<std::set<label::Label>, automaton::DFA>(UsefullStates::usefullStates); } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h index 9beaf5c1de..175e3815f0 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h @@ -13,8 +13,10 @@ #include <deque> #include <set> -#include <automaton/common/State.h> #include <automaton/Automaton.h> +#include <automaton/AutomatonFeatures.h> + +#include <label/Label.h> namespace automaton { @@ -22,15 +24,15 @@ namespace properties { namespace efficient { -class UsefullStates : public std::SingleDispatch<UsefullStates, std::set<automaton::State>, automaton::AutomatonBase> { +class UsefullStates : public std::SingleDispatch<UsefullStates, std::set<label::Label>, automaton::AutomatonBase> { public: - static std::set<automaton::State> usefullStates( const automaton::Automaton & automaton ); + static std::set<label::Label> usefullStates( const automaton::Automaton & automaton ); /** * Removes dead states from FSM. Melichar 2.32 */ template<class T> - static std::set<automaton::State> usefullStates( const T & fsm ); + static std::set<label::Label> usefullStates( const T & fsm ); }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp index 1430423bcd..315cdf09bf 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp @@ -15,15 +15,13 @@ namespace simplify { namespace efficient { -automaton::DFA EpsilonRemoverIncoming::remove(const automaton::DFA& origFSM) -{ +automaton::DFA EpsilonRemoverIncoming::remove(const automaton::DFA& origFSM) { return origFSM; } auto EpsilonRemoverIncomingDFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverIncoming::remove); -automaton::MultiInitialStateNFA EpsilonRemoverIncoming::remove(const automaton::MultiInitialStateNFA& origFSM) -{ +automaton::MultiInitialStateNFA EpsilonRemoverIncoming::remove(const automaton::MultiInitialStateNFA& origFSM) { return origFSM; } @@ -42,9 +40,9 @@ automaton::NFA EpsilonRemoverIncoming::remove( const automaton::EpsilonNFA & ori fsm.setStates( origFSM.getStates() ); fsm.setInputAlphabet( origFSM.getInputAlphabet() ); - std::map<automaton::State, std::set<automaton::State>> closures = automaton::properties::efficient::AllEpsilonClosure::allEpsilonClosure( origFSM ); + std::map<label::Label, std::set<label::Label>> closures = automaton::properties::efficient::AllEpsilonClosure::allEpsilonClosure( origFSM ); - std::map<std::pair<automaton::State, alphabet::Symbol>, std::set<automaton::State>> origTransitions = origFSM.getSymbolTransitions(); + std::map<std::pair<label::Label, alphabet::Symbol>, std::set<label::Label>> origTransitions = origFSM.getSymbolTransitions(); /** * Step 1 from Melichar 2.41 @@ -62,11 +60,11 @@ automaton::NFA EpsilonRemoverIncoming::remove( const automaton::EpsilonNFA & ori /** * Step 2 from Melichar 2.41 */ - const std::set<automaton::State> & F = origFSM.getFinalStates( ); + const std::set<label::Label> & F = origFSM.getFinalStates( ); for( const auto & q : fsm.getStates( ) ) { - const std::set<automaton::State> & cl = closures[ q ]; - std::set<automaton::State> intersect; + const std::set<label::Label> & cl = closures[ q ]; + std::set<label::Label> intersect; set_intersection( cl.begin(), cl.end(), F.begin(), F.end(), std::inserter( intersect, intersect.begin() ) ); if( intersect.size( ) != 0 ) diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp index 424bd41a7f..d957ab3b49 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp @@ -15,15 +15,13 @@ namespace simplify { namespace efficient { -automaton::DFA EpsilonRemoverOutgoing::remove(const automaton::DFA& origFSM) -{ +automaton::DFA EpsilonRemoverOutgoing::remove(const automaton::DFA& origFSM) { return origFSM; } auto EpsilonRemoverOutgoingDFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverOutgoing::remove); -automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove(const automaton::MultiInitialStateNFA& origFSM) -{ +automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove(const automaton::MultiInitialStateNFA& origFSM) { return origFSM; } @@ -42,19 +40,19 @@ automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove( const automaton: fsm.setFinalStates( origFSM.getFinalStates() ); fsm.setInputAlphabet( origFSM.getInputAlphabet() ); - std::map<automaton::State, std::set<automaton::State>> closures = automaton::properties::efficient::AllEpsilonClosure::allEpsilonClosure( origFSM ); + std::map<label::Label, std::set<label::Label>> closures = automaton::properties::efficient::AllEpsilonClosure::allEpsilonClosure( origFSM ); - std::map<std::pair<automaton::State, alphabet::Symbol>, std::set<automaton::State>> transitions = origFSM.getSymbolTransitions(); + std::map<std::pair<label::Label, alphabet::Symbol>, std::set<label::Label>> transitions = origFSM.getSymbolTransitions(); - for(const std::pair<const std::pair<automaton::State, alphabet::Symbol>, std::set<automaton::State>>& transition : transitions) - for(const automaton::State& to : transition.second) - for(const automaton::State& toClosure : closures[to]) + for(const std::pair<const std::pair<label::Label, alphabet::Symbol>, std::set<label::Label>>& transition : transitions) + for(const label::Label& to : transition.second) + for(const label::Label& toClosure : closures[to]) fsm.addTransition(transition.first.first, transition.first.second, toClosure); /** * Step 2 from Melichar 2.41 */ - const std::set<automaton::State>& cl = closures [ origFSM.getInitialState() ]; + const std::set<label::Label>& cl = closures [ origFSM.getInitialState() ]; fsm.setInitialStates( cl ); return fsm; diff --git a/alib2elgo/src/automaton/simplify/efficient/Trim.cpp b/alib2elgo/src/automaton/simplify/efficient/Trim.cpp index 35ebb813c8..8cda3ef4e0 100644 --- a/alib2elgo/src/automaton/simplify/efficient/Trim.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/Trim.cpp @@ -15,7 +15,6 @@ #include <automaton/FSM/NFA.h> #include <automaton/FSM/DFA.h> -#include "automaton/common/State.h" #include "automaton/Automaton.h" namespace automaton { diff --git a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp index 99bba43a2a..679e817e85 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp @@ -16,7 +16,6 @@ #include "../../properties/efficient/ReachableStates.h" -#include "automaton/common/State.h" #include "automaton/Automaton.h" namespace automaton { @@ -28,7 +27,7 @@ namespace efficient { template<class T> T UnreachableStatesRemover::remove( const T & fsm ) { // 1a - std::set<automaton::State> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); + std::set<label::Label> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); // 2 T M(fsm.getInitialState()); @@ -44,7 +43,7 @@ T UnreachableStatesRemover::remove( const T & fsm ) { for(const auto& to : transition.second ) M.addTransition( transition.first.first, transition.first.second, to ); - std::set<automaton::State> intersect; + std::set<label::Label> intersect; std::set_intersection( fsm.getFinalStates( ).begin(), fsm.getFinalStates( ).end(), Qa.begin( ), Qa.end( ), std::inserter( intersect, intersect.begin( ) ) ); for( auto const & state : intersect ) M.addFinalState( state ); @@ -60,7 +59,7 @@ auto UnreachableStatesRemoverExtendedNFA = UnreachableStatesRemover::Registrator template<> automaton::DFA UnreachableStatesRemover::remove( const automaton::DFA & fsm ) { // 1a - std::set<automaton::State> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); + std::set<label::Label> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); // 2 automaton::DFA M(fsm.getInitialState() ); @@ -75,7 +74,7 @@ automaton::DFA UnreachableStatesRemover::remove( const automaton::DFA & fsm ) { if( Qa.count( transition.first.first ) ) M.addTransition( transition.first.first, transition.first.second, transition.second ); - std::set<automaton::State> intersect; + std::set<label::Label> intersect; std::set_intersection( fsm.getFinalStates( ).begin(), fsm.getFinalStates( ).end(), Qa.begin( ), Qa.end( ), std::inserter( intersect, intersect.begin( ) ) ); for( auto const & state : intersect ) M.addFinalState( state ); @@ -88,7 +87,7 @@ auto UnreachableStatesRemoverDFA = UnreachableStatesRemover::RegistratorWrapper< template<> automaton::MultiInitialStateNFA UnreachableStatesRemover::remove( const automaton::MultiInitialStateNFA & fsm ) { // 1a - std::set<automaton::State> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); + std::set<label::Label> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); // 2 automaton::MultiInitialStateNFA M; @@ -106,7 +105,7 @@ automaton::MultiInitialStateNFA UnreachableStatesRemover::remove( const automato for(const auto& to : transition.second ) M.addTransition( transition.first.first, transition.first.second, to ); - std::set<automaton::State> intersect; + std::set<label::Label> intersect; std::set_intersection( fsm.getFinalStates( ).begin(), fsm.getFinalStates( ).end(), Qa.begin( ), Qa.end( ), std::inserter( intersect, intersect.begin( ) ) ); for( auto const & state : intersect ) M.addFinalState( state ); diff --git a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp index 0b334e12de..346ddcdf98 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp @@ -16,7 +16,6 @@ #include "../../properties/efficient/UsefullStates.h" -#include "automaton/common/State.h" #include "automaton/Automaton.h" namespace automaton { @@ -28,7 +27,7 @@ namespace efficient { template<class T> T UselessStatesRemover::remove( const T & fsm ) { // 1. - std::set<automaton::State> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm ); + std::set<label::Label> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm ); // 2. T M(fsm.getInitialState()); @@ -62,7 +61,7 @@ auto UselessStatesRemoverExtendedNFA = UselessStatesRemover::RegistratorWrapper< template<> automaton::DFA UselessStatesRemover::remove( const automaton::DFA & fsm ) { // 1. - std::set<automaton::State> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm ); + std::set<label::Label> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm ); // 2. automaton::DFA M ( fsm.getInitialState () ); @@ -92,7 +91,7 @@ auto UselessStatesRemoverDFA = UselessStatesRemover::RegistratorWrapper<automato template<> automaton::MultiInitialStateNFA UselessStatesRemover::remove( const automaton::MultiInitialStateNFA & fsm ) { // 1. - std::set<automaton::State> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm ); + std::set<label::Label> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm ); // 2. automaton::MultiInitialStateNFA M; diff --git a/alib2elgo/test-src/automaton/simplify/efficient/trimTest.cpp b/alib2elgo/test-src/automaton/simplify/efficient/trimTest.cpp index cbc1fae541..0a2810eedc 100644 --- a/alib2elgo/test-src/automaton/simplify/efficient/trimTest.cpp +++ b/alib2elgo/test-src/automaton/simplify/efficient/trimTest.cpp @@ -17,19 +17,19 @@ void trimTest::tearDown() { } void trimTest::testTrimAutomaton() { - automaton::DFA automaton(automaton::State(1)); + automaton::DFA automaton(label::labelFrom(1)); - automaton.addState(automaton::State(1)); - automaton.addState(automaton::State(2)); - automaton.addState(automaton::State(3)); + automaton.addState(label::labelFrom(1)); + automaton.addState(label::labelFrom(2)); + automaton.addState(label::labelFrom(3)); automaton.addInputSymbol(alphabet::symbolFrom("a")); automaton.addInputSymbol(alphabet::symbolFrom("b")); - automaton.addTransition(automaton::State(1), alphabet::symbolFrom("a"), automaton::State(2)); - automaton.addTransition(automaton::State(2), alphabet::symbolFrom("b"), automaton::State(1)); - automaton.addTransition(automaton::State(3), alphabet::symbolFrom("b"), automaton::State(1)); + automaton.addTransition(label::labelFrom(1), alphabet::symbolFrom("a"), label::labelFrom(2)); + automaton.addTransition(label::labelFrom(2), alphabet::symbolFrom("b"), label::labelFrom(1)); + automaton.addTransition(label::labelFrom(3), alphabet::symbolFrom("b"), label::labelFrom(1)); - automaton.addFinalState(automaton::State(1)); + automaton.addFinalState(label::labelFrom(1)); automaton::DFA trimed = automaton::simplify::Trim::trim(automaton); -- GitLab