Newer
Older
* 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/>.
*
#ifndef TO_REG_EXP_STATE_ELIMINATION_H_
#define TO_REG_EXP_STATE_ELIMINATION_H_
#include <regexp/unbounded/UnboundedRegExp.h>
#include <automaton/FSM/DFA.h>
#include <automaton/FSM/NFA.h>
#include <automaton/FSM/MultiInitialStateNFA.h>
#include <automaton/FSM/EpsilonNFA.h>
#include <automaton/FSM/ExtendedNFA.h>
* Converts a finite automaton to a regular expression using using the State Elimination algorithm (Melichar: Jazyky a překlady 2.118).
* This algorithm returns the regular expression as regexp::UnboundedRegExp.
* @tparam T type of the finite automaton
* @param automaton finite automaton to convert
* @return unbounded regular expression equivalent to the original automaton
static regexp::UnboundedRegExp < > convert(const T& automaton);
/**
* Helper function to create new initial and final states in the automaton for the algorithm.
* @param automaton extended finite automaton
*/
static void extendExtendedNFA(automaton::ExtendedNFA < > & automaton);
/**
* Helper function to create a regexp from all transitions between states @p from and @p to.
* It creates the alternation regexp of all such transitions.
* @param automaton automaton to select the transitions
* @param from source state in @param automaton
* @param to destination state in @param automaton
* @return the regular expression node representing the transitions between states @p from and @p to
*/
static const regexp::UnboundedRegExpStructure < DefaultSymbolType > transitionsToRegExp(const automaton::ExtendedNFA < > & automaton, const DefaultStateType& from, const DefaultStateType& to);
/**
* Helper function for the elimination of a single state according to the algorithm.
* @param extendedAutomaton automaton for the elimination
* @param state state to eliminate
* @return the @p extendedAutomaton after the elimination of a state @state.
*/
static automaton::ExtendedNFA < > eliminateState(const automaton::ExtendedNFA < > & extendedAutomaton, const DefaultStateType& state);