<!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>Gesellschaft für Informatik, Bonn</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Formal Verification of Intelligent Cyber-Physical Systems with the Interactive Theorem Prover KeYmaera X</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Paula Herber</string-name>
          <email>paula.herber@uni-muenster.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Julius Adelt</string-name>
          <email>julius.adelt@uni-muenster.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Timm Liebrenz</string-name>
          <email>timm.liebrenz@uni-muenster.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Münster, Computer Science Department, Embedded Systems Group</institution>
          ,
          <addr-line>Einsteinstr. 62, 48149 Münster</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <volume>1</volume>
      <abstract>
        <p>Cyber-physical systems are increasingly used in dynamic environments, and have to make safety-critical decisions autonomously. Machine learning is a powerful technique to make such decisions. For example, reinforcement learning can be used to learn controllers that outperform manually designed controllers in highly dynamic or uncertain environments. However, the learning process and the resulting controllers often impede system verification, as their behavior is hard to predict. To formally guarantee safety properties, a formal description is required, which is often not available in industrial design processes and hard to obtain for unpredictable machine learning components. In this paper, we briefly discuss our current work on the semi-automatic deductive verification of intelligent cyber-physical systems. To support industrial design processes, we target the widely used modeling language Simulink together with its Reinforcement Learning Toolbox. To support deductive formal verification, we propose to use and extend our existing framework for the service-oriented verification of hybrid systems that are modeled in Simulink. The framework enables the automated transformation of Simulink models or services into diferential dynamic logic and formal verification with the interactive theorem prover KeYmaera X.</p>
      </abstract>
      <kwd-group>
        <kwd>Formal Verification</kwd>
        <kwd>Reinforcement Learning</kwd>
        <kwd>Cyber-Physical Systems</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Cyber-physical systems (CPS) are increasingly used in dynamic environments, for example,
in smart factories or autonomous driving. With machine learning, CPS can adapt their
behavior to highly dynamic and uncertain environments. The use of machine learning,
however, is typically based on a statistical learning process, which makes the decisions hard
to predict. If a CPS is used in a safety-critical application, where a failure may result in
enormous cost or even endanger human lives, this poses a serious problem. To verify that
the system behaves correctly for all possible input scenarios, a precise description of the
possible system behavior is needed, i.e., a formal model. In industrial design processes,
such formal models are often not available. Existing approaches for safe learning typically
assume that a formal model, e.g., a Markov decision process, is provided by the designer.
In this extended abstract, we sketch an approach for the formal verification of intelligent
CPS using transformations from industrial design languages into formal languages together
with contracts and abstractions for intelligent components. Furthermore, we briefly discuss
our current work on the semi-automatic deductive verification of intelligent CPS with the</p>
      <p>Copyright © 2021 for this paper by its authors.</p>
      <p>Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
interactive theorem prover KeYmaera X. To support industrial design processes, we target
the widely used modeling language Simulink together with its Reinforcement Learning (RL)
Toolbox [Th21]. To support deductive formal verification, we propose to use and extend our
existing framework for the service-oriented verification of hybrid systems that are modeled
in Simulink [LHG18, LHG19] with KeYmaera X [Fu15].
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>There exist some approaches to provide formal semantics to industrial modeling languages,
e.g. [HRB13, AIER14, MF16, He18]. Most of them are based on an automated
transformation from a system description with informally defined semantics (e.g., a SystemC design
[IE11] or a Simulink model [Th21]) into a formally well-defined language. This enables
computer-aided formal verification. However, existing approaches do not support intelligent
systems. In [FP18], the authors ensure the safety of an RL controller via verified runtime
monitors that are based on a dL model. In [Al17], a shield is used to substitute unsafe
for safe actions. The shield is synthesized from a safety automaton and an abstraction of
the environment. These methods, however, require a formal model, which is typically not
available in industrial design processes and hard to obtain for machine learning algorithms.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Formalization and Verification of Intelligent CPS</title>
      <p>The key idea of our approach for the formal verification of intelligent CPS is to augment
