Skip to content

Commit

Permalink
(#330) SCCs coloring fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xendalm committed Jun 12, 2024
1 parent 1927f6e commit 92da0f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/UnitTestsApp/src/UnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,12 @@ TEST(TestBisimilar, MFA_Bisimilar) {
// несовпадение раскрасок
{"[a]:1*&1", "[a*]:1*&1", false},
{"[a]:1*[a*]:1&1", "[a|]:1*&1", false},
{"([a|]:1*&1)*", "([aa*|]:1&1)*", false},
// несовпадение по решающим действиям
{"[a|b]:1c(a|b)&1", "(a|b)c[a|b]:1&1", false},
// несовпадение CG
{"[aa]:1&1", "[|aa]:1&1", false},
{"[a*]:1a&1", "[a*a]:1&1", false},
{"([a|]:1*&1)*", "([aa*|]:1&1)*", false},
};

for_each(tests.begin(), tests.end(), [](const Test& test) {
Expand Down
23 changes: 13 additions & 10 deletions libs/Objects/src/MemoryFiniteAutomaton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,26 +1581,29 @@ optional<bool> MemoryFiniteAutomaton::bisimilarity_checker(const MemoryFiniteAut
for (const auto& SCC : SCCs[i]) {
unordered_set<int> colors_to_ignore;
for (auto state : SCC) {
unordered_set<int> state_colors_to_ignore;
bool has_transitions_without_actions = false;
unordered_set<int> cur_colors_to_ignore;
unordered_set<int> colors_of_internal_transitions;
for (const auto& [symbol, symbol_transitions] :
mfas[i]->states[state].transitions) {
for (const auto& tr : symbol_transitions) {
if (SCC.count(tr.to)) {
if (tr.memory_actions.empty()) {
state_colors_to_ignore.clear();
has_transitions_without_actions = true;
break;
for (auto color : mfa_colors[i][state]) {
if (mfa_colors[i][tr.to].find(color) !=
mfa_colors[i][tr.to].end()) {
colors_of_internal_transitions.insert(color);
}
}
}
for (const auto& [cell, action] : tr.memory_actions)
state_colors_to_ignore.insert(cell);
if (mfa_colors[i][state].count(cell))
cur_colors_to_ignore.insert(cell);
}
}
if (has_transitions_without_actions)
break;
}
colors_to_ignore.insert(state_colors_to_ignore.begin(),
state_colors_to_ignore.end());
for (const auto& color : colors_of_internal_transitions)
cur_colors_to_ignore.erase(color);
colors_to_ignore.insert(cur_colors_to_ignore.begin(), cur_colors_to_ignore.end());
}

set<pair<int, set<int>>> colored_SCC;
Expand Down

0 comments on commit 92da0f8

Please sign in to comment.