Exemple #1
0
        /**
         * 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/DSA for the LTL formula
         */
        public DRA calculate(LTLFormula ltl, BuchiAutomata ba, LTL2DSTAR_Options ltl_opt)
        {
            LTLFormula ltl_p = (ltl.toPNF());

            //if (ltl_opt.verbose_scheduler) {
            //  std::cerr << ltl_p->toStringInfix() << std::endl;
            //}

            LTL2DSTAR_Tree_Start root = new LTL2DSTAR_Tree_Start(ltl_p, ba, ltl_opt, this);

            //if (ltl_opt.verbose_scheduler) {
            //  root.printTree(std::cerr);
            //}

            root.calculate();

            DRA result = root._automaton;

            if (result != null)
            {
                result.setComment(root._comment); //+ getTimingInformation()
            }
            return(result);
        }
Exemple #3
0
        /**
         * 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/DSA for the LTL formula
          */
        public DRA calculate(LTLFormula ltl, BuchiAutomata ba, LTL2DSTAR_Options ltl_opt)
        {
            LTLFormula ltl_p = (ltl.toPNF());

            //if (ltl_opt.verbose_scheduler) {
            //  std::cerr << ltl_p->toStringInfix() << std::endl;
            //}

            LTL2DSTAR_Tree_Start root = new LTL2DSTAR_Tree_Start(ltl_p, ba, ltl_opt, this);

            //if (ltl_opt.verbose_scheduler) {
            //  root.printTree(std::cerr);
            //}

            root.calculate();

            DRA result = root._automaton;
            if (result != null)
            {
                result.setComment(root._comment); //+ getTimingInformation()
            }
            return result;
        }