existing approaches that provide transformations from industrially used design languages
into formal models with support for learning components. The general idea is depicted in
Fig. 1. In transformation-based approaches, the informally defined execution semantics
of industrially used design languages is automatically translated into an existing formally
well-defined language. By using existing formal languages, we gain access to existing
verification tools, which we can use to verify given requirements, for example, safety,
liveness, or timing properties. If the requirements are not satisfied, we typically get a
counter-example, which can be used for debugging. In previous work, for example, we
Informally Defined</p>
      <p>System Model</p>
      <p>Learning
Component</p>
      <p>Automatic
Transformation</p>
      <p>Formal
Model</p>
      <p>Requirements
Specification
Verification</p>
      <p>Tool
Fig. 1: Formalization of Intelligent CPS
satisfied
not satisfied</p>
      <p>Counter
Example</p>
      <p>Formal Verification of Intelligent Cyber-Physical Systems 3
have presented a transformation from SystemC into timed automata, which enables the
fully-automatic verification of HW/SW co-designs with the UPPAAL model checker
[HPG15], and an automated transformation from Simulink into dL (Simulink2dL) [LHG18],
which enables deductive verification of hybrid systems with KeYmaera X. To leverage
transformation-based formalizations to intelligent CPS, we assume that the informal system
model contains learning components, for example RL agents. RL is a class of machine
learning methods for learning in a trial and error approach by interacting with an environment
through actions. Their behavior is hard to describe. To overcome this problem, we propose
to capture embedded RL components by contracts or abstractions, which provide an
overapproximation of their possible safe behavior, for example, as a concise description of safe
actions in given system states. With that, we can then verify safety properties of the overall
system under the assumption that the learning component only performs safe actions in
each system state. To ensure that the RL component adheres to its contract or abstraction at
runtime, we propose to use a safe RL approach as, for example, proposed in [FP18, Al17].
4</p>
    </sec>
    <sec id="sec-4">
      <title>Verification of Intelligent CPS with KeYmaera X</title>
      <p>To put our general approach into practice, we are currently working on a contract-based
verification approach for intelligent CPS that are modeled with Simulink together with the
RL Toolbox. The key idea is to use hybrid contracts in dL [LHG19] to formally describe RL
agents, and to safely embed these contracts into the Simulink2dL transformation [LHG18].
We use a case study of an autonomous ground robot that moves around in a factory setting
with moving obstacles. We have formalized the prerequisites the intelligent controller of
the robot has to fulfill in order to avoid collisions, i.e., minimal safety distances, in a
hybrid contract. By translating the system with Simulink2dL and embedding the hybrid
contract of the RL agent, we are able to verify collision avoidance of the overall system
with deductive verification techniques using KeYmaera X. Preliminary results indicate that
this approach will enable us to precisely capture the safety-relevant behavior of learning
components within complex CPS, formally verify crucial safety properties of the overall
system, and automatically generate runtime monitors as proposed by [FP18] to ensure the
safety-compliant behavior of the learning component at runtime.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusion and Future Work</title>
      <p>We have sketched an approach for the formal verification of intelligent CPS that are modeled
