<!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 />
    <article-meta>
      <title-group>
        <article-title>EARS-CTRL: Generating Controllers for Dummies</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Alistair Mavin Rolls-Royce Derby</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>
        <contrib contrib-type="author">
          <string-name>UK alistair.mavin@rolls-royce.com</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>Levi L u ́cio Model-Based Software Engineering fortiss GmbH Munich</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Saad Bin Abid Model-Based Software Engineering fortiss GmbH Munich</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Salman Rahman Technische Universita ̈t Mu ̈nchen Munich</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>-In this paper we present the EARS-CTRL tool for synthesizing and validating controller software for embedded systems. EARS-CTRL has as starting point requirements written in (English) natural language, more specifically in the EARS (Easy Approach to Requirements Syntax) language invented at Rolls-Royce and currently in use at numerous organizations around the world. After expressing the requirements in English, the requirements engineer can produce the controller code at the press of a button. EARS-CTRL then provides facilities for validating the generated controller that allow step-by-step simulation or test-case generation using MATLAB Simulink. Index Terms-Software Controllers, Natural Language, Code Synthesis, MathLab Simulink</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
      <p>
        In this paper we describe the EARS-CTRL tool for
building and verifying discrete-event software controllers.
EARSCTRL has as starting point the EARS (Easy Approach to
Requirements Syntax) language. EARS was created at
RollsRoyce to improve the expression of natural language
requirements [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] and can be seen as a way to “gently” constrain
English. The application of EARS produces requirements in
a small number of patterns. EARS copes well with large
specifications of requirements for several domains [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ].
EARS is also an effective way of reducing many of the
problems that plague requirements documents written using
unconstrained natural language [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
      <p>With the EARS-CTRL tool we make a step in the direction
of controller construction using natural language as the central
specification. After specifying the vocabulary to be used in the
specification, a requirements engineer writes the specification
using EARS templates. Then, at the press of a button, the
controller is synthesized. Simulation and test case generation
panels allow the requirements engineer to immediately
experiment with and validate the controller.</p>
      <p>
        This paper builds on a previous article [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. Our new
contributions are a revision of the requirements language of
EARS-CTRL, which is now has exactly the same syntax
as the EARS language presented in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. We do so by
      </p>
      <p>
        The work presented in this paper was developed for the “IETS3” project,
funded by the German Federal Ministry of Education and Research under
code 01IS15037B.
improving the coverage of the semantic gap between EARS
and the underlying logical formalism used by the controller
synthesizer. We now also offer the possibilities of simulating
requirements specifications as well as of generating test cases.
The EARS-CTRL tool is freely available as a GitHub project
at [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
    </sec>
    <sec id="sec-2">
      <title>II. HIGHLIGHTS</title>
      <sec id="sec-2-1">
        <title>A. “Real” EARS</title>
        <p>EARS was not originally built to describe requirements at
a level where they can automatically be transposed into a
computer application. As such, an effort had to be made in
order to overcome the semantic gap between the structured
but non-formal nature of EARS and the strictly formal nature
of the Linear Temporal Logic (LTL) formalism needed by the
automated synthesis mechanisms. In particular, our work uses
the GXW subset of LTL as that subset is supported by the
autoCode4 tool we use for synthesizing controllers.</p>
        <p>
          Figure 1 illustrates a set of EARS-CTRL requirements for
the software controller for a sliding door. By remaining as
close as possible to the original EARS syntax our editor allows
building requirements as correct English sentences that can
easily be written and understood by humans. In fact, given
the requirements stated in figure 1, no additional explanations
are necessary for a human to understand the behavior of the
sliding door controller that should be generated. In [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] we have
presented a previous version of EARS-CTRL which included
templates that, although not part of the original EARS, had
been introduced to simplify translation into LTL. In particular
we had introduced the possibility of adding an until segment
at the end of requirements which is not standard EARS and
which we have removed in the current version of the tool. The
work of matching the syntax of EARS-CTRL closer to “real”
EARS while preserving a semantically meaningful translation
into LTL was done together with Alistair Mavin, the co-author
of this paper who is also the lead author of EARS [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ].
Our rationale is that, by remaining as faithful as possible
to the original EARS syntax, we: 1) benefit from all the
advantages of using EARS already investigated and described
in the literature [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ], [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]; and 2) provide to Rolls-Royce and
potentially other companies a tool that can immediately be
used by engineers trained in the use of EARS.
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>B. A Push-Button Approach</title>
        <p>
          EARS-CTRL can synthesize software controllers directly
from EARS requirements, at the push of a button. Such
syntheses are produced by the autoCode4 [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] tool in the form
of a synchronous dataflow (SDF) diagram which our tool can
display graphically.
        </p>
        <p>C. Validation</p>
        <p>
          1) Well-Formedness by Construction: In order to build
