예제 #1
0
        private static void extractVarFromBasicGuards(KPsystem kpSystem, MType kpType, Module module, BasicGuard basicGuard)
        {
            Multiset ms = basicGuard.Multiset;

            NuSMV.RelationalOperator oper = SMVUtil.getRelationalOperator(basicGuard.Operator);
            Variable variable             = null;

            foreach (var varName in ms.Objects)
            {
                if (!module.isVariableExist(varName))
                {
                    variable = new Variable(varName);
                    int upperBound = ms[varName];
                    //if the guard requires a number greater, or greaterEqual, then it upperbound should be at least one number greater then,
                    //the condition
                    if (oper.Operator == NuSMV.RelationalOperator.GEQ || oper.Operator == NuSMV.RelationalOperator.GT)
                    {
                        upperBound = upperBound + 1;
                    }
                    variable.Type = new BoundInt(0, upperBound);
                    setBoundIntType(kpSystem, kpType, module, variable);
                    variable.Behaviour = VariableBehaviour.REWRITING;
                    variable.Init      = setOrUpdateInit(module, variable);
                    module.Variables.Add(variable);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Extracts boolean expression from a KP guard. In addition it adds module name as an identifier.
        /// </summary>
        /// <param name="sourceModule">module of guard</param>
        /// <param name="basicGuard"></param>
        /// <returns></returns>
        public static ICondition getBoolExpression(BasicGuard basicGuard)
        {
            Multiset ms = basicGuard.Multiset;

            NuSMV.RelationalOperator oper = SMVUtil.getRelationalOperator(basicGuard.Operator);
            BoolExp booleanExpression     = new BoolExp();

            foreach (var obj in ms.Objects)
            {
                booleanExpression.Left = new Expression(obj);
                booleanExpression.RelationalOperator = oper;
                booleanExpression.Right = new Expression(ms[obj].ToString());
            }
            return(booleanExpression);
        }
예제 #3
0
 public static NuSMV.RelationalOperator getRelationalOperator(KpCore.RelationalOperator oper)
 {
     NuSMV.RelationalOperator relationalOperator = new RelationalOperator();
     switch (oper)
     {
         case KpCore.RelationalOperator.EQUAL:
             {
                 relationalOperator.Operator = NuSMV.RelationalOperator.EQUAL;
                 break;
             }
         case KpCore.RelationalOperator.GEQ:
             {
                 relationalOperator.Operator = NuSMV.RelationalOperator.GEQ;
                 break;
             }
         case KpCore.RelationalOperator.GT:
             {
                 relationalOperator.Operator = NuSMV.RelationalOperator.GT;
                 break;
             }
         case KpCore.RelationalOperator.LT:
             {
                 relationalOperator.Operator = NuSMV.RelationalOperator.LT;
                 break;
             }
         case KpCore.RelationalOperator.LEQ:
             {
                 relationalOperator.Operator = NuSMV.RelationalOperator.LEQ;
                 break;
             }
         case KpCore.RelationalOperator.NOT_EQUAL:
             {
                 relationalOperator.Operator = NuSMV.RelationalOperator.NOT_EQUAL;
                 break;
             }
         default:
             {
                 relationalOperator.Operator = "undefined relational operator";
                 break;
             }
     }
     return relationalOperator;
 }
예제 #4
0
        /// <summary>
        /// Extracts boolean expression from a KP guard. In addition it adds module name as an identifier.
        /// </summary>
        /// <param name="sourceModule">module of guard</param>
        /// <param name="basicGuard"></param>
        /// <returns></returns>
        private static ICondition getBoolExpression(Module sourceModule, BasicGuard basicGuard)
        {
            Multiset ms = basicGuard.Multiset;

            NuSMV.RelationalOperator oper = SMVUtil.getRelationalOperator(basicGuard.Operator);
            BoolExp booleanExpression     = new BoolExp();

            foreach (var obj in ms.Objects)
            {
                if (sourceModule != null)
                {
                    booleanExpression.Left = new InstancedExp(sourceModule.Type, obj);
                }
                else
                {
                    booleanExpression.Left = new InstancedExp(obj);
                }
                booleanExpression.RelationalOperator = oper;
                booleanExpression.Right = new Expression(ms[obj].ToString());
            }
            return(booleanExpression);
        }