├── .gitignore ├── .travis.yml ├── AUTHORS ├── Guidelines.md ├── LICENSE ├── README.md ├── libs ├── ObserverBlock.mdl └── cocosimLibs.slx ├── pre-commit.cmd ├── pre-commit.sh ├── sanity ├── README ├── pre_release_script.m └── sanity_check.py ├── sl_customization.m ├── src ├── add_cocospec.m ├── backEnd │ ├── jkind.m │ ├── kind2.m │ ├── lustrec.m │ ├── rust.m │ ├── seahorn.m │ ├── solver_result.m │ ├── templates │ │ ├── ann.html │ │ ├── annot.html │ │ ├── complex_arith_int.lus │ │ ├── complex_arith_real.lus │ │ ├── footer.html │ │ ├── header.html │ │ ├── launch_sim_embedded_annotation.m │ │ ├── launch_simulation.m │ │ ├── list_item.html │ │ ├── list_item_mat_code.html │ │ ├── list_title.html │ │ ├── materialize.css │ │ ├── plotting.m │ │ ├── title.html │ │ └── title2.html │ └── zustre.m ├── cocoSim.m ├── cocosim_menu.m ├── cocosim_pp.m ├── config.m ├── frontEnd │ ├── app_sprintf.m │ ├── blocks2lustre.m │ ├── blocks_dt_conversions.m │ ├── blocks_interconnection.m │ ├── blocks_interconnection_complet.m │ ├── clean_inter.m │ ├── flatten_subsystems.m │ ├── get_model_blocks_ports_dts.m │ ├── list_var_action.m │ ├── list_var_entree.m │ ├── list_var_input.m │ ├── list_var_outport.m │ ├── list_var_sortie.m │ ├── lookuptable.m │ ├── mk_internalRep.m │ ├── num_block.m │ ├── preprocess_model.m │ ├── realornot.m │ ├── ss2subsyst.m │ ├── transfo_entier_real.m │ ├── write_code.m │ └── ztransform.m ├── gui │ ├── add_property.m │ ├── cocosim_window.m │ ├── unsupported_blocks_gui.m │ └── validate_window.m ├── log4m.m ├── middleEnd │ ├── CoCoSpec.m │ ├── Parallel_states_call.m │ ├── add_node_param.m │ ├── add_unchanged_variables.m │ ├── add_variables.m │ ├── chart2lus.m │ ├── chart_and_function_code.m │ ├── construct_node_header.m │ ├── convert_cocospec.m │ ├── extern_nodes_header.m │ ├── math_functions.m │ ├── temporal_operators.m │ ├── transition_code.m │ ├── update_variables.m │ ├── write_3x3_Matrix.m │ ├── write_SignalConversion.m │ ├── write_Transition_actions.m │ ├── write_abs.m │ ├── write_action.m │ ├── write_assignment.m │ ├── write_bias.m │ ├── write_bitwise.m │ ├── write_busassignment.m │ ├── write_buscreator.m │ ├── write_buses.m │ ├── write_busselector.m │ ├── write_compareto.m │ ├── write_concatenate.m │ ├── write_constant.m │ ├── write_constantes.m │ ├── write_crossproduct.m │ ├── write_datatypeconversion.m │ ├── write_delay.m │ ├── write_demux.m │ ├── write_detect.m │ ├── write_discreteintegrator.m │ ├── write_dotproduct.m │ ├── write_dss.m │ ├── write_enableport.m │ ├── write_entree_sorties.m │ ├── write_extern_functions.m │ ├── write_extern_s_function.m │ ├── write_foriterator.m │ ├── write_fromworkspace.m │ ├── write_function_block.m │ ├── write_gain.m │ ├── write_global_node.m │ ├── write_goto_from.m │ ├── write_ifelseif.m │ ├── write_logic.m │ ├── write_lookupnddirect.m │ ├── write_math_fun.m │ ├── write_matlab_function_node.m │ ├── write_memory.m │ ├── write_merge.m │ ├── write_minmax.m │ ├── write_multiportswitch.m │ ├── write_mux.m │ ├── write_outport.m │ ├── write_polyval.m │ ├── write_product.m │ ├── write_property.m │ ├── write_relationaloperator.m │ ├── write_reshape.m │ ├── write_s_function.m │ ├── write_saturation.m │ ├── write_saturation_dynamic.m │ ├── write_selector.m │ ├── write_sf_Matlab_function_node.m │ ├── write_signalspecification.m │ ├── write_signum.m │ ├── write_state_actions.m │ ├── write_state_node.m │ ├── write_subsystem.m │ ├── write_sum.m │ ├── write_switch.m │ ├── write_switchcase.m │ ├── write_triggerport.m │ ├── write_trigo.m │ ├── write_unitdelay.m │ └── write_zero_pole.m ├── pp │ ├── README │ ├── default_constants.m │ ├── doc │ │ └── pp_doc.tex │ ├── lib │ │ ├── blocks │ │ │ ├── chart_process.m │ │ │ ├── clock_process.m │ │ │ ├── constant_process.m │ │ │ ├── deadzone_dynamic_process.m │ │ │ ├── deadzone_process.m │ │ │ ├── discrete_integrator_process.m │ │ │ ├── discrete_state_space_process.m │ │ │ ├── from_workspace_process.m │ │ │ ├── function_process.m │ │ │ ├── gain_process.m │ │ │ ├── goto_process.m │ │ │ ├── integrator_process.m │ │ │ ├── lookuptable_nD_process.m │ │ │ ├── lookuptable_process.m │ │ │ ├── math_process.m │ │ │ ├── product_process.m │ │ │ ├── pulsegenerator_process.m │ │ │ ├── rate_transition_process.m │ │ │ ├── replace_variables.m │ │ │ ├── saturation_dynamic_process.m │ │ │ ├── saturation_process.m │ │ │ ├── selector_process.m │ │ │ ├── signalbuilder_process.m │ │ │ ├── to_workspace_process.m │ │ │ ├── transfer_function_process.m │ │ │ └── zero_pole_process.m │ │ ├── common │ │ │ ├── datatable_process.m │ │ │ ├── gal_lib.slx │ │ │ ├── goto_block_process.m │ │ │ ├── pos.m │ │ │ ├── remove_line_tags.m │ │ │ ├── replace_one_block.m │ │ │ ├── state_matrix_process.m │ │ │ └── verification_template.slx │ │ └── math │ │ │ ├── expr_parser.py │ │ │ ├── expression_process.m │ │ │ └── parse_math.m │ └── pp.m ├── unsupported_blocks.m ├── utils │ ├── BusUtils.m │ ├── Constants.m │ ├── Utils.m │ ├── XML_Trace.m │ ├── cprintf.m │ ├── display_msg.m │ ├── func2node.py │ ├── generate-tables.py │ ├── get_full_name.m │ ├── log4m.m │ ├── messagetype.m │ ├── parse_json.m │ ├── sT2fT.m │ ├── setdiff_struct.m │ ├── sort_by_order.m │ ├── split_transition.m │ ├── to_XML.m │ └── traceability_annotation.m ├── validate_model.m └── view_cocospec.m ├── start_cocosim.m └── test ├── Fcn ├── Fcn.slx ├── Fcn2.slx └── Fcn3.slx ├── StateFlow ├── test_all.m ├── tests_with_properties │ ├── Arrays1V2.mdl │ ├── MicrowaveCex.slx │ ├── MicrowaveV2.mdl │ └── set_up_parameters.m └── tests_without_properties │ ├── BSCU.slx │ ├── BSCU_Active_State.mdl │ ├── BSCU_Brake_Mode.mdl │ ├── BSCU_Brake_cmd.mdl │ ├── BSCU_Duration.mdl │ ├── CruiseState.mdl │ ├── DA1.mdl │ ├── DockingApproachExample_Ext.mdl │ ├── GPCA_Alarm.mdl │ ├── GPCA_CONFIG.mdl │ ├── GPCA_INFUSION_MGR.mdl │ ├── GPCA_Logging.mdl │ ├── GPCA_System_Monitor.mdl │ ├── GPCA_Top_Level_Mode.mdl │ ├── MicrowaveModified.mdl │ └── set_up_parameters.m ├── cocospec ├── AltitudeControl_Demo.slx └── cocospec_3.slx ├── compilation └── simple.mdl └── properties ├── AltitudeControl_Demo.slx ├── assertion.mdl ├── assumption.slx ├── safe_1.mdl ├── safe_math_functions.slx ├── two_property.mdl └── unsafe_1.mdl /.gitignore: -------------------------------------------------------------------------------- 1 | src/config.m 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Lead developer: 2 | Temesghen Kahsai : teme DOT Kahsai AT sv DOT cmu DOT com (NASA AMES / CMU) 3 | 4 | Contributors: 5 | Hamza BOURBOUH : bourbouhh AT gmail DOT com 6 | Arnaud Dieumegard : arnaud DOT dieumegard AT gmail DOT com 7 | Thomas LOQUEN : Thomas DOT Loquen AT onera DOT fr (ONERA) 8 | Claire PAGETTI : Claire DOT Pagetti AT onera DOT fr (ONERA) 9 | Eric NOULARD : Eric DOT Noulard AT onera DOT fr (ONERA) 10 | -------------------------------------------------------------------------------- /Guidelines.md: -------------------------------------------------------------------------------- 1 | How to be sure your model is well supported by our tool: 2 | 3 | * Make sure all Simulink blocks has the same `Sample Time` 4 | * Blocks names should start with a character or underscore 5 | 6 | 7 | 8 | 9 | Some constraints for some specific blocks: 10 | 11 | ### Discrete-Time Integrator 12 | 13 | * We support only `Forward Euler method` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | CoCoSim Automated Analysis Framework 2 | Copyright (c) 2016 Carnegie Mellon University. 3 | All Rights Reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following acknowledgments and 11 | disclaimers. 12 | 13 | 2. Redistributions in binary form must reproduce the 14 | above copyright notice, this list of conditions and the following 15 | acknowledgments and disclaimers in the documentation and/or other 16 | materials provided with the distribution. 17 | 18 | 3. Products derived from this software may not include “Carnegie 19 | Mellon University,” in the name of such derived product, 20 | nor shall “Carnegie Mellon University,” be used to 21 | endorse or promote products derived from this software without prior 22 | written permission. 23 | 24 | 25 | ACKNOWLEDGMENTS AND DISCLAIMERS: 26 | 27 | Copyright 2016 Carnegie Mellon University 28 | 29 | This material is based upon work funded and supported by 30 | NASA NRA Contract No. NNX14AI09G and NSF Award No. 1422705. 31 | 32 | Any opinions, findings and conclusions or recommendations expressed in 33 | this material are those of the author(s) and do not necessarily 34 | reflect the views of NASA nor NSF. 35 | 36 | 37 | NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY MATERIAL 38 | IS FURNISHED ON AN “AS-IS” BASIS. CARNEGIE MELLON 39 | UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR 40 | IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF 41 | FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS 42 | OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT 43 | MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, 44 | TRADEMARK, OR COPYRIGHT INFRINGEMENT. 45 | 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://travis-ci.org/coco-team/cocoSim) 2 | 3 | # CoCoSim 4 | 5 | CoCoSim is an automated analysis and code generation framework for 6 | Simulink and Stateflow models. Specifically, CoCoSim can be used to 7 | verify automatically user-supplied safety requirements. Moreover, 8 | CoCoSim can be used to generate C and/or Rust code. CoCoSim uses 9 | Lustre as its intermediate language. CoCoSim is currently under 10 | development. We welcome any feedback and bug report. 11 | 12 | [](https://youtu.be/dcs8GOeFI9c) 13 | 14 | ## CoCoSim ToolBox 15 | 16 | The CoCoSim toolbox contains linux and osx binariers for the backend solvers. 17 | Download the [CoCoSim ToolBox](https://github.com/coco-team/cocoSim/releases) 18 | 19 | 20 | 21 | ## Installation 22 | 23 | CoCoSim can be installed and used as follows: 24 | 25 | ### Dependencies 26 | 27 | * MATLAB(c) version **R2014b** or newer 28 | * [Zustre](https://github.com/lememta/zustre) 29 | * (Optional) [JKind](https://github.com/agacek/jkind) -- Best for Windows OS users 30 | * (Optional) [Kind2](http://kind2-mc.github.io/kind2/) 31 | * Python2.7 32 | 33 | ### Configuration 34 | 35 | * Place the different solvers (Zustre, Kind2, JKind) under ```cocosim/tools/verifiers/```. 36 | * Set the configuration for the backend solvers in `src/config.m`: 37 | * `ZUSTRE`: Path to [Zustre](https://github.com/coco-team/zustre) binary. 38 | * `KIND2`: Path to [Kind2](https://github.com/kind2-mc/kind2) binary. 39 | * `LUSTREC`: Path to [LustreC](https://github.com/coco-team/lustrec) binary. 40 | * `Z3`: Path to Z3 binary. If you install Zustre, Z3 can be found in `ZUSTRE_PATH/build/run/bin/z3`. 41 | * `JKIND`: Path to [JKind](https://github.com/agacek/jkind). 42 | 43 | 44 | ### Launching 45 | 46 | + Launch Matlab(c) 47 | + Navigate to `cocosim/` 48 | + Just run the file ```start_cocosim``` 49 | + Make sure to have one of the backround solvers installed (e.g. Zustre, Kind2 and or JKind) 50 | + You can now open your Simulink model, e.g. ```open test/properties/safe_1.mdl``` 51 | 52 | ## # Example 53 | 54 | 1. To test a safe property: `open test/properties/safe_1.mdl` 55 | 2. Under the `Tools` menu choose `Verify with ...` and then `Zustre` (or JKind if you are under Windows OS). 56 | 3. To test an unsafe property (which also provide a counterexample): 57 | `open test/properties/unsafe_1.mdl` 58 | 59 | More information about CoCoSim can be found [here](https://github.com/coco-team/cocoSim/wiki/CoCoSim) 60 | 61 | ## Waffle 62 | [](https://waffle.io/coco-team/cocoSim) 63 | [](https://waffle.io/coco-team/cocoSim/metrics/throughput) 64 | 65 | ## Developers 66 | 67 | * Lead Developer: [Temesghen Kahsai](http://www.lememta.info/) 68 | 69 | * Current Contributors: Hamza Bourbouh (SGT - USA), Pierre-Loic 70 | Garoche (Onera - France), Claire Pagetti (Onera - France), Eric 71 | Noulard (Onera - France), Thomas Loquen (Onera - France), Xavier 72 | Thirioux (ENSEEIHT - France) 73 | 74 | * Past Contributors: Arnaud Dieumegard (Fabruary - August 2015) 75 | 76 | 77 | ## Acknowledgments and Disclaimers 78 | 79 | CoCoSim is partially funded by: 80 | 81 | * NASA NRA NNX14AI09G 82 | * NSF award 1136008 83 | 84 | Any opinions, findings and conclusions or recommendations expressed in 85 | this material are those of the author(s) do not necessarily 86 | reflect the views of NASA and NSF. 87 | -------------------------------------------------------------------------------- /libs/cocosimLibs.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim-deprecated/10fa76fee83458ee1b699255182a4a62e16b9864/libs/cocosimLibs.slx -------------------------------------------------------------------------------- /pre-commit.cmd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this hook is in SCM so that it can be shared 3 | # to install it, create a symbolic link in the projects .git/hooks folder 4 | # 5 | # i.e. - from the .git/hooks directory, run 6 | # $ ln -s ../../git-hooks/pre-commit.sh pre-commit 7 | # 8 | # to skip the tests, run with the --no-verify argument 9 | # i.e. - $ 'git commit --no-verify' 10 | 11 | echo "CoCoSim Pre Commit checks ... (you better have run the regression tests)" 12 | # stash any unstaged changes 13 | git stash -q --keep-index 14 | 15 | # check for results of regression te 16 | python sanity/sanity_check.py 17 | 18 | # store the last exit code in a variable 19 | RESULT=$? 20 | 21 | echo $RESULT 22 | 23 | # unstash the unstashed changes 24 | git stash pop -q 25 | 26 | # return the './gradlew test' exit code 27 | exit $RESULT 28 | -------------------------------------------------------------------------------- /pre-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this hook is in SCM so that it can be shared 3 | # to install it, create a symbolic link in the projects .git/hooks folder 4 | # 5 | # i.e. - from the .git/hooks directory, run 6 | # $ ln -s ../../pre-commit.sh pre-commit 7 | # 8 | # to skip the tests, run with the --no-verify argument 9 | # i.e. - $ 'git commit --no-verify' 10 | 11 | echo "CoCoSim Pre Commit checks ..." 12 | # stash any unstaged changes 13 | git stash -q --keep-index 14 | 15 | # check for results of regression te 16 | python sanity/sanity_check.py 17 | 18 | # store the last exit code in a variable 19 | RESULT=$? 20 | 21 | 22 | # unstash the unstashed changes 23 | git stash pop -q 24 | 25 | # return the './gradlew test' exit code 26 | exit $RESULT 27 | -------------------------------------------------------------------------------- /sanity/README: -------------------------------------------------------------------------------- 1 | This directory will contain one file reporting the result of regression testing 2 | -------------------------------------------------------------------------------- /sanity/pre_release_script.m: -------------------------------------------------------------------------------- 1 | function pre_release_script(folder_Path, version) 2 | 3 | if nargin==0 4 | [file_path, ~, ~] = fileparts(mfilename('fullpath')); 5 | folder_Path = fileparts(file_path); 6 | end 7 | if nargin < 2 8 | version = 'R2014a'; 9 | end 10 | mdl_models = dir(fullfile(folder_Path,'**/*.mdl')); 11 | slx_models = dir(fullfile(folder_Path,'**/*.slx')); 12 | models = [mdl_models; slx_models]; 13 | 14 | 15 | for i=1:numel(models) 16 | m = models(i); 17 | 18 | full_path = fullfile(folder_Path, m.name); 19 | try 20 | info = Simulink.MDLInfo(full_path); 21 | if str2double(info.SimulinkVersion) > 8.3 22 | fprintf('saving model %s in %s format\n', m.name, version); 23 | load_system(full_path); 24 | [path, base_name, ext] = fileparts(full_path); 25 | get_param(base_name,'Modelversionformat') 26 | target_filename = fullfile(path, strcat(base_name, '_tmp',ext)); 27 | 28 | Simulink.exportToVersion(base_name,target_filename,version); 29 | close_system(full_path,1); 30 | delete(full_path); 31 | copyfile(target_filename, full_path); 32 | delete(target_filename); 33 | delete(strcat(full_path,'.r20*')); 34 | display('Done'); 35 | end 36 | catch ME 37 | dsplay(ME.getReport()) 38 | continue; 39 | end 40 | 41 | end 42 | bdclose('all') 43 | end -------------------------------------------------------------------------------- /sanity/sanity_check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import glob 5 | #import time 6 | from os import path 7 | #from datetime import datetime, timedelta 8 | 9 | current_path = os.path.dirname(os.path.abspath(__file__)) 10 | 11 | print("Runing regression testing....") 12 | cocosim_path = os.path.abspath(os.path.join(current_path, os.pardir)) 13 | cocoTeam_path = os.path.abspath(os.path.join(cocosim_path, os.pardir)) 14 | regression_runner_path = os.path.abspath(os.path.join(cocoTeam_path, "regression-test/scripts")) 15 | add_path = "addpath('"+regression_runner_path+"')" 16 | bashCommand = "matlab -nodisplay -r \"try, "+add_path+"; test_all; bdclose('all'); catch e, disp(getReport(e)), exit(7); end, exit()\"" 17 | return_val = os.system(bashCommand) 18 | 19 | if return_val == 0: 20 | 21 | print("Checking for regression testing result ....") 22 | 23 | all_reg = glob.glob(current_path + os.sep + 'not_valid_models*') 24 | 25 | if len(all_reg) > 0: 26 | for reg in all_reg: 27 | print(":( You need to fix these models") 28 | with open(reg, 'r') as fin: 29 | print fin.read() 30 | exit(1) 31 | else: 32 | print(":) Good Job!!! All models are valid") 33 | exit(0) 34 | 35 | else: 36 | print(":( You need to check your regression tests:") 37 | print("1. Checkout https://github.com/coco-team/regression-test in the same folder as cocoSim") 38 | print("2. Configure scripts/test_all.m") 39 | exit(1) 40 | -------------------------------------------------------------------------------- /src/backEnd/lustrec.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | 6 | 7 | function lustrec(lustre_file_name) 8 | 9 | [path file ext] = fileparts(lustre_file_name); 10 | config; 11 | new_dir = [path '/' file '_cgen']; 12 | if ~exist(new_dir, 'dir') 13 | mkdir(new_dir); 14 | end 15 | if exist(LUSTREC,'file') 16 | date_value = datestr(now, 'ddmmyyyyHHMMSS'); 17 | command = sprintf('%s -I %s -d %s %s', LUSTREC, include_dir, new_dir, lustre_file_name); 18 | [status, lustrec_out] = system(command); 19 | if isempty(strfind(lustrec_out, '.. done')) 20 | display_msg('Error Generating C code', Constants.ERROR, 'C Generation', ''); 21 | else 22 | msg = ['C code is generated in : ' new_dir] ; 23 | display_msg(msg, Constants.RESULT, 'C Generation', ''); 24 | end 25 | else 26 | msg = 'Running C: Impossible to find LustreC'; 27 | display_msg(msg, Constants.ERROR, 'C Generation', ''); 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /src/backEnd/rust.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | 6 | 7 | function rust(lustre_file_name) 8 | 9 | [path file ext] = fileparts(lustre_file_name); 10 | config; 11 | new_dir = [path '_rust']; 12 | if ~exist(new_dir, 'dir') 13 | mkdir(new_dir); 14 | end 15 | if exist(KIND2,'file') 16 | date_value = datestr(now, 'ddmmyyyyHHMMSS'); 17 | command = sprintf('%s --compile true --z3_bin %s --output_dir %s --check_implem false %s', KIND2, Z3, new_dir, lustre_file_name); 18 | display_msg(['KIND2_COMMAND ' command], Constants.DEBUG, 'write_code', ''); 19 | [status, rust_out] = system(command); 20 | if isempty(strfind(rust_out, 'Success')) 21 | display_msg('Error Generating Rust code', Constants.ERROR, 'Rust Generation', ''); 22 | display_msg(rust_out, Constants.ERROR, 'Rust Generation', ''); 23 | else 24 | msg = ['Rust code is generated in : ' new_dir] ; 25 | display_msg(msg, Constants.INFO, 'Rust', ''); 26 | end 27 | else 28 | msg = 'Running Kind2: Impossible to find Kind2'; 29 | display_msg(msg, Constants.ERROR, 'Rust', ''); 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /src/backEnd/seahorn.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | 6 | 7 | function [smt_out_file] = seahorn(c_file_name) 8 | 9 | [path file ext] = fileparts(c_file_name); 10 | config; 11 | entry_function = file; 12 | display_msg(['Entry Function: ' entry_function], Constants.INFO, 'SEAHORN', ''); 13 | smt_out_file = fullfile(path, strcat(entry_function,'.smt2')); 14 | if exist(SEAHORN,'file') 15 | date_value = datestr(now, 'ddmmyyyyHHMMSS'); 16 | command = sprintf('%s smt -O0 --horn-no-verif --horn-stats --entry=%s -o %s %s', SEAHORN, entry_function, smt_out_file, c_file_name); 17 | 18 | [status, seahorn_out] = system(command); 19 | if isempty(strfind(seahorn_out, 'BRUNCH STATS END')) 20 | display_msg('Error Generating HORN Clause', Constants.ERROR, 'SEAHORN', ''); 21 | display_msg(seahorn_out, Constants.ERROR, 'SEAHORN', ''); 22 | else 23 | if exist(smt_out_file, 'file') 24 | msg = ['HORN Clauses are generated in : ' smt_out_file] ; 25 | display_msg(msg, Constants.RESULT, 'SEAHORN', ''); 26 | else 27 | display_msg('Error Generating HORN Clause', Constants.ERROR, 'SEAHORN', ''); 28 | display_msg(seahorn_out, Constants.ERROR, 'SEAHORN', ''); 29 | end 30 | end 31 | else 32 | msg = 'Running SEAHORN: Impossible to find SEAHORN'; 33 | display_msg(msg, Constants.ERROR, 'SeaHorn', ''); 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /src/backEnd/solver_result.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | 6 | % Parse the XML output of Solver and return the status of the result (SAFE, CEX, UNKNOWN) 7 | function [answer, cex] = solver_result(solver, xml_result, property_node_name, property_file_base_name) 8 | answer = ''; 9 | cex = ''; 10 | prop_file_name = [property_file_base_name '_' property_node_name '.xml']; 11 | fid = fopen(prop_file_name, 'w'); 12 | fprintf(fid, xml_result); 13 | fclose(fid); 14 | s = dir(prop_file_name); 15 | if s.bytes ~= 0 16 | xml_doc = xmlread(prop_file_name); 17 | xml_properties = xml_doc.getElementsByTagName('Property'); 18 | % logs = xml_doc.getElementsByTagName('Log'); 19 | % for idx=0:(logs.getLength-1) 20 | % log = logs.item(idx); 21 | % end 22 | for idx=0:(xml_properties.getLength-1) 23 | prop = xml_properties.item(idx); 24 | answer = prop.getElementsByTagName('Answer').item(0).getTextContent; 25 | 26 | if strcmp(solver, 'KIND2') || strcmp(solver, 'JKIND') 27 | if strcmp(answer, 'valid') 28 | answer = 'SAFE'; 29 | elseif strcmp(answer, 'falsifiable') 30 | answer = 'CEX'; 31 | else 32 | answer = 'UNKNOWN'; 33 | end 34 | end 35 | 36 | msg = [solver ' result for property node [' property_node_name ']: ' char(answer)]; 37 | display_msg(msg, Constants.RESULT, 'Property checking', ''); 38 | if strcmp(answer, 'CEX') || strcmp(answer, 'falsifiable') 39 | if strcmp(solver, 'JKIND') 40 | xml_cex = xml_doc.getElementsByTagName('Counterexample'); 41 | else 42 | xml_cex = xml_doc.getElementsByTagName('CounterExample'); 43 | end 44 | if xml_cex.getLength > 0 45 | cex = xml_cex; 46 | else 47 | msg = [solver ': FAILURE to get counter example: ']; 48 | msg = [msg property_node_name '\n']; 49 | display_msg(msg, Constants.WARNING, 'Property Checking', ''); 50 | end 51 | end 52 | end 53 | end 54 | end 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/backEnd/templates/ann.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 6 | 7 |8 | Counter example for property_assert_test/observer
9 | 10 |11 | Inputs:
12 |21 | Outputs:
22 | 23 |5 | Counter example for [observer_full_name]
6 | 7 |8 | Inputs:
9 |13 | Outputs:
14 |