requirements model illustrated in figure 1 it is necessary to
firstly build a glossary for the controller. Glossaries are specific
to EARS-CTRL and are not part of the EARS language
described in [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. An EARS-CTRL glossary identifies the
components of the system to be controlled. Each one of
those components contains actuators and (possibly) sensors
that will be used by the controller logic as outputs to and
inputs from the real system. The vocabulary defined in the
glossary is proposed to the requirements engineer by the
EARS-CTRL IDE in order to fill in the placeholders of
an EARS template when a new requirement is being
written. Because well-formedness is enforced by construction,
requirement specifications written in EARS-CTRL are always
syntactically correct. Once a controller has been synthesized
from a set of EARS requirements, it becomes important to
understand whether it behaves as expected. In order to do so
we have used the Simulink engine [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] as a simulation
backend. In figure 2 we display the EARS-CTRL panel that allows
“playing” the controller by providing a sequence of inputs
manually. Outputs are incrementally added to the panel as new
inputs are provided by the requirements engineer. Note that
the simulation panel dynamically displays the sensors of the
controller being simulated, as can be seen in figure 2 for the
sliding doors example.
        </p>
        <p>2) Generation of Test Cases: EARS-CTRL allows
generating test cases directly from the EARS requirements. A test
case consists of a sequence of hinput, outputi pairs, where
each input is a vector of sensor states and each output a vector
of actuator states. Note that individual sensors and actuators
can assume two states: ON or OFF. Test case generation is
configured by three parameters:
• Maximum test case length: defines the maximum length
of the hinput, outputi pair sequences to be generated.
• Allow parallel inputs: enables or disables the possibility
of having more than one sensor being active for inputs
in the test case.
• Allow repeated inputs: enables or disables having
repeated inputs in a test.</p>
        <p>Test cases generated by EARS-CTRL can serve two purposes:
firstly, they are traces of execution of the synthesized controller
and can be used as witnesses of correct/incorrect behavior;
secondly, it may be that the synthesizer is not trusted for
generating controllers used in production: in this case the
synthesized controller can behave as an oracle to generate test
cases for a controller implemented using alternative means.</p>
      </sec>
      <sec id="sec-2-3">
        <title>D. Code Generation</title>
        <p>Although it is not possible to generate C code for the
controller directly from EARS-CTRL, this can be achieved
by directly running Simulink’s code generator on the Simulink
model obtained from an EARS-CTRL requirements
specification. This possibility is particularly important for our next
steps in our collaboration with Rolls-Royce as we wish to
experiment with running the synthesized controllers in real or
simulated execution environments.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>III. ARCHITECTURE</title>
      <p>In figure 3 we depict the architecture of the EARS-CTRL
tool, its main components and the artifacts those components
they exchange. The paragraphs below are numbered such
that each description can be matched to the process-related
components of the tool depicted in figure 3. Letter-labels are
used in figure 3 to refer to data artifacts.</p>
      <p>
        a) Editors and Control Panels: The requirements
editor, the glossary editor, the simulation and test generation
control panels and the synchronous data-flow diagram
visualizer (respectively noted (a), (b), (c) and (d) in figure 3)
have all been built as domain-specific languages (DSLs)
in the Meta Programming System (MPS) tool [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. MPS is
both a projectional editor and a domain-specific language
workbench. Domain-specific languages in MPS are composed
of an abstract syntax, also known as meta-model, and a
concrete syntax. The concrete syntax allows displaying and/or
editing the information present in a model, as depicted for
instance in figures 1 and 2. Note that because MPS is a
projectional editor, the abstract syntax is directly edited
which avoids the explicit or implicit intermediate step where
the concrete syntax is parsed. A consequence of this is for
example the fact that when a component’s name is updated
an EARS-CTRL glossary, that change will immediately be
reflected in any requirements that refer to that component
name.
      </p>
      <p>b) From EARS to Lineal Temporal Logic: Let us
consider the requirement Req1 which is part of the specification
of the sliding doors controller in figure 1:</p>
      <sec id="sec-3-1">
        <title>When object proximity sensor is activated then the automatic door controller shall open door.</title>
        <p>This requirement, taken in isolation, translates to the following
LTL formula:</p>
        <p>[](objectproximitysensorisactivated ! dooropen)
which, if one takes into consideration the semantics of the
! operator as “implies”, is the expected logical meaning of
Req1. All EARS templates, when taken in isolation, can be
directly translated into LTL and propositional logic in such
a straightforward manner. However, when one translates the
whole set of requirements for the automatic door in 1 into
LTL, the result for Req1 will be as follows:
[](objectproximitysensorisactivated ! (dooropen W
(dooropeninglimitsensorisactivated _ timerexpires
_ doorclosinglimitsensorisactivated)))</p>
        <p>This is due to the fact that the requirements specify
