Browse Source

Merge branch 'master' into deterministicScheds

main
TimQu 7 years ago
parent
commit
b075c16ce0
  1. 5
      .travis.yml
  2. 1
      CHANGELOG.md
  3. 26
      CMakeLists.txt
  4. 23
      resources/3rdparty/CMakeLists.txt
  5. 4
      resources/3rdparty/carl/CMakeLists.txt
  6. 20
      resources/cmake/macros/export.cmake
  7. 11
      resources/cmake/stormConfigVersion.cmake.in
  8. 28
      resources/examples/testfiles/ctmc/simple2.sm
  9. 42
      resources/examples/testfiles/ma/simple2.ma
  10. 2
      src/CMakeLists.txt
  11. 4
      src/storm-cli-utilities/CMakeLists.txt
  12. 29
      src/storm-cli-utilities/cli.cpp
  13. 7
      src/storm-cli-utilities/cli.h
  14. 3
      src/storm-cli-utilities/model-handling.h
  15. 40
      src/storm-counterexamples/CMakeLists.txt
  16. 2
      src/storm-counterexamples/api/counterexamples.cpp
  17. 4
      src/storm-counterexamples/api/counterexamples.h
  18. 2
      src/storm-counterexamples/counterexamples/Counterexample.cpp
  19. 0
      src/storm-counterexamples/counterexamples/Counterexample.h
  20. 2
      src/storm-counterexamples/counterexamples/HighLevelCounterexample.cpp
  21. 2
      src/storm-counterexamples/counterexamples/HighLevelCounterexample.h
  22. 4
      src/storm-counterexamples/counterexamples/MILPMinimalLabelSetGenerator.h
  23. 315
      src/storm-counterexamples/counterexamples/SMTMinimalLabelSetGenerator.h
  24. 2
      src/storm-counterexamples/settings/modules/CounterexampleGeneratorSettings.cpp
  25. 0
      src/storm-counterexamples/settings/modules/CounterexampleGeneratorSettings.h
  26. 2
      src/storm-dft-cli/CMakeLists.txt
  27. 3
      src/storm-dft-cli/storm-dft.cpp
  28. 4
      src/storm-dft/CMakeLists.txt
  29. 3
      src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
  30. 4
      src/storm-dft/parser/DFTGalileoParser.h
  31. 2
      src/storm-dft/parser/DFTJsonParser.h
  32. 2
      src/storm-gspn-cli/CMakeLists.txt
  33. 5
      src/storm-gspn-cli/storm-gspn.cpp
  34. 2
      src/storm-gspn/CMakeLists.txt
  35. 2
      src/storm-gspn/builder/ExplicitGspnModelBuilder.cpp
  36. 2
      src/storm-pars-cli/CMakeLists.txt
  37. 2
      src/storm-pars/CMakeLists.txt
  38. 2
      src/storm-pars/settings/ParsSettings.cpp
  39. 42
      src/storm-parsers/CMakeLists.txt
  40. 6
      src/storm-parsers/api/model_descriptions.cpp
  41. 0
      src/storm-parsers/api/model_descriptions.h
  42. 71
      src/storm-parsers/api/properties.cpp
  43. 43
      src/storm-parsers/api/properties.h
  44. 4
      src/storm-parsers/api/storm-parsers.h
  45. 4
      src/storm-parsers/parser/AtomicPropositionLabelingParser.cpp
  46. 0
      src/storm-parsers/parser/AtomicPropositionLabelingParser.h
  47. 10
      src/storm-parsers/parser/AutoParser.cpp
  48. 0
      src/storm-parsers/parser/AutoParser.h
  49. 8
      src/storm-parsers/parser/DeterministicModelParser.cpp
  50. 0
      src/storm-parsers/parser/DeterministicModelParser.h
  51. 4
      src/storm-parsers/parser/DeterministicSparseTransitionParser.cpp
  52. 0
      src/storm-parsers/parser/DeterministicSparseTransitionParser.h
  53. 2
      src/storm-parsers/parser/DirectEncodingParser.cpp
  54. 2
      src/storm-parsers/parser/DirectEncodingParser.h
  55. 0
      src/storm-parsers/parser/ExpressionCreator.cpp
  56. 2
      src/storm-parsers/parser/ExpressionCreator.h
  57. 4
      src/storm-parsers/parser/ExpressionParser.cpp
  58. 4
      src/storm-parsers/parser/ExpressionParser.h
  59. 4
      src/storm-parsers/parser/FormulaParser.cpp
  60. 4
      src/storm-parsers/parser/FormulaParser.h
  61. 0
      src/storm-parsers/parser/FormulaParserGrammar.cpp
  62. 4
      src/storm-parsers/parser/FormulaParserGrammar.h
  63. 2
      src/storm-parsers/parser/ImcaMarkovAutomatonParser.cpp
  64. 2
      src/storm-parsers/parser/ImcaMarkovAutomatonParser.h
  65. 0
      src/storm-parsers/parser/JaniParser.cpp
  66. 0
      src/storm-parsers/parser/JaniParser.h
  67. 0
      src/storm-parsers/parser/KeyValueParser.cpp
  68. 0
      src/storm-parsers/parser/KeyValueParser.h
  69. 2
      src/storm-parsers/parser/MappedFile.cpp
  70. 0
      src/storm-parsers/parser/MappedFile.h
  71. 0
      src/storm-parsers/parser/MarkovAutomatonParser.cpp
  72. 2
      src/storm-parsers/parser/MarkovAutomatonParser.h
  73. 2
      src/storm-parsers/parser/MarkovAutomatonSparseTransitionParser.cpp
  74. 0
      src/storm-parsers/parser/MarkovAutomatonSparseTransitionParser.h
  75. 8
      src/storm-parsers/parser/NondeterministicModelParser.cpp
  76. 0
      src/storm-parsers/parser/NondeterministicModelParser.h
  77. 4
      src/storm-parsers/parser/NondeterministicSparseTransitionParser.cpp
  78. 0
      src/storm-parsers/parser/NondeterministicSparseTransitionParser.h
  79. 4
      src/storm-parsers/parser/PrismParser.cpp
  80. 4
      src/storm-parsers/parser/PrismParser.h
  81. 0
      src/storm-parsers/parser/ReadValues.h
  82. 4
      src/storm-parsers/parser/SparseChoiceLabelingParser.cpp
  83. 0
      src/storm-parsers/parser/SparseChoiceLabelingParser.h
  84. 4
      src/storm-parsers/parser/SparseItemLabelingParser.cpp
  85. 2
      src/storm-parsers/parser/SparseItemLabelingParser.h
  86. 4
      src/storm-parsers/parser/SparseStateRewardParser.cpp
  87. 0
      src/storm-parsers/parser/SparseStateRewardParser.h
  88. 2
      src/storm-parsers/parser/SpiritErrorHandler.h
  89. 0
      src/storm-parsers/parser/SpiritParserDefinitions.h
  90. 2
      src/storm-parsers/parser/ValueParser.cpp
  91. 2
      src/storm-parsers/parser/ValueParser.h
  92. 2
      src/storm-pgcl-cli/CMakeLists.txt
  93. 4
      src/storm-pgcl/CMakeLists.txt
  94. 6
      src/storm-pgcl/parser/PgclParser.h
  95. 6
      src/storm/CMakeLists.txt
  96. 21
      src/storm/adapters/Z3ExpressionAdapter.cpp
  97. 6
      src/storm/api/builder.h
  98. 56
      src/storm/api/properties.cpp
  99. 12
      src/storm/api/properties.h
  100. 2
      src/storm/api/storm.h

5
.travis.yml

@ -9,6 +9,9 @@ sudo: required
dist: trusty
language: cpp
git:
depth: false
# Enable caching
cache:
timeout: 1000
@ -25,7 +28,7 @@ notifications:
on_failure: always
on_success: change
recipients:
secure: "Q9CW/PtyWkZwExDrfFFb9n1STGYsRfI6awv1bZHcGwfrDvhpXoMCuF8CwviIfilm7fFJJEoKizTtdRpY0HrOnY/8KY111xrtcFYosxdndv7xbESodIxQOUoIEFCO0mCNHwWYisoi3dAA7H3Yn661EsxluwHjzX5vY0xSbw0n229hlsFz092HwGLSU33zHl7eXpQk+BOFmBTRGlOq9obtDZ17zbHz1oXFZntHK/JDUIYP0b0uq8NvE2jM6CIVdcuSwmIkOhZJoO2L3Py3rBbPci+L2PSK4Smv2UjCPF8KusnOaFIyDB3LcNM9Jqq5ssJMrK/KaO6BiuYrOZXYWZ7KEg3Y/naC8HjOH1dzty+P7oW46sb9F03pTsufqD4R7wcK+9wROTztO6aJPDG/IPH7EWgrBTxqlOkVRwi2eYuQouZpZUW6EMClKbMHMIxCH2S8aOk/r1w2cNwmPEcunnP0nl413x/ByHr4fTPFykPj8pQxIsllYjpdWBRQfDOauKWGzk6LcrFW0qpWP+/aJ2vYu/IoZQMG5lMHbp6Y1Lg09pYm7Q983v3b7D+JvXhOXMyGq91HyPahA2wwKoG1GA4uoZ2I95/IFYNiKkelDd3WTBoFLNF9YFoEJNdCywm1fO2WY4WkyEFBuQcgDA+YpFMJJMxjTbivYk9jvHk2gji//2w="
- secure: "VWnsiQkt1xjgRo1hfNiNQqvLSr0fshFmLV7jJlUixhCr094mgD0U2bNKdUfebm28Byg9UyDYPbOFDC0sx7KydKiL1q7FKKXkyZH0k04wUu8XiNw+fYkDpmPnQs7G2n8oJ/GFJnr1Wp/1KI3qX5LX3xot4cJfx1I5iFC2O+p+ng6v/oSX+pewlMv4i7KL16ftHHHMo80N694v3g4B2NByn4GU2/bjVQcqlBp/TiVaUa5Nqu9DxZi/n9CJqGEaRHOblWyMO3EyTZsn45BNSWeQ3DtnMwZ73rlIr9CaEgCeuArc6RGghUAVqRI5ao+N5apekIaILwTgL6AJn+Lw/+NRPa8xclgd0rKqUQJMJCDZKjKz2lmIs3bxfELOizxJ3FJQ5R95FAxeAZ6rb/j40YqVVTw2IMBDnEE0J5ZmpUYNUtPti/Adf6GD9Fb2y8sLo0XDJzkI8OxYhfgjSy5KYmRj8O5MXcP2MAE8LQauNO3MaFnL9VMVOTZePJrPozQUgM021uyahf960+QNI06Uqlmg+PwWkSdllQlxHHplOgW7zClFhtSUpnJxcsUBzgg4kVg80gXUwAQkaDi7A9Wh2bs+TvMlmHzBwg+2SaAfWDgjeJIeOaipDkF1uSGzC+EHAiiKYMLd4Aahoi8SuelJUucoyJyLAq00WdUFQIh/izVhM4Y="
#
# Configurations

1
CHANGELOG.md

@ -12,6 +12,7 @@ Version 1.2.x
- `storm-dft`: test cases for DFT analysis
- Sound value iteration (SVI) for DTMCs and MDPs
- Topological solver for linear equation systems and MinMax equation systems.
- Added support for expected total rewards in the sparse engine
### Version 1.2.1 (2018/02)

26
CMakeLists.txt

