From 8935f925eb999d8ef1dece17066f6ab18cb008fc Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sat, 18 Oct 2014 08:05:01 +0200
Subject: [PATCH] static entry functions of regexp optimize

---
 .../conversions/fa2re/StateElimination.cpp    |   6 +-
 .../re2fa/BrzozowskiDerivation.cpp            |   6 +-
 .../re2rg/re2rrg/BrzozowskiDerivation.cpp     |   7 +-
 .../equations/LeftRegularEquationSolver.cpp   |  12 +-
 .../equations/RightRegularEquationSolver.cpp  |  12 +-
 alib2algo/src/regexp/RegExpOptimize.cpp       |  20 +--
 alib2algo/src/regexp/RegExpOptimize.h         | 126 +++++++++---------
 .../src/regexp/RegExpOptimizeFormalPart.cxx   |  46 +++----
 .../regexp/RegExpOptimizeUnboundedPart.cxx    |  56 ++++----
 9 files changed, 147 insertions(+), 144 deletions(-)

diff --git a/alib2algo/src/conversions/fa2re/StateElimination.cpp b/alib2algo/src/conversions/fa2re/StateElimination.cpp
index 85f1101033..1c22f40119 100644
--- a/alib2algo/src/conversions/fa2re/StateElimination.cpp
+++ b/alib2algo/src/conversions/fa2re/StateElimination.cpp
@@ -52,7 +52,7 @@ regexp::RegExp StateElimination::convert(const T& automaton)
     // step 4
     regexp::RegExpOptimize opt;
 
-    return opt.optimize(regexp::RegExpConcatenate::concatenate(
+    return regexp::RegExpOptimize::optimize(regexp::RegExpConcatenate::concatenate(
 				transition(extendedAutomaton, extendedAutomaton.getInitialState(), *extendedAutomaton.getFinalStates().begin()),
 				regexp::RegExpIterate::iterate(transition(extendedAutomaton, *extendedAutomaton.getFinalStates().begin(), *extendedAutomaton.getFinalStates().begin()))));
 }
@@ -78,7 +78,7 @@ automaton::ExtendedNFA StateElimination::eliminateState(const automaton::Extende
 
             regexp::RegExp alt = regexp::RegExpAlternate::alternate(concat, transition(extendedAutomaton, p, r));
 
-            newAutomaton.addTransition(p, opt.optimize(alt), r);
+            newAutomaton.addTransition(p, regexp::RegExpOptimize::optimize(alt), r);
         }
     }
 
@@ -94,7 +94,7 @@ const regexp::RegExp StateElimination::transition(const automaton::ExtendedNFA&
         if(transition.second.count(to) > 0)
             ret = regexp::RegExpAlternate::alternate(ret, transition.first.second);
 
-    return opt.optimize(ret);
+    return regexp::RegExpOptimize::optimize(ret);
 }
 
 void StateElimination::extendExtendedNFA(automaton::ExtendedNFA& automaton)
