/** Translate the LTL formula to DRA using Safra's algorithm */ public override void calculate(int level, int limit) { // if (_options.verbose_scheduler) { //std::cerr << "Calculate ("<< level <<"): " << typeid(*this).name() << std::endl; //std::cerr << " Limit = " << limit << std::endl; // } generateNBA(); if (_nba == null) { throw new Exception("Couldn't create NBA from LTL formula"); } ; _automaton = _sched.getLTL2DRA().nba2dra(_nba, limit, _options.detailed_states, _stutter_information); _comment = "Safra[NBA=" + _nba.size() + "]"; if (_options.optimizeAcceptance) { _automaton.optimizeAcceptanceCondition(); } if (_options.bisim) { DRAOptimizations dra_optimizer = new DRAOptimizations(); _automaton = dra_optimizer.optimizeBisimulation(_automaton); //, false, _options.detailed_states, false } }
/** * 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); }
/** * Perform union construction */ public override void calculate(int level, int limit) { // if (_options.verbose_scheduler) { //std::cerr << "Calculate ("<< level <<"): " << typeid(*this).name() << std::endl; // } try { children[0].calculate(level + 1, limit); children[1].calculate(level + 1, limit); } catch (LimitReachedException e) { //_automaton.reset(); return; } if (children[0]._automaton == null || children[1]._automaton == null) { return; } bool union_trueloop = _sched.getLTL2DRA().getOptions().union_trueloop; if (_sched.getLTL2DRA().getOptions().stutter) { _automaton = DRA.calculateUnionStuttered(children[0]._automaton, children[1]._automaton, _stutter_information, union_trueloop, _options.detailed_states) as DRA; } else { _automaton = DRA.calculateUnion(children[0]._automaton, children[1]._automaton, union_trueloop, _options.detailed_states) as DRA; /* _automaton=DRAOperations::dra_union(*children[0]->_automaton, * children[1]->_automaton, * union_trueloop, * _options.detailed_states); */ } _comment = "Union{" + children[0]._comment + "," + children[1]._comment + "}"; if (_options.optimizeAcceptance) { _automaton.optimizeAcceptanceCondition(); } if (_options.bisim) { DRAOptimizations dra_optimizer = new DRAOptimizations(); _automaton = dra_optimizer.optimizeBisimulation(_automaton); //, false, _options.detailed_states, false } hook_after_calculate(); }
/** * 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; }
/** * Perform union construction */ public override void calculate(int level, int limit) { // if (_options.verbose_scheduler) { //std::cerr << "Calculate ("<< level <<"): " << typeid(*this).name() << std::endl; // } try { children[0].calculate(level + 1, limit); children[1].calculate(level + 1, limit); } catch (LimitReachedException e) { //_automaton.reset(); return; } if (children[0]._automaton == null || children[1]._automaton == null) { return; } bool union_trueloop = _sched.getLTL2DRA().getOptions().union_trueloop; if (_sched.getLTL2DRA().getOptions().stutter) { _automaton = DRA.calculateUnionStuttered(children[0]._automaton, children[1]._automaton, _stutter_information, union_trueloop, _options.detailed_states) as DRA; } else { _automaton = DRA.calculateUnion(children[0]._automaton, children[1]._automaton, union_trueloop, _options.detailed_states) as DRA; /* _automaton=DRAOperations::dra_union(*children[0]->_automaton, *children[1]->_automaton, union_trueloop, _options.detailed_states); */ } _comment = "Union{" + children[0]._comment + "," + children[1]._comment + "}"; if (_options.optimizeAcceptance) { _automaton.optimizeAcceptanceCondition(); } if (_options.bisim) { DRAOptimizations dra_optimizer = new DRAOptimizations(); _automaton = dra_optimizer.optimizeBisimulation(_automaton); //, false, _options.detailed_states, false } hook_after_calculate(); }
/** Translate the LTL formula to DRA using Safra's algorithm */ public override void calculate(int level, int limit) { // if (_options.verbose_scheduler) { //std::cerr << "Calculate ("<< level <<"): " << typeid(*this).name() << std::endl; //std::cerr << " Limit = " << limit << std::endl; // } generateNBA(); if (_nba == null) { throw new Exception("Couldn't create NBA from LTL formula"); }; _automaton = _sched.getLTL2DRA().nba2dra(_nba, limit, _options.detailed_states, _stutter_information); _comment = "Safra[NBA=" + _nba.size() + "]"; if (_options.optimizeAcceptance) { _automaton.optimizeAcceptanceCondition(); } if (_options.bisim) { DRAOptimizations dra_optimizer = new DRAOptimizations(); _automaton = dra_optimizer.optimizeBisimulation(_automaton); //, false, _options.detailed_states, false } }