<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Model name (FSA uniform)
leader</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Solving the State Elimination Case Study using Epsilon</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Shekoufeh Kolahdouz-Rahimi sh.rahimi@eng.ui.ac.ir</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Bahman Zamani</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>MDSE Research Group Department of Software Engineering University of Isfahan</institution>
          ,
          <country country="IR">Iran</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Mohammadreza Sharbaf</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>1933</year>
      </pub-date>
      <volume>2</volume>
      <issue>26</issue>
      <abstract>
        <p>The transformation of a finite state automaton into an equivalent regular expression is a challenging topic which is presented in TTC 2017. This paper presents a solution to State Elimination case using the Epsilon framework. The State Elimination case study includes both a model to model and a model to text transformation, which aims to transform Finite State Automata (FSA) or Finite State Machines (FSM) into equivalent Regular Expressions (RE). This is a challenging and expensive transformation. In this paper, we provide a solution to the transformation problem which eliminates states in an iterative manner. Our solution is based on random selection of a state and eliminating it from FSA. The solution is available as a Github repository1. Our solution is implemented using Epsilon2 invoked from a Java application. Epsilon is an extensible set of languages and tools for model management which is built atop the Eclipse Modeling Framework (EMF) [1]. Epsilon can be used to perform all model management tasks, including in-place and out-place model transformations. Epsilon is an appropriate tool for solving the above mentioned case study that involves model modification, before generating equivalent regular expressions based on finite stated automata. The remainder of this paper is structured as follows. Section 2 provides an introduction to the fundamental parts of Epsilon which are used for solving this problem. Section 3 provides our solution to the case study. Evaluation of the proposed solution is presented in section 4. Finally, section 5 summarizes our findings.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Epsilon Transformation Language (ETL): ETL is a declarative model-to-model transformation
language, which inherits the imperative feature of EOL to perform complex transformations. It accepts multiple
input models and is able to generate multiple target models. However, for this solution, we only used a
single source and target model. Each ETL program consists of several ETL modules. A module can contain
any number of transformation rules, operations and optional pre and post blocks, which are executed before
and after the transformation rules, respectively.</p>
      <p>Epsilon Generation Language (EGL): EGL is a template-based language for text generation, which
facilitates the construction of model-to-text transformations. Each EGL template consists of static and
dynamic parts that reuses the EOL mechanism for defining declarative operations.</p>
      <p>The aforementioned languages are used to create scripts (Epsilon codes) that take one or more models and
transform them into another model or text. The ETL and EGL scripts can be executed with launch configuration
facilities or alternatively invoked directly from a Java program.
3</p>
    </sec>
    <sec id="sec-2">
      <title>Solving the State Elimination Case Study using Epsilon</title>
      <p>
        In TTC 2017 a state elimination case study [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] based on the state elimination algorithm for FSA has announced.
This case study includes a main task and two extensions. The main task is to convert a uniform FSA to the
equivalent RE. An FSA is uniformed if it has a unique initial state with no incoming transitions and a unique
final state with no outgoing transitions. A regular expression is a mathematical expression which specifies the
language generated or accepted by a uniform FSA. The first extension is to transform a non-uniform FSA into
a uniform one. The second extension is to convert a probabilistic FSA to a stochastic RE.
      </p>
      <p>The state elimination algorithm for the main task takes a uniform FSA and generates an equivalent regular
expression. In this paper the Epsilon framework is used to solve the main task and the first extension. In the
following sections the description of the solutions are provided in more detail.
3.1</p>
      <sec id="sec-2-1">
        <title>Overview of the Main Task Solution</title>
        <p>In order to solve the main task problem, the transformation specification takes the uniform FSA as input model,
and generates the equivalent regular expression as output model. The transformation eliminates each state
with corresponding transitions and adds a new equivalent transition for predecessor and successor states in each
iteration, until there is only one initial and one final state. In this solution the transformation chain includes
two main phases:</p>
        <p>Phase 1: Transformation of a uniform FSA to a generalized transition graph (GTG)</p>
        <p>Phase 2: Transformation of a GTG to a final regular expression
In the following section each phase is explained in more detail.</p>
      </sec>
      <sec id="sec-2-2">
        <title>Phase 1: Transformation of a uniform FSA to a GTG</title>
        <p>This phase is a model-to-model transformation, which is divided into three steps as follows:
