Skip to content
Snippets Groups Projects
Commit 038558a6 authored by Tomáš Pecka's avatar Tomáš Pecka Committed by Tomáš Pecka
Browse files

Algo: Compute partitions of undistinguishable states

parent df4f38be
No related branches found
No related tags found
1 merge request!79Dev tp
/*
* UndistinguishableStates.cpp
*
* Created on: 27. 3. 2019
* Author: Tomas Pecka
*/
#include "UndistinguishableStates.h"
#include <registration/AlgoRegistration.hpp>
namespace automaton {
namespace properties {
auto UndistinguishableStatesDFA = registration::AbstractRegister < UndistinguishableStates, ext::set < ext::set < DefaultStateType > >, const automaton::DFA < > & > ( UndistinguishableStates::undistinguishable, "fsm" ).setDocumentation (
"Computes the partitions of undistinguishable states states in given DFA.\n\
\n\
@param dfa finite automaton.\n\
@return set of blocks of undistinguishable states" );
} /* namespace properties */
} /* namespace automaton */
/*
* UndistinguishableStates.h
*
* This file is part of Algorithms library toolkit.
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
* Algorithms library toolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Algorithms library toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
*
* Created on: 27. 3. 2019
* Author: Tomas Pecka
*/
#ifndef DISTINGUISHABLE_STATES_PARTITIONING_H_
#define DISTINGUISHABLE_STATES_PARTITIONING_H_
#include <alib/set>
#include <alib/map>
#include <automaton/FSM/DFA.h>
#include <automaton/Automaton.h>
#include <automaton/properties/DistinguishableStates.h>
namespace automaton {
namespace properties {
/**
* Partition undistinguishable states in automata
*
* @sa DistinguishableStates
*/
class UndistinguishableStates {
public:
/**
* Creates state partitioning of undistinguishable states using DistinguishableStates algorithm
*
* @tparam SymbolType Type for input symbols.
* @tparam StateType Type for states.
* @param dfa automaton which states are to be partitioned
*
* @sa DistinguishableStates
*
* @return state partitioning of undistinguishable states
*/
template < class SymbolType, class StateType >
static ext::set < ext::set < StateType > > undistinguishable ( const automaton::DFA < SymbolType, StateType > & fsm );
};
template < class SymbolType, class StateType >
ext::set < ext::set < StateType > > UndistinguishableStates::undistinguishable ( const automaton::DFA < SymbolType, StateType > & fsm ) {
const ext::set < ext::pair < StateType, StateType > > distinguishable = automaton::properties::DistinguishableStates::distinguishableStates ( fsm );
ext::set < ext::set < StateType > > res;
for ( const StateType & state : fsm.getStates ( ) ) {
ext::set < StateType > partition;
for ( const StateType & other : fsm.getStates ( ) )
if ( distinguishable.count ( ext::make_pair ( state, other ) ) == 0 )
partition.insert ( other );
res.insert ( partition );
}
return res;
}
} /* namespace properties */
} /* namespace automaton */
#endif /* DISTINGUISHABLE_STATES_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment