├── .gitignore ├── .travis.yml ├── AUTHORS ├── CocosimMenu.m ├── Guidelines.md ├── LICENSE ├── PreContextMenu.m ├── README.md ├── doc ├── compositionalAnalysis.md ├── images │ ├── 2_contracts_simulink.png │ ├── compositionalAnalysis.png │ ├── contextMenuVerificationResults.png │ ├── counterExampleOptions.png │ ├── generalArchitecture.png │ ├── kindLibrary.png │ ├── menu.png │ ├── preferences.png │ ├── propertyColors.png │ ├── subsystemColors.png │ └── validatorMask.png ├── installation.md ├── kind2 installation.md ├── menu.md ├── pp_doc │ └── pp_doc.tex ├── specificationLibrary.md ├── verificationVisualization.md └── videos │ ├── compositionalAbstract.mp4 │ ├── compositionalAbstract.png │ ├── docker.PNG │ ├── docker.html │ ├── docker.mp4 │ ├── htmlVerificationResults.mp4 │ ├── htmlVerificationResults.png │ ├── installation.mp4 │ ├── installation.png │ ├── kind2WebService.PNG │ ├── kind2WebService.html │ └── kind2WebService.mp4 ├── examples ├── StateFlow │ ├── Arrays1V2.mdl │ ├── MicrowaveCex.slx │ ├── MicrowaveV2.mdl │ └── set_up_parameters.m ├── contract │ ├── Days.m │ ├── DaysEnum.slx │ ├── DaysEnumInvalid.slx │ ├── DoorLock.slx │ ├── DoorLockCompositional.slx │ ├── DoorLockCompositionalHtml.slx │ ├── DoorLockInvalid.slx │ ├── StopwatchSpec.slx │ ├── absolute.slx │ ├── bacteriaPopulation.lus │ ├── bacteriaPopulation.slx │ ├── bacteriaPopulationDemo.slx │ ├── bacteriaPopulationStateflow.slx │ └── bacteriaPopulationTruthTable.slx └── properties │ ├── AltitudeControl_Demo.slx │ ├── assertion.mdl │ ├── assumption.slx │ ├── safe_1.mdl │ ├── safe_math_functions.slx │ ├── two_property.mdl │ └── unsafe_1.mdl ├── libs └── contract │ ├── CoCoSimSpecification.slx │ ├── CoCoSimSpecification_r2015a.slx │ ├── Kind.slx │ ├── contract.m │ ├── contractAfterSimulation.m │ ├── contractBeforeSimulation.m │ ├── contract_callback.m │ ├── saveValidatorParameters.m │ └── slblocks.m ├── pre-commit.cmd ├── pre-commit.sh ├── sanity ├── README ├── pre_release_script.m └── sanity_check.py ├── sl_customization.m ├── src ├── backEnd │ ├── common │ │ ├── Kind2Utils.m │ │ └── plotting.m │ ├── generate_code │ │ ├── lustrec.m │ │ └── rust.m │ ├── generate_invariants │ │ ├── ViewContractMenu.m │ │ └── zustre_invariants │ │ │ ├── utils │ │ │ ├── get_block_name_from_variable_using_xRoot.m │ │ │ └── parse_json.m │ │ │ └── view_cocospec.m │ ├── templates │ │ ├── ann.html │ │ ├── annot.html │ │ ├── footer.html │ │ ├── header.html │ │ ├── list_item.html │ │ ├── list_item_mat_code.html │ │ ├── list_title.html │ │ ├── materialize.css │ │ ├── title.html │ │ └── title2.html │ ├── unsupported_blocks │ │ ├── UnsupportedBlocksMenu.m │ │ └── unsupported_blocks.m │ ├── validation │ │ ├── ValidationMenu.m │ │ ├── cocoSpecValidate │ │ │ └── cocoSpecValidate.m │ │ ├── common │ │ │ └── ValidateUtils.m │ │ └── lustreValidate │ │ │ └── validate_lustre.m │ └── verification │ │ ├── VerificationMenu.m │ │ ├── cocoSpecVerify │ │ ├── cocoSpecVerify.m │ │ └── utils │ │ │ ├── CocoSim_IR_Compiler-0.1-jar-with-dependencies.jar │ │ │ ├── cocoSpecKind2.m │ │ │ ├── displayCexHtmlTables.m │ │ │ ├── displayCexSignals.m │ │ │ ├── displayCexTables.m │ │ │ ├── displayVerificationResults.m │ │ │ ├── generateModelWithSignalBuilders.m │ │ │ └── html │ │ │ ├── cexTemplate.html │ │ │ ├── css │ │ │ ├── bootstrap.min.css │ │ │ ├── fa-svg-with-js.css │ │ │ └── jquery.dataTables.min.css │ │ │ ├── js │ │ │ ├── bootstrap.min.js │ │ │ ├── fontawesome-all.js │ │ │ ├── jquery.dataTables.min.js │ │ │ ├── jquery.min.js │ │ │ └── popper.min.js │ │ │ ├── test │ │ │ ├── bootstrap.min.css │ │ │ ├── bootstrap.min.js │ │ │ ├── fa-svg-with-js.css │ │ │ ├── fontawesome-all.js │ │ │ ├── jquery.min.js │ │ │ ├── popper.min.js │ │ │ └── verificationResultsTest.html │ │ │ └── verificationResultsTemplate.html │ │ └── lustreVerify │ │ ├── lustre_verify.m │ │ └── utils │ │ ├── jkind.m │ │ ├── kind2.m │ │ ├── seahorn.m │ │ ├── solver_result.m │ │ └── zustre.m ├── cocosim_config.m ├── frontEnd │ ├── IR │ │ ├── IR_config.m │ │ ├── README.md │ │ ├── blocks │ │ │ ├── chart_struct.m │ │ │ ├── common_struct.m │ │ │ ├── specific_parameters_struct.m │ │ │ └── subsystems_struct.m │ │ ├── cocosim_IR.m │ │ ├── example │ │ │ ├── Model_example.json │ │ │ ├── Model_example.slx │ │ │ └── Model_example_IR.json │ │ ├── meta │ │ │ └── buildDeclarationsStruct.m │ │ └── utils │ │ │ ├── ChartParser.jar │ │ │ ├── ChartParser │ │ │ ├── README.md │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ ├── Main.java │ │ │ │ │ └── edu │ │ │ │ │ └── uiowa │ │ │ │ │ └── chart │ │ │ │ │ ├── state │ │ │ │ │ ├── StateAction.java │ │ │ │ │ ├── StateParser.java │ │ │ │ │ ├── StateVisitor.java │ │ │ │ │ └── antlr │ │ │ │ │ │ ├── StateLabel.g4 │ │ │ │ │ │ ├── StateLabelBaseListener.java │ │ │ │ │ │ ├── StateLabelBaseVisitor.java │ │ │ │ │ │ ├── StateLabelLexer.java │ │ │ │ │ │ ├── StateLabelListener.java │ │ │ │ │ │ ├── StateLabelParser.java │ │ │ │ │ │ ├── StateLabelVisitor.java │ │ │ │ │ │ ├── antlr-4.7.1-complete.jar │ │ │ │ │ │ ├── antlr.bat │ │ │ │ │ │ ├── antlrForGui.bat │ │ │ │ │ │ ├── compile.bat │ │ │ │ │ │ ├── grun.bat │ │ │ │ │ │ └── test.txt │ │ │ │ │ └── transition │ │ │ │ │ ├── Transition.java │ │ │ │ │ ├── TransitionParser.java │ │ │ │ │ ├── TransitionVisitor.java │ │ │ │ │ └── antlr │ │ │ │ │ ├── TransitionLabel.g4 │ │ │ │ │ ├── TransitionLabelBaseListener.java │ │ │ │ │ ├── TransitionLabelBaseVisitor.java │ │ │ │ │ ├── TransitionLabelLexer.java │ │ │ │ │ ├── TransitionLabelListener.java │ │ │ │ │ ├── TransitionLabelParser.java │ │ │ │ │ ├── TransitionLabelVisitor.java │ │ │ │ │ ├── antlr-4.7.1-complete.jar │ │ │ │ │ ├── antlr.bat │ │ │ │ │ ├── compile.bat │ │ │ │ │ ├── grun.bat │ │ │ │ │ └── test.txt │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── edu │ │ │ │ └── uiowa │ │ │ │ └── chart │ │ │ │ ├── state │ │ │ │ └── StateActionParserTest.java │ │ │ │ └── transition │ │ │ │ └── TransitionParserTest.java │ │ │ ├── IRUtils.m │ │ │ ├── catstruct.m │ │ │ ├── cocoget_param.m │ │ │ ├── get_struct.m │ │ │ ├── jsmn.c │ │ │ ├── jsmn.h │ │ │ ├── json_decode.c │ │ │ ├── json_decode.m │ │ │ ├── json_decode.mexa64 │ │ │ ├── json_decode.mexmaci64 │ │ │ ├── json_decode.mexw64 │ │ │ ├── json_encode.c │ │ │ ├── json_encode.m │ │ │ ├── json_encode.mexa64 │ │ │ ├── json_encode.mexmaci64 │ │ │ ├── json_encode.mexw64 │ │ │ ├── license.txt │ │ │ └── make.m │ └── pp │ │ ├── PreprocessingMenu.m │ │ ├── README │ │ ├── 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 │ │ ├── link_process.m │ │ ├── lookuptable_nD_process.m │ │ ├── lookuptable_process.m │ │ ├── math_process.m │ │ ├── product_process.m │ │ ├── pulsegenerator_process.m │ │ ├── rate_transition_process.m │ │ ├── rename_numerical_prefix.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 │ │ ├── cocosim_pp.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 │ │ ├── default_constants.m │ │ └── math │ │ ├── expr_parser.py │ │ ├── expr_parser.pyc │ │ ├── expression_process.m │ │ └── parse_math.m ├── gui │ ├── CocosimWindow │ │ ├── CocosimWindowMenu.m │ │ └── cocosim_window.m │ ├── PropertyGeneration │ │ ├── PropertyGenerationMenu.m │ │ └── add_property.m │ ├── cocosim_window.m │ ├── unsupported_blocks_gui.m │ ├── utils │ │ └── add_cocospec.m │ └── validate_window.m ├── middleEnd │ ├── cocoSpecCompiler │ │ ├── IR_pp │ │ │ └── cocoSpecIRPP.m │ │ └── cocoSpecCompiler.m │ └── lustre_compiler │ │ ├── IR_pp │ │ ├── README │ │ ├── fields │ │ │ ├── conversion.m │ │ │ └── lustre_pp.m │ │ └── ir_pp.m │ │ ├── blocks │ │ ├── Stateflow │ │ │ ├── common │ │ │ │ ├── Parallel_states_call.m │ │ │ │ ├── add_node_param.m │ │ │ │ ├── add_unchanged_variables.m │ │ │ │ ├── add_variables.m │ │ │ │ ├── chart_and_function_code.m │ │ │ │ ├── construct_node_header.m │ │ │ │ ├── extern_nodes_header.m │ │ │ │ ├── get_full_name.m │ │ │ │ ├── sT2fT.m │ │ │ │ ├── temporal_operators.m │ │ │ │ ├── transition_code.m │ │ │ │ ├── update_variables.m │ │ │ │ ├── write_Transition_actions.m │ │ │ │ ├── write_action.m │ │ │ │ ├── write_global_node.m │ │ │ │ ├── write_sf_Matlab_function_node.m │ │ │ │ ├── write_state_actions.m │ │ │ │ └── write_state_node.m │ │ │ └── write_Chart.m │ │ ├── write_Abs.m │ │ ├── write_ActionPort.m │ │ ├── write_Assignment.m │ │ ├── write_Bias.m │ │ ├── write_BitwiseOperator.m │ │ ├── write_BusAssignment.m │ │ ├── write_BusCreator.m │ │ ├── write_BusSelector.m │ │ ├── write_CoCoSimImplies.m │ │ ├── write_CompareTo.m │ │ ├── write_Concatenate.m │ │ ├── write_Constant.m │ │ ├── write_Create3x3Matrix.m │ │ ├── write_CrossProduct.m │ │ ├── write_DataTypeConversion.m │ │ ├── write_Delay.m │ │ ├── write_Demux.m │ │ ├── write_Detect.m │ │ ├── write_DiscreteIntegrator.m │ │ ├── write_DiscreteStateSpace.m │ │ ├── write_DiscreteZeroPole.m │ │ ├── write_DiscretizedZeroPole.m │ │ ├── write_DotProduct.m │ │ ├── write_EnablePort.m │ │ ├── write_Fcn.m │ │ ├── write_ForIterator.m │ │ ├── write_From.m │ │ ├── write_FromWorkspace.m │ │ ├── write_Gain.m │ │ ├── write_Goto.m │ │ ├── write_If.m │ │ ├── write_Inport.m │ │ ├── write_Logic.m │ │ ├── write_LookupNDDirect.m │ │ ├── write_Math.m │ │ ├── write_Memory.m │ │ ├── write_Merge.m │ │ ├── write_MinMax.m │ │ ├── write_Multiportswitch.m │ │ ├── write_Mux.m │ │ ├── write_Observer.m │ │ ├── write_Outport.m │ │ ├── write_Polyval.m │ │ ├── write_Product.m │ │ ├── write_RelationalOperator.m │ │ ├── write_Reshape.m │ │ ├── write_SFunction.m │ │ ├── write_Saturate.m │ │ ├── write_SaturationDynamic.m │ │ ├── write_Scope.m │ │ ├── write_Selector.m │ │ ├── write_SignalConversion.m │ │ ├── write_SignalSpecification.m │ │ ├── write_Signum.m │ │ ├── write_Sqrt.m │ │ ├── write_SubSystem.m │ │ ├── write_Sum.m │ │ ├── write_Switch.m │ │ ├── write_SwitchCase.m │ │ ├── write_Terminator.m │ │ ├── write_ToWorkspace.m │ │ ├── write_TriggerPort.m │ │ ├── write_Trigonometry.m │ │ ├── write_UnitDelay.m │ │ └── write_matlab_function_node.m │ │ ├── common │ │ ├── BlockUtils.m │ │ ├── BusUtils.m │ │ ├── CoCoSpec.m │ │ ├── LusUtils.m │ │ ├── XML_Trace.m │ │ ├── blockType_format.m │ │ ├── complex_arith_int.lus │ │ ├── complex_arith_real.lus │ │ ├── compute_complex_structs.m │ │ ├── convert_cocospec.m │ │ ├── func2node.py │ │ ├── generate-tables.py │ │ ├── get_subsystem_struct.m │ │ ├── list_var_action.m │ │ ├── list_var_entree.m │ │ ├── list_var_input.m │ │ ├── list_var_outport.m │ │ ├── list_var_sortie.m │ │ ├── math_functions.m │ │ ├── name_block.m │ │ ├── setdiff_struct.m │ │ ├── sort_by_order.m │ │ ├── split_transition.m │ │ ├── traceability_annotation.m │ │ ├── write_buses.m │ │ ├── write_extern_SFunction.m │ │ └── write_extern_functions.m │ │ ├── frontEnd │ │ ├── blocks2lustre.m │ │ ├── write_code.m │ │ └── write_config.m │ │ └── lustre_compiler.m ├── miscellaneous │ └── MiscellaneousMenu.m ├── preferences │ ├── PreferencesMenu.m │ └── loadCoCoSimPreferences.m └── utils │ ├── Constants.m │ ├── Utils.m │ ├── app_sprintf.m │ ├── cprintf.m │ ├── display_msg.m │ └── log4m.m └── start_cocosim.m /.gitignore: -------------------------------------------------------------------------------- 1 | src/config.m 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | Project leaders: 3 | Temesghen Kahsai : teme DOT kahsai AT sv DOT cmu DOT com (NASA AMES / CMU) 4 | Cesare Tinelli : cesare DASH tinelli AT uiowa DOT edu (UIOWA) 5 | Corina Pasareanu : corina DOT pasareanu AT west DOT cmu DOT edu (NASA AMES / CMU) 6 | 7 | Developers/Contributors: 8 | Hamza Bourbouh : hamza DOT bourbouh AT nasa DOT gov (NASA AMES) 9 | Pierre-Loic Garoche : pierre DASH loic DOT garoche AT onera DOT fr (ONERA) 10 | Mudathir Mohamed : mudathir DASH mahgoubyahia AT uiowa DOT edu (UIOWA) 11 | Baoluo Meng : baoluo DASH meng AT uiowa DOT edu (UIOWA) 12 | Daniel Larraz : daniel DASH larraz AT uiowa DOT edu (UIOWA) 13 | Christelle Dambreville : christelledambreville AT hotmail DOT fr (ENSEEIHTENSEEIHT) 14 | Claire Pagetti : claire DOT pagetti AT onera DOT fr (ONERA) 15 | Eric Noulard : eric DOT noulard AT onera DOT fr (ONERA) 16 | Thomas Loquen : thomas DOT loquen AT onera DOT fr (ONERA) 17 | Xavier Thirioux : xavier DOT thirioux AT enseeiht DOT fr (ENSEEIHT) 18 | Arnaud Dieumegard : arnaud DOT dieumegard AT gmail DOT com (IRIT) 19 | 20 | -------------------------------------------------------------------------------- /CocosimMenu.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | % Copyright (C) 2018 The university of Iowa 5 | % Authors: Temesghen Kahsai, Hamza Bourbouh, Mudathir Mahgoub 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | 8 | classdef CocosimMenu 9 | methods(Static) 10 | %% Define the custom menu function. 11 | function schemaFcns = cocosimMenu 12 | schemaFcns = {@CocosimMenu.getcocoSim}; 13 | end 14 | 15 | %% Define the custom menu function. 16 | function schema = getcocoSim(callbackInfo) 17 | schema = sl_container_schema; 18 | schema.label = 'CoCoSim'; 19 | schema.statustip = 'Automated Analysis Framework'; 20 | schema.autoDisableWhen = 'Busy'; 21 | 22 | % modelWorkspace = get_param(callbackInfo.studio.App.blockDiagramHandle,'modelworkspace'); 23 | % if modelWorkspace.hasVariable('isPreprocessedModel') && ... 24 | % modelWorkspace.getVariable('isPreprocessedModel') == 1 25 | % schema.state = 'Disabled'; 26 | % end 27 | 28 | schema.childrenFcns = {... 29 | @VerificationMenu.verify, ... 30 | @VerificationMenu.verifyUsing,... 31 | @ValidationMenu.validate, ... 32 | @UnsupportedBlocksMenu.checkUnsupportedBlocks, ... 33 | %@ViewContractMenu.viewContract, ... 34 | @PropertyGenerationMenu.generateProperty, ... 35 | @PreprocessingMenu.preprocess,... 36 | @CocosimWindowMenu.getCompiler, ... 37 | @PreferencesMenu.getMenu ... 38 | }; 39 | end 40 | end 41 | end -------------------------------------------------------------------------------- /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) 2015-2018 Carnegie Mellon University 3 | Copyright (c) 2015-2018 The University of Iowa 4 | All Rights Reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following acknowledgments and 12 | disclaimers. 13 | 14 | 2. Redistributions in binary form must reproduce the 15 | above copyright notice, this list of conditions and the following 16 | acknowledgments and disclaimers in the documentation and/or other 17 | materials provided with the distribution. 18 | 19 | 3. Products derived from this software may not include “Carnegie Mellon 20 | University” or “The University of Iowa” in the name of such derived product, 21 | nor shall “Carnegie Mellon University” or “The University of Iowa” 22 | be used to endorse or promote products derived from this software without 23 | prior written permission. 24 | 25 | 26 | ACKNOWLEDGMENTS AND DISCLAIMERS: 27 | 28 | Copyright 2015-2018 Carnegie Mellon University 29 | Copyright 2015-2018 The University of Iowa 30 | 31 | This material is based upon work funded and supported by 32 | NASA NRA Contract No. NNX14AI09G and NSF Award No. 1422705. 33 | 34 | Any opinions, findings and conclusions or recommendations expressed in 35 | this material are those of the author(s) and do not necessarily 36 | reflect the views of NASA nor NSF. 37 | 38 | 39 | NO WARRANTY. THIS MATERIAL IS FURNISHED ON AN “AS-IS” BASIS. CARNEGIE MELLON 40 | UNIVERSITY AND THE UNIVERSITY OF IOWA MAKE NO WARRANTIES OF ANY KIND, 41 | EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, 42 | WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS 43 | OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY AND 44 | THE UNIVERSITY OF IOWA DO NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO 45 | FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. 46 | 47 | 48 | -------------------------------------------------------------------------------- /PreContextMenu.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2018 The university of Iowa 4 | % Author: Mudathir Mahgoub 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | classdef PreContextMenu 8 | methods(Static) 9 | function schemaFcns = preContextMenu 10 | schemaFcns = {@PreContextMenu.cocoSimActions}; 11 | end 12 | 13 | function schema = cocoSimActions(callbackInfo) 14 | schema = sl_container_schema; 15 | schema.label = 'CoCoSim'; 16 | schema.statustip = 'CoCoSim'; 17 | schema.autoDisableWhen = 'Busy'; 18 | 19 | modelWorkspace = get_param(callbackInfo.studio.App.blockDiagramHandle,'modelworkspace'); 20 | if ~isempty(modelWorkspace) && modelWorkspace.hasVariable('compositionalMap') 21 | schema.childrenFcns = {... 22 | @VerificationMenu.displayHtmlVerificationResults,... 23 | @VerificationMenu.compositionalOptions,... 24 | @MiscellaneousMenu.replaceInportsWithSignalBuilders... 25 | }; 26 | else 27 | schema.childrenFcns = {@MiscellaneousMenu.replaceInportsWithSignalBuilders}; 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /doc/images/2_contracts_simulink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/2_contracts_simulink.png -------------------------------------------------------------------------------- /doc/images/compositionalAnalysis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/compositionalAnalysis.png -------------------------------------------------------------------------------- /doc/images/contextMenuVerificationResults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/contextMenuVerificationResults.png -------------------------------------------------------------------------------- /doc/images/counterExampleOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/counterExampleOptions.png -------------------------------------------------------------------------------- /doc/images/generalArchitecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/generalArchitecture.png -------------------------------------------------------------------------------- /doc/images/kindLibrary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/kindLibrary.png -------------------------------------------------------------------------------- /doc/images/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/menu.png -------------------------------------------------------------------------------- /doc/images/preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/preferences.png -------------------------------------------------------------------------------- /doc/images/propertyColors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/propertyColors.png -------------------------------------------------------------------------------- /doc/images/subsystemColors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/subsystemColors.png -------------------------------------------------------------------------------- /doc/images/validatorMask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/images/validatorMask.png -------------------------------------------------------------------------------- /doc/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | There are two ways to use CoCoSim on your computer. You can install it as a MATLAB toolbox, or you can get a local copy of the source code. CoCoSim requires MATLAB version **R2015a** or newer. CoCoSim works better with recent versions of MATLAB. 4 | 5 | ## Installation using MATLAB toolbox 6 | 7 | The CoCoSim toolbox (CoCoSim.mltbx) contains Linux and macOS binaries for the backend solvers. You can download the latest release for CoCoSim toolbox from [here](https://github.com/coco-team/cocoSim2/releases). 8 | 9 | The following video explains how to install and start CoCoSim: 10 | 11 | [](http://milner.cs.uiowa.edu/cocosim/installation.mp4) 12 | 13 | The latest version of CoCoSim depends on the [Kind 2](https://github.com/kind2-mc/kind2) model checker. Kind 2 binaries for Linux and macOS are provided in the toolbox. Alternatively, CoCoSim can run Kind 2 remotely as a [web service](#kind2-web-service) or locally as a [Docker](#docker) image. Please note that Kind 2 binaries are not available for Windows. 14 | 15 | ## Installation using source code 16 | 17 | 1. Clone the CoCoSim repository: ```git clone https://github.com/coco-team/cocoSim2``` 18 | 2. For Linux and macOS users: download and extract the tools zip file ```https://github.com/coco-team/cocoSim2/releases/download/v.0.4/tools.zip``` into the ```cocoSim2``` folder. For Windows, configure CoCoSim to use the [Kind 2 web service](#kind2-web-service) or a [Docker](#docker) image of Kind 2. 19 | 20 | ### Kind2 web service 21 | 22 | The following video explains how to configure CoCoSim to use the Kind 2 web service: 23 | 24 | [](http://milner.cs.uiowa.edu/cocosim/kind2WebService.mp4) 25 | 26 | ### Docker 27 | 28 | The following video explains how to install and configure CoCoSim to use a Docker image of Kind 2: 29 | 30 | [](http://milner.cs.uiowa.edu/cocosim/docker.mp4) 31 | 32 | ## Launching 33 | 34 | + Launch MATLAB 35 | + Run the command ```start_cocosim``` 36 | + You can now open and verify your Simulink model 37 | 38 | -------------------------------------------------------------------------------- /doc/kind2 installation.md: -------------------------------------------------------------------------------- 1 | 1. Install Automake 2 | 3 | ```sudo apt-get install automake``` 4 | 5 | 2. Install opam for ocaml: 6 | 7 | ``` 8 | wget https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sh -s /usr/local/bin 9 | 10 | opam init 11 | 12 | opam switch 4.06.1 13 | 14 | eval `opam config env` 15 | 16 | opam install ocamlbuild 17 | 18 | opam install menhir 19 | 20 | opam install num 21 | ``` 22 | 23 | 3. Install z3 24 | 25 | ``` 26 | git clone https://github.com/Z3Prover/z3 27 | 28 | cd z3 29 | 30 | python scripts/mk_make.py 31 | 32 | cd build 33 | 34 | make 35 | 36 | sudo make install 37 | 38 | ``` 39 | 40 | 4. Install kind2 41 | 42 | ``` 43 | git clone https://github.com/kind2-mc/kind2 44 | 45 | cd kind2 46 | 47 | ./autogen.sh 48 | 49 | ./build.sh 50 | 51 | make install 52 | 53 | ``` 54 | -------------------------------------------------------------------------------- /doc/menu.md: -------------------------------------------------------------------------------- 1 | # CoCoSim menu 2 | 3 |  4 | 5 | CoCoSim Menu can be accessed after [launching CoCoSim](https://github.com/coco-team/cocoSim2/blob/master/doc/installation.md#launching) through the Tools menu in Simulink models. CoCoSim menu contains many items: 6 | 7 | + Verify: this option starts the verification process for the current model using the current user's preferences 8 | + Create Property (deprecated): This option adds an observer property to the model. Observers are subsumed by the new [CoCoSim Specification Library](https://github.com/coco-team/cocoSim2/blob/master/doc/specificationLibrary.md) 9 | + Verify using: this option starts the verification process for the current model using the selected back-end solver 10 | + Simplifier: [to be completed] 11 | + Compiler Validation (experimental): [to be completed] 12 | + Check unsupported blocks: check whether all blocks used in the model are supported by the plugin 13 | + Preferences: user's preferences are updated using this menu item: 14 |  15 | + Use IR to lustre Compiler (enabled by default): CoCoSim uses the latest [translator](https://github.com/coco-team/ir2lustre) from CoCoSim IR to Lustre (written in Java) which supports [contract specification](https://github.com/coco-team/cocoSim2/blob/master/doc/specificationLibrary.md). If this option is disabled, CoCoSim will use the old translator (written in MATLAB) which only supports the observer block. 16 | + Compositional Analysis (enabled by default): CoCoSim will verify the model specification using a [compositional analysis](https://github.com/coco-team/cocoSim2/blob/master/doc/compositionalAnalysis.md). If it is disabled, CoCoSim will perform only a modular analysis. 17 | + Kind 2 binary: This option specifies which Kind 2 binary is used in the backend: 18 | + Local: The default option in Linux and macOS which tells CoCoSim to use the local binary located inside the tools folder. 19 | + Docker: This option tells CoCoSim to use Kind 2 image installed in docker container platform. See [here](https://github.com/coco-team/cocoSim2/blob/master/doc/installation.md#docker) on how to install docker and Kind 2 in Windows 20 | + Kind2 web service: This is the default option in Windows. This option tells CoCoSim to use [Kind2 web service](https://github.com/kind2-mc/kind2-webservices/wiki) which supports verification and simulation requests. 21 | + Verification timeout: the timeout argument for Kind 2 22 | -------------------------------------------------------------------------------- /doc/videos/compositionalAbstract.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/compositionalAbstract.mp4 -------------------------------------------------------------------------------- /doc/videos/compositionalAbstract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/compositionalAbstract.png -------------------------------------------------------------------------------- /doc/videos/docker.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/docker.PNG -------------------------------------------------------------------------------- /doc/videos/docker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /doc/videos/docker.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/docker.mp4 -------------------------------------------------------------------------------- /doc/videos/htmlVerificationResults.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/htmlVerificationResults.mp4 -------------------------------------------------------------------------------- /doc/videos/htmlVerificationResults.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/htmlVerificationResults.png -------------------------------------------------------------------------------- /doc/videos/installation.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/installation.mp4 -------------------------------------------------------------------------------- /doc/videos/installation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/installation.png -------------------------------------------------------------------------------- /doc/videos/kind2WebService.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/kind2WebService.PNG -------------------------------------------------------------------------------- /doc/videos/kind2WebService.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /doc/videos/kind2WebService.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/doc/videos/kind2WebService.mp4 -------------------------------------------------------------------------------- /examples/StateFlow/MicrowaveCex.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/StateFlow/MicrowaveCex.slx -------------------------------------------------------------------------------- /examples/StateFlow/set_up_parameters.m: -------------------------------------------------------------------------------- 1 | 2 | step_size = Simulink.Parameter; 3 | step_size.Value = 1.0; 4 | step_size.DataType = 'double'; 5 | 6 | dt = 0.01; 7 | 8 | Primary_Side = Simulink.Parameter; 9 | Primary_Side.Value = 0; 10 | Primary_Side.DataType = 'boolean'; 11 | 12 | MANUAL = Simulink.Parameter; 13 | MANUAL.Value = 1; 14 | MANUAL.DataType = 'uint8'; 15 | 16 | LO = Simulink.Parameter; 17 | LO.Value = 2; 18 | LO.DataType = 'uint8'; 19 | 20 | MED = Simulink.Parameter; 21 | MED.Value = 3; 22 | MED.DataType = 'uint8'; 23 | 24 | MAX = Simulink.Parameter; 25 | MAX.Value = 4; 26 | MAX.DataType = 'uint8'; 27 | 28 | BRAKE_PRESSURE_LO = Simulink.Parameter; 29 | BRAKE_PRESSURE_LO.Value = 170; 30 | BRAKE_PRESSURE_LO.DataType = 'int32'; 31 | 32 | BRAKE_PRESSURE_MED = Simulink.Parameter; 33 | BRAKE_PRESSURE_MED.Value = 340; 34 | BRAKE_PRESSURE_MED.DataType = 'int32'; 35 | 36 | BRAKE_PRESSURE_MAX = Simulink.Parameter; 37 | BRAKE_PRESSURE_MAX.Value = 510; 38 | BRAKE_PRESSURE_MAX.DataType = 'int32'; -------------------------------------------------------------------------------- /examples/contract/Days.m: -------------------------------------------------------------------------------- 1 | classdef Days < Simulink.IntEnumType 2 | enumeration 3 | Sunday(1) 4 | Monday(2) 5 | Tuesday(3) 6 | Wednesday(4) 7 | Thursday(5) 8 | Friday(6) 9 | Saturday(7) 10 | end 11 | % methods(Static) 12 | % function retVal = getDefaultValue() 13 | % % GETDEFAULTVALUE Specifies the default enumeration member. 14 | % % Return a valid member of this enumeration class to specify the default. 15 | % % If you do not define this method, Simulink uses the first member. 16 | % retVal = Days.Monday; 17 | % end 18 | % end 19 | end -------------------------------------------------------------------------------- /examples/contract/DaysEnum.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/DaysEnum.slx -------------------------------------------------------------------------------- /examples/contract/DaysEnumInvalid.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/DaysEnumInvalid.slx -------------------------------------------------------------------------------- /examples/contract/DoorLock.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/DoorLock.slx -------------------------------------------------------------------------------- /examples/contract/DoorLockCompositional.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/DoorLockCompositional.slx -------------------------------------------------------------------------------- /examples/contract/DoorLockCompositionalHtml.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/DoorLockCompositionalHtml.slx -------------------------------------------------------------------------------- /examples/contract/DoorLockInvalid.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/DoorLockInvalid.slx -------------------------------------------------------------------------------- /examples/contract/StopwatchSpec.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/StopwatchSpec.slx -------------------------------------------------------------------------------- /examples/contract/absolute.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/absolute.slx -------------------------------------------------------------------------------- /examples/contract/bacteriaPopulation.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/bacteriaPopulation.slx -------------------------------------------------------------------------------- /examples/contract/bacteriaPopulationDemo.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/bacteriaPopulationDemo.slx -------------------------------------------------------------------------------- /examples/contract/bacteriaPopulationStateflow.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/bacteriaPopulationStateflow.slx -------------------------------------------------------------------------------- /examples/contract/bacteriaPopulationTruthTable.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/contract/bacteriaPopulationTruthTable.slx -------------------------------------------------------------------------------- /examples/properties/AltitudeControl_Demo.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/properties/AltitudeControl_Demo.slx -------------------------------------------------------------------------------- /examples/properties/assertion.mdl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/properties/assertion.mdl -------------------------------------------------------------------------------- /examples/properties/assumption.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/properties/assumption.slx -------------------------------------------------------------------------------- /examples/properties/safe_math_functions.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/examples/properties/safe_math_functions.slx -------------------------------------------------------------------------------- /libs/contract/CoCoSimSpecification.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/libs/contract/CoCoSimSpecification.slx -------------------------------------------------------------------------------- /libs/contract/CoCoSimSpecification_r2015a.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/libs/contract/CoCoSimSpecification_r2015a.slx -------------------------------------------------------------------------------- /libs/contract/Kind.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coco-team/cocoSim2/c179a83979512d8db1e7b7d98dbfd5688ad80d04/libs/contract/Kind.slx -------------------------------------------------------------------------------- /libs/contract/contractAfterSimulation.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2018 The university of Iowa 4 | % Author: Mudathir Mahgoub 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | function contractAfterSimulation() 8 | assignin('base','ContractValidatorReady', 0); 9 | end 10 | 11 | -------------------------------------------------------------------------------- /libs/contract/contractBeforeSimulation.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2018 The university of Iowa 4 | % Author: Mudathir Mahgoub 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | function contractBeforeSimulation() 8 | assignin('base','ContractValidatorReady', 1); 9 | end 10 | 11 | -------------------------------------------------------------------------------- /libs/contract/saveValidatorParameters.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2018 The university of Iowa 4 | % Author: Mudathir Mahgoub 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | 8 | function saveValidatorParameters(blockPath) 9 | values = get_param(blockPath,'MaskValues'); 10 | 11 | ContractValidatorBlock.block = blockPath; 12 | 13 | ContractValidatorBlock.assumePorts = str2num(char(values(1))); 14 | ContractValidatorBlock.guaranteePorts = str2num(char(values(2))); 15 | ContractValidatorBlock.modeBlocksPorts = str2num(char(values(3))); 16 | 17 | ContractValidatorBlock.portHandles = get_param(ContractValidatorBlock.block, 'PortHandles'); 18 | ContractValidatorBlock.portConnectivity =get_param(ContractValidatorBlock.block, 'PortConnectivity'); 19 | 20 | % store ContractValidatorBlock in ContractValidatorBlocksMap 21 | modelWorkspace = get_param(bdroot,'ModelWorkspace'); 22 | if modelWorkspace.hasVariable('ContractValidatorBlocksMap') 23 | ContractValidatorBlocksMap = modelWorkspace.getVariable('ContractValidatorBlocksMap'); 24 | else 25 | ContractValidatorBlocksMap = containers.Map; 26 | end 27 | 28 | ContractValidatorBlocksMap(ContractValidatorBlock.block) = ContractValidatorBlock; 29 | assignin(modelWorkspace,'ContractValidatorBlocksMap',ContractValidatorBlocksMap); 30 | 31 | end 32 | 33 | -------------------------------------------------------------------------------- /libs/contract/slblocks.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2018 The university of Iowa 4 | % Author: Mudathir Mahgoub 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | function blkStruct = slblocks 8 | % This function specifies that the library should appear 9 | % in the Library Browser 10 | % and be cached in the browser repository 11 | version_year = regexp(version('-release'), '^\d+', 'match', 'once'); 12 | version_year = str2double(version_year); 13 | if version_year >= 2017 14 | Browser.Library = 'CoCoSimSpecification'; 15 | else 16 | Browser.Library = 'CoCoSimSpecification_r2015a'; 17 | end 18 | % 'CoCoSimSpecification' is the name of the library 19 | 20 | Browser.Name = 'CoCoSim Specification'; 21 | % 'CoCoSim Specification' is the library name that appears 22 | % in the Library Browser 23 | blkStruct.Browser = Browser; 24 | end -------------------------------------------------------------------------------- /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 | display(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 | -------------------------------------------------------------------------------- /sl_customization.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | % Copyright (C) 2018 The university of Iowa 5 | % Authors: Temesghen Kahsai, Hamza Bourbouh, Mudathir Mahgoub 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | 8 | function sl_customization(cm) 9 | cm.addCustomMenuFcn('Simulink:ToolsMenu', @CocosimMenu.cocosimMenu); 10 | cm.addCustomMenuFcn('Simulink:PreContextMenu', @PreContextMenu.preContextMenu); 11 | end 12 | -------------------------------------------------------------------------------- /src/backEnd/common/plotting.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | 6 | function plotting(name, in ) 7 | %PLOTTING Summary of this function goes here 8 | % Detailed explanation goes here 9 | 10 | fig = findobj('Type', 'Figure', 'name', name); 11 | n_prev = 0; 12 | if numel(fig) == 0 13 | fig = figure('name', name, 'NumberTitle', 'off'); 14 | else 15 | figure(fig); 16 | axes = findall(fig, 'type', 'axes'); 17 | prev_stairs = findall(axes(1), 'type', 'stair'); 18 | n_prev = numel(prev_stairs); 19 | end 20 | 21 | cm = jet(500); 22 | step = .083; 23 | 24 | nb_io = 0; 25 | for idx_in=1:numel(in) 26 | nb_io = nb_io + numel(in{idx_in}.signals); 27 | end 28 | 29 | last_time = in{1}.time(end) + 1; 30 | time_values = [in{1}.time last_time]; 31 | 32 | cpt = 1; 33 | for idx_in=1:numel(in) 34 | for idx_sig=1:numel(in{idx_in}.signals) 35 | subplot(nb_io, 1, cpt); 36 | color_f = ((cpt -1)/nb_io) + (n_prev * step); 37 | if color_f > 1 38 | integ = floor(color_f); 39 | color_f = color_f - integ; 40 | end 41 | colorID = max(1, sum(color_f > [0:1/length(cm(:,1)):1])); 42 | color = cm(colorID, :); 43 | if numel(in{idx_in}.signals(idx_sig).values) ~= numel(time_values) 44 | last_value = in{idx_in}.signals(idx_sig).values(end); 45 | signal_values = [in{idx_in}.signals(idx_sig).values ; last_value]; 46 | else 47 | signal_values = in{idx_in}.signals(idx_sig).values; 48 | end 49 | if n_prev == 0 50 | leg = in{idx_in}.signals(idx_sig).var_name; 51 | else 52 | leg = [in{idx_in}.signals(idx_sig).var_name '_' num2str(n_prev + 1)]; 53 | end 54 | stairs(time_values, signal_values, 'LineStyle', '-', 'LineWidth', 2, 'Color', color, 'DisplayName', leg); 55 | legend('off'); 56 | l = legend('show'); 57 | set(l, 'Interpreter', 'none'); 58 | xbounds = xlim(); 59 | ylabel(in{idx_in}.signals(idx_sig).var_name, 'FontSize', 8); 60 | set(gca, 'xtick', xbounds(1):1:xbounds(2)); 61 | hold on; 62 | cpt = cpt + 1; 63 | end 64 | end 65 | xlabel('time', 'FontSize', 8); 66 | end 67 | 68 | -------------------------------------------------------------------------------- /src/backEnd/generate_code/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 | cocosim_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/generate_code/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 | cocosim_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/generate_invariants/ViewContractMenu.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % This file is part of CoCoSim. 3 | % Copyright (C) 2014-2016 Carnegie Mellon University 4 | % Copyright (C) 2018 The university of Iowa 5 | % Authors: Temesghen Kahsai, Hamza Bourbouh, Mudathir Mahgoub 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | 8 | classdef ViewContractMenu 9 | methods(Static) 10 | 11 | function schema = viewContract(callbackInfo) 12 | schema = sl_action_schema; 13 | schema.label = 'View generated CoCoSpec (Experimental)'; 14 | schema.callback = @ViewContractMenu.viewContractCallback; 15 | end 16 | 17 | function viewContractCallback(callbackInfo) 18 | model_full_path = ViewContractMenu.get_file_name(gcs); 19 | simulink_name = gcs; 20 | contract_name = [simulink_name '_COCOSPEC']; 21 | emf_name = [simulink_name '_EMF']; 22 | try 23 | CONTRACT = evalin('base', contract_name); 24 | EMF = evalin('base', emf_name); 25 | disp(['CONTRACT LOCATION ' char(CONTRACT)]); 26 | 27 | catch ME 28 | display_msg(ME.getReport(),Constants.DEBUG,'viewContract',''); 29 | msg = sprintf('No CoCoSpec Contract for %s \n Verify the model with Zustre', simulink_name); 30 | warndlg(msg,'CoCoSim: Warning'); 31 | end 32 | try 33 | Output_url = view_cocospec(model_full_path, char(EMF)); 34 | open(Output_url); 35 | catch ME 36 | display_msg(ME.getReport(),Constants.DEBUG,'viewContract',''); 37 | end 38 | end 39 | 40 | 41 | function fname = get_file_name(gcs) 42 | names = regexp(gcs,'/','split'); 43 | fname = get_param(names{1},'FileName'); 44 | end % get_file_name 45 | 46 | end 47 | end -------------------------------------------------------------------------------- /src/backEnd/generate_invariants/zustre_invariants/utils/get_block_name_from_variable_using_xRoot.m: -------------------------------------------------------------------------------- 1 | function block_name = get_block_name_from_variable_using_xRoot(xRoot, node_name, var_name) 2 | %GET_BLOCK_NAME_FROM_VARIABLE_USING_XROOT 3 | %this function help to get the name of Simulink block from lustre 4 | %variable name, using the generated tracability by Cocosim. 5 | 6 | block_name = ''; 7 | nodes = xRoot.getElementsByTagName('Node'); 8 | for idx_node=0:nodes.getLength-1 9 | block_name_node = nodes.item(idx_node).getAttribute('node_name'); 10 | if strcmp(block_name_node, node_name) 11 | inputs = nodes.item(idx_node).getElementsByTagName('Input'); 12 | for idx_input=0:inputs.getLength-1 13 | input = inputs.item(idx_input); 14 | if strcmp(input.getAttribute('variable'), var_name) 15 | block = input.getElementsByTagName('block_name'); 16 | block_name = char(block.item(0).getFirstChild.getData); 17 | return; 18 | end 19 | end 20 | outputs = nodes.item(idx_node).getElementsByTagName('Output'); 21 | for idx_output=0:outputs.getLength-1 22 | output = outputs.item(idx_output); 23 | if strcmp(output.getAttribute('variable'), var_name) 24 | block = output.getElementsByTagName('block_name'); 25 | block_name = char(block.item(0).getFirstChild.getData); 26 | return; 27 | end 28 | end 29 | end 30 | end 31 | end 32 | 33 | -------------------------------------------------------------------------------- /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 |