@ -78,7 +78,15 @@ set(BIN_INSTALL_DIR lib/ CACHE PATH "Installation directory for executables")
set(DEF_INSTALL_CMAKE_DIR "lib/CMake/storm")
set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}")
# Add CMake install prefix
foreach(p LIB BIN INCLUDE CMAKE)
set(var ${p}_INSTALL_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
message(STATUS "Storm - CMake install dir: ${CMAKE_INSTALL_DIR}")
# If the STORM_DEVELOPER option was turned on, by default we target a debug version, otherwise a release version.
if (STORM_DEVELOPER)
@ -145,15 +153,15 @@ elseif (WIN32)
set(STATIC_EXT ".lib")
set(LIB_PREFIX "")
endif()
message(STATUS "Assuming extension for shared libraries: ${DYNAMIC_EXT}")
message(STATUS "Assuming extension for static libraries: ${STATIC_EXT}")
message(STATUS "Storm - Assuming extension for shared libraries: ${DYNAMIC_EXT}")
message(STATUS "Storm - Assuming extension for static libraries: ${STATIC_EXT}")
if(BUILD_SHARED_LIBS)
set(LIB_EXT ${DYNAMIC_EXT})
message(STATUS "Build dynamic libraries.")
message(STATUS "Storm - Build dynamic libraries.")
else()
set(LIB_EXT ${STATIC_EXT})
message(STATUS "Build static libraries.")
message(STATUS "Storm - Build static libraries.")
endif()
#############################################################
@ -435,7 +443,7 @@ if (STORM_GIT_VERSION_STRING MATCHES "NOTFOUND")
set(STORM_VERSION_SOURCE "VersionSource::Static")
set(STORM_VERSION_COMMITS_AHEAD "boost::none")
include(version.cmake)
message(WARNING "Storm - git version information not available, statically assuming version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}.")
message(WARNING "Storm - Git version information not available, statically assuming version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}.")
endif()
# check whether there is a label ('alpha', 'pre', etc.)
@ -465,7 +473,7 @@ endif()
set(STORM_VERSION "${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_DEV_PATCH}")
set(STORM_VERSION_STRING "${STORM_VERSION}${STORM_VERSION_LABEL_STRING}${STORM_VERSION_DEV_STRING}")
message(STATUS "Storm - version is ${STORM_VERSION_STRING} (version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}${STORM_VERSION_LABEL_STRING} + ${STORM_VERSION_COMMITS_AHEAD} commits), building from git: ${STORM_VERSION_GIT_HASH} (dirty: ${STORM_VERSION_DIRTY}).")
message(STATUS "Storm - Version is ${STORM_VERSION_STRING} (version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}${STORM_VERSION_LABEL_STRING} + ${STORM_VERSION_COMMITS_AHEAD} commits), building from git: ${STORM_VERSION_GIT_HASH} (dirty: ${STORM_VERSION_DIRTY}).")
# Configure a header file to pass some of the CMake settings to the source code
@ -500,4 +508,8 @@ add_subdirectory(src)
include(export)
install(FILES ${CMAKE_BINARY_DIR}/stormConfig.install.cmake DESTINATION ${CMAKE_INSTALL_DIR} RENAME stormConfig.cmake)
install(FILES ${CMAKE_BINARY_DIR}/stormConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DIR})
install(EXPORT storm_Targets FILE stormTargets.cmake DESTINATION ${CMAKE_INSTALL_DIR})
include(StormCPackConfig.cmake)

23
resources/3rdparty/CMakeLists.txt