behaviors that are interwined during execution. For example,
from Req1 in figure 1 we know that if the object proximity
sensor is activated, the doors will open. We also know
from Req2 that, when the opening limit reached sensor is
activated, the doors will stop. Without additional information,
the autoCode4 synthesis tool identifies a contradition in these
two requirements since, if the two sensors are activated during
the same execution, the doors will logically simultaneously
open and close. In order to avoid such contradictions it
becomes necessary to establish a temporal dependency
between the behaviors specified by the requirements. To
achieve this our tool performs a static analysis of the
requirements in order to identify such dependencies and to
add this information to the generated LTL specification. This
additional contextual information in the generated LTL is
clear from the second translation above: the door will only
open, until (denoted by the “W” operator) the door opening
limit reached sensor is activated, or other events stated in
door-related requirements occur.</p>
        <sec id="sec-3-1-1">
          <title>c) Synthesizing a Controller using autoCode4:</title>
          <p>Controller synthesis is achieved via autoCode4’s Java API.
The LTL specification obtained as explained in section III-0b
is passed into the synthesizer, which returns a synchronous
data-flow (SDF) diagram as a Java object instance. The
SDF diagram is then rebuilt as a visual model which is
an instance of the synchonous data-flow diagram visualizer
DSL (identified by label (e) in figure 1). Such a visual
model provides the requirements engineer with a graphical
and technical view of the synthesized controller as a set
of blocks and wires, which can be used as a debugging artifact.</p>
        </sec>
        <sec id="sec-3-1-2">
          <title>d) Simulation and Test Generation using Simulink:</title>
          <p>
            The SDF diagram obtained from autoCode4 consists, for
short, of a set of synchronized blocks that perform arithmetic,
logical or other functions on input signals and return the result
as output signals. The controller’s inputs and outputs are also
themselves represented as blocks. The fashion in which blocks
are synchronized is declared by connecting those blocks’
inputs and outputs via wires. In order to simulate
EARSCTRL specifications we have built a translator from such
SDF diagrams onto Simulink models (label (e) in figure 1).
Given that the SDF formalism is very similar to the Simulink
formalism, the structural translation is one-to-one. However,
only a subset of all blocks present in the SDF specifications
that are produced by autoCode4 is available off-the-shelf in
Simulink. As such, a number of stateful Simulink blocks had
to be built by us to mimic the semantics of some of the
blocks present in SDF specifications. The EARS-CTRL IDE
communicates with Simulink via the matlabcontrol [
            <xref ref-type="bibr" rid="ref3">3</xref>
            ] Java
API.
          </p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>IV. RELATED WORK</title>
      <p>
        Given the recent fast-paced development of Artificial
Intelligence relying on increasingly powerful hardware, a number
of projects have devoted effort to the generation of controllers
from requirements. The ARSENAL project [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] has as starting
point specifications written in arbitrary natural language and
uses the GR-1 [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] synthesizer for automatically building
controllers. In [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] the authors also use the GR-1 synthesizer
to automatically build robot controllers. The work of Yan et.
al. [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] takes as inputs full LTL specifications and includes
features such as the use of dictionaries for automatically derive
relations between terms, or guessing the I/O partitioning that
allow detecting inconsistencies in the specifications. The
commercial argosym STIMULUS tool [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], while not based on AI
algorithms from controller synthesis, is a commercial platform
that allows specifying requirements in a formal language using
a close-to natural language syntax. Requirements expressed
in STIMULUS can be simulated and test cases can also be
directly generated from the requirements.
      </p>
      <p>
        Our approach differs from the GR-1-based projects
mentioned above in the sense that we do not aim at applying
pure natural language parsing to arbitrary requirements. Using
EARS allows us to provide the readability of the English
language while gently constraining it to fit the domain of
expressing requirements. Also, rather than using the full
expressiveness of LTL, we have restricted our approach to
the GXW subset of LTL which is handled by the autoCode4
tool. We then directly generate controllers as SDF diagrams,
which are easy to inspect and to simulate. GR-1- or bounded
synthesis [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]-based tools typically produce controllers as
BDD or explicit state machine structures that can be very large
and difficult to inspect or simulate.
      </p>
      <p>Regarding the STIMULUS tool, our approach was
