Skip to content

Commit dfb7eda

Browse files
committed
CoCoSim v1.0
1 parent c34ccb1 commit dfb7eda

File tree

1,568 files changed

+146900
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,568 files changed

+146900
-2
lines changed

Dockerfile

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
FROM ubuntu:18.04 as builder
2+
3+
4+
# Install build dependencies
5+
RUN apt-get update && apt-get install -y \
6+
automake \
7+
autoconf \
8+
libtool \
9+
git \
10+
pkg-config \
11+
unzip \
12+
wget
13+
14+
RUN git clone --depth=1 --branch develop https://github.com/kind2-mc/kind2.git kind2-build
15+
RUN git clone --depth=1 --branch master https://cavale.enseeiht.fr/git/lustrec lustrec-build
16+
17+
# Install opam and ocaml from GitHub (Ubuntu version causes problems)
18+
RUN wget -qq https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux \
19+
&& mv opam-2.0.1-x86_64-linux /usr/local/bin/opam && chmod a+x /usr/local/bin/opam \
20+
&& opam init --disable-sandboxing --yes --comp 4.04.0 && eval $(opam env)
21+
22+
# Install ocaml packages needed for Kind 2.
23+
RUN opam install --yes ocamlfind camlp4 menhir ocamlgraph cmdliner fmt logs num yojson
24+
25+
# Force to use opam version of ocamlc.
26+
ENV PATH="/root/.opam/4.04.0/bin:${PATH}"
27+
28+
29+
30+
# Retrieve Z3 binary
31+
RUN wget -qq https://github.com/Z3Prover/z3/releases/download/z3-4.7.1/z3-4.7.1-x64-ubuntu-16.04.zip \
32+
&& unzip z3-4.7.1-x64-ubuntu-16.04.zip
33+
34+
# Retrieve Yices 2
35+
RUN wget -qq http://yices.csl.sri.com/releases/2.6.0/yices-2.6.0-x86_64-pc-linux-gnu-static-gmp.tar.gz \
36+
&& tar xvf yices-2.6.0-x86_64-pc-linux-gnu-static-gmp.tar.gz
37+
38+
# Retrieve JKind and CVC4 (required for certification)
39+
RUN wget -qq https://github.com/agacek/jkind/releases/download/v4.0.1/jkind.zip && unzip jkind.zip \
40+
&& ./kind2-build/docker_scripts/latest_cvc4.sh
41+
42+
# Build Lustrec
43+
WORKDIR lustrec-build
44+
RUN autoconf && ./configure --prefix=/ && make && make install
45+
46+
# Build Kind 2
47+
WORKDIR ../kind2-build
48+
RUN if [ -f "Makefile" ] ; then make clean \
49+
&& rm -rf src/_build configure Makefile bin src/Makefile src/kind2.native \
50+
&& autoreconf ; fi
51+
RUN ./autogen.sh && ./build.sh
52+
53+
54+
FROM ubuntu:18.04
55+
# Install runtime dependencies:
56+
# JRE (required by JKind) and libgomp1 (required by Z3)
57+
# Make and gcc for compilation
58+
RUN apt-get update && apt-get install -y default-jre libgomp1 make gcc\
59+
&& rm -rf /var/lib/apt/lists/*
60+
61+
COPY --from=builder /z3-4.7.1-x64-ubuntu-16.04/bin/z3 /bin/
62+
COPY --from=builder /yices-2.6.0/bin/yices-smt2 /bin/
63+
COPY --from=builder /cvc4 /bin/
64+
COPY --from=builder /jkind/jkind /jkind/*.jar /bin/
65+
COPY --from=builder /kind2-build/bin/kind2 /bin/
66+
COPY --from=builder /lustrec-build/bin/* /bin/
67+
COPY --from=builder /lustrec-build/include /include/lustrec
68+
69+
# Entry point.
70+
#ENTRYPOINT ["/bin/kind2"]
71+
72+
WORKDIR /lus
73+
74+
CMD tail -f /dev/null

INSTALL.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
3+
### **Dependencies**
4+
5+
* MATLAB(c) and Simulink version **R2017** or newer (CoCoSim has been well tested in R2017b version)
6+
7+
* [Lustrec](https://github.com/coco-team/lustrec) tool is a modular compiler of Lustre code into C and Horn Clauses. CoCoSim uses lustrec in many features: Test case generation, requirements importation...
8+
9+
* [Kind2](http://kind2-mc.github.io/kind2/) is a multi-engine, parallel, SMT-based automatic model checker for safety properties of Lustre programs.
10+
11+
<!-- * Formal verification backends: In order to analyse the model, at least one of the following model-checkers should be installed. Currently we support Kind2.
12+
* [Kind2](http://kind2-mc.github.io/kind2/) (Supported and highly recommended)
13+
* [Zustre](https://github.com/lememta/zustre) (Support in progress)
14+
* [JKind](https://github.com/agacek/jkind) (Support in progress) -->
15+
16+
17+
18+
CoCoSim uses the following external libraries:
19+
20+
* CoCoSim standard libraries from https://github.com/coco-team/cocoSim2
21+
* Simulink/Matlab selected toolboxes from https://github.com/hbourbouh/cocosim-external-libs
22+
23+
24+
### **Installation**
25+
26+
#### Using latest stable version
27+
28+
We recommend this option. You can download the latest stable version of CoCoSim source code from [here](https://github.com/NASA-SW-VnV/CoCoSim/releases).
29+
30+
CoCoSim is a Matlab Toolbox, in the zip we include the external libraries and binaries for Lustrec and Kind2.
31+
32+
You still need to run the install script to make sure binaries are working on your machine. If not they will be installed from scratch.
33+
34+
In your terminal, go first to `scripts` folder in `cocosim` and run the `install_cocosim` script.
35+
```
36+
>cd CoCoSim/scripts
37+
>./install_cocosim
38+
```
39+
40+
The script may require some dependencies, please install them and run the script again.
41+
42+
43+
#### Use developer version
44+
45+
1. Clone this cocosim repository in your local machine (develop branch).
46+
47+
2. Download External Matlab Libraries:
48+
49+
* Open your Matlab and navigate to `cocosim/scripts` run `install_cocosim_lib(true)` from the Matlab Command window. \
50+
Function `cocosim2/scripts/install_cocosim_lib.m` is responsible of copying all required external libraries to the right destination in our repository.
51+
It needs `git` to clones external repositories from github and copy some of their code on the
52+
right place on CoCoSim.
53+
Read function `cocosim2/scripts/install_cocosim_lib.m` to know what are the external libraries are copied to cocosim2 to do it manually in case the function failed for internet connection or `git` issues.
54+
55+
* Navigate back to `cocosim` then run `start_cocosim` from the Matlab Command window.
56+
57+
3. In your terminal, go first to `scripts` folder in `cocosim` and run the `install_cocosim` script.
58+
```
59+
>cd CoCoSim/scripts
60+
>./install_cocosim
61+
```
62+
63+
install_cocosim script assumes the operating system provides:
64+
bash, basename, dirname, mkdir, touch, sed, date,
65+
cat, rm, mv, cp, ln, find, tee, patch,tar, gzip,
66+
gunzip, xz, make, git
67+
68+
Also the following dependencies:
69+
autoconf, automake, aclocal, pkg-config.
70+
71+
The script detects the missing dependencies that should be installed by
72+
the user.
73+
74+
If the above script failed to install the tools. You may install them in the following paths. If you have linux machin, change `osx` by `linux`.
75+
76+
KIND2 binary: `CoCoSim/tools/verfiers/osx/bin/kind2`
77+
78+
Z3 binary: `CoCoSim/tools/verfiers/osx/bin/z3`
79+
80+
<!-- JKIND binary: `CoCoSim/tools/verfiers/jkind/jkind` -->
81+
82+
<!-- JLUSTRE2KIND binray: `CoCoSim/tools/verfiers/jkind/jlustre2kind` -->
83+
84+
<!-- ZUSTRE binary: `CoCoSim/tools/verfiers/osx/bin/zustre` -->
85+
86+
LUSTREC binary: `CoCoSim/tools/verfiers/osx/bin/lustrec`
87+
88+
LUSTRET binary: `CoCoSim/tools/verfiers/osx/bin/lustret`
89+
90+
LUCTREC_INCLUDE_DIR: `CoCoSim/tools/verfiers/osx/include/lustrec`
91+
92+
93+
If you want to customize these paths go to `cocosim/tools/tools_config.m` and change the values of variables KIND2, Z3, <!--JKIND, JLUSTRE2KIND, ZUSTRE, --> LUSTREC, LUSTRET, LUCTREC_INCLUDE_DIR to your preferences.
94+
95+
96+
**Quick Start**
97+
-------------------
98+
Explanation for each CoCoSim features can be found [here](doc/EXAMPLES.md)

LICENSE.pdf

236 KB
Binary file not shown.

README.md

+86-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,86 @@
1-
# CoCoSim
2-
Automated Analysis Framework for Simulink/Stateflow models.
1+
**CoCoSim: Contract based Compositional verification of Simulink models**
2+
=====================================================================
3+
4+
[![License](https://img.shields.io/badge/license-NOSA%201.3-blue.svg)](LICENSE.pdf)
5+
[![Release](https://img.shields.io/badge/release-v1.0-orange.svg)](https://github.com/NASA-SW-VnV/CoCoSim/releases/)
6+
7+
CoCoSim (Contract based Compositional verification of Simulink models)
8+
consists of an open architecture, allowing the integration of different analyses. The motivation is to support different verification techniques to scale to large models. The main objective of CoCoSim is to provide the following:
9+
* A **formal semantic** for a well defined subset of Simulink/Stateflow blocks. This formal representation allows the use of formal verification methods and code generation. It also can be used as a semantic of reference for other tools. Find more about the formal semantics of Simulink/Stateflow used in the [CoCoSim manual](doc/cocosim_user_manual.pdf).
10+
* A **highly automated** toolchain: all the steps of verification or code generation are automated, check [CoCoSim manual](doc/cocosim_user_manual.pdf).
11+
* A **Customizable** and **configurable** architecture: Currently CoCosim supports most frequently used Simulink blocks libraries (> 100 blocks) either by transforming them to simpler blocks or by direct translation to a formal language. The translation is customizable and extensible; new blocks can be easily supported.
12+
* Full **traceability** throughout the analysis process. This traceability is crucial in reporting analysis results expressed in the formal model back to the user in the context of the Simulink model. For instance, the Counter-examples generated by model checkers is reported back to the Simulink level using a Signal Builder block to help the user debug the internal Signals values.
13+
* **Scalability** to large models: abtained through the use of various verification techniques and compositional reasoning.
14+
15+
CoCoSim can be used to
16+
verify automatically user-supplied safety requirements. Moreover,
17+
CoCoSim can be used to generate C and/or Rust code.
18+
CoCoSim uses various model checkers for verification (Zustre, Kind2, JKind).
19+
CoCoSim is currently under development. We welcome any feedback and bug report.
20+
21+
**License**
22+
-------
23+
24+
CoCoSim has been released under the NASA Open Source Agreement.
25+
26+
**Contact**
27+
-------
28+
29+
Please contact [email protected] for further information on CoCoSim. Detailed information can be found at the [CoCoSim manual](doc/cocosim_user_manual.pdf)
30+
31+
**Installation**
32+
---------------
33+
34+
Platforms
35+
---------
36+
CoCoSim currently is supported for Mac OS and Linux distributions. Future support is planned for Windows.
37+
38+
Dependancies and Installation instructions can be found [here](INSTALL.md)
39+
40+
**Quick Start**
41+
-------------------
42+
43+
Explanation for each CoCoSim features can be found [here](doc/EXAMPLES.md)
44+
45+
46+
**Release notes and work in progress**
47+
-------------
48+
49+
For release notes and what actually we are working on see [here](RELEASE_NOTES.md)
50+
51+
**Troubleshooting**
52+
-------------------
53+
54+
Solution of some common issues with CoCoSim are [here](doc/TROUBLESHOOTING.md)
55+
56+
57+
## **Developers**
58+
59+
* Project leader: [Guillaume Brat](https://ti.arc.nasa.gov/profile/brat/) (NASA Ames - USA), [Pierre-Loic Garoche](https://ti.arc.nasa.gov/profile/garoche/) (NASA Ames - USA)
60+
* Lead Developer: [Hamza Bourbouh](https://ti.arc.nasa.gov/profile/bourbouh/) (NASA Ames - USA)
61+
62+
* Current Contributors: \
63+
Khanh Trinh (NASA Ames - USA)
64+
65+
* Past Contributors: \
66+
[Temesghen Kahsai](http://www.lememta.info/), Francois Conzelmann (NASA Ames - USA)
67+
68+
69+
**Publications**
70+
------------
71+
72+
* [Automated analysis of Stateflow models](https://oatao.univ-toulouse.fr/22654/1/bourbouh_22654.pdf)\
73+
H Bourbouh, PL Garoche, C Garion, A Gurfinkel, T Kahsai, X Thirioux\
74+
EasyChair 46, 144-161
75+
76+
* [CoCoSim, a code generation framework for control/command applications. An overview of CoCoSim for multi-periodic discrete Simulink models](https://hal.archives-ouvertes.fr/hal-02441334/document)\
77+
H Bourbouh, PL Garoche, T Loquen, É Noulard, C Pagetti\
78+
10th European Congress on Embedded Real Time Software and Systems (ERTS 2020)
79+
80+
* [Evaluation of the FRET and CoCoSim tools on the Ten Lockheed Martin Cyber-Physical Challenge Problems](http://www.garoche.net/publication/nasatm-2019-220374/nasatm-2019-220374.pdf)\
81+
A Mavridou, H Bourbouh, PL Garoche, M Hejase\
82+
NASA Technial Report: NASA/TM-2019-220374
83+
84+
* Bridging the Gap Between Requirements and Simulink Model Analysis\
85+
A Mavridou, H Bourbouh, PL Garoche, D Giannakopoulou, T Pressburger, J Schumann\
86+
REFSQ2020

RELEASE_NOTES.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
CoCoSim version 1.0 release notes
2+
===================================
3+
4+
Release date
5+
------------
6+
7+
Feb 2020
8+
9+
List of features:
10+
----------------
11+
The following is the list of actions the user can call from CoCoSim menu:
12+
* **Check compatibility** of a model against the CoCoSim compiler from Simulink to Lustre: This will check and report all blocks in the model that are not supported by the compiler. \
13+
The checking compatibility does not guarantee that the model is fully supported but it detects the blocks/options we already know we do not support.
14+
You may have other error messages that a specific block is not supported.
15+
In addition the compatibility is performed for Verification, a model can be supported for verification and not for code generation.
16+
17+
* **Prove properties**: The model should contain requirements to be verified by one of the supported model checkers (currently only KIND2 is integrated). These requirements can be expressed using SLDV verification blocks or CoCoSpec specification blocks (See [CoCoSpec Specification library](https://github.com/coco-team/cocoSim2/blob/master/doc/specificationLibrary.md)).
18+
* **Design Error Detection**: Currently cocosim only check for specified minimum and maximum signal values specified by the user on blocks outputs using OutMin and OutMax parameters in blocks dialogue box. The check is done using Kind2 model checker. Future work is planned to support the check of integer overflow, out of bound access array and division by zero.
19+
This features requires Kind2 to be installed.
20+
* **Test-case Generation**: Currently cocosim supports:
21+
* **Random Testing**: cocosim generates in this case random inputs, a range can be specified by the user using OutMin and OutMax parameters in the Inport block.
22+
* **Code Generation**: CoCoSim support the generation of C, Lustre and Rust code from a Simulink model.
23+
24+
25+
26+
27+
Features in progress:
28+
---------------------
29+
* Support [nuXmv](https://nuxmv.fbk.eu/) model checker.
30+
* **Check model against guidelines**: This will run the model against a list of guidelines from [NASA - Orion GN&C: MATLAB and Simulink Standards](https://www.mathworks.com/solutions/aerospace-defense/standards/nasa.html).
31+
32+
* **Test-case Generation**: Currently we are working on:
33+
* **MC-DC test coverage**: cocosim uses lustret tool to generate MC-DC conditions on the lustre code that will be checked using Kind2. Counterexamples are the test-cases that detects those MC-DC conditions. In the case the condition is not falsified, it means the condition is never activated, therefore a dead logic.
34+
* **Mutation based testing**: cocosim uses lustret tool to generate mutations on the lustre code, a mutation can be a change of arithmetic operator, a relational operator or a constant value. Kind2 is used to find traces that detect those mutations.
35+

0 commit comments

Comments
 (0)