示例#1
0
        /*
         * PerformYieldTypeChecking :
         * 3.1 Input parameters :
         * 3.1.1 MoverTypeChecker moverTypeChecker :
         * 3.2 Action : This function is called in TypeCheck.cs. This is the only function that is externalized. This function traverses the program declarations and performs
         */
        public static void PerformYieldTypeChecking(MoverTypeChecker moverTypeChecker)
        {
            Program          yieldTypeCheckedProgram = moverTypeChecker.program;
            YieldTypeChecker regExprToAuto           = new YieldTypeChecker();

            foreach (var decl in yieldTypeCheckedProgram.TopLevelDeclarations)
            {
                Implementation impl = decl as Implementation;
                if (impl == null)
                {
                    continue;
                }
                int phaseNumSpecImpl = moverTypeChecker.FindPhaseNumber(impl.Proc);

                YieldTypeCheckerCore     yieldTypeCheckerPerImpl = new YieldTypeCheckerCore(moverTypeChecker);
                List <Tuple <int, int> > phaseIntervals          = ComputePhaseIntervals(impl, phaseNumSpecImpl, moverTypeChecker); // Compute intervals

                for (int i = 0; i < phaseIntervals.Count; i++)                                                                      // take current phase check num from each interval
                {
                    int yTypeCheckCurrentPhaseNum = phaseIntervals[i].Item1;
                    Automaton <BvSet> yieldTypeCheckAutoPerPhase = yieldTypeCheckerPerImpl.YieldTypeCheckAutomaton(impl, phaseNumSpecImpl, yTypeCheckCurrentPhaseNum);
                    if (!IsYieldTypeSafe(yieldTypeCheckAutoPerPhase, impl, moverTypeChecker, i))
                    {
                        moverTypeChecker.Error(impl, "\n Body of " + impl.Proc.Name + " is not yield type safe " + "\n");
                    }
                }
            }
        }
示例#2
0
        /*
         * IsYieldTypeSafe :
         * 2.1 Input parameters :
         * 2.1.1 Automaton<BvSet> implTypeCheckAutomaton : This input Automaton is generated for a phase of YTS checking of an impl.
         * 2.2 Return value : returns true if input automaton is subset of YTS property autoamaton.
         * 2.3 Action : Subset checking for a phase of an implementation. f L(YTSI) is subset of L(YTSP) {TRUE} else {FALSE}
         */
        public static bool IsYieldTypeSafe(Automaton <BvSet> implTypeCheckAutomaton, Implementation impl, MoverTypeChecker moverTypeChecker, int phaseNum)
        {
            List <BvSet> witnessSet;

            var isNonEmpty = Automaton <BvSet> .CheckDifference(
                implTypeCheckAutomaton,
                yieldTypeCheckerAutomaton,
                0,
                yieldTypeCheckerAutomatonSolver,
                out witnessSet);

#if DEBUG && !DEBUG_DETAIL
            var    diffAutomaton          = implTypeCheckAutomaton.Minus(yieldTypeCheckerAutomaton, yieldTypeCheckerAutomatonSolver);
            string diffAutomatonGraphName = "diffAutomaton" + impl.Proc.Name + phaseNum.ToString();
            yieldTypeCheckerAutomatonSolver.ShowGraph(diffAutomaton, diffAutomatonGraphName + ".dgml");
#endif

#if DEBUG && !DEBUG_DETAIL
            string s = yieldTypeCheckerAutomatonSolver.GenerateMember(implTypeCheckAutomaton);
            Console.WriteLine("\n member " + s + " \n");
            if (!yieldTypeCheckerAutomatonSolver.Accepts(yieldTypeCheckerAutomaton, s))
            {
                Console.WriteLine("Property Automaton accepts a random member of impl_automaton " + s);
            }
            else
            {
                Console.WriteLine("Property Automaton does not accept a random member of impl_automaton " + s);
            }
#endif
            if (isNonEmpty)
            {
                var witness = new String(Array.ConvertAll(witnessSet.ToArray(), bvset => (char)yieldTypeCheckerAutomatonSolver.Choose(bvset)));
                moverTypeChecker.Error(impl, "\n Body of " + impl.Proc.Name + " has invalid trace of actions " + witness + "\n");
                return(false);
            }

            return(true);
        }