conceptually though of starting from an opposite direction – while
STIMULUS essentially uses as central formalism state
machines wrapped by a syntactic-sugar English-like specification
language, EARS-CTRL uses a constrained version of the
English language. We have purposefully placed EARS at the
center on our tool – the goal has been to adapt the subset of
LTL used by autoCode4 to EARS and to remain unbiased
towards the formalisms “under the hood”. STIMULUS relies
on the state machines underlying the requirements to allow
simulation as in fact the approach’s goal is to verify
requirements and not to synthesize usable controllers.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <article-title>[1] Ears-ctrl github project</article-title>
          . https://github.com/saadbinabid1/ EARS-CTRLReqAnalysis/.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <article-title>[2] Matlab simulink</article-title>
          . https://de.mathworks.com/products/simulink.html/.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <article-title>[3] matlabcontrol java api</article-title>
          . https://code.google.com/archive/p/ matlabcontrol/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Meta</given-names>
            <surname>Programming</surname>
          </string-name>
          <article-title>System</article-title>
          . https://www.jetbrains.com/mps/.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>C.-H. Cheng</surname>
            , E. Lee, and
            <given-names>H.</given-names>
          </string-name>
          <string-name>
            <surname>Ruess</surname>
          </string-name>
          . autoCode4:
          <article-title>Structural Reactive Synthesis</article-title>
          .
          <source>In TACAS'17</source>
          . Tool available at: http://autocode4.sourceforge.net.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>S.</given-names>
            <surname>Ghosh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Elenius</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Lincoln</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Shankar</surname>
          </string-name>
          , and
          <string-name>
            <given-names>W.</given-names>
            <surname>Steiner</surname>
          </string-name>
          . ARSENAL:
          <article-title>Automatic Requirements Specification Extraction from NL</article-title>
          .
          <string-name>
            <surname>In</surname>
            <given-names>NFM</given-names>
          </string-name>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>B.</given-names>
            <surname>Jeannet</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Gaucher</surname>
          </string-name>
          .
          <source>Debugging Embedded Systems Requirements with STIMULUS: an Automotive Case-Study. In 8th European Congress on Embedded Real Time Software and Systems (ERTS</source>
          <year>2016</year>
          ), TOULOUSE, France, Jan.
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>H.</given-names>
            <surname>Kress-Gazit</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. E.</given-names>
            <surname>Fainekos</surname>
          </string-name>
          , and
          <string-name>
            <given-names>G. J.</given-names>
            <surname>Pappas</surname>
          </string-name>
          . Translating Structured English to Robot Controllers.
          <source>Advanced Robotics</source>
          ,
          <volume>22</volume>
          (
          <issue>12</issue>
          ):
          <fpage>1343</fpage>
          -
          <lpage>1359</lpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>L.</given-names>
            <surname>Lu</surname>
          </string-name>
          ´cio, S. Rahman, C. Cheng, and
          <string-name>
            <given-names>A.</given-names>
            <surname>Mavin</surname>
          </string-name>
          .
          <article-title>Just formal enough? automated analysis of EARS requirements</article-title>
          .
          <source>In NASA Formal Methods - 9th Intl. Symposium, NFM</source>
          <year>2017</year>
          , Moffett Field, CA, USA, May
          <volume>16</volume>
          -18,
          <year>2017</year>
          , Proceedings,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>A.</given-names>
            <surname>Mavin</surname>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Wilkinson. Big</surname>
          </string-name>
          <article-title>Ears (The Return of ”Easy Approach to Requirements Engineering”)</article-title>
          .
          <source>In RE. IEEE</source>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>A.</given-names>
            <surname>Mavin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Wilkinson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Gregory</surname>
          </string-name>
          , and
          <string-name>
            <given-names>E.</given-names>
            <surname>Uusitalo</surname>
          </string-name>
          .
          <article-title>Listens Learned (8 Lessons Learned Applying EARS)</article-title>
          .
          <source>In RE. IEEE</source>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>A.</given-names>
            <surname>Mavin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Wilkinson</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Novak</surname>
          </string-name>
          .
          <article-title>Easy Approach to Requirements Syntax (EARS)</article-title>
          .
          <source>In RE. IEEE</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>N.</given-names>
            <surname>Piterman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pnueli</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Y.</given-names>
            <surname>Saar</surname>
          </string-name>
          .
          <article-title>Synthesis of reactive (1) designs</article-title>
          . In VMCAI. Springer,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>S.</given-names>
            <surname>Schewe</surname>
          </string-name>
          and
          <string-name>
            <given-names>B.</given-names>
            <surname>Finkbeiner</surname>
          </string-name>
          .
          <article-title>Bounded Synthesis</article-title>
          . In ATVA. Springer,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>R.</given-names>
            <surname>Yan</surname>
          </string-name>
          , C. Cheng, and
          <string-name>
            <given-names>Y.</given-names>
            <surname>Chai</surname>
          </string-name>
          .
          <article-title>Formal Consistency Checking Over Specifications in Natural Languages</article-title>
          .
          <source>In DATE</source>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>