/** * Convert an LTL formula to a DRA. * @param ltl the LTL formula * @param options which operators are allowed * @return a shared_ptr to the DRA */ private DRA ltl2dra(LTLFormula ltl, BuchiAutomata buchiAutomata, LTL2DSTAR_Options options) { APSet ap_set = ltl.getAPSet(); LTLFormula ltl_pnf = ltl.toPNF(); if (options.allow_union && ltl_pnf.getRootNode().getType() == type_t.T_OR) { LTLFormula ltl_left = ltl_pnf.getSubFormula(ltl_pnf.getRootNode().getLeft()); LTLFormula ltl_right = ltl_pnf.getSubFormula(ltl_pnf.getRootNode().getRight()); LTL2DSTAR_Options rec_opt = options; rec_opt.recursion(); DRA dra_left = ltl2dra(ltl_left, buchiAutomata, rec_opt); DRA dra_right = ltl2dra(ltl_right, buchiAutomata, rec_opt); return(DRA.calculateUnion(dra_left, dra_right, _safra_opt.union_trueloop) as DRA); } if (options.safety) { LTLSafetyAutomata lsa = new LTLSafetyAutomata(); DRA safety_dra = lsa.ltl2dra(ltl, buchiAutomata); if (safety_dra != null) { return(safety_dra); } } DRA dra = new DRA(ap_set); NBA nba = LTL2NBA.ltl2nba(ltl_pnf, buchiAutomata); if (nba == null) { throw new Exception("Couldn't create NBA from LTL formula"); } NBA2DRA nba2dra = new NBA2DRA(_safra_opt); nba2dra.convert(nba, dra); if (options.optimizeAcceptance) { dra.optimizeAcceptanceCondition(); } if (options.bisim) { DRAOptimizations dra_optimizer = new DRAOptimizations(); dra = dra_optimizer.optimizeBisimulation(dra); } return(dra); }
/** * Generate a DRA for an LTL formula using scheck * @param ltl the formula * @param scheck_path the path to the scheck executable * @return a shared_ptr to the generated DRA (on failure returns a ptr to 0) */ //template <class DRA> //typename DRA::shared_ptr public DRA ltl2dra(LTLFormula ltl, BuchiAutomata buchiAutomata) { LTLFormula ltl_; LTLFormula ltl_for_scheck = null; bool safe = false; if (ltl.isSafe()) { safe = true; ltl_ = ltl.negate(); ltl_for_scheck = ltl_; } else if (ltl.isCoSafe()) { ltl_for_scheck = ltl; } else { if (_only_syn) { // Not syntactically safe -> abort //typename //DRA::shared_ptr p; //return p; return(null); } } // std::cerr<< "Calling scheck with " // <<ltl_for_scheck->toStringPrefix() << " : " << safe << std::endl; //NBA nba = ltl2dba(ltl_for_scheck, buchiAutomata); //, scheck_path, _only_syn NBA nba = LTL2NBA.ltl2nba(ltl_for_scheck, buchiAutomata); //, scheck_path, _only_syn if (nba == null) { //typename //DRA::shared_ptr p; //return p; return(null); } // nba->print(std::cerr); // safe -> negate DRA return(DBA2DRA.dba2dra(nba, safe)); // return dba2dra<DRA>(*nba, safe); // nba is auto-destructed //<NBA_t,DRA> }
public NBA ltl2nba(LTLFormula ltl, BuchiAutomata buchiAutomata, bool exception_on_failure) { //Debug.Assert(_ltl2nba != null); NBA nba = LTL2NBA.ltl2nba(ltl, buchiAutomata); if (exception_on_failure && nba == null) { throw new Exception("Couldn't generate NBA from LTL formula!"); } return(nba); }