|
@ -123,52 +123,41 @@ namespace storm { |
|
|
|
|
|
|
|
|
template<typename ValueType, storm::dd::DdType LibraryType> |
|
|
template<typename ValueType, storm::dd::DdType LibraryType> |
|
|
void buildAndCheckSymbolicModel(storm::prism::Program const& program, std::vector<std::shared_ptr<storm::logic::Formula>> const& formulas) { |
|
|
void buildAndCheckSymbolicModel(storm::prism::Program const& program, std::vector<std::shared_ptr<storm::logic::Formula>> const& formulas) { |
|
|
|
|
|
|
|
|
storm::settings::modules::GeneralSettings const& settings = storm::settings::generalSettings(); |
|
|
storm::settings::modules::GeneralSettings const& settings = storm::settings::generalSettings(); |
|
|
|
|
|
|
|
|
if (settings.getEngine() == storm::settings::modules::GeneralSettings::Engine::AbstractionRefinement) { |
|
|
if (settings.getEngine() == storm::settings::modules::GeneralSettings::Engine::AbstractionRefinement) { |
|
|
verifySymbolicModelWithAbstractionRefinementEngine<ValueType, LibraryType>(program, formulas); |
|
|
verifySymbolicModelWithAbstractionRefinementEngine<ValueType, LibraryType>(program, formulas); |
|
|
} else { |
|
|
} else { |
|
|
storm::storage::ModelProgramPair modelProgramPair = buildSymbolicModel<ValueType, LibraryType>(program, formulas); |
|
|
|
|
|
STORM_LOG_THROW(modelProgramPair.model != nullptr, storm::exceptions::InvalidStateException, "Model could not be constructed for an unknown reason."); |
|
|
|
|
|
|
|
|
storm::storage::ModelFormulasPair modelFormulasPair = buildSymbolicModel<ValueType, LibraryType>(program, formulas); |
|
|
|
|
|
STORM_LOG_THROW(modelFormulasPair.model != nullptr, storm::exceptions::InvalidStateException, |
|
|
|
|
|
"Model could not be constructed for an unknown reason."); |
|
|
|
|
|
|
|
|
// Preprocess the model if needed. |
|
|
// Preprocess the model if needed. |
|
|
BRANCH_ON_MODELTYPE(modelProgramPair.model, modelProgramPair.model, ValueType, LibraryType, preprocessModel, formulas); |
|
|
|
|
|
|
|
|
BRANCH_ON_MODELTYPE(modelFormulasPair.model, modelFormulasPair.model, ValueType, LibraryType, preprocessModel, formulas); |
|
|
|
|
|
|
|
|
// Print some information about the model. |
|
|
// Print some information about the model. |
|
|
modelProgramPair.model->printModelInformationToStream(std::cout); |
|
|
|
|
|
|
|
|
modelFormulasPair.model->printModelInformationToStream(std::cout); |
|
|
|
|
|
|
|
|
// Verify the model, if a formula was given. |
|
|
// Verify the model, if a formula was given. |
|
|
if (!formulas.empty()) { |
|
|
if (!formulas.empty()) { |
|
|
// There may be constants of the model appearing in the formulas, so we replace all their occurrences |
|
|
|
|
|
// by their definitions in the translated program. |
|
|
|
|
|
|
|
|
|
|
|
// Start by building a mapping from constants of the (translated) model to their defining expressions. |
|
|
|
|
|
std::map<storm::expressions::Variable, storm::expressions::Expression> constantSubstitution; |
|
|
|
|
|
for (auto const& constant : modelProgramPair.program.getConstants()) { |
|
|
|
|
|
if (constant.isDefined()) { |
|
|
|
|
|
constantSubstitution.emplace(constant.getExpressionVariable(), constant.getExpression()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<storm::logic::Formula>> preparedFormulas; |
|
|
|
|
|
for (auto const& formula : formulas) { |
|
|
|
|
|
preparedFormulas.emplace_back(formula->substitute(constantSubstitution)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (modelProgramPair.model->isSparseModel()) { |
|
|
|
|
|
if(settings.isCounterexampleSet()) { |
|
|
|
|
|
|
|
|
if (modelFormulasPair.model->isSparseModel()) { |
|
|
|
|
|
if (storm::settings::generalSettings().isCounterexampleSet()) { |
|
|
// If we were requested to generate a counterexample, we now do so for each formula. |
|
|
// If we were requested to generate a counterexample, we now do so for each formula. |
|
|
for(auto const& formula : preparedFormulas) { |
|
|
|
|
|
generateCounterexample<ValueType>(program, modelProgramPair.model->as<storm::models::sparse::Model<ValueType>>(), formula); |
|
|
|
|
|
|
|
|
for (auto const &formula : modelFormulasPair.formulas) { |
|
|
|
|
|
generateCounterexample<ValueType>(program, modelFormulasPair.model->as<storm::models::sparse::Model<ValueType>>(), formula); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
verifySparseModel<ValueType>(modelProgramPair.model->as<storm::models::sparse::Model<ValueType>>(), preparedFormulas); |
|
|
|
|
|
|
|
|
verifySparseModel<ValueType>(modelFormulasPair.model->as<storm::models::sparse::Model<ValueType>>(), modelFormulasPair.formulas); |
|
|
} |
|
|
} |
|
|
} else if (modelProgramPair.model->isSymbolicModel()) { |
|
|
|
|
|
if (settings.getEngine() == storm::settings::modules::GeneralSettings::Engine::Hybrid) { |
|
|
|
|
|
verifySymbolicModelWithHybridEngine(modelProgramPair.model->as<storm::models::symbolic::Model<LibraryType>>(), preparedFormulas); |
|
|
|
|
|
|
|
|
} else if (modelFormulasPair.model->isSymbolicModel()) { |
|
|
|
|
|
if (storm::settings::generalSettings().getEngine() == storm::settings::modules::GeneralSettings::Engine::Hybrid) { |
|
|
|
|
|
verifySymbolicModelWithHybridEngine(modelFormulasPair.model->as<storm::models::symbolic::Model<LibraryType>>(), |
|
|
|
|
|
modelFormulasPair.formulas); |
|
|
} else { |
|
|
} else { |
|
|
verifySymbolicModelWithSymbolicEngine(modelProgramPair.model->as<storm::models::symbolic::Model<LibraryType>>(), preparedFormulas); |
|
|
|
|
|
|
|
|
verifySymbolicModelWithSymbolicEngine(modelFormulasPair.model->as<storm::models::symbolic::Model<LibraryType>>(), |
|
|
|
|
|
modelFormulasPair.formulas); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Invalid input model type."); |
|
|
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "Invalid input model type."); |
|
|