diff --git a/src/storm-dft-cli/storm-dft.cpp b/src/storm-dft-cli/storm-dft.cpp index c59da090a..7eaa1ffac 100644 --- a/src/storm-dft-cli/storm-dft.cpp +++ b/src/storm-dft-cli/storm-dft.cpp @@ -51,6 +51,12 @@ void processOptions() { return; } + if (dftIOSettings.isExportToSmt()) { + // Export to json + storm::api::exportDFTToSMT(*dft, dftIOSettings.getExportSmtFilename()); + return; + } + // Check well-formedness of DFT std::stringstream stream; if (!dft->checkWellFormedness(stream)) { diff --git a/src/storm-dft/api/storm-dft.cpp b/src/storm-dft/api/storm-dft.cpp index 2da0b5b2c..32796b7e8 100644 --- a/src/storm-dft/api/storm-dft.cpp +++ b/src/storm-dft/api/storm-dft.cpp @@ -50,6 +50,7 @@ namespace storm { std::vector results = smtChecker.toSolver(); if (printOutput) { + // TODO add suitable output function, maybe add query descriptions for better readability for (size_t i = 0; i < results.size(); ++i) { std::string tmp = "unknonwn"; if (results.at(i) == storm::solver::SmtSolver::CheckResult::Sat) { diff --git a/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp b/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp index 8436fd215..da5daa574 100644 --- a/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp +++ b/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp @@ -456,6 +456,8 @@ namespace storm { // Set backtracking marker to check several properties without reconstructing DFT encoding solver->push(); + //TODO put different queries in separate functions for further modularization + // Constraint that toplevel element will not fail (part of constraint 13) std::shared_ptr tleNeverFailedConstr = std::make_shared( timePointVariables.at(dft.getTopLevelIndex()), notFailed); diff --git a/src/storm-dft/modelchecker/dft/SmtConstraint.h b/src/storm-dft/modelchecker/dft/SmtConstraint.h index 2487f9dfd..56c66ca73 100644 --- a/src/storm-dft/modelchecker/dft/SmtConstraint.h +++ b/src/storm-dft/modelchecker/dft/SmtConstraint.h @@ -8,8 +8,19 @@ namespace storm { virtual ~SmtConstraint() { } + /** Generate a string describing the constraint in Smtlib2 format + * + * @param varNames vector of variable names + * @return Smtlib2 format string + */ virtual std::string toSmtlib2(std::vector const &varNames) const = 0; + /** Generate an expression describing the constraint in Storm format + * + * @param varNames vector of variable names + * @param manager the expression manager used to handle the expressions + * @return the expression + */ virtual storm::expressions::Expression toExpression(std::vector const &varNames, std::shared_ptr manager) const = 0; diff --git a/src/storm-dft/settings/modules/DftIOSettings.cpp b/src/storm-dft/settings/modules/DftIOSettings.cpp index 2c4caeb8e..6a039341a 100644 --- a/src/storm-dft/settings/modules/DftIOSettings.cpp +++ b/src/storm-dft/settings/modules/DftIOSettings.cpp @@ -25,6 +25,7 @@ namespace storm { const std::string DftIOSettings::minValueOptionName = "min"; const std::string DftIOSettings::maxValueOptionName = "max"; const std::string DftIOSettings::exportToJsonOptionName = "export-json"; + const std::string DftIOSettings::exportToSmtOptionName = "export-smt"; const std::string DftIOSettings::displayStatsOptionName = "show-dft-stats"; @@ -56,6 +57,11 @@ namespace storm { this->addOption(storm::settings::OptionBuilder(moduleName, exportToJsonOptionName, false, "Export the model to the Cytoscape JSON format.") .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file to export to.").build()) .build()); + this->addOption(storm::settings::OptionBuilder(moduleName, exportToSmtOptionName, false, + "Export the model as SMT encoding to the smtlib2 format.") + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", + "The name of the smtlib2 file to export to.").build()) + .build()); this->addOption(storm::settings::OptionBuilder(moduleName, displayStatsOptionName, false, "Print stats to stdout").build()); } @@ -122,6 +128,14 @@ namespace storm { return this->getOption(exportToJsonOptionName).getArgumentByName("filename").getValueAsString(); } + bool DftIOSettings::isExportToSmt() const { + return this->getOption(exportToSmtOptionName).getHasOptionBeenSet(); + } + + std::string DftIOSettings::getExportSmtFilename() const { + return this->getOption(exportToSmtOptionName).getArgumentByName("filename").getValueAsString(); + } + bool DftIOSettings::isDisplayStatsSet() const { return this->getOption(displayStatsOptionName).getHasOptionBeenSet(); } diff --git a/src/storm-dft/settings/modules/DftIOSettings.h b/src/storm-dft/settings/modules/DftIOSettings.h index d99e6d970..60369b36e 100644 --- a/src/storm-dft/settings/modules/DftIOSettings.h +++ b/src/storm-dft/settings/modules/DftIOSettings.h @@ -108,6 +108,13 @@ namespace storm { */ bool isExportToJson() const; + /*! + * Retrieves whether the export to smtlib2 file option was set. + * + * @return True if the export to smtlib2 file option was set. + */ + bool isExportToSmt() const; + /*! * Retrieves the name of the json file to export to. * @@ -115,6 +122,13 @@ namespace storm { */ std::string getExportJsonFilename() const; + /*! + * Retrieves the name of the smtlib2 file to export to. + * + * @return The name of the smtlib2 file to export to. + */ + std::string getExportSmtFilename() const; + /*! * Retrieves whether statistics for the DFT should be displayed. * @@ -142,6 +156,7 @@ namespace storm { static const std::string minValueOptionName; static const std::string maxValueOptionName; static const std::string exportToJsonOptionName; + static const std::string exportToSmtOptionName; static const std::string displayStatsOptionName; }; diff --git a/src/storm/solver/SmtSolver.h b/src/storm/solver/SmtSolver.h index 6d842500c..27a506ff0 100644 --- a/src/storm/solver/SmtSolver.h +++ b/src/storm/solver/SmtSolver.h @@ -50,7 +50,7 @@ namespace storm { storm::expressions::ExpressionManager const& getManager() const; private: - // The expression manager responsible for the variableswhose value can be requested via this model + // The expression manager responsible for the variables whose value can be requested via this model // reference. storm::expressions::ExpressionManager const& manager; };