<!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>A Review of Formal Methods for Intelligent Adaptive Systems with an Application to Intelligent Water Level Monitoring System*</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Pranali S. Tekale,</string-name>
          <email>tekale.pranali@gmail.com</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ramakalyan Ayyagari,</string-name>
          <email>rkalyn@nitt.edu</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>S D Sudarsan ,</string-name>
          <email>sudarsan.sd@in.abb.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Raoul Jetley,</string-name>
          <email>raoul.jetley@in.abb.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ABB Bangalore</institution>
          ,
          <country country="IN">India.</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>NIT Trichy</institution>
          ,
          <country country="IN">India.</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Intelligent adaptive systems are sensitive to their environment, which enables them to address the complexity of modern software systems. As a result, they are able to adapt to changes in the environment autonomously. Numerous algorithms are available to provide adaptivity to the system. However, formal methods have not been widely used for specification and verification of adaptive systems. Our main aim is application of formal methods to the intelligent adaptive systems to ensure correctness of system design. In this paper, we present a case study of intelligent water level monitoring system. UPPAAL model checking tool is used for formal specification, modelling and verification of the presented case study. Also counter example analysis is used to identify sources of two problems in the system design.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        1. INTRODUCTION
Intelligent adaptive systems adapt to changing
environments as well as the users they interact with, so
that they can communicate efficiently and naturally with
them. They are expected not only to automatically acquire
knowledge through a variety of intelligent tools and
technologies but also to learn and optimize their behavior
over time. They can be used in a large number of
applications such as intelligent transportation systems,
smart Grid, smart logistics, smart environmental
protection, smart home, smart medical, smart safety,
industrial automation, smart agriculture etc. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
∗Copyright ©2017 for the individual papers by the papers’ authors.
Copying permitted for private and academic purposes. This volume is
published and copyrighted by its editors.
      </p>
      <p>In this paper, we present a case study on water level
monitoring system for residential consumers. It uses
UPPAAL model checking tool for Formal specification and
verification of the proposed system. This system has three
different monitoring mechanisms which ensure its
adaptive behavior in the diverse changing environments.
These environments are not necessarily exhaustive as
exemplified in the paper. The remainder of the paper is
organized as follows. Section 2 provides the background
including a short introduction to formal methods and its
key elements. Section 3 presents the case study on
intelligent water level monitoring system. Formalization
of the case study using UPPAAL is explained in detail in
section 4. Section 5 concludes the paper.</p>
      <p>The architecture proposed in the paper is the very
basic architecture but covers a large class of problems
(such as factory automation, oil and gas refineries, mining
operations, power generation and distribution, to name
just a few).</p>
    </sec>
    <sec id="sec-2">
      <title>2. BACKGROUND</title>
    </sec>
    <sec id="sec-3">
      <title>2.1 Formal methods</title>
      <p>
        Formal methods are mathematics based techniques for
