diff --git a/src/storage/dft/DFT.cpp b/src/storage/dft/DFT.cpp index bf68a095c..890e2de25 100644 --- a/src/storage/dft/DFT.cpp +++ b/src/storage/dft/DFT.cpp @@ -436,6 +436,41 @@ namespace storm { } return DFTIndependentSymmetries(res); } + + template + std::vector DFT::findModularisationRewrite() const { + for(auto const& e : mElements) { + if(e->isGate() && (e->type() == DFTElementType::AND || e->type() == DFTElementType::OR) ) { + // suitable parent gate! - Lets check the independent submodules of the children + auto const& children = std::static_pointer_cast>(e)->children(); + for(auto const& child : children) { + //std::cout << "check idea for: " << child->id() << std::endl;; + auto ISD = std::static_pointer_cast>(child)->independentSubDft(true); + // In the ISD, check for other children: + //std::cout << "** subdft = "; + for(auto const& isdelemid : ISD) { + std::cout << isdelemid << " "; + } + std::cout << std::endl; + + std::vector rewrite = {e->id(), child->id()}; + for(size_t isdElemId : ISD) { + if(isdElemId == child->id()) continue; + if(std::find_if(children.begin(), children.end(), [&isdElemId](std::shared_ptr> const& e) { return e->id() == isdElemId; } ) != children.end()) { + //std::cout << "** found child in subdft: " << isdElemId << std::endl; + rewrite.push_back(isdElemId); + } + } + if(rewrite.size() > 2) { + return rewrite; + } + + } + } + } + return {}; + } + template std::pair, std::vector> DFT::getSortedParentAndOutDepIds(size_t index) const { diff --git a/src/storage/dft/DFT.h b/src/storage/dft/DFT.h index 32e807197..75092e479 100644 --- a/src/storage/dft/DFT.h +++ b/src/storage/dft/DFT.h @@ -236,6 +236,8 @@ namespace storm { DFTIndependentSymmetries findSymmetries(DFTColouring const& colouring) const; std::vector immediateFailureCauses(size_t index) const; + + std::vector findModularisationRewrite() const; private: std::pair, std::vector> getSortedParentAndOutDepIds(size_t index) const; diff --git a/src/storm-dyftee.cpp b/src/storm-dyftee.cpp index 13b43f5ff..c5997ddd3 100644 --- a/src/storm-dyftee.cpp +++ b/src/storm-dyftee.cpp @@ -29,6 +29,14 @@ void analyzeDFT(std::string filename, std::string property, bool symred = false) std::vector> formulas(parsedFormulas.begin(), parsedFormulas.end()); assert(formulas.size() == 1); std::cout << "Parsed formula." << std::endl; + auto modIdea = dft.findModularisationRewrite(); + std::cout << "Modularisation idea: " << std::endl; + + for( auto const& i : modIdea ) { + std::cout << i << ", "; + } + std::cout << std::endl; + std::map>> emptySymmetry; storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry); if(symred) {