diff --git a/alib2algo/src/conversions/re2fa/BrzozowskiDerivation.cpp b/alib2algo/src/conversions/re2fa/BrzozowskiDerivation.cpp
index 1b2f0bef56..4916c8e363 100644
--- a/alib2algo/src/conversions/re2fa/BrzozowskiDerivation.cpp
+++ b/alib2algo/src/conversions/re2fa/BrzozowskiDerivation.cpp
@@ -39,7 +39,7 @@ automaton::NFA BrzozowskiDerivation::convert(const T& regexp)
 {
 	// 1.
 	regexp::RegExpOptimize opt;
-	regexp::RegExp V = regexp::RegExp{opt.optimize(regexp)};
+	regexp::RegExp V = regexp::RegExp{regexp::RegExpOptimize::optimize(regexp)};
 
 	std::set<regexp::RegExp> Q = { V };
 	std::deque<std::set<regexp::RegExp>> Qi;
@@ -62,7 +62,7 @@ automaton::NFA BrzozowskiDerivation::convert(const T& regexp)
 			{
 				string::LinearString string(std::vector<alphabet::Symbol>{a});
 				regexp::RegExp derived = deriv.derivation(dregexp, string);
-				derived = opt.optimize(derived);
+				derived = regexp::RegExpOptimize::optimize(derived);
 
 				// this will also add \emptyset as a regexp (and as FA state)
 				if(Q.count(derived) == 0) // if this state has already been found, do not add
@@ -103,7 +103,7 @@ automaton::NFA BrzozowskiDerivation::convert(const T& regexp)
 		{
 			string::LinearString string(std::vector<alphabet::Symbol>{a});
 			regexp::RegExp derived = deriv.derivation(r, string);
-			derived = opt.optimize(derived);
+			derived = regexp::RegExpOptimize::optimize(derived);
 
 			automaton.addTransition(stateMap.find(r)->second, a, stateMap.find(derived)->second);
 		}
diff --git a/alib2algo/src/conversions/re2rg/re2rrg/BrzozowskiDerivation.cpp b/alib2algo/src/conversions/re2rg/re2rrg/BrzozowskiDerivation.cpp
index 095953a86b..27e75fcdf0 100644
--- a/alib2algo/src/conversions/re2rg/re2rrg/BrzozowskiDerivation.cpp
+++ b/alib2algo/src/conversions/re2rg/re2rrg/BrzozowskiDerivation.cpp
@@ -37,8 +37,7 @@ template<class T>
 grammar::RightRG BrzozowskiDerivation::convert(const T& regexp)
 {
 	// 1.
-	regexp::RegExpOptimize opt;
-	regexp::RegExp V = regexp::RegExp{opt.optimize(regexp)};
+	regexp::RegExp V = regexp::RegExp{regexp::RegExpOptimize::optimize(regexp)};
 
 	std::set<regexp::RegExp> N = { V };
 	std::deque<std::set<regexp::RegExp>> Ni;
@@ -61,7 +60,7 @@ grammar::RightRG BrzozowskiDerivation::convert(const T& regexp)
 			{
 				string::LinearString string(std::vector<alphabet::Symbol>{a});
 				regexp::RegExp derived = deriv.derivation(dregexp, string);
-				derived = opt.optimize(derived);
+				derived = regexp::RegExpOptimize::optimize(derived);
 
 				// this will also add \emptyset as a regexp (and as FA state)
 				if(N.count(derived) == 0) // if this state has already been found, do not add
@@ -102,7 +101,7 @@ grammar::RightRG BrzozowskiDerivation::convert(const T& regexp)
 		{
 			string::LinearString string(std::vector<alphabet::Symbol>{a});
 			regexp::RegExp derived = deriv.derivation(r, string);
-			derived = opt.optimize(derived);
+			derived = regexp::RegExpOptimize::optimize(derived);
 
 			grammar.addRule(nonterminalMap.find(r)->second, std::make_pair(a, nonterminalMap.find(derived)->second));
 
diff --git a/alib2algo/src/equations/LeftRegularEquationSolver.cpp b/alib2algo/src/equations/LeftRegularEquationSolver.cpp
index 80051cc993..72351deeaa 100644
--- a/alib2algo/src/equations/LeftRegularEquationSolver.cpp
+++ b/alib2algo/src/equations/LeftRegularEquationSolver.cpp
@@ -24,7 +24,7 @@ regexp::UnboundedRegExp LeftRegularEquationSolver::eliminate(void) {
 		 * => A = 10*B + 20*C
 		 */
 		regexp::UnboundedRegExpIteration loop(std::move(equationTransition.find(std::make_pair(a, a))->second));
-		opt.optimize(loop);
+		regexp::RegExpOptimize::optimize(loop);
 
 		// for all transitions from A apply Arden's Lemma
 		for(auto itB = std::next(itA) ; itB != nonterminalSymbolsByDepth.rend(); itB ++) {
@@ -35,7 +35,7 @@ regexp::UnboundedRegExp LeftRegularEquationSolver::eliminate(void) {
 			regexp::UnboundedRegExpAlternation alt;
 			alt.appendElement(std::move(concat));
 			equationTransition.find(std::make_pair(a, b))->second = std::move(alt);
-			opt.optimize(equationTransition.find(std::make_pair(a, b))->second);
+			regexp::RegExpOptimize::optimize(equationTransition.find(std::make_pair(a, b))->second);
 		}
 		regexp::UnboundedRegExpConcatenation concat;
 		concat.appendElement(std::move(equationFinal.find(a)->second));
@@ -43,7 +43,7 @@ regexp::UnboundedRegExp LeftRegularEquationSolver::eliminate(void) {
 		regexp::UnboundedRegExpAlternation alt;
 		alt.appendElement(std::move(concat));
 		equationFinal.find(a)->second = std::move(alt);
-		opt.optimize(equationFinal.find(a)->second);
+		regexp::RegExpOptimize::optimize(equationFinal.find(a)->second);
 
 		/*
 		 * eliminate A from rest of the equations using this pattern:
@@ -62,7 +62,7 @@ regexp::UnboundedRegExp LeftRegularEquationSolver::eliminate(void) {
 				alt.appendElement(std::move(equationTransition.find(std::make_pair(b, c))->second));
 				alt.appendElement(std::move(concat));
 				equationTransition.find(std::make_pair(b, c))->second = std::move(alt);
-				opt.optimize(equationTransition.find(std::make_pair(b, c))->second);
+				regexp::RegExpOptimize::optimize(equationTransition.find(std::make_pair(b, c))->second);
 			}
 
 			regexp::UnboundedRegExpConcatenation concat;
@@ -72,11 +72,11 @@ regexp::UnboundedRegExp LeftRegularEquationSolver::eliminate(void) {
 			alt.appendElement(std::move(equationFinal.find(b)->second));
 			alt.appendElement(std::move(concat));
 			equationFinal.find(b)->second = std::move(alt);
-			opt.optimize(equationFinal.find(b)->second);
+			regexp::RegExpOptimize::optimize(equationFinal.find(b)->second);
 		}
 	}
 
-	return opt.optimize(regexp::UnboundedRegExp(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second)));
+	return regexp::RegExpOptimize::optimize(regexp::UnboundedRegExp(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second)));
 }
 
 } /* namespace equations */
diff --git a/alib2algo/src/equations/RightRegularEquationSolver.cpp b/alib2algo/src/equations/RightRegularEquationSolver.cpp
index 63b14225b7..08cf2fb03d 100644
--- a/alib2algo/src/equations/RightRegularEquationSolver.cpp
+++ b/alib2algo/src/equations/RightRegularEquationSolver.cpp
@@ -24,7 +24,7 @@ regexp::UnboundedRegExp RightRegularEquationSolver::eliminate(void) {
 		 * => A = 0*1B + 0*2C
 		 */
 		regexp::UnboundedRegExpIteration loop(std::move(equationTransition.find(std::make_pair(a, a))->second));
-		opt.optimize(loop);
+		regexp::RegExpOptimize::optimize(loop);
 
 		// for all transitions from A apply Arden's Lemma
 		for(auto itB = std::next(itA) ; itB != nonterminalSymbolsByDepth.rend(); itB ++) {
@@ -35,7 +35,7 @@ regexp::UnboundedRegExp RightRegularEquationSolver::eliminate(void) {
 			regexp::UnboundedRegExpAlternation alt;
 			alt.appendElement(std::move(concat));
 			equationTransition.find(std::make_pair(a, b))->second = std::move(alt);
-			opt.optimize(equationTransition.find(std::make_pair(a, b))->second);
+			regexp::RegExpOptimize::optimize(equationTransition.find(std::make_pair(a, b))->second);
 		}
 		regexp::UnboundedRegExpConcatenation concat;
 		concat.appendElement(std::move(loop));
@@ -43,7 +43,7 @@ regexp::UnboundedRegExp RightRegularEquationSolver::eliminate(void) {
 		regexp::UnboundedRegExpAlternation alt;
 		alt.appendElement(std::move(concat));
 		equationFinal.find(a)->second = std::move(alt);
-		opt.optimize(equationFinal.find(a)->second);
+		regexp::RegExpOptimize::optimize(equationFinal.find(a)->second);
 
 		/*
 		 * eliminate A from rest of the equations using this pattern:
@@ -62,7 +62,7 @@ regexp::UnboundedRegExp RightRegularEquationSolver::eliminate(void) {
 				alt.appendElement(std::move(equationTransition.find(std::make_pair(b, c))->second));
 				alt.appendElement(std::move(concat));
 				equationTransition.find(std::make_pair(b, c))->second = std::move(alt);
-				opt.optimize(equationTransition.find(std::make_pair(b, c))->second);
+				regexp::RegExpOptimize::optimize(equationTransition.find(std::make_pair(b, c))->second);
 			}
 
 			regexp::UnboundedRegExpConcatenation concat;
@@ -72,11 +72,11 @@ regexp::UnboundedRegExp RightRegularEquationSolver::eliminate(void) {
 			alt.appendElement(std::move(equationFinal.find(b)->second));
 			alt.appendElement(std::move(concat));
 			equationFinal.find(b)->second = std::move(alt);
-			opt.optimize(equationFinal.find(b)->second);
+			regexp::RegExpOptimize::optimize(equationFinal.find(b)->second);
 		}
 	}
 
-	return opt.optimize(regexp::UnboundedRegExp(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second)));
+	return regexp::RegExpOptimize::optimize(regexp::UnboundedRegExp(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second)));
 }
 
 } /* namespace equations */
diff --git a/alib2algo/src/regexp/RegExpOptimize.cpp b/alib2algo/src/regexp/RegExpOptimize.cpp
index ed2e2c0049..42573dc1e8 100644
--- a/alib2algo/src/regexp/RegExpOptimize.cpp
+++ b/alib2algo/src/regexp/RegExpOptimize.cpp
@@ -18,29 +18,29 @@ namespace regexp {
 regexp::RegExp RegExpOptimize::optimize(const regexp::RegExp& regexp)
 {
     regexp::RegExp * out = NULL;
-    regexp.getData().Accept((void*) &out, *this);
+    regexp.getData().Accept((void*) &out, RegExpOptimize::REG_EXP_OPTIMIZE);
     regexp::RegExp res( std::move( * out ) );
     delete out;
     return res;
 }
 
-void RegExpOptimize::Visit(void* userData, const regexp::FormalRegExp& regexp)
+void RegExpOptimize::Visit(void* userData, const regexp::FormalRegExp& regexp) const
 {
     regexp::RegExp * &ret = *(regexp::RegExp **) userData;
 
-    ret = new regexp::RegExp( this->optimize( regexp ) );
+    ret = new regexp::RegExp( optimize( regexp ) );
 }
 
-void RegExpOptimize::Visit(void* userData, const regexp::UnboundedRegExp& regexp)
+void RegExpOptimize::Visit(void* userData, const regexp::UnboundedRegExp& regexp) const
 {
     regexp::RegExp * &ret = *(regexp::RegExp **) userData;
 
-    ret = new regexp::RegExp( this->optimize( regexp ) );
+    ret = new regexp::RegExp( optimize( regexp ) );
 }
 
 FormalRegExp RegExpOptimize::optimize( FormalRegExp const & regexp )
 {
-	FormalRegExpElement* optimized = optimize( & regexp.getRegExp( ) );
+	FormalRegExpElement* optimized = RegExpOptimize::REG_EXP_OPTIMIZE.optimize( & regexp.getRegExp( ) );
 
 	FormalRegExp ret( std::move( * optimized ) );
 
@@ -51,7 +51,7 @@ FormalRegExp RegExpOptimize::optimize( FormalRegExp const & regexp )
 
 void RegExpOptimize::optimize( FormalRegExpElement & element )
 {
-	FormalRegExpElement* optimized = optimize( & element );
+	FormalRegExpElement* optimized = RegExpOptimize::REG_EXP_OPTIMIZE.optimize( & element );
 
 	FormalRegExpAlternation * alternation = dynamic_cast<FormalRegExpAlternation *>( & element );
 	if( alternation ) {
@@ -98,7 +98,7 @@ void RegExpOptimize::optimize( FormalRegExpElement & element )
 
 UnboundedRegExp RegExpOptimize::optimize( UnboundedRegExp const & regexp )
 {
-	UnboundedRegExpElement* optimized = optimize( & regexp.getRegExp( ) );
+	UnboundedRegExpElement* optimized = RegExpOptimize::REG_EXP_OPTIMIZE.optimize( & regexp.getRegExp( ) );
 
 	UnboundedRegExp ret( std::move( * optimized ) );
 
@@ -108,7 +108,7 @@ UnboundedRegExp RegExpOptimize::optimize( UnboundedRegExp const & regexp )
 }
 
 void RegExpOptimize::optimize( UnboundedRegExpElement & element ) {
-	UnboundedRegExpElement* optimized = optimize( & element );
+	UnboundedRegExpElement* optimized = RegExpOptimize::REG_EXP_OPTIMIZE.optimize( & element );
 
 	UnboundedRegExpAlternation * alternation = dynamic_cast<UnboundedRegExpAlternation *>( & element );
 	if( alternation ) {
@@ -155,6 +155,8 @@ void RegExpOptimize::optimize( UnboundedRegExpElement & element ) {
 	return;
 }
 
+const RegExpOptimize RegExpOptimize::REG_EXP_OPTIMIZE;
+
 #include "RegExpOptimizeUnboundedPart.cxx"
 #include "RegExpOptimizeFormalPart.cxx"
 
diff --git a/alib2algo/src/regexp/RegExpOptimize.h b/alib2algo/src/regexp/RegExpOptimize.h
index eb0fb7e135..1cd12f7a68 100644
--- a/alib2algo/src/regexp/RegExpOptimize.h
+++ b/alib2algo/src/regexp/RegExpOptimize.h
@@ -59,77 +59,79 @@ namespace regexp {
  *
  *  - X1 : -> : a* + \e = a*
  */
-class RegExpOptimize : public regexp::VisitableRegExpBase::visitor_type
+class RegExpOptimize : public regexp::VisitableRegExpBase::const_visitor_type
 {
 public:
-    regexp::RegExp optimize( const regexp::RegExp & regexp );
+    static regexp::RegExp optimize( const regexp::RegExp & regexp );
 
-    regexp::UnboundedRegExp optimize( const regexp::UnboundedRegExp & regexp );
-    void optimize( regexp::UnboundedRegExpElement & regexp );
+    static regexp::UnboundedRegExp optimize( const regexp::UnboundedRegExp & regexp );
+    static void optimize( regexp::UnboundedRegExpElement & regexp );
 
-    regexp::FormalRegExp optimize( const regexp::FormalRegExp & regexp );
-    void optimize( regexp::FormalRegExpElement & regexp );
+    static regexp::FormalRegExp optimize( const regexp::FormalRegExp & regexp );
+    static void optimize( regexp::FormalRegExpElement & regexp );
 private:
-    regexp::FormalRegExpElement * optimize( regexp::FormalRegExpElement const * const & node );
+    regexp::FormalRegExpElement * optimize( regexp::FormalRegExpElement const * const & node ) const;
 
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpElement const * const & node );
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpAlternation const * const & node );
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpConcatenation const * const & node );
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpIteration const * const & node );
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpSymbol const * const & node );
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpEpsilon const * const & node );
-    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpEmpty const * const & node );
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpElement const * const & node ) const;
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpAlternation const * const & node ) const;
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpConcatenation const * const & node ) const;
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpIteration const * const & node ) const;
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpSymbol const * const & node ) const;
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpEpsilon const * const & node ) const;
+    regexp::UnboundedRegExpElement * optimize( regexp::UnboundedRegExpEmpty const * const & node ) const;
 
-    void Visit(void*, const regexp::UnboundedRegExp& regexp);
-    void Visit(void*, const regexp::FormalRegExp& regexp);
+    void Visit(void*, const regexp::UnboundedRegExp& regexp) const;
+    void Visit(void*, const regexp::FormalRegExp& regexp) const;
 
 private:
-    bool A1( regexp::UnboundedRegExpAlternation * const & node );
-    bool A2( regexp::UnboundedRegExpAlternation * const & node );
-    bool A3( regexp::UnboundedRegExpAlternation * const & node );
-    bool A4( regexp::UnboundedRegExpAlternation * const & node );
-    bool A5( regexp::UnboundedRegExpConcatenation * const & node );
-    bool A6( regexp::UnboundedRegExpConcatenation * const & node );
-    bool A7( regexp::UnboundedRegExpConcatenation * const & node );
-    bool A8( regexp::UnboundedRegExpConcatenation * const & node );
-    bool A9( regexp::UnboundedRegExpConcatenation * const & node );
-    bool A10( regexp::UnboundedRegExpAlternation * const & node );
-    bool A11( regexp::UnboundedRegExpIteration * const & node );
-    bool V1( regexp::UnboundedRegExpIteration * const & node );
-    bool V2( regexp::UnboundedRegExpAlternation * const & node );
-    bool V3( regexp::UnboundedRegExpIteration * const & node );
-    bool V4( regexp::UnboundedRegExpIteration * const & node );
-    bool V5( regexp::UnboundedRegExpAlternation * const & node );
-    bool V6( regexp::UnboundedRegExpAlternation * const & node );
-    bool V8( regexp::UnboundedRegExpConcatenation * const & node );
-    bool V9( regexp::UnboundedRegExpConcatenation * const & node );
-    bool V10( regexp::UnboundedRegExpIteration * const & node );
-
-    bool X1( regexp::UnboundedRegExpAlternation * const & node );
-
-    bool S( regexp::FormalRegExpElement * & node );
-    bool A1( regexp::FormalRegExpElement * & node );
-    bool A2( regexp::FormalRegExpElement * & node );
-    bool A3( regexp::FormalRegExpElement * & node );
-    bool A4( regexp::FormalRegExpElement * & node );
-    bool A5( regexp::FormalRegExpElement * & node );
-    bool A6( regexp::FormalRegExpElement * & node );
-    bool A7( regexp::FormalRegExpElement * & node );
-    bool A8( regexp::FormalRegExpElement * & node );
-    bool A9( regexp::FormalRegExpElement * & node );
-    bool A10( regexp::FormalRegExpElement * & node );
-    bool A11( regexp::FormalRegExpElement * & node );
-    bool V1( regexp::FormalRegExpElement * & node );
-    bool V2( regexp::FormalRegExpElement * & node );
-    bool V3( regexp::FormalRegExpElement * & node );
-    bool V4( regexp::FormalRegExpElement * & node );
-    bool V5( regexp::FormalRegExpElement * & node );
-    bool V6( regexp::FormalRegExpElement * & node );
-    bool V8( regexp::FormalRegExpElement * & node );
-    bool V9( regexp::FormalRegExpElement * & node );
-    bool V10( regexp::FormalRegExpElement * & node );
-
-    bool X1( regexp::FormalRegExpElement * & node );
+    bool A1( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool A2( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool A3( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool A4( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool A5( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool A6( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool A7( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool A8( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool A9( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool A10( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool A11( regexp::UnboundedRegExpIteration * const & node ) const;
+    bool V1( regexp::UnboundedRegExpIteration * const & node ) const;
+    bool V2( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool V3( regexp::UnboundedRegExpIteration * const & node ) const;
+    bool V4( regexp::UnboundedRegExpIteration * const & node ) const;
+    bool V5( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool V6( regexp::UnboundedRegExpAlternation * const & node ) const;
+    bool V8( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool V9( regexp::UnboundedRegExpConcatenation * const & node ) const;
+    bool V10( regexp::UnboundedRegExpIteration * const & node ) const;
+
+    bool X1( regexp::UnboundedRegExpAlternation * const & node ) const;
+
+    bool S( regexp::FormalRegExpElement * & node ) const;
+    bool A1( regexp::FormalRegExpElement * & node ) const;
+    bool A2( regexp::FormalRegExpElement * & node ) const;
+    bool A3( regexp::FormalRegExpElement * & node ) const;
+    bool A4( regexp::FormalRegExpElement * & node ) const;
+    bool A5( regexp::FormalRegExpElement * & node ) const;
+    bool A6( regexp::FormalRegExpElement * & node ) const;
+    bool A7( regexp::FormalRegExpElement * & node ) const;
+    bool A8( regexp::FormalRegExpElement * & node ) const;
+    bool A9( regexp::FormalRegExpElement * & node ) const;
+    bool A10( regexp::FormalRegExpElement * & node ) const;
+    bool A11( regexp::FormalRegExpElement * & node ) const;
+    bool V1( regexp::FormalRegExpElement * & node ) const;
+    bool V2( regexp::FormalRegExpElement * & node ) const;
+    bool V3( regexp::FormalRegExpElement * & node ) const;
+    bool V4( regexp::FormalRegExpElement * & node ) const;
+    bool V5( regexp::FormalRegExpElement * & node ) const;
+    bool V6( regexp::FormalRegExpElement * & node ) const;
+    bool V8( regexp::FormalRegExpElement * & node ) const;
+    bool V9( regexp::FormalRegExpElement * & node ) const;
+    bool V10( regexp::FormalRegExpElement * & node ) const;
+
+    bool X1( regexp::FormalRegExpElement * & node ) const;
+
+    static const RegExpOptimize REG_EXP_OPTIMIZE;
 };
 
 }
diff --git a/alib2algo/src/regexp/RegExpOptimizeFormalPart.cxx b/alib2algo/src/regexp/RegExpOptimizeFormalPart.cxx
index 9fc1361f41..8a6793f16e 100644
--- a/alib2algo/src/regexp/RegExpOptimizeFormalPart.cxx
+++ b/alib2algo/src/regexp/RegExpOptimizeFormalPart.cxx
@@ -1,4 +1,4 @@
-FormalRegExpElement* RegExpOptimize::optimize( FormalRegExpElement const * const & node )
+FormalRegExpElement* RegExpOptimize::optimize( FormalRegExpElement const * const & node ) const
 {
 	FormalRegExpElement* elem = node->clone();
 
@@ -10,7 +10,7 @@ FormalRegExpElement* RegExpOptimize::optimize( FormalRegExpElement const * const
 	return elem;
 }
 
-bool RegExpOptimize::S( FormalRegExpElement * & node )
+bool RegExpOptimize::S( FormalRegExpElement * & node ) const
 {
 	bool optimized = false;
 	FormalRegExpAlternation * alternation = dynamic_cast<FormalRegExpAlternation*>( node );
@@ -56,7 +56,7 @@ bool RegExpOptimize::S( FormalRegExpElement * & node )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A1( FormalRegExpElement * & n )
+bool RegExpOptimize::A1( FormalRegExpElement * & n ) const
 {
 	FormalRegExpAlternation * node = dynamic_cast<FormalRegExpAlternation *>( n );
 	if( ! node ) return false;
@@ -84,7 +84,7 @@ bool RegExpOptimize::A1( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A2( FormalRegExpElement * & n )
+bool RegExpOptimize::A2( FormalRegExpElement * & n ) const
 {
 	FormalRegExpAlternation * node = dynamic_cast<FormalRegExpAlternation *>( n );
 	if( ! node ) return false;
@@ -111,7 +111,7 @@ bool RegExpOptimize::A2( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A3( FormalRegExpElement * & n )
+bool RegExpOptimize::A3( FormalRegExpElement * & n ) const
 {
 	FormalRegExpAlternation * node = dynamic_cast<FormalRegExpAlternation *>( n );
 	if( ! node ) return false;
@@ -144,7 +144,7 @@ bool RegExpOptimize::A3( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A4( FormalRegExpElement * & n )
+bool RegExpOptimize::A4( FormalRegExpElement * & n ) const
 {
 	/*
 	 * two ways of implementing this opitimization:
@@ -173,7 +173,7 @@ bool RegExpOptimize::A4( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A5( FormalRegExpElement * & n )
+bool RegExpOptimize::A5( FormalRegExpElement * & n ) const
 {
 	FormalRegExpConcatenation * node = dynamic_cast<FormalRegExpConcatenation *>( n );
 	if( ! node ) return false;
@@ -201,7 +201,7 @@ bool RegExpOptimize::A5( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A6( FormalRegExpElement * & n )
+bool RegExpOptimize::A6( FormalRegExpElement * & n ) const
 {
 	FormalRegExpConcatenation * node = dynamic_cast<FormalRegExpConcatenation *>( n );
 	if( ! node ) return false;
@@ -234,7 +234,7 @@ bool RegExpOptimize::A6( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A7( FormalRegExpElement * & n )
+bool RegExpOptimize::A7( FormalRegExpElement * & n ) const
 {
 	FormalRegExpConcatenation * node = dynamic_cast<FormalRegExpConcatenation *>( n );
 	if( ! node ) return false;
@@ -253,7 +253,7 @@ bool RegExpOptimize::A7( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A8( FormalRegExpElement * & n )
+bool RegExpOptimize::A8( FormalRegExpElement * & n ) const
 {
 	return false;
 }
@@ -263,7 +263,7 @@ bool RegExpOptimize::A8( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A9( FormalRegExpElement * & n )
+bool RegExpOptimize::A9( FormalRegExpElement * & n ) const
 {
 	return false;
 }
@@ -273,7 +273,7 @@ bool RegExpOptimize::A9( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A10( FormalRegExpElement * & n )
+bool RegExpOptimize::A10( FormalRegExpElement * & n ) const
 {
 	/*
 	 * problem:
@@ -352,7 +352,7 @@ bool RegExpOptimize::A10( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A11( FormalRegExpElement * & n )
+bool RegExpOptimize::A11( FormalRegExpElement * & n ) const
 {
 	FormalRegExpIteration * node = dynamic_cast<FormalRegExpIteration *>( n );
 	if( ! node ) return false;
@@ -382,7 +382,7 @@ bool RegExpOptimize::A11( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V1( FormalRegExpElement * & n )
+bool RegExpOptimize::V1( FormalRegExpElement * & n ) const
 {
 	FormalRegExpIteration * node = dynamic_cast<FormalRegExpIteration *>( n );
 	if( ! node ) return false;
@@ -401,7 +401,7 @@ bool RegExpOptimize::V1( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V2( FormalRegExpElement * & n )
+bool RegExpOptimize::V2( FormalRegExpElement * & n ) const
 {
 	FormalRegExpAlternation * node = dynamic_cast<FormalRegExpAlternation *>( n );
 	if( ! node ) return false;
@@ -434,7 +434,7 @@ bool RegExpOptimize::V2( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V3( FormalRegExpElement * & n )
+bool RegExpOptimize::V3( FormalRegExpElement * & n ) const
 {
 	FormalRegExpIteration * node = dynamic_cast<FormalRegExpIteration *>( n );
 	if( ! node ) return false;
@@ -457,7 +457,7 @@ bool RegExpOptimize::V3( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V4( FormalRegExpElement * & n )
+bool RegExpOptimize::V4( FormalRegExpElement * & n ) const
 {
 	FormalRegExpConcatenation * node = dynamic_cast<FormalRegExpConcatenation *>( n );
 	if( ! node ) return false;
@@ -479,7 +479,7 @@ bool RegExpOptimize::V4( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V5( FormalRegExpElement * & n )
+bool RegExpOptimize::V5( FormalRegExpElement * & n ) const
 {
 	return false;
 }
@@ -489,7 +489,7 @@ bool RegExpOptimize::V5( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V6( FormalRegExpElement * & n )
+bool RegExpOptimize::V6( FormalRegExpElement * & n ) const
 {
 	return false;
 }
@@ -499,7 +499,7 @@ bool RegExpOptimize::V6( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V8( FormalRegExpElement * & n )
+bool RegExpOptimize::V8( FormalRegExpElement * & n ) const
 {
 	return false;
 }
@@ -509,7 +509,7 @@ bool RegExpOptimize::V8( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V9( FormalRegExpElement * & n )
+bool RegExpOptimize::V9( FormalRegExpElement * & n ) const
 {
 	return false;
 }
@@ -519,7 +519,7 @@ bool RegExpOptimize::V9( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V10( FormalRegExpElement * & n )
+bool RegExpOptimize::V10( FormalRegExpElement * & n ) const
 {
 	FormalRegExpAlternation * node = dynamic_cast<FormalRegExpAlternation *>( n );
 	if( ! node ) return false;
@@ -541,7 +541,7 @@ bool RegExpOptimize::V10( FormalRegExpElement * & n )
   * @param node FormalRegExpElement node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::X1( FormalRegExpElement * & n )
+bool RegExpOptimize::X1( FormalRegExpElement * & n ) const
 {
 	FormalRegExpAlternation * node = dynamic_cast<FormalRegExpAlternation *>( n );
 	if( ! node ) return false;
diff --git a/alib2algo/src/regexp/RegExpOptimizeUnboundedPart.cxx b/alib2algo/src/regexp/RegExpOptimizeUnboundedPart.cxx
index f375cbadfa..95f668405c 100644
--- a/alib2algo/src/regexp/RegExpOptimizeUnboundedPart.cxx
+++ b/alib2algo/src/regexp/RegExpOptimizeUnboundedPart.cxx
@@ -1,4 +1,4 @@
-UnboundedRegExpElement* RegExpOptimize::optimize( UnboundedRegExpElement const * const & node )
+UnboundedRegExpElement* RegExpOptimize::optimize( UnboundedRegExpElement const * const & node ) const
 {
 	const UnboundedRegExpAlternation * alternation = dynamic_cast<const UnboundedRegExpAlternation*>( node );
 	if( alternation )
@@ -28,7 +28,7 @@ UnboundedRegExpElement* RegExpOptimize::optimize( UnboundedRegExpElement const *
 }
 
 
-UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpAlternation const * const & node )
+UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpAlternation const * const & node ) const
 {
 	UnboundedRegExpAlternation* alt = new UnboundedRegExpAlternation( );
 
@@ -54,7 +54,7 @@ UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpAlternation co
 	return alt;
 }
 
-UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpConcatenation const * const & node )
+UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpConcatenation const * const & node ) const
 {
 	UnboundedRegExpConcatenation* concat = new UnboundedRegExpConcatenation( );
 
@@ -79,7 +79,7 @@ UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpConcatenation
 	return concat;
 }
 
-UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpIteration const * const & node )
+UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpIteration const * const & node ) const
 {
 	UnboundedRegExpIteration* iter = new UnboundedRegExpIteration(* optimize( node->element ) );
 
@@ -97,17 +97,17 @@ UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpIteration cons
 	return iter;
 }
 
-UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpSymbol const * const & node )
+UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpSymbol const * const & node ) const
 {
 	return node->clone( );
 }
 
-UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpEmpty const * const & node )
+UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpEmpty const * const & node ) const
 {
 	return node->clone( );
 }
 
-UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpEpsilon const * const & node )
+UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpEpsilon const * const & node ) const
 {
 	return node->clone( );
 }
@@ -117,7 +117,7 @@ UnboundedRegExpElement * RegExpOptimize::optimize( UnboundedRegExpEpsilon const
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A1( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::A1( UnboundedRegExpAlternation * const & node ) const
 {
 	bool optimized = false;
 
@@ -154,7 +154,7 @@ bool RegExpOptimize::A1( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A2( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::A2( UnboundedRegExpAlternation * const & node ) const
 {
 	std::function<bool( UnboundedRegExpElement const * const & a, UnboundedRegExpElement const * const & b )> cmp = [ ]( UnboundedRegExpElement const * const & a, UnboundedRegExpElement const * const & b ) -> bool { return *a < *b; };
 
@@ -170,7 +170,7 @@ bool RegExpOptimize::A2( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A3( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::A3( UnboundedRegExpAlternation * const & node ) const
 {
 	bool optimized = false;
 
@@ -201,7 +201,7 @@ bool RegExpOptimize::A3( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A4( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::A4( UnboundedRegExpAlternation * const & node ) const
 {
 	/*
 	 * two ways of implementing this opitimization:
@@ -234,7 +234,7 @@ bool RegExpOptimize::A4( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A5( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::A5( UnboundedRegExpConcatenation * const & node ) const
 {
 	bool optimized = false;
 
@@ -269,7 +269,7 @@ bool RegExpOptimize::A5( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A6( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::A6( UnboundedRegExpConcatenation * const & node ) const
 {
 	bool optimized = false;
 
@@ -295,7 +295,7 @@ bool RegExpOptimize::A6( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A7( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::A7( UnboundedRegExpConcatenation * const & node ) const
 {
 	bool optimized = false;
 
@@ -320,7 +320,7 @@ bool RegExpOptimize::A7( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A8( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::A8( UnboundedRegExpConcatenation * const & node ) const
 {
 /*
 	bool optimized = false;
@@ -368,7 +368,7 @@ bool RegExpOptimize::A8( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A9( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::A9( UnboundedRegExpConcatenation * const & node ) const
 {
 /*
 	bool optimized = false;
@@ -419,7 +419,7 @@ bool RegExpOptimize::A9( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A10( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::A10( UnboundedRegExpAlternation * const & node ) const
 {
 	bool optimized = false, optimizedIter = false;
 
@@ -495,7 +495,7 @@ bool RegExpOptimize::A10( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpIteration node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::A11( UnboundedRegExpIteration * const & node )
+bool RegExpOptimize::A11( UnboundedRegExpIteration * const & node ) const
 {
 	bool optimized = false;
 
@@ -526,7 +526,7 @@ bool RegExpOptimize::A11( UnboundedRegExpIteration * const & node )
   * @param node UnboundedRegExpIteration node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V1( UnboundedRegExpIteration * const & node )
+bool RegExpOptimize::V1( UnboundedRegExpIteration * const & node ) const
 {
 	// implemented in optimize( UnboundedRegExpIteration )
 
@@ -538,7 +538,7 @@ bool RegExpOptimize::V1( UnboundedRegExpIteration * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V2( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::V2( UnboundedRegExpAlternation * const & node ) const
 {
 	bool optimized = false;
 
@@ -615,7 +615,7 @@ bool RegExpOptimize::V2( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpIteration node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V3( UnboundedRegExpIteration * const & node )
+bool RegExpOptimize::V3( UnboundedRegExpIteration * const & node ) const
 {
 	UnboundedRegExpIteration* childIter = dynamic_cast<UnboundedRegExpIteration*>( node->element );
 	if( childIter )
@@ -635,7 +635,7 @@ bool RegExpOptimize::V3( UnboundedRegExpIteration * const & node )
   * @param node UnboundedRegExpIteration node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V4( UnboundedRegExpIteration * const & node )
+bool RegExpOptimize::V4( UnboundedRegExpIteration * const & node ) const
 {
 	// interpretation: if iteration's element is concat and every concat's element is iteration
 	UnboundedRegExpConcatenation* alt = dynamic_cast<UnboundedRegExpConcatenation*>( node->element );
@@ -663,7 +663,7 @@ bool RegExpOptimize::V4( UnboundedRegExpIteration * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V5( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::V5( UnboundedRegExpAlternation * const & node ) const
 {
 	bool optimized = false;
 
@@ -816,7 +816,7 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V6( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::V6( UnboundedRegExpAlternation * const & node ) const
 {
 	bool optimized = false;
 
@@ -967,7 +967,7 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V8( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::V8( UnboundedRegExpConcatenation * const & node ) const
 {
 	bool optimized = false;
 
@@ -1050,7 +1050,7 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpConcatenation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V9( UnboundedRegExpConcatenation * const & node )
+bool RegExpOptimize::V9( UnboundedRegExpConcatenation * const & node ) const
 {
 	bool optimized = false;
 
@@ -1115,7 +1115,7 @@ bool RegExpOptimize::V9( UnboundedRegExpConcatenation * const & node )
   * @param node UnboundedRegExpIteration node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::V10( UnboundedRegExpIteration * const & node )
+bool RegExpOptimize::V10( UnboundedRegExpIteration * const & node ) const
 {
 	// interpretation: if iter's child is alternation where its every child is iteration, then they do not have to be iteration
 	UnboundedRegExpAlternation* alt = dynamic_cast<UnboundedRegExpAlternation*>( node->element );
@@ -1143,7 +1143,7 @@ bool RegExpOptimize::V10( UnboundedRegExpIteration * const & node )
   * @param node UnboundedRegExpAlternation node
   * @return bool true if optimization applied else false
   */
-bool RegExpOptimize::X1( UnboundedRegExpAlternation * const & node )
+bool RegExpOptimize::X1( UnboundedRegExpAlternation * const & node ) const
 {
 	// theorem: In regexp like a* + \e, \e is described twice, first in a*, second in \e.
 	//  therefore we can delete the \e as it is redundant
-- 
GitLab