in industrially used system design languages such as Simulink and the RL Toolbox. We
believe that existing approaches for the formal verification of CPS urgently need to be
leveraged to learning components, as the demand to cope with highly dynamic, uncertain
environments is on the rise. The statistical, trial-and-error approach of such components
leads to inherently hard to predict behavior. We propose to use contracts and abstractions
to overcome this problem. However, how to define good contracts and abstractions, which
provide enough abstraction to enable scalable verification and still capture safety-relevant
behavior of learning components precisely enough such that the component is not restricted
too much at runtime, is an open challenge for future work. We also plan to extend our
SystemC to timed automata engine to cope with intelligent CPS. As the UPPAAL model
checker does not support contracts, we plan to base this work on abstractions.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [AIER14]
          <string-name>
            <surname>Araiza-Illan</surname>
          </string-name>
          , Dejanira; Eder, Kerstin; Richards, Arthur:
          <article-title>Formal verification of control systems' properties with theorem proving</article-title>
          .
          <source>In: UKACC Int. Conference on Control (CONTROL)</source>
          . IEEE, pp.
          <fpage>244</fpage>
          -
          <lpage>249</lpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <source>[Al17] [FP18] [Fu15] [He18] Alshiekh</source>
          , Mohammed; Bloem, Roderick; Ehlers, Rüdiger; Könighofer, Bettina; Niekum, Scott; Topcu, Ufuk: Safe Reinforcement Learning via Shielding.
          <source>arXiv preprint arXiv:1708.08611</source>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <surname>Fulton</surname>
          </string-name>
          , Nathan; Platzer,
          <article-title>André: Safe Reinforcement Learning via Formal Methods: Toward Safe Control Through Proof and Learning</article-title>
          .
          <source>The Thirty-Second AAAI Conference on Artificial Intelligence (AAAI-18)</source>
          ,
          <volume>32</volume>
          (
          <issue>1</issue>
          ):
          <fpage>6485</fpage>
          -
          <lpage>6492</lpage>
          ,
          <year>02 2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>Fulton</surname>
            , Nathan; Mitsch, Stefan; Quesel, Jan-David; Völp, Marcus; Platzer, André: KeYmaera
            <given-names>X</given-names>
          </string-name>
          :
          <article-title>An Axiomatic Tactical Theorem Prover for Hybrid Systems</article-title>
          . In: International Conference on Automated Deduction. Springer, pp.
          <fpage>527</fpage>
          -
          <lpage>538</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <surname>Herdt</surname>
          </string-name>
          , Vladimir; Le,
          <string-name>
            <surname>Hoang</surname>
            <given-names>M</given-names>
          </string-name>
          ; Grosse, Daniel; Drechsler,
          <article-title>Rolf: Verifying SystemC using intermediate verification language and stateful symbolic simulation</article-title>
          .
          <source>IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems</source>
          ,
          <volume>38</volume>
          (
          <issue>7</issue>
          ):
          <fpage>1359</fpage>
          -
          <lpage>1372</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [HPG15] Herber, Paula; Pockrandt, Marcel; Glesner,
          <article-title>Sabine: STATE - a SystemC to Timed Automata Transformation Engine</article-title>
          . In: ICESS. IEEE,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [HRB13] Herber, Paula; Reicherdt, Robert; Bittner, Patrick:
          <article-title>Bit-precise formal verification of discrete-time MATLAB/Simulink models using SMT solving</article-title>
          .
          <source>In: Int. Conference on Embedded Software (EMSOFT)</source>
          . IEEE, pp.
          <fpage>1</fpage>
          -
          <lpage>10</lpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <article-title>[IE11] IEEE Standards Association:</article-title>
          ,
          <source>IEEE Std. 1666-2011</source>
          ,
          <article-title>Open SystemC Language Reference Manual</article-title>
          . IEEE Press,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [LHG18] Liebrenz, Timm; Herber, Paula; Glesner,
          <article-title>Sabine: Deductive Verification of Hybrid Control Systems Modeled in Simulink with KeYmaera X</article-title>
          . In: International Conference on Formal Engineering Methods. Springer, pp.
          <fpage>89</fpage>
          -
          <lpage>105</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [LHG19] Liebrenz, Timm; Herber, Paula; Glesner,
          <article-title>Sabine: A Service-Oriented Approach for Decomposing and Verifying Hybrid System Models</article-title>
          .
          <source>In: International Conference on Formal Aspects of Component Software</source>
          . Springer, pp.
          <fpage>127</fpage>
          -
          <lpage>146</lpage>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [MF16] Minopoli, Stefano; Frehse,
          <string-name>
            <surname>Goran:</surname>
          </string-name>
          <article-title>SL2SX translator: from Simulink to SpaceEx models</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <source>In: Int. Conf. on Hybrid Systems: Computation and Control. ACM</source>
          , pp.
          <fpage>93</fpage>
          -
          <lpage>98</lpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <surname>The</surname>
            <given-names>MathWorks:</given-names>
          </string-name>
          , Simulink. www.mathworks.com/products/simulink.html,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>