@ -168,6 +168,15 @@ else()
message (WARNING "Storm - Z3 not found. Building of Prism/JANI models will not be supported.")
endif(Z3_FOUND)
# split Z3 version into its components
string(REPLACE "." ";" Z3_VERSION_LIST ${Z3_VERSION})
list(GET Z3_VERSION_LIST 0 STORM_Z3_VERSION_MAJOR)
list(GET Z3_VERSION_LIST 1 STORM_Z3_VERSION_MINOR)
list(GET Z3_VERSION_LIST 2 STORM_Z3_VERSION_PATCH)
if (NOT "${Z3_VERSION}" VERSION_LESS "4.7.1")
set(STORM_Z3_API_USES_STANDARD_INTEGERS ON)
endif()
#############################################################
##
## glpk
@ -239,16 +248,16 @@ if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
else()
set(STORM_SHIPPED_CARL ON)
# The first external project will be built at *configure stage*
message("START CARL CONFIG PROCESS")
file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
message(STATUS "Carl - Start of config process")
file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
execute_process(
COMMAND ${CMAKE_COMMAND} ${STORM_3RDPARTY_SOURCE_DIR}/carl "-DSTORM_3RDPARTY_BINARY_DIR=${STORM_3RDPARTY_BINARY_DIR}" "-DBoost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}" "-DBoost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}"
WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
OUTPUT_VARIABLE carlconfig_out
RESULT_VARIABLE carlconfig_result)
if(NOT carlconfig_result)
message("${carlconfig_out}")
message(STATUS "${carlconfig_out}")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} --build . --target carl-config
@ -257,10 +266,10 @@ else()
RESULT_VARIABLE carlconfig_result
)
if(NOT carlconfig_result)
message("${carlconfig_out}")
message(STATUS "${carlconfig_out}")
endif()
message("END CARL CONFIG PROCESS")
message(STATUS "Carl - End of config process")
message(STATUS "Storm - Using shipped version of carl.")
ExternalProject_Add(
carl

4
resources/3rdparty/carl/CMakeLists.txt

@ -4,7 +4,7 @@ include(ExternalProject)
option(STORM_3RDPARTY_BINARY_DIR "3rd party bin dir")
message(STORM_3RDPARTY_BINARY_DIR: ${STORM_3RDPARTY_BINARY_DIR})
message(STATUS "Carl - Storm 3rdparty binary dir: ${STORM_3RDPARTY_BINARY_DIR}")
ExternalProject_Add(carl-config
GIT_REPOSITORY https://github.com/smtrat/carl
@ -22,4 +22,4 @@ ExternalProject_Add(carl-config
add_custom_target(build-carl)
add_dependencies(build-carl carl-config)
message("done")
message(STATUS "Carl - Finished configuration.")

20
resources/cmake/macros/export.cmake

@ -8,7 +8,7 @@ message(STATUS "Registered with cmake")
export(PACKAGE storm)
set(DEP_TARGETS "")
foreach(dt ${STORM_DEP_TARGETS})
foreach(dt ${STORM_DEP_TARGETS})
export_target(DEP_TARGETS ${dt})
endforeach()
@ -19,10 +19,26 @@ endforeach()
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/stormConfigVersion.cmake
VERSION 0.1.0
COMPATIBILITY SameMajorVersion )
# For the build tree
set(CONF_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/include/")
configure_package_config_file(
resources/cmake/stormConfig.cmake.in
${PROJECT_BINARY_DIR}/stormConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR #SYSCONFIG_INSTALL_DIR
PATH_VARS INCLUDE_INSTALL_DIR
)
# For the install tree
file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_INSTALL_DIR}" "${INCLUDE_INSTALL_DIR}")
set(CONF_INCLUDE_DIRS "\${storm_CMAKE_DIR}/${REL_INCLUDE_DIR}/storm")
configure_package_config_file(
resources/cmake/stormConfig.cmake.in
${PROJECT_BINARY_DIR}/stormConfig.install.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR
)

11
resources/cmake/stormConfigVersion.cmake.in

@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@storm_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

28
resources/examples/testfiles/ctmc/simple2.sm

@ -0,0 +1,28 @@
ctmc
module main
s : [0..4]; // current state:
<> s=0 -> 4 : (s'=1) + 4 : (s'=2);
<> s=1 -> 0.3 : (s'=2) + 0.7 : (s'=1);
<> s=2 -> 0.5 : (s'=2) + 0.5 : (s'=3);
<> s=3 -> 1 : (s'=4);
<> s=4 -> 1 : (s'=3);
endmodule
rewards "rew1"
s=0 : 7;
[] s=2 : 1;
endrewards
rewards "rew2"
s=0 : 7;
[] s=2 : 1;
[] s=4 : 100;
endrewards

42
resources/examples/testfiles/ma/simple2.ma

@ -0,0 +1,42 @@
ma
module main
s : [0..5]; // current state:
<> s=0 -> 4 : (s'=1) + 4 : (s'=2);
[alpha] s=1 -> 1 : (s'=0);
[beta] s=1 -> 0.3 : (s'=5) + 0.7 : (s'=1);
<> s=5 -> 1 : (s'=2);
[gamma] s=2 -> 1 : (s'=1);
[delta] s=2 -> 0.5 : (s'=2) + 0.5 : (s'=3);
<> s=3 -> 1 : (s'=4);
[lambda] s=4 -> 1 : (s'=3);
endmodule
rewards "rew0"
[delta] s=2 : 1;
endrewards
rewards "rew1"
s=0 : 7;
[delta] s=2 : 1;
endrewards
rewards "rew2"
s=0 : 7;
[delta] s=2 : 1;
[lambda] s=4 : 100;
endrewards
rewards "rew3"
s=0 : 7;
[delta] s=2 : 1;
[gamma] s=2 : 100;
[lambda] s=4 : 27;
endrewards

2
src/CMakeLists.txt

@ -5,6 +5,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_custom_target(binaries)
add_subdirectory(storm)
add_subdirectory(storm-counterexamples)
add_subdirectory(storm-parsers)
add_subdirectory(storm-cli-utilities)
add_subdirectory(storm-pgcl)
add_subdirectory(storm-pgcl-cli)

4
src/storm-cli-utilities/CMakeLists.txt

@ -17,7 +17,7 @@ set_target_properties(storm-cli-utilities PROPERTIES DEFINE_SYMBOL "")
list(APPEND STORM_TARGETS storm-cli-utilities)
set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE)
target_link_libraries(storm-cli-utilities PUBLIC storm)
target_link_libraries(storm-cli-utilities PUBLIC storm storm-counterexamples storm-parsers)
# Install storm headers to include directory.
foreach(HEADER ${STORM_CLI_UTIL_HEADERS})
@ -36,5 +36,5 @@ add_custom_target(copy_storm_cli_util_headers DEPENDS ${STORM_CLI_UTIL_OUTPUT_HE
add_dependencies(storm-cli-utilities copy_storm_pars_headers)
# installation
install(TARGETS storm-cli-utilities RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-cli-utilities EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

29
src/storm-cli-utilities/cli.cpp

@ -11,6 +11,7 @@
#include <type_traits>
#include <ctime>
#include <boost/algorithm/string/replace.hpp>
#include "storm-cli-utilities/model-handling.h"
@ -48,6 +49,8 @@ namespace storm {
storm::cli::printHeader("Storm", argc, argv);
storm::settings::initializeAll("Storm", "storm");
storm::settings::addModule<storm::settings::modules::CounterexampleGeneratorSettings>();
storm::utility::Stopwatch totalTimer(true);
if (!storm::cli::parseOptions(argc, argv)) {
return -1;
@ -63,7 +66,27 @@ namespace storm {
storm::utility::cleanUp();
return 0;
}
std::string shellQuoteSingleIfNecessary(const std::string& arg) {
// quote empty argument
if (arg.empty()) {
return "''";
}
if (arg.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_./=") != std::string::npos) {
// contains potentially unsafe character, needs quoting
if (arg.find('\'') != std::string::npos) {
// contains ', we have to replace all ' with '\''
std::string escaped(arg);
boost::replace_all(escaped, "'", "'\\''");
return "'" + escaped + "'";
} else {
return "'" + arg + "'";
}
}
return arg;
}
void printHeader(std::string const& name, const int argc, const char** argv) {
STORM_PRINT(name << " " << storm::utility::StormVersion::shortVersionString() << std::endl << std::endl);
@ -71,7 +94,7 @@ namespace storm {
// "Compute" the command line argument string with which storm was invoked.
std::stringstream commandStream;
for (int i = 1; i < argc; ++i) {
commandStream << argv[i] << " ";
commandStream << " " << shellQuoteSingleIfNecessary(argv[i]);
}
std::string command = commandStream.str();
@ -79,7 +102,7 @@ namespace storm {
if (!command.empty()) {
std::time_t result = std::time(nullptr);
STORM_PRINT("Date: " << std::ctime(&result));
STORM_PRINT("Command line arguments: " << commandStream.str() << std::endl);
STORM_PRINT("Command line arguments:" << commandStream.str() << std::endl);
STORM_PRINT("Current working directory: " << storm::utility::cli::getCurrentWorkingDirectory() << std::endl << std::endl);
}
}

7
src/storm-cli-utilities/cli.h

@ -11,6 +11,13 @@ namespace storm {
*/
int64_t process(const int argc, const char** argv);
/*!
* For a command-line argument, returns a quoted version
* with single quotes if it contains unsafe characters.
* Otherwise, just returns the unquoted argument.
*/
std::string shellQuoteSingleIfNecessary(const std::string& arg);
void printHeader(std::string const& name, const int argc, const char** argv);
void printVersion(std::string const& name);

3
src/storm-cli-utilities/model-handling.h

@ -2,6 +2,9 @@
#include "storm/api/storm.h"
#include "storm-counterexamples/api/counterexamples.h"
#include "storm-parsers/api/storm-parsers.h"
#include "storm/utility/resources.h"
#include "storm/utility/file.h"
#include "storm/utility/storm-version.h"

40
src/storm-counterexamples/CMakeLists.txt

@ -0,0 +1,40 @@
file(GLOB_RECURSE ALL_FILES ${PROJECT_SOURCE_DIR}/src/storm-counterexamples/*.h ${PROJECT_SOURCE_DIR}/src/storm-counterexamples/*.cpp)
register_source_groups_from_filestructure("${ALL_FILES}" storm-counterexamples)
file(GLOB_RECURSE STORM_CEX_SOURCES ${PROJECT_SOURCE_DIR}/src/storm-counterexamples/*/*.cpp)
file(GLOB_RECURSE STORM_CEX_HEADERS ${PROJECT_SOURCE_DIR}/src/storm-counterexamples/*/*.h)
# Create storm-dft.
add_library(storm-counterexamples SHARED ${STORM_CEX_SOURCES} ${STORM_CEX_HEADERS})
# Remove define symbol for shared libstorm.
set_target_properties(storm-counterexamples PROPERTIES DEFINE_SYMBOL "")
#add_dependencies(storm resources)
list(APPEND STORM_TARGETS storm-counterexamples)
set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE)
target_link_libraries(storm-counterexamples PUBLIC storm)
# Install storm headers to include directory.
foreach(HEADER ${STORM_CEX_HEADERS})
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER})
string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH})
string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH})
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}
DEPENDS ${HEADER}
)
list(APPEND STORM_CEX_OUTPUT_HEADERS "${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}")
endforeach()
add_custom_target(copy_storm_cex_headers DEPENDS ${STORM_CEX_OUTPUT_HEADERS} ${STORM_CEX_HEADERS})
add_dependencies(storm-counterexamples copy_storm_cex_headers)
# installation
install(TARGETS storm-counterexamples EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

2
src/storm/api/counterexamples.cpp → src/storm-counterexamples/api/counterexamples.cpp

@ -1,4 +1,4 @@
#include "storm/api/counterexamples.h"
#include "storm-counterexamples/api/counterexamples.h"
#include "storm/environment/Environment.h"

4
src/storm/api/counterexamples.h → src/storm-counterexamples/api/counterexamples.h

@ -1,7 +1,7 @@
#pragma once
#include "storm/counterexamples/MILPMinimalLabelSetGenerator.h"
#include "storm/counterexamples/SMTMinimalLabelSetGenerator.h"
#include "storm-counterexamples/counterexamples/MILPMinimalLabelSetGenerator.h"
#include "storm-counterexamples/counterexamples/SMTMinimalLabelSetGenerator.h"
namespace storm {
namespace api {

2
src/storm/counterexamples/Counterexample.cpp → src/storm-counterexamples/counterexamples/Counterexample.cpp

@ -1,4 +1,4 @@
#include "storm/counterexamples/Counterexample.h"
#include "storm-counterexamples/counterexamples/Counterexample.h"
namespace storm {
namespace counterexamples {

0
src/storm/counterexamples/Counterexample.h → src/storm-counterexamples/counterexamples/Counterexample.h

2
src/storm/counterexamples/HighLevelCounterexample.cpp → src/storm-counterexamples/counterexamples/HighLevelCounterexample.cpp

@ -1,4 +1,4 @@
#include "storm/counterexamples/HighLevelCounterexample.h"
#include "storm-counterexamples/counterexamples/HighLevelCounterexample.h"
namespace storm {
namespace counterexamples {

2
src/storm/counterexamples/HighLevelCounterexample.h → src/storm-counterexamples/counterexamples/HighLevelCounterexample.h

@ -1,6 +1,6 @@
#pragma once
#include "storm/counterexamples/Counterexample.h"
#include "Counterexample.h"
#include "storm/storage/SymbolicModelDescription.h"

4
src/storm/counterexamples/MILPMinimalLabelSetGenerator.h → src/storm-counterexamples/counterexamples/MILPMinimalLabelSetGenerator.h

@ -17,7 +17,7 @@
#include "storm/solver/MinMaxLinearEquationSolver.h"
#include "storm/counterexamples/HighLevelCounterexample.h"
#include "storm-counterexamples/counterexamples/HighLevelCounterexample.h"
#include "storm/utility/graph.h"
#include "storm/utility/counterexamples.h"
@ -29,7 +29,7 @@
#include "storm/settings/SettingsManager.h"
#include "storm/settings/modules/GeneralSettings.h"
#include "storm/settings/modules/CounterexampleGeneratorSettings.h"
#include "storm-counterexamples/settings/modules/CounterexampleGeneratorSettings.h"
namespace storm {

315
src/storm/counterexamples/SMTMinimalLabelSetGenerator.h → src/storm-counterexamples/counterexamples/SMTMinimalLabelSetGenerator.h

@ -5,7 +5,7 @@
#include "storm/solver/Z3SmtSolver.h"
#include "storm/counterexamples/HighLevelCounterexample.h"
#include "storm-counterexamples/counterexamples/HighLevelCounterexample.h"
#include "storm/storage/prism/Program.h"
#include "storm/storage/expressions/Expression.h"
@ -49,14 +49,20 @@ namespace storm {
// The set of labels that matter in terms of minimality.
boost::container::flat_set<uint_fast64_t> minimalityLabels;
// A set of labels that is definitely known to be taken in the final solution.
boost::container::flat_set<uint_fast64_t> knownLabels;
boost::container::flat_set<uint64_t> dontCareLabels;
// A list of relevant choices for each relevant state.
std::map<uint_fast64_t, std::list<uint_fast64_t>> relevantChoicesForRelevantStates;
};
struct GeneratorStats {
};
struct VariableInformation {
// The manager responsible for the constraints we are building.
std::shared_ptr<storm::expressions::ExpressionManager> manager;
@ -154,10 +160,12 @@ namespace storm {
std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(remainingLabels, remainingLabels.end()));
relevancyInformation.relevantLabels = remainingLabels;
}
relevancyInformation.dontCareLabels = dontCareLabels;
std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), dontCareLabels.begin(), dontCareLabels.end(), std::inserter(relevancyInformation.minimalityLabels, relevancyInformation.minimalityLabels.begin()));
STORM_LOG_DEBUG("Found " << relevancyInformation.relevantLabels.size() << " relevant and " << relevancyInformation.knownLabels.size() << " known labels.");
STORM_LOG_DEBUG("Found " << relevancyInformation.minimalityLabels.size() << " labels to minize over.");
return relevancyInformation;
}
@ -649,10 +657,11 @@ namespace storm {
// Popping the disjunction of negated guards from the solver stack.
localSolver->pop();
STORM_LOG_ERROR_COND(backwardImplicationAdded, "Error in adding cuts for counterexample generation (backward implication misses a label set).");
} else {
STORM_LOG_DEBUG("Selection is enabled in initial state.");
}
STORM_LOG_ERROR_COND(backwardImplicationAdded, "Error in adding cuts for counterexample generation (backward implication misses a label set).");
}
} else if (symbolicModel.isJaniModel()) {
STORM_LOG_WARN("Model uses assignment levels, did not assert backward implications.");
@ -1153,112 +1162,6 @@ namespace storm {
return relaxingVariable;
}
/*!
* Asserts that the input vector encodes a decimal smaller or equal to one.
*
* @param context The Z3 context in which to build the expressions.
* @param solver The solver to use for the satisfiability evaluation.
* @param input The binary encoded input number.
*/
static void assertLessOrEqualOne(z3::context& context, z3::solver& solver, std::vector<z3::expr> input) {
std::transform(input.begin(), input.end(), input.begin(), [](z3::expr e) -> z3::expr { return !e; });
assertConjunction(context, solver, input);
}
/*!
* Asserts that at most one of given literals may be true at any time.
*
* @param context The Z3 context in which to build the expressions.
* @param solver The solver to use for the satisfiability evaluation.
* @param blockingVariables A vector of variables out of which only one may be true.
*/
static void assertAtMostOne(z3::context& context, z3::solver& solver, std::vector<z3::expr> const& literals) {
std::vector<z3::expr> counter = createCounterCircuit(context, literals);
assertLessOrEqualOne(context, solver, counter);
}
/*!
* Performs one Fu-Malik-Maxsat step.
*
* @param context The Z3 context in which to build the expressions.
* @param solver The solver to use for the satisfiability evaluation.
* @param variableInformation A structure with information about the variables for the labels.
* @return True iff the constraint system was satisfiable.
*/
static bool fuMalikMaxsatStep(z3::context& context, z3::solver& solver, std::vector<z3::expr>& auxiliaryVariables, std::vector<z3::expr>& softConstraints, uint_fast64_t& nextFreeVariableIndex) {
z3::expr_vector assumptions(context);
for (auto const& auxiliaryVariable : auxiliaryVariables) {
assumptions.push_back(!auxiliaryVariable);
}
// Check whether the assumptions are satisfiable.
STORM_LOG_DEBUG("Invoking satisfiability checking.");
z3::check_result result = solver.check(assumptions);
STORM_LOG_DEBUG("Done invoking satisfiability checking.");
if (result == z3::sat) {
return true;
} else {
STORM_LOG_DEBUG("Computing unsat core.");
z3::expr_vector unsatCore = solver.unsat_core();
STORM_LOG_DEBUG("Computed unsat core.");
std::vector<z3::expr> blockingVariables;
blockingVariables.reserve(unsatCore.size());
// Create stringstream to build expression names.
std::stringstream variableName;
for (uint_fast64_t softConstraintIndex = 0; softConstraintIndex < softConstraints.size(); ++softConstraintIndex) {
for (uint_fast64_t coreIndex = 0; coreIndex < unsatCore.size(); ++coreIndex) {
bool isContainedInCore = false;
if (softConstraints[softConstraintIndex] == unsatCore[coreIndex]) {
isContainedInCore = true;
}
if (isContainedInCore) {
variableName.clear();
variableName.str("");
variableName << "b" << nextFreeVariableIndex;
blockingVariables.push_back(context.bool_const(variableName.str().c_str()));
variableName.clear();
variableName.str("");
variableName << "a" << nextFreeVariableIndex;
++nextFreeVariableIndex;
auxiliaryVariables[softConstraintIndex] = context.bool_const(variableName.str().c_str());
softConstraints[softConstraintIndex] = softConstraints[softConstraintIndex] || blockingVariables.back();
solver.add(softConstraints[softConstraintIndex] || auxiliaryVariables[softConstraintIndex]);
}
}
}
assertAtMostOne(context, solver, blockingVariables);
}
return false;
}
/*!
* Rules out the given command set for the given solver.
*
* @param context The Z3 context in which to build the expressions.
* @param solver The solver to use for the satisfiability evaluation.
* @param commandSet The command set to rule out as a solution.
* @param variableInformation A structure with information about the variables for the labels.
*/
static void ruleOutSolution(z3::context& context, z3::solver& solver, boost::container::flat_set<uint_fast64_t> const& commandSet, VariableInformation const& variableInformation) {
z3::expr blockSolutionExpression = context.bool_val(false);
for (auto labelIndexPair : variableInformation.labelToIndexMap) {
if (commandSet.find(labelIndexPair.first) != commandSet.end()) {
blockSolutionExpression = blockSolutionExpression || variableInformation.labelVariables[labelIndexPair.second];
}
}
solver.add(blockSolutionExpression);
}
/*!
* Determines the set of labels that was chosen by the given model.
@ -1316,7 +1219,7 @@ namespace storm {
* in order to satisfy the constraint system.
* @return The smallest set of labels such that the constraint system of the solver is satisfiable.
*/
static boost::container::flat_set<uint_fast64_t> findSmallestCommandSet(storm::solver::SmtSolver& solver, VariableInformation& variableInformation, uint_fast64_t& currentBound) {
static boost::optional<boost::container::flat_set<uint_fast64_t>> findSmallestCommandSet(storm::solver::SmtSolver& solver, VariableInformation& variableInformation, uint_fast64_t& currentBound) {
// Check if we can find a solution with the current bound.
storm::expressions::Expression assumption = !variableInformation.auxiliaryVariables.back();
@ -1331,6 +1234,10 @@ namespace storm {
solver.add(variableInformation.auxiliaryVariables.back());
variableInformation.auxiliaryVariables.push_back(assertLessOrEqualKRelaxed(solver, variableInformation, ++currentBound));
assumption = !variableInformation.auxiliaryVariables.back();
if (currentBound > (1 << variableInformation.minimalityLabelVariables.size())) {
STORM_LOG_DEBUG("Constraint system fully explored: Bound exceeds maximum of " << (1 << variableInformation.minimalityLabelVariables.size()));
return boost::none;
}
}
// At this point we know that the constraint system was satisfiable, so compute the induced label
@ -1342,12 +1249,17 @@ namespace storm {
std::vector<storm::expressions::Expression> formulae;
boost::container::flat_set<uint_fast64_t> unknownLabels;
std::set_difference(labelSet.begin(), labelSet.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownLabels, unknownLabels.end()));
std::set_intersection(labelSet.begin(), labelSet.end(), relevancyInformation.minimalityLabels.begin(), relevancyInformation.minimalityLabels.end(), std::inserter(unknownLabels, unknownLabels.end()));
//std::set_difference(labelSet.begin(), labelSet.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownLabels, unknownLabels.end()));
for (auto const& label : unknownLabels) {
formulae.emplace_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
}
boost::container::flat_set<uint_fast64_t> remainingLabels;
std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), labelSet.begin(), labelSet.end(), std::inserter(remainingLabels, remainingLabels.end()));
//std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), labelSet.begin(), labelSet.end(), std::inserter(remainingLabels, remainingLabels.end()));
std::set_difference(relevancyInformation.minimalityLabels.begin(), relevancyInformation.minimalityLabels.end(), labelSet.begin(), labelSet.end(), std::inserter(remainingLabels, remainingLabels.end()));
for (auto const& label : remainingLabels) {
formulae.emplace_back(variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
}
@ -1355,6 +1267,22 @@ namespace storm {
STORM_LOG_DEBUG("Ruling out single solution.");
assertDisjunction(solver, formulae, *variableInformation.manager);
}
static void ruleOutBiggerSolutions(storm::solver::SmtSolver& solver, boost::container::flat_set<uint_fast64_t> const& labelSet, VariableInformation& variableInformation, RelevancyInformation const& relevancyInformation) {
std::vector<storm::expressions::Expression> formulae;
boost::container::flat_set<uint_fast64_t> unknownLabels;
std::set_intersection(labelSet.begin(), labelSet.end(), relevancyInformation.minimalityLabels.begin(), relevancyInformation.minimalityLabels.end(), std::inserter(unknownLabels, unknownLabels.end()));
//std::set_difference(labelSet.begin(), labelSet.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownLabels, unknownLabels.end()));
for (auto const& label : unknownLabels) {
formulae.emplace_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
}
STORM_LOG_DEBUG("Ruling out set of solutions.");
assertDisjunction(solver, formulae, *variableInformation.manager);
}
/*!
* Analyzes the given sub-model that has a maximal reachability of zero (i.e. no psi states are reachable) and tries to construct assertions that aim to make at least one psi state reachable.
@ -1582,7 +1510,7 @@ namespace storm {
* Returns the sub-model obtained from removing all choices that do not originate from the specified filterLabelSet.
* Also returns the Labelsets of the sub-model.
*/
static std::pair<std::shared_ptr<storm::models::sparse::Model<T>>, std::vector<boost::container::flat_set<uint_fast64_t>>> restrictModelToLabelSet(storm::models::sparse::Model<T> const& model, boost::container::flat_set<uint_fast64_t> const& filterLabelSet) {
static std::pair<std::shared_ptr<storm::models::sparse::Model<T>>, std::vector<boost::container::flat_set<uint_fast64_t>>> restrictModelToLabelSet(storm::models::sparse::Model<T> const& model, boost::container::flat_set<uint_fast64_t> const& filterLabelSet, boost::optional<uint64_t> absorbState = boost::none) {
bool customRowGrouping = model.isOfType(storm::models::ModelType::Mdp);
@ -1616,7 +1544,8 @@ namespace storm {
if (customRowGrouping) {
transitionMatrixBuilder.newRowGroup(currentRow);
}
transitionMatrixBuilder.addNextValue(currentRow, state, storm::utility::one<T>());
uint64_t targetState = absorbState == boost::none ? state : absorbState.get();
transitionMatrixBuilder.addNextValue(currentRow, targetState, storm::utility::one<T>());
// Insert an empty label set for this choice
resultLabelSet.emplace_back();
++currentRow;
@ -1633,17 +1562,25 @@ namespace storm {
return std::make_pair(resultModel, std::move(resultLabelSet));
}
static T computeMaximalReachabilityProbability(Environment const& env, storm::models::sparse::Model<T> const& model, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates) {
static T computeMaximalReachabilityProbability(Environment const& env, storm::models::sparse::Model<T> const& model, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, boost::optional<std::string> const& rewardName) {
T result = storm::utility::zero<T>();
std::vector<T> allStatesResult;
STORM_LOG_DEBUG("Invoking model checker.");
if (model.isOfType(storm::models::ModelType::Dtmc)) {
allStatesResult = storm::modelchecker::helper::SparseDtmcPrctlHelper<T>::computeUntilProbabilities(env, false, model.getTransitionMatrix(), model.getBackwardTransitions(), phiStates, psiStates, false);
if (rewardName == boost::none) {
allStatesResult = storm::modelchecker::helper::SparseDtmcPrctlHelper<T>::computeUntilProbabilities(env, false, model.getTransitionMatrix(), model.getBackwardTransitions(), phiStates, psiStates, false);
} else {
allStatesResult = storm::modelchecker::helper::SparseDtmcPrctlHelper<T>::computeReachabilityRewards(env, false, model.getTransitionMatrix(), model.getBackwardTransitions(), model.getRewardModel(rewardName.get()), psiStates, false);
}
} else {
storm::modelchecker::helper::SparseMdpPrctlHelper<T> modelCheckerHelper;
allStatesResult = std::move(modelCheckerHelper.computeUntilProbabilities(env, false, model.getTransitionMatrix(), model.getBackwardTransitions(), phiStates, psiStates, false, false).values);
if (rewardName == boost::none) {
storm::modelchecker::helper::SparseMdpPrctlHelper<T> modelCheckerHelper;
allStatesResult = std::move(modelCheckerHelper.computeUntilProbabilities(env, false, model.getTransitionMatrix(),model.getBackwardTransitions(), phiStates,psiStates, false, false).values);
} else {
STORM_LOG_THROW(rewardName != boost::none, storm::exceptions::NotSupportedException, "Reward property counterexample generation is currently only supported for DTMCs.");
}
}
for (auto state : model.getInitialStates()) {
result = std::max(result, allStatesResult[state]);
@ -1664,6 +1601,9 @@ namespace storm {
bool encodeReachability;
bool useDynamicConstraints;
bool silent = false;
uint64_t continueAfterFirstCounterexampleUntil = 0;
uint64_t maximumCounterexamples = 1;
uint64_t multipleCounterexampleSizeCap = 100000000;
};
/*!
@ -1673,12 +1613,14 @@ namespace storm {
* @param model The sparse model in which to find the minimal command set.
* @param phiStates A bit vector characterizing all phi states in the model.
* @param psiStates A bit vector characterizing all psi states in the model.
* @param probabilityThreshold The threshold that is to be achieved or exceeded.
* @param propertyThreshold The threshold that is to be achieved or exceeded.
* @param rewardName The name of the reward structure to use, or boost::none if probabilities are considerd.
* @param strictBound Indicates whether the threshold needs to be achieved (true) or exceeded (false).
* @param options A set of options for customization.
*/
static boost::container::flat_set<uint_fast64_t> getMinimalLabelSet(Environment const& env, storm::storage::SymbolicModelDescription const& symbolicModel, storm::models::sparse::Model<T> const& model, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, boost::container::flat_set<uint_fast64_t> const& dontCareLabels = boost::container::flat_set<uint_fast64_t>(), Options const& options = Options()) {
static std::vector<boost::container::flat_set<uint_fast64_t>> getMinimalLabelSet(Environment const& env, storm::storage::SymbolicModelDescription const& symbolicModel, storm::models::sparse::Model<T> const& model, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double propertyThreshold, boost::optional<std::string> const& rewardName, bool strictBound, boost::container::flat_set<uint_fast64_t> const& dontCareLabels = boost::container::flat_set<uint_fast64_t>(), Options const& options = Options()) {
#ifdef STORM_HAVE_Z3
std::vector<boost::container::flat_set<uint_fast64_t>> result;
// Set up all clocks used for time measurement.
auto totalClock = std::chrono::high_resolution_clock::now();
auto timeOfLastMessage = std::chrono::high_resolution_clock::now();
@ -1718,10 +1660,10 @@ namespace storm {
// (1) Check whether its possible to exceed the threshold if checkThresholdFeasible is set.
double maximalReachabilityProbability = 0;
if (options.checkThresholdFeasible) {
maximalReachabilityProbability = computeMaximalReachabilityProbability(env, model, phiStates, psiStates);
maximalReachabilityProbability = computeMaximalReachabilityProbability(env, model, phiStates, psiStates, rewardName);
STORM_LOG_THROW((strictBound && maximalReachabilityProbability >= probabilityThreshold) || (!strictBound && maximalReachabilityProbability > probabilityThreshold), storm::exceptions::InvalidArgumentException, "Given probability threshold " << probabilityThreshold << " can not be " << (strictBound ? "achieved" : "exceeded") << " in model with maximal reachability probability of " << maximalReachabilityProbability << ".");
std::cout << std::endl << "Maximal reachability in model is " << maximalReachabilityProbability << "." << std::endl << std::endl;
STORM_LOG_THROW((strictBound && maximalReachabilityProbability >= propertyThreshold) || (!strictBound && maximalReachabilityProbability > propertyThreshold), storm::exceptions::InvalidArgumentException, "Given probability threshold " << propertyThreshold << " can not be " << (strictBound ? "achieved" : "exceeded") << " in model with maximal reachability probability of " << maximalReachabilityProbability << ".");
std::cout << std::endl << "Maximal property value in model is " << maximalReachabilityProbability << "." << std::endl << std::endl;
}
// (2) Identify all states and commands that are relevant, because only these need to be considered later.
@ -1762,10 +1704,10 @@ namespace storm {
// If there are no relevant labels, return directly.
if (relevancyInformation.relevantLabels.empty()) {
return commandSet;
return {commandSet};
} else if (relevancyInformation.minimalityLabels.empty()) {
commandSet.insert(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end());
return commandSet;
return {commandSet};
}
// Set up some variables for the iterations.
@ -1773,31 +1715,45 @@ namespace storm {
uint_fast64_t lastSize = 0;
uint_fast64_t iterations = 0;
uint_fast64_t currentBound = 0;
maximalReachabilityProbability = 0;
double maximalPropertyValue = 0;
uint_fast64_t zeroProbabilityCount = 0;
uint64_t smallestCounterexampleSize = model.getNumberOfChoices(); // Definitive u
uint64_t progressDelay = storm::settings::getModule<storm::settings::modules::GeneralSettings>().getShowProgressDelay();
do {
STORM_LOG_DEBUG("Computing minimal command set.");
solverClock = std::chrono::high_resolution_clock::now();
commandSet = findSmallestCommandSet(*solver, variableInformation, currentBound);
boost::optional<boost::container::flat_set<uint_fast64_t>> smallest = findSmallestCommandSet(*solver, variableInformation, currentBound);
totalSolverTime += std::chrono::high_resolution_clock::now() - solverClock;
STORM_LOG_DEBUG("Computed minimal command set of size " << commandSet.size() + relevancyInformation.knownLabels.size() << " (" << commandSet.size() << " + " << relevancyInformation.knownLabels.size() << ") ");
if(smallest == boost::none) {
STORM_LOG_DEBUG("No further counterexamples.");
break;
} else {
commandSet = smallest.get();
}
STORM_LOG_DEBUG("Computed minimal command with bound " << currentBound << " and set of size " << commandSet.size() + relevancyInformation.knownLabels.size() << " (" << commandSet.size() << " + " << relevancyInformation.knownLabels.size() << ") ");
// Restrict the given model to the current set of labels and compute the reachability probability.
modelCheckingClock = std::chrono::high_resolution_clock::now();
commandSet.insert(relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end());
auto subChoiceOrigins = restrictModelToLabelSet(model, commandSet);
commandSet.insert(relevancyInformation.dontCareLabels.begin(), relevancyInformation.dontCareLabels.end());
if (commandSet.size() > smallestCounterexampleSize + options.continueAfterFirstCounterexampleUntil || (result.size() > 1 && commandSet.size() > options.multipleCounterexampleSizeCap) ) {
STORM_LOG_DEBUG("No further counterexamples of similar size.");
break;
}
auto subChoiceOrigins = restrictModelToLabelSet(model, commandSet, psiStates.getNextSetIndex(0));
std::shared_ptr<storm::models::sparse::Model<T>> const& subModel = subChoiceOrigins.first;
std::vector<boost::container::flat_set<uint_fast64_t>> const& subLabelSets = subChoiceOrigins.second;
// Now determine the maximal reachability probability in the sub-model.
maximalReachabilityProbability = computeMaximalReachabilityProbability(env, *subModel, phiStates, psiStates);
maximalPropertyValue = computeMaximalReachabilityProbability(env, *subModel, phiStates, psiStates, rewardName);
totalModelCheckingTime += std::chrono::high_resolution_clock::now() - modelCheckingClock;
// Depending on whether the threshold was successfully achieved or not, we proceed by either analyzing the bad solution or stopping the iteration process.
analysisClock = std::chrono::high_resolution_clock::now();
if ((strictBound && maximalReachabilityProbability < probabilityThreshold) || (!strictBound && maximalReachabilityProbability <= probabilityThreshold)) {
if (maximalReachabilityProbability == storm::utility::zero<T>()) {
if ((strictBound && maximalPropertyValue < propertyThreshold) || (!strictBound && maximalPropertyValue <= propertyThreshold)) {
if (maximalPropertyValue == storm::utility::zero<T>()) {
++zeroProbabilityCount;
}
@ -1813,12 +1769,26 @@ namespace storm {
// the given threshold, we analyze the solution and try to guide the solver into the right direction.
analyzeInsufficientProbabilitySolution(*solver, *subModel, subLabelSets, model, labelSets, phiStates, psiStates, commandSet, variableInformation, relevancyInformation);
}
if (relevancyInformation.dontCareLabels.size() > 0) {
ruleOutSingleSolution(*solver, commandSet, variableInformation, relevancyInformation);
}
} else {
// Do not guide solver, just rule out current solution.
ruleOutSingleSolution(*solver, commandSet, variableInformation, relevancyInformation);
}
} else {
done = true;
STORM_LOG_DEBUG("Found a counterexample.");
result.push_back(commandSet);
if (options.maximumCounterexamples > result.size()) {
STORM_LOG_DEBUG("Exclude counterexample for future.");
ruleOutBiggerSolutions(*solver, commandSet, variableInformation, relevancyInformation);
} else {
STORM_LOG_DEBUG("Stop searching for further counterexamples.");
done = true;
}
}
totalAnalysisTime += (std::chrono::high_resolution_clock::now() - analysisClock);
++iterations;
@ -1828,10 +1798,10 @@ namespace storm {
if (static_cast<uint64_t>(durationSinceLastMessage) >= progressDelay || lastSize < commandSet.size()) {
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now - totalClock).count();
if (lastSize < commandSet.size()) {
std::cout << "Improved lower bound to " << commandSet.size() << " after " << milliseconds << "ms." << std::endl;
std::cout << "Improved lower bound to " << currentBound << " after " << milliseconds << "ms." << std::endl;
lastSize = commandSet.size();
} else {
std::cout << "Lower bound on label set size is " << commandSet.size() << " after " << milliseconds << "ms (checked " << iterations << " models, " << zeroProbabilityCount << " could not reach the target set)." << std::endl;
std::cout << "Lower bound on label set size is " << currentBound << " after " << milliseconds << "ms (checked " << iterations << " models, " << zeroProbabilityCount << " could not reach the target set)." << std::endl;
timeOfLastMessage = std::chrono::high_resolution_clock::now();
}
}
@ -1863,7 +1833,7 @@ namespace storm {
std::cout << " * number of models that could not reach a target state: " << zeroProbabilityCount << " (" << 100 * static_cast<double>(zeroProbabilityCount)/iterations << "%)" << std::endl << std::endl;
}
return commandSet;
return result;
#else
throw storm::exceptions::NotImplementedException() << "This functionality is unavailable since storm has been compiled without support for Z3.";
#endif
@ -1953,28 +1923,47 @@ namespace storm {
}
static boost::container::flat_set<uint_fast64_t> computeCounterexampleLabelSet(Environment const& env, storm::storage::SymbolicModelDescription const& symbolicModel, storm::models::sparse::Model<T> const& model, std::shared_ptr<storm::logic::Formula const> const& formula, boost::container::flat_set<uint_fast64_t> const& dontCareLabels = boost::container::flat_set<uint_fast64_t>(), Options const& options = Options(true)) {
static std::vector<boost::container::flat_set<uint_fast64_t>> computeCounterexampleLabelSet(Environment const& env, storm::storage::SymbolicModelDescription const& symbolicModel, storm::models::sparse::Model<T> const& model, std::shared_ptr<storm::logic::Formula const> const& formula, boost::container::flat_set<uint_fast64_t> const& dontCareLabels = boost::container::flat_set<uint_fast64_t>(), Options const& options = Options(true)) {
STORM_LOG_THROW(model.isOfType(storm::models::ModelType::Dtmc) || model.isOfType(storm::models::ModelType::Mdp), storm::exceptions::NotSupportedException, "MaxSAT-based counterexample generation is supported only for discrete-time models.");
if (!options.silent) {
std::cout << std::endl << "Generating minimal label counterexample for formula " << *formula << std::endl;
}
STORM_LOG_THROW(formula->isProbabilityOperatorFormula(), storm::exceptions::InvalidPropertyException, "Counterexample generation does not support this kind of formula. Expecting a probability operator as the outermost formula element.");
storm::logic::ProbabilityOperatorFormula const& probabilityOperator = formula->asProbabilityOperatorFormula();
STORM_LOG_THROW(probabilityOperator.hasBound(), storm::exceptions::InvalidPropertyException, "Counterexample generation only supports bounded formulas.");
STORM_LOG_THROW(probabilityOperator.getSubformula().isUntilFormula() || probabilityOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'phi U psi' for counterexample generation.");
storm::logic::ComparisonType comparisonType;
double threshold;
boost::optional<std::string> rewardName = boost::none;
STORM_LOG_THROW(formula->isProbabilityOperatorFormula() || formula->isRewardOperatorFormula(), storm::exceptions::InvalidPropertyException, "Counterexample generation does not support this kind of formula. Expecting a probability operator as the outermost formula element.");
if (formula->isProbabilityOperatorFormula()) {
storm::logic::ProbabilityOperatorFormula const& probabilityOperator = formula->asProbabilityOperatorFormula();
STORM_LOG_THROW(probabilityOperator.hasBound(), storm::exceptions::InvalidPropertyException, "Counterexample generation only supports bounded formulas.");
STORM_LOG_THROW(probabilityOperator.getSubformula().isUntilFormula() || probabilityOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'phi U psi' for counterexample generation.");
storm::logic::ComparisonType comparisonType = probabilityOperator.getComparisonType();
bool strictBound = comparisonType == storm::logic::ComparisonType::Less;
double threshold = probabilityOperator.getThresholdAs<T>();
comparisonType = probabilityOperator.getComparisonType();
threshold = probabilityOperator.getThresholdAs<T>();
} else {
assert(formula->isRewardOperatorFormula());
storm::logic::RewardOperatorFormula const& rewardOperator = formula->asRewardOperatorFormula();
STORM_LOG_THROW(rewardOperator.hasBound(), storm::exceptions::InvalidPropertyException, "Counterexample generation only supports bounded formulas.");
STORM_LOG_THROW( rewardOperator.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Path formula is required to be of the form 'F phi' for counterexample generation.");
comparisonType = rewardOperator.getComparisonType();
threshold = rewardOperator.getThresholdAs<T>();
rewardName = rewardOperator.getRewardModelName();
STORM_LOG_THROW(!storm::logic::isLowerBound(comparisonType), storm::exceptions::NotSupportedException, "Lower bounds in counterexamples are only supported for probability formulas.");
}
bool strictBound = comparisonType == storm::logic::ComparisonType::Less;
storm::logic::Formula const& subformula = formula->asOperatorFormula().getSubformula();
storm::storage::BitVector phiStates;
storm::storage::BitVector psiStates;
storm::modelchecker::SparsePropositionalModelChecker<storm::models::sparse::Model<T>> modelchecker(model);
if (probabilityOperator.getSubformula().isUntilFormula()) {
if (subformula.isUntilFormula()) {
STORM_LOG_THROW(!storm::logic::isLowerBound(comparisonType), storm::exceptions::NotSupportedException, "Lower bounds in counterexamples are only supported for eventually formulas.");
storm::logic::UntilFormula const& untilFormula = probabilityOperator.getSubformula().asUntilFormula();
storm::logic::UntilFormula const& untilFormula = subformula.asUntilFormula();
std::unique_ptr<storm::modelchecker::CheckResult> leftResult = modelchecker.check(env, untilFormula.getLeftSubformula());
std::unique_ptr<storm::modelchecker::CheckResult> rightResult = modelchecker.check(env, untilFormula.getRightSubformula());
@ -1984,8 +1973,8 @@ namespace storm {
phiStates = leftQualitativeResult.getTruthValuesVector();
psiStates = rightQualitativeResult.getTruthValuesVector();
} else if (probabilityOperator.getSubformula().isEventuallyFormula()) {
storm::logic::EventuallyFormula const& eventuallyFormula = probabilityOperator.getSubformula().asEventuallyFormula();
} else if (subformula.isEventuallyFormula()) {
storm::logic::EventuallyFormula const& eventuallyFormula = subformula.asEventuallyFormula();
std::unique_ptr<storm::modelchecker::CheckResult> subResult = modelchecker.check(env, eventuallyFormula.getSubformula());
@ -2025,28 +2014,36 @@ namespace storm {
// Delegate the actual computation work to the function of equal name.
auto startTime = std::chrono::high_resolution_clock::now();
auto labelSet = getMinimalLabelSet(env, symbolicModel, model, phiStates, psiStates, threshold, strictBound, dontCareLabels, options);
auto labelSets = getMinimalLabelSet(env, symbolicModel, model, phiStates, psiStates, threshold, rewardName, strictBound, dontCareLabels, options);
auto endTime = std::chrono::high_resolution_clock::now();
if (!options.silent) {
std::cout << std::endl << "Computed minimal label set of size " << labelSet.size() << " in " << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() << "ms." << std::endl;
for (auto const& labelSet : labelSets) {
std::cout << std::endl << "Computed minimal label set of size " << labelSet.size();
}
std::cout << std::endl << " in " << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() << "ms." << std::endl;
}
// Extend the command set properly.
if (lowerBoundedFormula) {
extendLabelSetLowerBound(model, labelSet, phiStates, psiStates, options.silent);
for (auto& labelSet : labelSets) {
if (lowerBoundedFormula) {
extendLabelSetLowerBound(model, labelSet, phiStates, psiStates, options.silent);
}
}
return labelSet;
return labelSets;
}
static std::shared_ptr<HighLevelCounterexample> computeCounterexample(Environment const& env, storm::storage::SymbolicModelDescription const& symbolicModel, storm::models::sparse::Model<T> const& model, std::shared_ptr<storm::logic::Formula const> const& formula) {
#ifdef STORM_HAVE_Z3
auto labelSet = computeCounterexampleLabelSet(env, symbolicModel, model, formula);
auto labelSets = computeCounterexampleLabelSet(env, symbolicModel, model, formula);
if (symbolicModel.isPrismProgram()) {
return std::make_shared<HighLevelCounterexample>(symbolicModel.asPrismProgram().restrictCommands(labelSet));
return std::make_shared<HighLevelCounterexample>(symbolicModel.asPrismProgram().restrictCommands(labelSets[0]));
} else {
STORM_LOG_ASSERT(symbolicModel.isJaniModel(), "Unknown symbolic model description type.");
return std::make_shared<HighLevelCounterexample>(symbolicModel.asJaniModel().restrictEdges(labelSet));
return std::make_shared<HighLevelCounterexample>(symbolicModel.asJaniModel().restrictEdges(labelSets[0]));
}
#else
throw storm::exceptions::NotImplementedException() << "This functionality is unavailable since storm has been compiled without support for Z3.";

2
src/storm/settings/modules/CounterexampleGeneratorSettings.cpp → src/storm-counterexamples/settings/modules/CounterexampleGeneratorSettings.cpp

@ -1,4 +1,4 @@
#include "storm/settings/modules/CounterexampleGeneratorSettings.h"
#include "CounterexampleGeneratorSettings.h"
#include "storm/settings/SettingsManager.h"
#include "storm/exceptions/InvalidSettingsException.h"

0
src/storm/settings/modules/CounterexampleGeneratorSettings.h → src/storm-counterexamples/settings/modules/CounterexampleGeneratorSettings.h

2
src/storm-dft-cli/CMakeLists.txt

@ -6,4 +6,4 @@ set_target_properties(storm-dft-cli PROPERTIES OUTPUT_NAME "storm-dft")
add_dependencies(binaries storm-dft-cli)
# installation
install(TARGETS storm-dft-cli RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-dft-cli EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

3
src/storm-dft-cli/storm-dft.cpp

@ -5,7 +5,10 @@
#include "storm-dft/settings/modules/FaultTreeSettings.h"
#include "storm/settings/modules/IOSettings.h"
#include "storm/settings/modules/ResourceSettings.h"
#include "storm/settings/modules/GeneralSettings.h"
#include "storm-parsers/api/storm-parsers.h"
#include "storm/utility/initialize.h"
#include "storm-cli-utilities/cli.h"

4
src/storm-dft/CMakeLists.txt

@ -17,7 +17,7 @@ set_target_properties(storm-dft PROPERTIES DEFINE_SYMBOL "")
list(APPEND STORM_TARGETS storm-dft)
set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE)
target_link_libraries(storm-dft PUBLIC storm storm-gspn ${STORM_DFT_LINK_LIBRARIES})
target_link_libraries(storm-dft PUBLIC storm storm-gspn storm-parsers ${STORM_DFT_LINK_LIBRARIES})
# Install storm headers to include directory.
foreach(HEADER ${STORM_DFT_HEADERS})
@ -36,5 +36,5 @@ add_custom_target(copy_storm_dft_headers DEPENDS ${STORM_DFT_OUTPUT_HEADERS} ${S
add_dependencies(storm-dft copy_storm_dft_headers)
# installation
install(TARGETS storm-dft RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-dft EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

3
src/storm-dft/modelchecker/dft/DFTModelChecker.cpp

@ -1,9 +1,12 @@
#include "DFTModelChecker.h"
#include "storm/settings/modules/IOSettings.h"
#include "storm/settings/modules/GeneralSettings.h"
#include "storm/builder/ParallelCompositionBuilder.h"
#include "storm/utility/bitoperations.h"
#include "storm/utility/DirectEncodingExporter.h"
#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h"
#include "storm/modelchecker/results/ExplicitQualitativeCheckResult.h"
#include "storm-dft/builder/ExplicitDFTModelBuilder.h"
#include "storm-dft/storage/dft/DFTIsomorphism.h"

4
src/storm-dft/parser/DFTGalileoParser.h

@ -3,12 +3,12 @@
#include <map>
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/storage/expressions/ExpressionEvaluator.h"
#include "storm-dft/storage/dft/DFT.h"
#include "storm-dft/builder/DFTBuilder.h"
#include "storm/parser/ValueParser.h"
#include "storm-parsers/parser/ValueParser.h"
namespace storm {

2
src/storm-dft/parser/DFTJsonParser.h

@ -3,7 +3,7 @@
#include <map>
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/storage/expressions/ExpressionEvaluator.h"
#include "storm-dft/storage/dft/DFT.h"

2
src/storm-gspn-cli/CMakeLists.txt

@ -5,4 +5,4 @@ set_target_properties(storm-gspn-cli PROPERTIES OUTPUT_NAME "storm-gspn")
add_dependencies(binaries storm-gspn-cli)
# installation
install(TARGETS storm-gspn-cli RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-gspn-cli EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

5
src/storm-gspn-cli/storm-gspn.cpp

@ -12,9 +12,11 @@
#include "storm/utility/initialize.h"
#include "api/storm.h"
#include "storm-parsers/api/storm-parsers.h"
#include "storm-cli-utilities/cli.h"
#include "storm/parser/FormulaParser.h"
#include "storm-parsers/parser/FormulaParser.h"
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/storage/jani/Model.h"
@ -27,6 +29,7 @@
#include "storm/exceptions/FileIoException.h"
#include "storm/settings/modules/GeneralSettings.h"
#include "storm/settings/modules/IOSettings.h"
#include "storm-gspn/settings/modules/GSPNSettings.h"
#include "storm-gspn/settings/modules/GSPNExportSettings.h"

2
src/storm-gspn/CMakeLists.txt

@ -15,4 +15,4 @@ set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE)
target_link_libraries(storm-gspn storm ${STORM_GSPN_LINK_LIBRARIES})
# installation
install(TARGETS storm-gspn RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-gspn EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

2
src/storm-gspn/builder/ExplicitGspnModelBuilder.cpp

@ -5,7 +5,7 @@
//#include "storm/utility/macros.h"
//#include "storm/exceptions/NotImplementedException.h"
//#include "storm/storage/expressions/ExpressionManager.h"
//#include "storm/parser/FormulaParser.h"
//#include "storm-parsers/parser/FormulaParser.h"
//#include "storm/storage/expressions/ExpressionEvaluator.h"
//
//namespace storm {

2
src/storm-pars-cli/CMakeLists.txt

@ -6,4 +6,4 @@ set_target_properties(storm-pars-cli PROPERTIES OUTPUT_NAME "storm-pars")
add_dependencies(binaries storm-pars-cli)
# installation
install(TARGETS storm-pars-cli RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-pars-cli EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

2
src/storm-pars/CMakeLists.txt

@ -36,5 +36,5 @@ add_custom_target(copy_storm_pars_headers DEPENDS ${STORM_PARS_OUTPUT_HEADERS} $
add_dependencies(storm-pars copy_storm_pars_headers)
# installation
install(TARGETS storm-pars RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-pars EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

2
src/storm-pars/settings/ParsSettings.cpp

@ -1,4 +1,3 @@
#include <storm/settings/modules/CounterexampleGeneratorSettings.h>
#include "storm-pars/settings/ParsSettings.h"
#include "storm-pars/settings/modules/ParametricSettings.h"
@ -38,7 +37,6 @@ namespace storm {
storm::settings::addModule<storm::settings::modules::ParametricSettings>();
storm::settings::addModule<storm::settings::modules::RegionSettings>();
storm::settings::addModule<storm::settings::modules::BuildSettings>();
storm::settings::addModule<storm::settings::modules::CounterexampleGeneratorSettings>();
storm::settings::addModule<storm::settings::modules::ModelCheckerSettings>();
storm::settings::addModule<storm::settings::modules::DebugSettings>();
storm::settings::addModule<storm::settings::modules::SylvanSettings>();

42
src/storm-parsers/CMakeLists.txt

@ -0,0 +1,42 @@
file(GLOB_RECURSE ALL_FILES ${PROJECT_SOURCE_DIR}/src/storm-parsers/*.h ${PROJECT_SOURCE_DIR}/src/storm-parsers/*.cpp)
register_source_groups_from_filestructure("${ALL_FILES}" storm-parsers)
file(GLOB_RECURSE STORM_PARSER_SOURCES ${PROJECT_SOURCE_DIR}/src/storm-parsers/*/*.cpp)
file(GLOB_RECURSE STORM_PARSER_HEADERS ${PROJECT_SOURCE_DIR}/src/storm-parsers/*/*.h)
# Disable Debug compiler flags for PrismParser to lessen memory consumption during compilation
SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/src/storm-parsers/parser/PrismParser.cpp PROPERTIES COMPILE_FLAGS -g0)
# Create storm-parsers.
add_library(storm-parsers SHARED ${STORM_PARSER_SOURCES} ${STORM_PARSER_HEADERS})
# Remove define symbol for shared libstorm.
set_target_properties(storm-parsers PROPERTIES DEFINE_SYMBOL "")
#add_dependencies(storm resources)
list(APPEND STORM_TARGETS storm-parsers)
set(STORM_TARGETS ${STORM_TARGETS} PARENT_SCOPE)
target_link_libraries(storm-parsers PUBLIC storm)
# Install storm headers to include directory.
foreach(HEADER ${STORM_PARSER_HEADERS})
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER})
string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH})
string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH})
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}
DEPENDS ${HEADER}
)
list(APPEND STORM_PARSER_OUTPUT_HEADERS "${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}")
endforeach()
add_custom_target(copy_storm_parser_headers DEPENDS ${STORM_PARSER_OUTPUT_HEADERS} ${STORM_PARSER_HEADERS})
add_dependencies(storm-parsers copy_storm_parser_headers)
# installation
install(TARGETS storm-parsers EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

6
src/storm/api/model_descriptions.cpp → src/storm-parsers/api/model_descriptions.cpp

@ -1,7 +1,7 @@
#include "storm/api/model_descriptions.h"
#include "model_descriptions.h"
#include "storm/parser/PrismParser.h"
#include "storm/parser/JaniParser.h"
#include "storm-parsers/parser/PrismParser.h"
#include "storm-parsers/parser/JaniParser.h"
#include "storm/storage/jani/Model.h"
#include "storm/storage/jani/Property.h"

0
src/storm/api/model_descriptions.h → src/storm-parsers/api/model_descriptions.h

71
src/storm-parsers/api/properties.cpp

@ -0,0 +1,71 @@
#include "storm-parsers/parser/FormulaParser.h"
#include "storm/api/properties.h"
#include "storm/storage/SymbolicModelDescription.h"
#include "storm/storage/prism/Program.h"
#include "storm/storage/jani/Model.h"
#include "storm/storage/jani/Property.h"
#include "storm/logic/Formula.h"
#include "storm/utility/cli.h"
namespace storm {
namespace api {
boost::optional <std::set<std::string>> parsePropertyFilter(std::string const &propertyFilter) {
if (propertyFilter == "all") {
return boost::none;
}
std::vector <std::string> propertyNames = storm::utility::cli::parseCommaSeparatedStrings(propertyFilter);
std::set <std::string> propertyNameSet(propertyNames.begin(), propertyNames.end());
return propertyNameSet;
}
std::vector <storm::jani::Property> parseProperties(storm::parser::FormulaParser &formulaParser, std::string const &inputString, boost::optional <std::set<std::string>> const &propertyFilter) {
// If the given property is a file, we parse it as a file, otherwise we assume it's a property.
std::vector <storm::jani::Property> properties;
if (std::ifstream(inputString).good()) {
STORM_LOG_INFO("Loading properties from file: " << inputString << std::endl);
properties = formulaParser.parseFromFile(inputString);
} else {
properties = formulaParser.parseFromString(inputString);
}
return filterProperties(properties, propertyFilter);
}
std::vector <storm::jani::Property> parseProperties(std::string const &inputString, boost::optional <std::set<std::string>> const &propertyFilter) {
auto exprManager = std::make_shared<storm::expressions::ExpressionManager>();
storm::parser::FormulaParser formulaParser(exprManager);
return parseProperties(formulaParser, inputString, propertyFilter);
}
std::vector <storm::jani::Property> parsePropertiesForJaniModel(std::string const &inputString, storm::jani::Model const &model, boost::optional <std::set<std::string>> const &propertyFilter) {
storm::parser::FormulaParser formulaParser(model.getManager().getSharedPointer());
auto formulas = parseProperties(formulaParser, inputString, propertyFilter);
return substituteConstantsInProperties(formulas, model.getConstantsSubstitution());
}
std::vector <storm::jani::Property> parsePropertiesForPrismProgram(std::string const &inputString, storm::prism::Program const &program, boost::optional <std::set<std::string>> const &propertyFilter) {
storm::parser::FormulaParser formulaParser(program);
auto formulas = parseProperties(formulaParser, inputString, propertyFilter);
return substituteConstantsInProperties(formulas, program.getConstantsSubstitution());
}
std::vector <storm::jani::Property> parsePropertiesForSymbolicModelDescription(std::string const &inputString, storm::storage::SymbolicModelDescription const &modelDescription, boost::optional <std::set<std::string>> const &propertyFilter) {
std::vector <storm::jani::Property> result;
if (modelDescription.isPrismProgram()) {
result = storm::api::parsePropertiesForPrismProgram(inputString, modelDescription.asPrismProgram(), propertyFilter);
} else {
STORM_LOG_ASSERT(modelDescription.isJaniModel(), "Unknown model description type.");
result = storm::api::parsePropertiesForJaniModel(inputString, modelDescription.asJaniModel(), propertyFilter);
}
return result;
}
}
}

43
src/storm-parsers/api/properties.h

@ -0,0 +1,43 @@
#pragma once
#include <string>
#include <set>
#include <map>
#include <vector>
#include <memory>
#include <boost/optional.hpp>
namespace storm {
namespace parser {
class FormulaParser;
}
namespace jani {
class Property;
class Model;
}
namespace expressions {
class Variable;
class Expression;
}
namespace prism {
class Program;
}
namespace storage {
class SymbolicModelDescription;
}
namespace logic {
class Formula;
}
namespace api {
boost::optional<std::set<std::string>> parsePropertyFilter(std::string const& propertyFilter);
// Parsing properties.
std::vector<storm::jani::Property> parseProperties(storm::parser::FormulaParser& formulaParser, std::string const& inputString, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parseProperties(std::string const& inputString, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parsePropertiesForPrismProgram(std::string const& inputString, storm::prism::Program const& program, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parsePropertiesForJaniModel(std::string const& inputString, storm::jani::Model const& model, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parsePropertiesForSymbolicModelDescription(std::string const& inputString, storm::storage::SymbolicModelDescription const& modelDescription, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
}
}

4
src/storm-parsers/api/storm-parsers.h

@ -0,0 +1,4 @@
#pragma once
#include "storm-parsers/api/model_descriptions.h"
#include "storm-parsers/api/properties.h"

4
src/storm/parser/AtomicPropositionLabelingParser.cpp → src/storm-parsers/parser/AtomicPropositionLabelingParser.cpp

@ -5,14 +5,14 @@
* Author: Gereon Kremer
*/
#include "storm/parser/AtomicPropositionLabelingParser.h"
#include "storm-parsers/parser/AtomicPropositionLabelingParser.h"
#include <cstring>
#include <string>
#include <iostream>
#include "storm/utility/cstring.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/FileIoException.h"

0
src/storm/parser/AtomicPropositionLabelingParser.h → src/storm-parsers/parser/AtomicPropositionLabelingParser.h

10
src/storm/parser/AutoParser.cpp → src/storm-parsers/parser/AutoParser.cpp

@ -1,12 +1,12 @@
#include "storm/parser/AutoParser.h"
#include "storm-parsers/parser/AutoParser.h"
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/parser/DeterministicModelParser.h"
#include "storm/parser/NondeterministicModelParser.h"
#include "storm/parser/MarkovAutomatonParser.h"
#include "storm-parsers/parser/DeterministicModelParser.h"
#include "storm-parsers/parser/NondeterministicModelParser.h"
#include "storm-parsers/parser/MarkovAutomatonParser.h"
#include "storm/utility/macros.h"
#include "storm/exceptions/WrongFormatException.h"

0
src/storm/parser/AutoParser.h → src/storm-parsers/parser/AutoParser.h

8
src/storm/parser/DeterministicModelParser.cpp → src/storm-parsers/parser/DeterministicModelParser.cpp

@ -1,13 +1,13 @@
#include "storm/parser/DeterministicModelParser.h"
#include "storm-parsers/parser/DeterministicModelParser.h"
#include <string>
#include <vector>
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/parser/DeterministicSparseTransitionParser.h"
#include "storm/parser/SparseItemLabelingParser.h"
#include "storm/parser/SparseStateRewardParser.h"
#include "storm-parsers/parser/DeterministicSparseTransitionParser.h"
#include "storm-parsers/parser/SparseItemLabelingParser.h"
#include "storm-parsers/parser/SparseStateRewardParser.h"
#include "storm/adapters/RationalFunctionAdapter.h"

0
src/storm/parser/DeterministicModelParser.h → src/storm-parsers/parser/DeterministicModelParser.h

4
src/storm/parser/DeterministicSparseTransitionParser.cpp → src/storm-parsers/parser/DeterministicSparseTransitionParser.cpp

@ -1,4 +1,4 @@
#include "storm/parser/DeterministicSparseTransitionParser.h"
#include "storm-parsers/parser/DeterministicSparseTransitionParser.h"
#include <cstdio>
#include <cstring>
@ -9,7 +9,7 @@
#include "storm/utility/constants.h"
#include "storm/utility/cstring.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/exceptions/FileIoException.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/InvalidArgumentException.h"

0
src/storm/parser/DeterministicSparseTransitionParser.h → src/storm-parsers/parser/DeterministicSparseTransitionParser.h

2
src/storm/parser/DirectEncodingParser.cpp → src/storm-parsers/parser/DirectEncodingParser.cpp

@ -1,4 +1,4 @@
#include "storm/parser/DirectEncodingParser.h"
#include "storm-parsers/parser/DirectEncodingParser.h"
#include <iostream>
#include <string>

2
src/storm/parser/DirectEncodingParser.h → src/storm-parsers/parser/DirectEncodingParser.h

@ -1,7 +1,7 @@
#ifndef STORM_PARSER_DIRECTENCODINGPARSER_H_
#define STORM_PARSER_DIRECTENCODINGPARSER_H_
#include "storm/parser/ValueParser.h"
#include "storm-parsers/parser/ValueParser.h"
#include "storm/models/sparse/Model.h"
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/storage/sparse/ModelComponents.h"

0
src/storm/parser/ExpressionCreator.cpp → src/storm-parsers/parser/ExpressionCreator.cpp

2
src/storm/parser/ExpressionCreator.h → src/storm-parsers/parser/ExpressionCreator.h

@ -1,7 +1,7 @@
#pragma once
#include <memory>
// Very ugly, but currently we would like to have the symbol table here.
#include "storm/parser/SpiritParserDefinitions.h"
#include "storm-parsers/parser/SpiritParserDefinitions.h"
#include <boost/optional.hpp>
#include "storm/adapters/RationalNumberAdapter.h"

4
src/storm/parser/ExpressionParser.cpp → src/storm-parsers/parser/ExpressionParser.cpp

@ -1,10 +1,10 @@
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/exceptions/InvalidArgumentException.h"
#include "storm/exceptions/InvalidTypeException.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/utility/constants.h"
#include "storm/parser/ExpressionCreator.h"
#include "storm-parsers/parser/ExpressionCreator.h"
#include "storm/storage/expressions/Expression.h"

4
src/storm/parser/ExpressionParser.h → src/storm-parsers/parser/ExpressionParser.h

@ -2,8 +2,8 @@
#include <sstream>
#include "storm/parser/SpiritParserDefinitions.h"
#include "storm/parser/SpiritErrorHandler.h"
#include "storm-parsers/parser/SpiritParserDefinitions.h"
#include "storm-parsers/parser/SpiritErrorHandler.h"
#include "storm/storage/expressions/OperatorType.h"
#include "storm/adapters/RationalNumberAdapter.h"

4
src/storm/parser/FormulaParser.cpp → src/storm-parsers/parser/FormulaParser.cpp

@ -1,8 +1,8 @@
#include "storm/parser/FormulaParser.h"
#include "storm-parsers/parser/FormulaParser.h"
#include <fstream>
#include "storm/parser/SpiritErrorHandler.h"
#include "storm-parsers/parser/SpiritErrorHandler.h"
#include "storm/storage/prism/Program.h"

4
src/storm/parser/FormulaParser.h → src/storm-parsers/parser/FormulaParser.h

@ -3,8 +3,8 @@
#include <sstream>
#include "storm/parser/SpiritParserDefinitions.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/SpiritParserDefinitions.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/storage/jani/Property.h"
#include "storm/storage/expressions/Expression.h"
#include "storm/utility/macros.h"

0
src/storm/parser/FormulaParserGrammar.cpp → src/storm-parsers/parser/FormulaParserGrammar.cpp

4
src/storm/parser/FormulaParserGrammar.h → src/storm-parsers/parser/FormulaParserGrammar.h

@ -3,11 +3,11 @@
#include <memory>
#include <fstream>
#include "storm/parser/SpiritErrorHandler.h"
#include "storm-parsers/parser/SpiritErrorHandler.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/storage/jani/Property.h"
#include "storm/logic/Formulas.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/modelchecker/results/FilterType.h"

2
src/storm/parser/ImcaMarkovAutomatonParser.cpp → src/storm-parsers/parser/ImcaMarkovAutomatonParser.cpp

@ -1,4 +1,4 @@
#include "storm/parser/ImcaMarkovAutomatonParser.h"
#include "storm-parsers/parser/ImcaMarkovAutomatonParser.h"
#include "storm/settings/SettingsManager.h"
#include "storm/settings/modules/BuildSettings.h"

2
src/storm/parser/ImcaMarkovAutomatonParser.h → src/storm-parsers/parser/ImcaMarkovAutomatonParser.h

@ -7,7 +7,7 @@
#include "storm/models/sparse/MarkovAutomaton.h"
#include "storm/generator/StateBehavior.h"
#include "storm/parser/SpiritErrorHandler.h"
#include "storm-parsers/parser/SpiritErrorHandler.h"
namespace storm {
namespace parser {

0
src/storm/parser/JaniParser.cpp → src/storm-parsers/parser/JaniParser.cpp

0
src/storm/parser/JaniParser.h → src/storm-parsers/parser/JaniParser.h

0
src/storm/parser/KeyValueParser.cpp → src/storm-parsers/parser/KeyValueParser.cpp

0
src/storm/parser/KeyValueParser.h → src/storm-parsers/parser/KeyValueParser.h

2
src/storm/parser/MappedFile.cpp → src/storm-parsers/parser/MappedFile.cpp

@ -5,7 +5,7 @@
* Author: Manuel Sascha Weiand
*/
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include <fstream>
#include <cstring>

0
src/storm/parser/MappedFile.h → src/storm-parsers/parser/MappedFile.h

0
src/storm/parser/MarkovAutomatonParser.cpp → src/storm-parsers/parser/MarkovAutomatonParser.cpp

2
src/storm/parser/MarkovAutomatonParser.h → src/storm-parsers/parser/MarkovAutomatonParser.h

@ -2,7 +2,7 @@
#define STORM_PARSER_MARKOVAUTOMATONPARSER_H_
#include "storm/models/sparse/MarkovAutomaton.h"
#include "storm/parser/MarkovAutomatonSparseTransitionParser.h"
#include "storm-parsers/parser/MarkovAutomatonSparseTransitionParser.h"
namespace storm {
namespace parser {

2
src/storm/parser/MarkovAutomatonSparseTransitionParser.cpp → src/storm-parsers/parser/MarkovAutomatonSparseTransitionParser.cpp

@ -4,7 +4,7 @@
#include "storm/settings/modules/CoreSettings.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/FileIoException.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/utility/cstring.h"
#include "storm/utility/constants.h"
#include "storm/utility/macros.h"

0
src/storm/parser/MarkovAutomatonSparseTransitionParser.h → src/storm-parsers/parser/MarkovAutomatonSparseTransitionParser.h

8
src/storm/parser/NondeterministicModelParser.cpp → src/storm-parsers/parser/NondeterministicModelParser.cpp

@ -1,13 +1,13 @@
#include "storm/parser/NondeterministicModelParser.h"
#include "storm-parsers/parser/NondeterministicModelParser.h"
#include <string>
#include <vector>
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/parser/NondeterministicSparseTransitionParser.h"
#include "storm/parser/SparseItemLabelingParser.h"
#include "storm/parser/SparseStateRewardParser.h"
#include "storm-parsers/parser/NondeterministicSparseTransitionParser.h"
#include "storm-parsers/parser/SparseItemLabelingParser.h"
#include "storm-parsers/parser/SparseStateRewardParser.h"
#include "storm/adapters/RationalFunctionAdapter.h"
#include "storm/utility/macros.h"

0
src/storm/parser/NondeterministicModelParser.h → src/storm-parsers/parser/NondeterministicModelParser.h

4
src/storm/parser/NondeterministicSparseTransitionParser.cpp → src/storm-parsers/parser/NondeterministicSparseTransitionParser.cpp

@ -1,8 +1,8 @@
#include "storm/parser/NondeterministicSparseTransitionParser.h"
#include "storm-parsers/parser/NondeterministicSparseTransitionParser.h"
#include <string>
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/settings/SettingsManager.h"
#include "storm/settings/modules/CoreSettings.h"
#include "storm/exceptions/FileIoException.h"

0
src/storm/parser/NondeterministicSparseTransitionParser.h → src/storm-parsers/parser/NondeterministicSparseTransitionParser.h

4
src/storm/parser/PrismParser.cpp → src/storm-parsers/parser/PrismParser.cpp

@ -1,4 +1,4 @@
#include "storm/parser/PrismParser.h"
#include "storm-parsers/parser/PrismParser.h"
#include "storm/storage/prism/Compositions.h"
@ -11,7 +11,7 @@
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/ExpressionParser.h"
namespace storm {
namespace parser {

4
src/storm/parser/PrismParser.h → src/storm-parsers/parser/PrismParser.h

@ -6,8 +6,8 @@
#include <memory>
#include <iomanip>
#include "storm/parser/SpiritParserDefinitions.h"
#include "storm/parser/SpiritErrorHandler.h"
#include "storm-parsers/parser/SpiritParserDefinitions.h"
#include "storm-parsers/parser/SpiritErrorHandler.h"
#include "storm/storage/prism/Program.h"
#include "storm/storage/expressions/Expression.h"

0
src/storm/parser/ReadValues.h → src/storm-parsers/parser/ReadValues.h

4
src/storm/parser/SparseChoiceLabelingParser.cpp → src/storm-parsers/parser/SparseChoiceLabelingParser.cpp

@ -1,10 +1,10 @@
#include "storm/parser/SparseChoiceLabelingParser.h"
#include "storm-parsers/parser/SparseChoiceLabelingParser.h"
#include "storm/utility/macros.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/OutOfRangeException.h"
#include "storm/exceptions/FileIoException.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/utility/cstring.h"
namespace storm {

0
src/storm/parser/SparseChoiceLabelingParser.h → src/storm-parsers/parser/SparseChoiceLabelingParser.h

4
src/storm/parser/SparseItemLabelingParser.cpp → src/storm-parsers/parser/SparseItemLabelingParser.cpp

@ -1,11 +1,11 @@
#include "storm/parser/SparseItemLabelingParser.h"
#include "storm-parsers/parser/SparseItemLabelingParser.h"
#include <cstring>
#include <string>
#include <iostream>
#include "storm/utility/cstring.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/utility/macros.h"
#include "storm/exceptions/WrongFormatException.h"

2
src/storm/parser/SparseItemLabelingParser.h → src/storm-parsers/parser/SparseItemLabelingParser.h

@ -4,7 +4,7 @@
#include <cstdint>
#include <boost/optional.hpp>
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/models/sparse/StateLabeling.h"
#include "storm/models/sparse/ChoiceLabeling.h"

4
src/storm/parser/SparseStateRewardParser.cpp → src/storm-parsers/parser/SparseStateRewardParser.cpp

@ -1,11 +1,11 @@
#include <iostream>
#include "storm/parser/SparseStateRewardParser.h"
#include "storm-parsers/parser/SparseStateRewardParser.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/OutOfRangeException.h"
#include "storm/exceptions/FileIoException.h"
#include "storm/utility/cstring.h"
#include "storm/parser/MappedFile.h"
#include "storm-parsers/parser/MappedFile.h"
#include "storm/adapters/RationalFunctionAdapter.h"
#include "storm/utility/macros.h"

0
src/storm/parser/SparseStateRewardParser.h → src/storm-parsers/parser/SparseStateRewardParser.h

2
src/storm/parser/SpiritErrorHandler.h → src/storm-parsers/parser/SpiritErrorHandler.h

@ -1,6 +1,6 @@
#pragma once
#include "storm/parser/SpiritParserDefinitions.h"
#include "storm-parsers/parser/SpiritParserDefinitions.h"
#include "storm/utility/macros.h"
#include "storm/exceptions/WrongFormatException.h"

0
src/storm/parser/SpiritParserDefinitions.h → src/storm-parsers/parser/SpiritParserDefinitions.h

2
src/storm/parser/ValueParser.cpp → src/storm-parsers/parser/ValueParser.cpp

@ -1,4 +1,4 @@
#include "storm/parser/ValueParser.h"
#include "storm-parsers/parser/ValueParser.h"
#include "storm/exceptions/NotSupportedException.h"

2
src/storm/parser/ValueParser.h → src/storm-parsers/parser/ValueParser.h

@ -2,7 +2,7 @@
#define STORM_PARSER_VALUEPARSER_H_
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/storage/expressions/ExpressionEvaluator.h"
#include "storm/exceptions/WrongFormatException.h"

2
src/storm-pgcl-cli/CMakeLists.txt

@ -5,4 +5,4 @@ set_target_properties(storm-pgcl-cli PROPERTIES OUTPUT_NAME "storm-pgcl")
add_dependencies(binaries storm-pgcl-cli)
# installation
install(TARGETS storm-pgcl-cli RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-pgcl-cli EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

4
src/storm-pgcl/CMakeLists.txt

@ -10,7 +10,7 @@ file(GLOB_RECURSE STORM_PGCL_HEADERS ${PROJECT_SOURCE_DIR}/src/storm-pgcl/*/*.h)
# Create storm-pgcl.
add_library(storm-pgcl SHARED ${STORM_PGCL_SOURCES} ${STORM_PGCL_HEADERS})
target_link_libraries(storm-pgcl storm)
target_link_libraries(storm-pgcl storm storm-parsers)
# installation
install(TARGETS storm-pgcl RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm-pgcl EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)

6
src/storm-pgcl/parser/PgclParser.h

@ -5,9 +5,9 @@
#include <memory>
#include <iomanip>
// Includes files for building and parsing the PGCL program
#include "storm/parser/SpiritParserDefinitions.h"
#include "storm/parser/SpiritErrorHandler.h"
#include "storm/parser/ExpressionParser.h"
#include "storm-parsers/parser/SpiritParserDefinitions.h"
#include "storm-parsers/parser/SpiritErrorHandler.h"
#include "storm-parsers/parser/ExpressionParser.h"
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/storage/expressions/Expression.h"
#include "storm-pgcl/storage/pgcl/PgclProgram.h"

6
src/storm/CMakeLists.txt

@ -28,8 +28,6 @@ if (ADDITIONAL_LINK_DIRS)
link_directories(${ADDITIONAL_LINK_DIRS})
endif(ADDITIONAL_LINK_DIRS)
# Disable Debug compiler flags for PrismParser to lessen memory consumption during compilation
SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/src/storm/parser/PrismParser.cpp PROPERTIES COMPILE_FLAGS -g0)
###############################################################################
##
@ -72,7 +70,7 @@ add_dependencies(storm copy_resources_headers)
add_dependencies(binaries storm-main)
# installation
install(TARGETS storm RUNTIME DESTINATION bin LIBRARY DESTINATION lib)
install(TARGETS storm-main RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(TARGETS storm EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib)
install(TARGETS storm-main EXPORT storm_Targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib OPTIONAL)
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/ DESTINATION include/storm
FILES_MATCHING PATTERN "*.h")

21
src/storm/adapters/Z3ExpressionAdapter.cpp

@ -1,5 +1,7 @@
#include "storm/adapters/Z3ExpressionAdapter.h"
#include <cstdint>
#include "storm/storage/expressions/Expressions.h"
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/utility/macros.h"
@ -12,6 +14,15 @@ namespace storm {
namespace adapters {
#ifdef STORM_HAVE_Z3
#ifdef STORM_Z3_API_USES_STANDARD_INTEGERS
typedef int64_t Z3_SIGNED_INTEGER;
typedef uint64_t Z3_UNSIGNED_INTEGER;
#else
typedef long long Z3_SIGNED_INTEGER;
typedef unsigned long long Z3_UNSIGNED_INTEGER;
#endif
Z3ExpressionAdapter::Z3ExpressionAdapter(storm::expressions::ExpressionManager& manager, z3::context& context) : manager(manager), context(context), additionalAssertions(), variableToExpressionMapping() {
// Intentionally left empty.
}
@ -133,17 +144,17 @@ namespace storm {
case Z3_OP_ANUM:
// Arithmetic numeral.
if (expr.is_int() && expr.is_const()) {
long long value;
Z3_SIGNED_INTEGER value;
if (Z3_get_numeral_int64(expr.ctx(), expr, &value)) {
return manager.integer(value);
} else {
STORM_LOG_THROW(false, storm::exceptions::ExpressionEvaluationException, "Failed to convert Z3 expression. Expression is constant integer and value does not fit into 64-bit integer.");
}
} else if (expr.is_real() && expr.is_const()) {
long long num;
long long den;
Z3_SIGNED_INTEGER num;
Z3_SIGNED_INTEGER den;
if (Z3_get_numeral_rational_int64(expr.ctx(), expr, &num, &den)) {
return manager.rational(storm::utility::convertNumber<storm::RationalNumber>((int_fast64_t) num) / storm::utility::convertNumber<storm::RationalNumber>((int_fast64_t) den));
return manager.rational(storm::utility::convertNumber<storm::RationalNumber>(static_cast<int_fast64_t>(num)) / storm::utility::convertNumber<storm::RationalNumber>(static_cast<int_fast64_t>(den)));
} else {
return manager.rational(storm::utility::convertNumber<storm::RationalNumber>(std::string(Z3_get_numeral_string(expr.ctx(), expr))));
}
@ -304,7 +315,7 @@ namespace storm {
return cacheIt->second;
}
z3::expr result = context.int_val(static_cast<long long>(expression.getValue()));
z3::expr result = context.int_val(static_cast<Z3_SIGNED_INTEGER>(expression.getValue()));
expressionCache.emplace(&expression, result);
return result;

6
src/storm/api/builder.h

@ -1,8 +1,8 @@
#pragma once
#include "storm/parser/AutoParser.h"
#include "storm/parser/DirectEncodingParser.h"
#include "storm/parser/ImcaMarkovAutomatonParser.h"
#include "storm-parsers/parser/AutoParser.h"
#include "storm-parsers/parser/DirectEncodingParser.h"
#include "storm-parsers/parser/ImcaMarkovAutomatonParser.h"
#include "storm/storage/SymbolicModelDescription.h"

56
src/storm/api/properties.cpp

@ -1,6 +1,5 @@
#include "storm/api/properties.h"
#include "storm/parser/FormulaParser.h"
#include "storm/storage/SymbolicModelDescription.h"
#include "storm/storage/prism/Program.h"
@ -13,57 +12,7 @@
namespace storm {
namespace api {
boost::optional<std::set<std::string>> parsePropertyFilter(std::string const& propertyFilter) {
if (propertyFilter == "all") {
return boost::none;
}
std::vector<std::string> propertyNames = storm::utility::cli::parseCommaSeparatedStrings(propertyFilter);
std::set<std::string> propertyNameSet(propertyNames.begin(), propertyNames.end());
return propertyNameSet;
}
std::vector<storm::jani::Property> parseProperties(storm::parser::FormulaParser& formulaParser, std::string const& inputString, boost::optional<std::set<std::string>> const& propertyFilter) {
// If the given property looks like a file (containing a dot and there exists a file with that name),
// we try to parse it as a file, otherwise we assume it's a property.
std::vector<storm::jani::Property> properties;
if (inputString.find(".") != std::string::npos && std::ifstream(inputString).good()) {
properties = formulaParser.parseFromFile(inputString);
} else {
properties = formulaParser.parseFromString(inputString);
}
return filterProperties(properties, propertyFilter);
}
std::vector<storm::jani::Property> parseProperties(std::string const& inputString, boost::optional<std::set<std::string>> const& propertyFilter) {
auto exprManager = std::make_shared<storm::expressions::ExpressionManager>();
storm::parser::FormulaParser formulaParser(exprManager);
return parseProperties(formulaParser, inputString, propertyFilter);
}
std::vector<storm::jani::Property> parsePropertiesForJaniModel(std::string const& inputString, storm::jani::Model const& model, boost::optional<std::set<std::string>> const& propertyFilter) {
storm::parser::FormulaParser formulaParser(model.getManager().getSharedPointer());
auto formulas = parseProperties(formulaParser, inputString, propertyFilter);
return substituteConstantsInProperties(formulas, model.getConstantsSubstitution());
}
std::vector<storm::jani::Property> parsePropertiesForPrismProgram(std::string const& inputString, storm::prism::Program const& program, boost::optional<std::set<std::string>> const& propertyFilter) {
storm::parser::FormulaParser formulaParser(program);
auto formulas = parseProperties(formulaParser, inputString, propertyFilter);
return substituteConstantsInProperties(formulas, program.getConstantsSubstitution());
}
std::vector<storm::jani::Property> parsePropertiesForSymbolicModelDescription(std::string const& inputString, storm::storage::SymbolicModelDescription const& modelDescription, boost::optional<std::set<std::string>> const& propertyFilter) {
std::vector<storm::jani::Property> result;
if (modelDescription.isPrismProgram()) {
result = storm::api::parsePropertiesForPrismProgram(inputString, modelDescription.asPrismProgram(), propertyFilter);
} else {
STORM_LOG_ASSERT(modelDescription.isJaniModel(), "Unknown model description type.");
result = storm::api::parsePropertiesForJaniModel(inputString, modelDescription.asJaniModel(), propertyFilter);
}
return result;
}
std::vector<storm::jani::Property> substituteConstantsInProperties(std::vector<storm::jani::Property> const& properties, std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) {
std::vector<storm::jani::Property> preprocessedProperties;
@ -78,6 +27,11 @@ namespace storm {
std::set<std::string> const& propertyNameSet = propertyFilter.get();
std::vector<storm::jani::Property> result;
std::set<std::string> reducedPropertyNames;
if (propertyNameSet.empty()) {
STORM_LOG_WARN("Filtering all properties.");
}
for (auto const& property : properties) {
if (propertyNameSet.find(property.getName()) != propertyNameSet.end()) {
result.push_back(property);

12
src/storm/api/properties.h

@ -8,9 +8,7 @@
#include <boost/optional.hpp>
namespace storm {
namespace parser {
class FormulaParser;
}
namespace jani {
class Property;
class Model;
@ -30,14 +28,6 @@ namespace storm {
}
namespace api {
boost::optional<std::set<std::string>> parsePropertyFilter(std::string const& propertyFilter);
// Parsing properties.
std::vector<storm::jani::Property> parseProperties(storm::parser::FormulaParser& formulaParser, std::string const& inputString, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parseProperties(std::string const& inputString, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parsePropertiesForPrismProgram(std::string const& inputString, storm::prism::Program const& program, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parsePropertiesForJaniModel(std::string const& inputString, storm::jani::Model const& model, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
std::vector<storm::jani::Property> parsePropertiesForSymbolicModelDescription(std::string const& inputString, storm::storage::SymbolicModelDescription const& modelDescription, boost::optional<std::set<std::string>> const& propertyFilter = boost::none);
// Process properties.
std::vector<storm::jani::Property> substituteConstantsInProperties(std::vector<storm::jani::Property> const& properties, std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution);

2
src/storm/api/storm.h

@ -1,10 +1,8 @@
#pragma once
#include "storm/api/model_descriptions.h"
#include "storm/api/properties.h"
#include "storm/api/builder.h"
#include "storm/api/bisimulation.h"
#include "storm/api/transformation.h"
#include "storm/api/verification.h"
#include "storm/api/counterexamples.h"
#include "storm/api/export.h"

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save