示例#3
0
        /*
PerformYieldTypeChecking : 
 3.1 Input parameters :
   3.1.1 MoverTypeChecker moverTypeChecker : 
 3.2 Action : This function is called in TypeCheck.cs. This is the only function that is externalized. This function traverses the program declarations and performs
        */
        public static void PerformYieldTypeChecking(MoverTypeChecker moverTypeChecker)
        {
            Program yieldTypeCheckedProgram = moverTypeChecker.program;
            YieldTypeChecker regExprToAuto = new YieldTypeChecker();
            foreach (var decl in yieldTypeCheckedProgram.TopLevelDeclarations)
            {
                Implementation impl = decl as Implementation;
                if (impl == null) continue;
                int phaseNumSpecImpl = moverTypeChecker.FindPhaseNumber(impl.Proc);

                YieldTypeCheckerCore yieldTypeCheckerPerImpl = new YieldTypeCheckerCore(moverTypeChecker);
                List<Tuple<int, int>> phaseIntervals = ComputePhaseIntervals(impl, phaseNumSpecImpl, moverTypeChecker); // Compute intervals

                for (int i = 0; i < phaseIntervals.Count; i++) // take current phase check num from each interval
                {
                    int yTypeCheckCurrentPhaseNum = phaseIntervals[i].Item1;
                    Automaton<BvSet> yieldTypeCheckAutoPerPhase = yieldTypeCheckerPerImpl.YieldTypeCheckAutomaton(impl, phaseNumSpecImpl, yTypeCheckCurrentPhaseNum);
                    if (!IsYieldTypeSafe(yieldTypeCheckAutoPerPhase, impl, moverTypeChecker, i))
                    {
                        moverTypeChecker.Error(impl, "\n Body of " + impl.Proc.Name + " is not yield type safe " + "\n");
                    }
                }
            }
        }
示例#4
0
        /*
  IsYieldTypeSafe :
    2.1 Input parameters :
      2.1.1 Automaton<BvSet> implTypeCheckAutomaton : This input Automaton is generated for a phase of YTS checking of an impl.
    2.2 Return value : returns true if input automaton is subset of YTS property autoamaton.
    2.3 Action : Subset checking for a phase of an implementation. f L(YTSI) is subset of L(YTSP) {TRUE} else {FALSE}  
  */
        public static bool IsYieldTypeSafe(Automaton<BvSet> implTypeCheckAutomaton, Implementation impl, MoverTypeChecker moverTypeChecker, int phaseNum)
        {

            List<BvSet> witnessSet;

            var isNonEmpty = Automaton<BvSet>.CheckDifference(
                                                           implTypeCheckAutomaton,
                                                           yieldTypeCheckerAutomaton,
                                                           0,
                                                           yieldTypeCheckerAutomatonSolver,
                                                           out witnessSet);

#if DEBUG && !DEBUG_DETAIL
            
            var diffAutomaton = implTypeCheckAutomaton.Minus(yieldTypeCheckerAutomaton, yieldTypeCheckerAutomatonSolver);
            string diffAutomatonGraphName = "diffAutomaton" + impl.Proc.Name + phaseNum.ToString();
            yieldTypeCheckerAutomatonSolver.ShowGraph(diffAutomaton, diffAutomatonGraphName+".dgml");
#endif

#if DEBUG && !DEBUG_DETAIL
            string s = yieldTypeCheckerAutomatonSolver.GenerateMember(implTypeCheckAutomaton);
            Console.WriteLine("\n member " + s+ " \n");
            if(!yieldTypeCheckerAutomatonSolver.Accepts(yieldTypeCheckerAutomaton,s)){
                Console.WriteLine("Property Automaton accepts a random member of impl_automaton " + s);
            }else{
                Console.WriteLine("Property Automaton does not accept a random member of impl_automaton " + s);
            }
#endif
            if (isNonEmpty)
            {
                var witness = new String(Array.ConvertAll(witnessSet.ToArray(), bvset => (char)yieldTypeCheckerAutomatonSolver.Choose(bvset)));
                moverTypeChecker.Error(impl, "\n Body of " + impl.Proc.Name + " has invalid trace of actions " + witness + "\n");
                return false;
            }

            return true;
        }