Step 1: Creating a GTG, with initial and final states, and an unlabeled transition between them
Step 2: Selection and deletion of intermediate states (i.e., states other than initial and final) of FSA and
their incoming and outgoing transitions
Step 3: Labelled transition between initial and final states in GTG, equivalent to all transitions of the
input FSA
These steps are implemented in an ETL module, which consists of ETL rules and sets of operations. In the
following more details of this transformation is provided.</p>
      </sec>
      <sec id="sec-2-3">
        <title>Step 1: Creation of GTG</title>
        <p>In this step a GTG with a single initial and final state, and a single outgoing and incoming transitions is
generated. Listing 1 illustrates the implementation of this rule in ETL. In this rule the initial and final
states of input model is given to the transformation, and it then generates the model in the output with
initial state, final state and a transition between them. Calculation of transition label is performed in the
second and third steps.</p>
        <p>
          In this step all the intermediate states and related transitions are eliminated and new labeled transitions
corresponding to them are generated. The implementation of this step is provided in Listing 2. The EOL
operations and expressions are used here for identification and deletion of the elements in the source model.
In order to calculate the label of transition it is required to delete each intermediate state of FSA (for instance
K), and transform its transitions into a new one with respect to its predecessor (P) and successor states (Q).
These states are detected by examining the incoming and outgoing transitions for the intermediate state.
In addition it is required to check the existence of loop, i.e., a transition with an identical initial and final
state, in the selected state (K) and to identify the direct transitions between predecessor (P) and successor
(Q) states. Following that all the transitions between predecessor (P) and successor states are eliminated
and new transitions are generated. Finally a transition is labeled according to the ( pk *kk kq) formula [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
var lbl_PKQ = "" ;
var flag_lbl_PKQ = false ;
for(tp in P.outgoing.select(tr|tr.target == K)){
for(tq in Q.incoming.select(tr|tr.source == K)){
if(flag_lbl_PKQ == true)
        </p>
        <p>lbl_PKQ += "+" ;
lbl_PKQ += tp.label + lbl_K_Self_Loop + tq.label ;
flag_lbl_PKQ = true ;
}
}
delete tp ;</p>
        <p>Listing 2: EOL expression to calculate the label of new transitions corresponding to eliminated states</p>
      </sec>
      <sec id="sec-2-4">
        <title>Step 3: Labelling the unlabeled transition in the GTG</title>
        <p>In this step a single initial and final state with one or more transitions between them are remained in FSA.
Additionally, it may be possible for each state to have loop. The transformation in this step generates a
label equivalent to all the labels of transitions existed or generated in the previous step based on the state
elimination rule. This label is then attached to the new transition between initial and final states in the
GTG. The EOL statements are used for implementation of this part in the post condition of ETL module.</p>
      </sec>
      <sec id="sec-2-5">
        <title>Phase 2: Transformation of a GTG to a final regular expression</title>
        <p>In this phase the generated GTG is transformed to a textual file that only contains a final regular expression,
which is implemented with an EGL script as indicated in listing 3. EGL has been used to transform model to
textual artifact and automatically generate a textual file.
3.2</p>
      </sec>
      <sec id="sec-2-6">
        <title>Overview of the First Extension Solution</title>
        <p>For the main task it was assumed that the input FSA is uniformed. However, in the first extension it is possible
to have more than one initial and final states. The extension is a model-to-model transformation. In our solution</p>
        <sec id="sec-2-6-1">
          <title>Phase 1 Phase 2</title>
        </sec>
      </sec>
      <sec id="sec-2-7">
        <title>Main Task</title>
        <p>Transformation of a Uniform FSA to a GTG
Transformation of a GTG to a final regular expression
Overall solution</p>
      </sec>
      <sec id="sec-2-8">
        <title>Extension 1</title>
        <p>Overall solution</p>
        <sec id="sec-2-8-1">
          <title>Medium High Medium</title>
        </sec>
        <sec id="sec-2-8-2">
          <title>Medium</title>
          <p>we have used ETL and EOL to solve this extension. In order to apply the state elimination algorithm to this
cases, we should add a new initial state and change its isInitial property to true. Following that, a transition
with a null label should be inserted from the new initial state to each original initial states and their isInitial
property is changed to false. For the elimination of final states into a single state, we have followed a similar
procedure.</p>
          <p>In the proposed solution an operation is added to the ETL transformation for transforming non-uniform to
uniform FSA, which generates a single initial and final state with its corresponding transitions. This operation
is called in the pre-condition of the ETL module written for this extension.
3.3</p>
        </sec>
      </sec>
      <sec id="sec-2-9">
        <title>Execution of the Solution</title>
        <p>The proposed solution in this paper requires Epsilon Core for execution of EOL, ETL and EGL scripts. Therefore,
we use the Eclipse Distribution which contains most of the required prerequisites of Epsilon. The complete
solution uses the ANT Epsilon tasks to execute transformation chains in the specific workflow and enables the
user to run it from the Eclipse toolbar.
4</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Evaluation</title>
      <p>4.1</p>
      <sec id="sec-3-1">
        <title>Correctness</title>
        <p>
          In the case study description [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] a set of quality characteristics with its measurable attributes are defined for
systematic evaluation of each solution. In the following sections the evaluation of our solution according to the
correctness, suitability, performance and scalability are provided.
        </p>
        <p>According to the evaluation criteria, a solution for the main task is correct when the RE obtained as a final
result of the State Elimination passes all sets of positive and negative test cases. Each test case is a set of
strings to which the produced Regular Expression should match or should not match, which can be checked by
the Evaluation Framework provided in the case description. Regarding the result of Evaluation Framework, our
main task solution is correct and passed all the positive and negative test cases.</p>
        <p>Additionally, the correctness of the solution for the first extension task generates a uniform FSA which is
equivalent to the input FSA with some initial and final states. The Epsilon solution in this paper generates a
correct output model for each input model in the extension part.
4.2</p>
      </sec>
      <sec id="sec-3-2">
        <title>Suitability</title>
        <p>The suitability in this case study is evaluated by the level of abstraction of transformation language, which
is High for primarily declarative language and Low for primarily imperative language. Although our solution
combines imperative EOL statements with ETL and uses EGL script as textual file generator which are primarily
declarative, the overall level of abstraction in this solution is Medium. Table 1 shows the abstraction level for
each phase of the main task, and an overall value for solutions of the main task and first extension.
The solution performance should be measured as the seconds spent for executing two transformation phases with
the provided input models. This includes the loading of input FSA models and generating a text file as the
equivalent regular expression output. The following table shows the execution time for our solution in seconds.
We measured execution time automatically by Ant builder. This measures are the average execution time of ten
consecutive executions of Ant builder with the specified input model. All tests were carried out on a standard
Windows 7 PC using an Intel R CoreTM i7 with 3.6 GHz processor and 8GB RAM.</p>
        <p>Correct
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes</p>
        <p>Execution Time (s)
0.1476
0.1617
0.1769
0.2252
0.2398
0.3877
0.3639
0.4528
0.71
1
2
2
7
23
29
31
341.6
920.8
9834.34
102602</p>
      </sec>
      <sec id="sec-3-3">
        <title>Scalability</title>
        <sec id="sec-3-3-1">
          <title>Leader6_6</title>
          <p>4.4</p>
        </sec>
      </sec>
      <sec id="sec-3-4">
        <title>Scalability</title>
        <p>5</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Conclusion References</title>
      <p>According to the evaluation criteria, scalability is a model with a maximum number of states which is correctly
converted to an equivalent regular expression. According to the table 2 the transformation generates result for
all the test cases specially for model leader6_6 with 234210 states.</p>
      <p>In this paper we used Epsilon languages to transform a finite state automaton into an equivalent regular
expression. The suitability of transformation languages in this solution is medium for implementation of the main
task and first extension. Transformation generates correct results for all the test cases and the result of
execution is extensively better than the results provided in the case description. Additionally, the scalability of
transformation is high as it managed to execute the largest test case with 234210 states.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>D.</given-names>
            <surname>Steinberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Budinsky</surname>
          </string-name>
          , E. Merks, and
          <string-name>
            <given-names>M.</given-names>
            <surname>Paternostro</surname>
          </string-name>
          , EMF: eclipse modeling framework.
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Kolovos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Rose</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Paige</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Garcıa-Domınguez</surname>
          </string-name>
          ,
          <source>The Epsilon Book</source>
          .
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>S.</given-names>
            <surname>Getir</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. A.</given-names>
            <surname>Vu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Peverali</surname>
          </string-name>
          , and T. Kehrer, “
          <article-title>State Elimination as Model Transformation Problem,” in Proceedings of the 10th Transformation Tool Contest, a part of the Software Technologies: Applications and Foundations (STAF 2017) federation of conferences (A</article-title>
          .
          <string-name>
            <surname>Garcia-Dominguez</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <string-name>
            <surname>Hinkel</surname>
          </string-name>
          , and F. Krikava, eds.),
          <source>CEUR Workshop Proceedings</source>
          , CEUR-WS.org,
          <year>July 2017</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>