Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
AutomatonComplement.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
27
28namespace automaton {
29
30namespace transform {
31
37public:
45 template < class SymbolType, class StateType >
47};
48
49template < class SymbolType, class StateType >
51 // create a complement of automaton's final states
52 ext::set < StateType > newFinalStates = automaton.getStates ( );
53
54 // FIXME Not working?
55 // const ext::set < StateType > & oldFinalStates = automaton.getFinalStates ( );
56 // newFinalStates.erase ( oldFinalStates.begin ( ), oldFinalStates.end ( ) );
57
58 for ( const auto & fin : automaton.getFinalStates ( ) )
59 newFinalStates.erase ( fin );
60
62 res.setFinalStates ( newFinalStates );
63 return res;
64}
65
66} /* namespace transform */
67
68} /* namespace automaton */
69
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
Definition: AutomatonComplement.h:36
static automaton::DFA< SymbolType, StateType > complement(const automaton::DFA< SymbolType, StateType > &automaton)
Definition: AutomatonComplement.h:50
Definition: set.hpp:44
return res
Definition: AutomataConcatenation.h:102
Definition: ToGrammar.h:31
ContainerType< ResType > transform(const ContainerType< InType, Ts ... > &in, Callback transform)
In container tranformation of all elements according to the tranform.
Definition: algorithm.hpp:150