describing system properties. They provide frameworks
within which people can specify, develop, and verify
systems in a systematic manner. They help identify errors,
ambiguities and problems in the early stages of the system
development process [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <sec id="sec-3-1">
        <title>Key elements of Formal methods</title>
        <p>2.1.1</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Formal Specification</title>
      <p>
        It is a complete representation of the system under study
using certain formal specification languages. They provide
a complete syntax, semantics and pragmatics for its
representation. Different specification languages used in
developing formal methods are abstract state machines,
CSP,LOTOS, RAISE, Rebeca modeling language, SPARK
Ada, VDM and Z notation etc.[
        <xref ref-type="bibr" rid="ref2 ref3">2,3</xref>
        ].
2.1.2
In general a model is a mathematical representation of the
system under study. They can of different types such as
abstract state machine models, automata based models,
object oriented models etc. Further automata based
models can make use of deterministic finite automata,
nondeterministic finite automata, timed automata, Buchi
automata, ω-automata etc. These models are used for
modelling the formally specified system.
      </p>
    </sec>
    <sec id="sec-5">
      <title>2.1.3 Formal Verification</title>
      <p>
        It is a process of confirming that system under study
satisfies its specifications or requirements [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. It can be
achieved by various approaches such as simulation,
theorem proving and model checking. They are mainly
used to check different system requirements like safety,
liveness, deadlock freeness and reachability requirements.
      </p>
    </sec>
    <sec id="sec-6">
      <title>2.1.4 Counterexample analysis</title>
      <p>A counterexample has been generated by the model
checker, when certain requirements are not satisfied
during verification process. It gives relevant information
to identify sources of problems</p>
    </sec>
    <sec id="sec-7">
      <title>3. THE CASE STUDY ON INTELLIGENT WATER</title>
    </sec>
    <sec id="sec-8">
      <title>LEVEL MONITORING SYSTEM</title>
      <p>4.</p>
      <p>Generally residential consumers have an overhead tank
whose size depends upon their requirement. They use an
electric motor to pump the water from underground to
this tank. Since monitoring water level in the tank is a
tedious task which requires efficient use of the motor for
uninterrupted utility, instead of using conventional
ONOFF control strategy we should incorporate machine
control. This eliminates requirement of the human in the
loop. Therefore the system becomes automatic. Moreover
functionality and adaptive behavior of the system can be
separated in the design process.</p>
    </sec>
    <sec id="sec-9">
      <title>3.1 Functionality of the system</title>
    </sec>
    <sec id="sec-10">
      <title>3.1.1 Principle of working of the monitoring unit. water level</title>
      <p>The working principle of the proposed system is
illustrated in the fig.1. This construction follows a top
down self-adaptive approach. Here the system is
centralized, and operates with the guidance of a central
control unit. It assesses its own behavior in the current
environment and adapts itself whenever its monitoring
and analysis systems indicate that it should do so. It
consists of four main blocks - the tank, the motor, the
sensors and the central adaptive control unit. Here, tank is
presumed to be subjected to a number of disturbances by
its environment. They are explained in the subsequent
sections in the paper.</p>
      <p>When water in the tank goes below the specified low
level, the motor will be automatically switched ON by the
proposed control circuit. Likewise, as soon as water
reaches the specified high level in the tank, the control
circuit should switch OFF the motor.</p>
      <p>High level and low level of the tank are first fixed
based on the height and size of the tank for a typical
household application. Sensors are presumed to have been
fixed at these positions, and they play the role of feedback
element in the closed-loop control system. Thus, the
construction in fig.1 is a feedback system as well.</p>
    </sec>
    <sec id="sec-11">
      <title>3.1.2 General layout of the proposed water level monitoring system using Conductive sensors</title>
      <p>
        It is shown in the fig. 2. Its Components are described
below
 The liquid level control unit is a microcontroller based
circuit. It is an electric device with contacts that open
and closes in response to liquid levels sensed by the
probes. Because it is wired directly to the power
source and to the sensing source, it can send signals
that activate or deactivate the electric motor.
 The fitting is a housing that holds the probes (i.e.
conductive sensors).It insulates them from the vessel,
and provides a means of connection to the control.
 The probe is a sensor that extends downward from the
fitting with the tip positioned precisely at the level
where the control should be activated.
 The Motor is an electrical device which pumps ground
water into the tank as per instructions from control
circuit [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
    </sec>
    <sec id="sec-12">
      <title>3.1.3 Monitoring mechanisms</title>
      <p>Water level can be monitored by three possible ways as
shown in fig.3. They are explained briefly below.
I. Monitoring by conductive sensors unit</p>
      <p>The sensors are made up of 316 stainless steel rods.
They are sometimes called as probes. Its working
principle is explained in section 3.1.1 and is pictorially
represented in fig.2</p>
      <sec id="sec-12-1">
        <title>II. Monitoring by stainless steel magnetic float level sensors unit</title>
        <p>The sensors are made up of stainless steel magnetic
floats. Their working principle is same as for
conductive sensors.</p>
      </sec>
      <sec id="sec-12-2">
        <title>III. Monitoring by ON and OFF delay timer unit</title>
        <p>
          Generally the timer is a relay having such an output
which electrically closes or opens the circuit after a
preset time elapses when electrical input is given. This
unit makes use of ON and OFF delay operation of the
timer [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. ON and OFF delay timers are assigned values
22.5 and 1.5 hours respectively. These values are based
on assumption that it takes approximately 1.5 hours to
fill the tank and 22.5 hours to empty the tank.
First priority for water level monitoring is always given to
conductive sensors unit. It is shown by solid line in fig.3.In
case of any fault in it, magnetic float sensors and timer
circuit monitoring unit will be given the next preference
in the same order. It is represented by dotted lines in fig.3.
Here faults in any one of the components such as sensors
and timers can be regarded as changes in the
environment. In this system control unit takes decision
autonomously and adapt to these changes. Moreover, the
control unit can be connected to a GSM dialer unit to
messages about this fault to registered mobile number.
Hence consumer can take necessary troubleshooting
action for it.
        </p>
        <p>However failure of sensor and timer unit components
are not the only changes expected in the current system
environment which account for the adaptation.
Numerous other changes present in the environment can
also be listed, after an observation of the system and the
consumer behavior over a certain period of time. For
example, we neither mentioned about rating of the electric
motor nor faults occurring in it. Its rating and size of the
tank depends upon the consumer demand. It depends in
turn upon number of people residing in the particular
house. Further there is a possibility of leakage in the pipes
used to pump water from ground to overhead tank. We
can also account for the alternative power supply unit to
ensure the continuity of electric supply to the system.</p>
      </sec>
    </sec>
    <sec id="sec-13">
      <title>4. FORMALIZATION</title>
    </sec>
    <sec id="sec-14">
      <title>UPPAAL</title>
    </sec>
    <sec id="sec-15">
      <title>OF THE CASE STUDY IN</title>
      <p>
        UPPAAL model checking tool is used for formalization of
the system [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. It consists of number of processes for the
particular system. Every process is modelled as a grid of
timed automata [7]. Further it uses TCTL for defining
requirements, known as query language. This language
contains state and path formulae. Individual states, with
regular expressions such as y &gt;= 0 or y &lt;=0 or y == 0, can
be described by state formulae. Path formulae quantify
over the path of the model. They can be classified over
safety, liveness and reachability properties.
      </p>
      <p> Safety Properties are used to verify that something
bad will never happen.
 Reachability properties are used to check whether
a given state formula can be satisfied by some
reachable state.
 Liveness properties are used to verify that
something eventually will hold
This process of formalization of the system is divided in
three steps as discussed in section 2. These steps are
explained as follws.


4.1</p>
    </sec>
    <sec id="sec-16">
      <title>Formal specification</title>
      <p>Some of the safety and reachbility requirements to be
formally specified for the case study are listed below.
</p>
      <p>The electric motor should be switced ON by any
one of the three monitoring units, illustrated in
section 3.2.This can be specified by the equation1
given below
(c ∧ ¬f ∧ ¬t ) ∨ (¬c ∧ f ∧ ¬t) ∨ (¬c ∧ ¬f ∧ t)
There is no deadlock formation in the system.</p>
      <p>All the monitoring mechanisms are expected to be
as follows
: If the low level of water in the tank is sensed,
then motor should switch ON.
 If the high level of water in the tank is sensed,
then motor should switch OFF.
 At no point, both low and high level sensors
should become zero or one simultaneously.
4.2</p>
    </sec>
    <sec id="sec-17">
      <title>Modelling</title>
      <p>All the elements of water level monitoring system
shown in fig. 1, 2 and 3 are modelled in UPPAAL. These
models are explained in following subsections.</p>
      <sec id="sec-17-1">
        <title>4.2.1 Control unit</title>
        <p>It consists of five states. StartOfCycle2 state initiates the
process of water level monitoring. Three monitoring units
using conductive sensors, float sensors and timer circuit
are indicated by states One, Two, Three respectively. Here,
state One has been marked as an urgent state to indicate
its first priority in the monitoring process. Also variables
c, f and t are used to indicate the current mode of
operation of three monitoring units conductive sensors(c),
float sensors(f) and timer circuit (t) respectively. These
monitoring units can operate in either normal or faulty
mode. Whenever they operate in normal mode, value zero
should be assigned to all the three variables and whenever
they operate in the faulty mode, value one should be
assigned to them. Further synchronization channels
Activate1, Activate2 and Activate3 are used to
communicate to the process models of the corresponding
monitoring units. This unit is shown in fig.4.</p>
      </sec>
      <sec id="sec-17-2">
        <title>4.2.2 Monitoring unit using conductive sensors</title>
        <p>It is a state machine with three states. It is shown in fig.5.
Initial state On_1 initiates the process of Monitoring by
Conductive sensors. Remaining two states,
LowLevelElectrode and HighLevelElectrode are used to
indicate that the specified low level and high level of the
water in the tank is sensed by them respectively.
1Detailed descriptions about variables c, f and t are given in the section
4.2.1
2All the states and channels shown in figures particularly in the
modelling section are shown by italic font in this section.</p>
        <p>Start and Stop channels are used to communicate to the
electrical motor, by giving the command to switch it ON
and OFF respectively. It responds to the message Activate1
from the control unit and then starts its monitoring
action.</p>
      </sec>
      <sec id="sec-17-3">
        <title>4.2.3 Monitoring unit using float sensors</title>
        <p>This state machines construction and principle of
operation is same as conductive sensors monitoring unit.
However LowLevelFloat and HighLevelFloat are used
instead of LowLevelElectrode and HighLevelElectrode
respectively. It should receive Activate2 message from the
control unit to begin its monitoring action. Its pictorial
representation is given in the fig.6.</p>
      </sec>
      <sec id="sec-17-4">
        <title>4.2.4 Monitoring unit using timer circuit</title>
        <p>Its construction contains 5 states. It is represented in fig.7.
Initial state On_3 initiates the process of monitoring as
soon as it receives message Activate3 from microcontroller
based control unit. States OnDelayTimer and
OffDelayTimer are used to indicate ON and OFF delay
operations of the timer respectively. Two intermediate
states TankEmptying and TankFilling are defined for
communication with the motor model. For this purpose, it
uses Start and Stop synchronization channels.</p>
      </sec>
      <sec id="sec-17-5">
        <title>4.2.5 The electric motor</title>
        <p>It consists of only two states ON and OFF. OFF being an
initial state will start the motor when it receives message
Start from one of the three monitoring units .Then it
remains in this ON state as long as 90 minutes. It will go
back to the OFF state after receiving message Stop from
monitoring unit. Further,to restart the operation of
monitoring once again ,state OFF is provided with the self
loop. For this purpose ,it will send the message
RestartCycle to the control unit. Diagramatic
representation of this unit is shown in fig.8.</p>
      </sec>
      <sec id="sec-17-6">
        <title>Functional and adaptive behavior of the system modelled in</title>
      </sec>
      <sec id="sec-17-7">
        <title>UPPAAL</title>
        <p>The control unit is the heart of the proposed system.
When the working cycle starts, it immediately makes
transition to the state One from the initial state, because
state one is marked as an urgent state and by default
variable c is set to zero. In the One state, message
Activate1 will be sent to the conductive sensors
monitoring unit to initiate the process of water level
monitoring. For this purpose, this unit will communicate
with the motor unit by sending messages Start and Stop to
it.</p>
        <p>If one of the sensors in the conductive sensors unit fails,
then variable c will become one. Now float sensors
monitoring unit will come in action. If this unit also fails,
then timer circuit will perform water monitoring function
because variable t still has value zero. In this way, the
system modelled in the UPPAAL exhibits the property of
adaptation.
4.3</p>
      </sec>
    </sec>
    <sec id="sec-18">
      <title>Formal verification</title>
      <p>All the safety and reachability requirements formally
specified in the section 4.1 are verified in the UPPAAL
using A and E state formulae. They are listed as below
 A[ ] not ( ElectricMotor.ON and (c==1 &amp;&amp; f==1 &amp;&amp;
t==1))
 A[] ElectricMotor.ON imply ((c==0 &amp;&amp; f==1 &amp;&amp;
t==1 ) || (c==1 &amp;&amp; f==0 &amp;&amp; t==1 ) || (c==1 &amp;&amp; f==1
&amp;&amp; t==0 ) )
 A [ ] not deadlock.
 E&lt;&gt; ElectricMotor.ON imply</p>
      <p>Control.WaterMonitoringOn
 E&lt;&gt; ConductiveSensors.HighLevelElectrode
 E&lt;&gt; ConductiveSensors.LowLevelElectrode
 E&lt;&gt; FloatSensors.HighLevelFloat
 E&lt;&gt; FloatSensors.LowLevelFloat
 E&lt;&gt;TimerCircuit.OnDelayTimer
 E&lt;&gt;TimerCircuit.OffDelayTimer
 E&lt;&gt; ElectricMotor.OFF
 E&lt;&gt; ElectricMotor.ON
These properties prove that the system under study
satisfy the specified requirements. In other words, they
indicate that water level monitoring system work properly
and adapt to the specified changes in the environment
successfully.
4.4</p>
    </sec>
    <sec id="sec-19">
      <title>Counterexample analysis</title>
      <p>In UPPAAL, a counterexample can be generated using
diagnostic trace option. This counterexample can be
used to analyze the sources of problems. Typical
problems could be requirement specification or the
model of the system itself. In the current case study by
using the counterexample, we were able to find the
source of two problems. It turned out that two
requirements of the system were not correctly specified.
First one is about deadlock formation in the system. As
long as one of the three monitoring units are working in
the normal operating condition, there was no deadlock
formation in the system. But this requirement was not
satisfied when all three monitoring mechanisms fail. So
the requirement specification:</p>
      <p>“A [] not deadlock”
should be modified to
“A [] not deadlock implies ((c==0) ||(c==1 &amp;
||(c==1 &amp;&amp; f==1 &amp;&amp; t == 0))”
f==0)
or
“A [] deadlock imply (c==1 &amp;&amp; f==1 &amp;&amp; t==1)”
A second problem was found regarding the requirement
specification of the motor during switched ON condition.
As per the specification in the section 4.1, motor in the
switched ON condition indicates that one of the
monitoring mechanism, which is working in the healthy
operating condition, is activated. But counterexample
analysis result showed that motor can’t be turned ON by
any one of the healthy monitoring unit randomly. Instead,
a hierarchy among the units must be maintained
according to the adaptive behavior of the designed system.
Thus, the requirement specification should be changed to
“A [] ElectricMotor.ON imply ((c==0) || (c==1 &amp;&amp; f==0 ) ||
(c==1 &amp;&amp; f==1 &amp;&amp; t==0 ) )”
from
“A[] ElectricMotor.ON imply ((c==0 &amp;&amp; f==1 &amp;&amp; t==1 ) ||
(c==1 &amp;&amp; f==0 &amp;&amp; t==1 ) || (c==1 &amp;&amp; f==1 &amp;&amp; t==0 ) ) ”</p>
    </sec>
    <sec id="sec-20">
      <title>5. CONCLUSION</title>
      <p>In this paper, we presented the case study of intelligent
water level monitoring system. Different safety and
reachability requirements of the system are specified,
modelled and verified in the UPPAAL model checking
tool. Also bugs in the requirements specifications were
reported after counterexample analysis. Here failure in the
sensors and timers are regarded as changes in the
environment. Formal verification process validates the
adaptive behavior of the system in defined changing
environments. However, there is wide scope for defining
various unaccounted changes in the environment and add
additional functionality to the present system so that it
will adapt to those changes.</p>
    </sec>
    <sec id="sec-21">
      <title>REFERENCES</title>
      <p>UPPAAL - a Tool Suite for Automatic Verification of Real-Time
Systems, in Proceedings of the 4th DIMACS Workshop on
Verification and Control of Hybrid Systems, New Brunswick, New</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Frank D.</surname>
          </string-name>
          macias-escriva,
          <source>Rodolf Haber, Raul Del Toro</source>
          ,
          <string-name>
            <given-names>Vicente</given-names>
            <surname>Hernandez</surname>
          </string-name>
          ,
          <article-title>Self -Adaptive Systems: a survey of current approaches, Research challenges &amp; applications</article-title>
          ,
          <source>Science directExpert systems with applications</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>J.M.</given-names>
            <surname>Wing</surname>
          </string-name>
          ,
          <string-name>
            <surname>A Specifiers</surname>
          </string-name>
          <article-title>Introduction to formal methods</article-title>
          , IEEE computer,Sep1990.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Edmund</surname>
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Clarke</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jeannette M. Wing</surname>
          </string-name>
          , Et al, Formal Methods:
          <article-title>State of the Art and Future Directions, ACM Computing Surveys</article-title>
          , Vol.
          <volume>28</volume>
          , No.
          <issue>4</issue>
          ,
          <string-name>
            <surname>December</surname>
            <given-names>1996</given-names>
          </string-name>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <article-title>[4] Gems sensors &amp; controls corporation official website http://www</article-title>
          .gemssensors.com/Level/Warrick/Conductivity-BasedLiquid-Level-Control
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>[5] Panasonic corporation official website http://www3.panasonic.biz/ac/ae/fasys/component/timer/explain_te rm/</mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Bengtsson</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , larsen, K.G.,
          <string-name>
            <surname>Larsson</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pettersson</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yi</surname>
            <given-names>W.</given-names>
          </string-name>
          ,
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>