From 6d177b64dace3728743d9039453726b7e5738296 Mon Sep 17 00:00:00 2001 From: Tomas Pecka <peckato1@fit.cvut.cz> Date: Mon, 16 Jul 2018 11:09:53 +0200 Subject: [PATCH] algo: doc automaton::determinize --- .../src/automaton/determinize/Determinize.h | 179 ++++++++++++++++-- .../determinize/DeterminizeNFTAPart.hxx | 2 +- 2 files changed, 168 insertions(+), 13 deletions(-) diff --git a/alib2algo/src/automaton/determinize/Determinize.h b/alib2algo/src/automaton/determinize/Determinize.h index 02ad1f5a8d..5f1952d67b 100644 --- a/alib2algo/src/automaton/determinize/Determinize.h +++ b/alib2algo/src/automaton/determinize/Determinize.h @@ -1,6 +1,22 @@ /* * Determinize.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: 16. 1. 2014 * Author: Jan Vesely */ @@ -37,59 +53,198 @@ namespace automaton { namespace determinize { /** - * Class for running determinization algorithm on fsm. + * Class implementing various algorithms for determinization of various kinds of automata. */ class Determinize { public: + /** + * Determinization of deterministic finite automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam StateType Type for the states. + * @param dfa deterministic finite automaton + * @return deterministic finite automaton equivalent to @p nfa + */ template < class SymbolType, class StateType > - static automaton::DFA < SymbolType, StateType > determinize ( const automaton::DFA < SymbolType, StateType > & nfa ); + static automaton::DFA < SymbolType, StateType > determinize ( const automaton::DFA < SymbolType, StateType > & dfa ); /** - * @param nfsm nondeterministic final-state machine given for determinization - * @return DFA - * Runs determinization algorithm on nondeterministic fsm given in constructor. + * Implementation of subset determinization for nondeterministic finite automata. + * + * @tparam SymbolType Type for the input symbols. + * @tparam StateType Type for the states. + * @param nfa nondeterministic finite automaton + * @return deterministic finite automaton equivalent to @p nfa */ template < class SymbolType, class StateType > static automaton::DFA < SymbolType, ext::set < StateType > > determinize ( const automaton::NFA < SymbolType, StateType > & nfa ); + /** + * Implementation of subset determinization for nondeterministic finite automata with multiple initial states. + * + * @tparam SymbolType Type for the input symbols. + * @tparam StateType Type for the states. + * @param nfa nondeterministic finite automaton with multiple initial states + * @return deterministic finite automaton equivalent to @p nfa + */ template < class SymbolType, class StateType > static automaton::DFA < SymbolType, ext::set < StateType > > determinize ( const automaton::MultiInitialStateNFA < SymbolType, StateType > & nfa ); + /** + * Determinization of deterministic finite tree automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam RankType Type for the rank (arity) in ranked alphabet. + * @tparam StateType Type for the states. + * @param dfta deterministic finite tree automaton + * @return deterministic finite tree automaton equivalent to @p dfta + */ template < class SymbolType, class RankType, class StateType > - static automaton::DFTA < SymbolType, RankType, StateType > determinize ( const automaton::DFTA < SymbolType, RankType, StateType > & nfta ); + static automaton::DFTA < SymbolType, RankType, StateType > determinize ( const automaton::DFTA < SymbolType, RankType, StateType > & dfta ); + /** + * Implementation of subset determinization for nondeterministic finite tree automata. + * + * @tparam SymbolType Type for the input symbols. + * @tparam RankType Type for the rank (arity) in ranked alphabet. + * @tparam StateType Type for the states. + * @param nfta nondeterministic finite tree automaton + * @return deterministic finite tree automaton equivalent to @p nfta + */ template < class SymbolType, class RankType, class StateType > static automaton::DFTA < SymbolType, RankType, ext::set < StateType > > determinize ( const automaton::NFTA < SymbolType, RankType, StateType > & nfta ); + /** + * Determinization of deterministic input-driven pushdown automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param dpda deterministic input-driven pushdown automaton + * @return deterministic input-driven pushdown automaton equivalent to @p dpda + */ template < class InputSymbolType, class PushdownSymbolType, class StateType > static automaton::InputDrivenDPDA < InputSymbolType, PushdownSymbolType, StateType > determinize ( const automaton::InputDrivenDPDA < InputSymbolType, PushdownSymbolType, StateType > & dpda ); + /** + * Implementation of determinization for input-driven pushdown automata. + * + * @tparam SymbolType Type for the input symbols. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param npda nondeterministic input-driven pushdown automaton + * @return deterministic input-driven pushdown automaton equivalent to @p dpda + */ template < class InputSymbolType, class PushdownSymbolType, class StateType > static automaton::InputDrivenDPDA < InputSymbolType, PushdownSymbolType, ext::set < StateType > > determinize ( const automaton::InputDrivenNPDA < InputSymbolType, PushdownSymbolType, StateType > & npda ); + /** + * Determinization of deterministic visibly pushdown automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param dpda deterministic visibly pushdown automaton + * @return deterministic pushdown automaton equivalent to @p dpda + */ template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > - static automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > determinize ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & nondeterministic ); + static automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > determinize ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & dpda ); + /** + * Determinization of nondeterministic visibly pushdown automata. + * + * @tparam SymbolType Type for the input symbols. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param npda nondeterministic visibly pushdown automaton + * @return deterministic pushdown automaton equivalent to @p npda + */ template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > - static automaton::VisiblyPushdownDPDA < InputSymbolType, ext::pair < ext::set < ext::pair < StateType, StateType > >, InputSymbolType >, ext::set < ext::pair < StateType, StateType > > > determinize ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & nondeterministic ); + static automaton::VisiblyPushdownDPDA < InputSymbolType, ext::pair < ext::set < ext::pair < StateType, StateType > >, InputSymbolType >, ext::set < ext::pair < StateType, StateType > > > determinize ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & npda ); + /** + * Determinization of deterministic real-time height-deterministic pushdown automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam EpsilonType Type for the epsilon symbol. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param dpda deterministic real-time height-deterministic pushdown automaton + * @return deterministic pushdown automaton equivalent to @p dpda + */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > - static automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > determinize ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & nondeterministic ); + static automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > determinize ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & dpda ); + /** + * Determinization of nondeterministic real-time height-deterministic pushdown automata. + * + * @tparam SymbolType Type for the input symbols. + * @tparam EpsilonType Type for the epsilon symbol. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param npda nondeterministic real-time height-deterministic pushdown automaton + * @return deterministic pushdown automaton equivalent to @p npda + */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > - static automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, ext::pair < ext::set < ext::pair < StateType, StateType > >, ext::variant < EpsilonType, InputSymbolType > >, ext::set < ext::pair < StateType, StateType > > > determinize ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & nondeterministic ); + static automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, ext::pair < ext::set < ext::pair < StateType, StateType > >, ext::variant < EpsilonType, InputSymbolType > >, ext::set < ext::pair < StateType, StateType > > > determinize ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & npda ); + /** + * Determinization of deterministic single pop pushdown automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam EpsilonType Type for the epsilon symbol. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param dpda nondeterministic finite automaton with multiple initial states + * @return deterministic single pop deterministic pushdown automaton equivalent do @p dpda + */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > static automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > determinize ( const automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & dpda ); + /** + * Determinization of deterministic pushdown automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam EpsilonType Type for the epsilon symbol. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param dpda deterministic pushdown automaton + * @return deterministic pushdown automaton equivalent to @p dpda + */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > static automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > determinize ( const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & dpda ); + /** + * Determinization of nondeterministic pushdown automata is implemented as a cast of such automaton to RhPDA. + * + * @tparam SymbolType Type for the input symbols. + * @tparam EpsilonType Type for the epsilon symbol. + * @tparam PushdownSymbolType Type for the pushdown store symbols. + * @tparam StateType Type for the states. + * @param npda nondeterministic pushdown automaton + * @return nondeterministic pushdown automaton equivalent to @p npda + */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > - static automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > determinize ( const automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & dpda ); + static automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > determinize ( const automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & npda ); + /** + * Determinization of deterministic pushdown automata. + * Implemented as a no-op. + * + * @tparam SymbolType Type for the input symbols. + * @tparam StateType Type for the states. + * @param dtm deterministic one-tape turing machine + * @return deterministic one-tape turing machine equivalent to @p dtm + */ template < class SymbolType, class StateType > - static automaton::OneTapeDTM < SymbolType, StateType > determinize ( const automaton::OneTapeDTM < SymbolType, StateType > & nfta ); + static automaton::OneTapeDTM < SymbolType, StateType > determinize ( const automaton::OneTapeDTM < SymbolType, StateType > & dtm ); }; template < class SymbolType, class StateType > diff --git a/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.hxx b/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.hxx index 03b6e1eec2..8a13e4c854 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.hxx +++ b/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.hxx @@ -34,7 +34,7 @@ ext::set < StateType > getTransitionRightSide ( const NFTA < SymbolType, RankTyp } template < class SymbolType, class RankType, class StateType > -automaton::DFTA < SymbolType, RankType, ext::set < StateType > > Determinize::determinize ( const NFTA < SymbolType, RankType, StateType > & nfta ) { +automaton::DFTA < SymbolType, RankType, ext::set < StateType > > Determinize::determinize ( const automaton::NFTA < SymbolType, RankType, StateType > & nfta ) { automaton::DFTA < SymbolType, RankType, ext::set < StateType > > res; res.setInputAlphabet ( nfta.getInputAlphabet ( ) ); -- GitLab