Exemple #1
0
        /// <summary>
        /// Adds guards for the rules of NonDeter and INVAR of ARB and MAX strategies.
        /// </summary>
        /// <param name="kpRule"></param>
        /// <param name="module"></param>
        /// <param name="strategyIndex"></param>
        /// <returns></returns>
        public static NuSMV.Rule extractStandardRuleWithGuard4ARBandMAX(KpCore.Rule kpRule)
        {
            NuSMV.Rule smvRule = new NuSMV.Rule();
            smvRule.Type = SMVRuleType.REWRITING;
            if (kpRule is ConsumerRule)
            {
                ConsumerRule consumerRule = (ConsumerRule)kpRule;
                // it adds guards to _arb0 and _max0
                if (kpRule.IsGuarded)
                {
                    ICondition guardCondition = extractGuardConditionFromKPRule(kpRule);
                    smvRule.Condition = guardCondition;
                }
                foreach (var multiset in consumerRule.Lhs)
                {
                    BoolExp ruleConditions = new BoolExp();

                    ruleConditions.Left = new Expression(multiset.Key);
                    ruleConditions.RelationalOperator.Operator = NuSMV.RelationalOperator.GEQ;
                    ruleConditions.Right = new Expression(multiset.Value.ToString());
                    if (smvRule.Condition == null)
                    {
                        smvRule.Condition = ruleConditions;
                    }
                    else
                    {
                        smvRule.AppendBoolExpression(ruleConditions, BinaryOperator.AND);
                    }
                }
            }
            return(smvRule);
        }
Exemple #2
0
        /// <summary>
        /// return the last caseline which is TRUE : result
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public static CaseLine trueCaseLine(string result)
        {
            CaseLine caseLine = new CaseLine();

            NuSMV.Rule rule = new NuSMV.Rule();
            rule.Condition = new TruthValue(Truth.TRUE);
            Expression exp = new Expression(result);

            caseLine.Rule   = rule;
            caseLine.Result = exp;
            return(caseLine);
        }
Exemple #3
0
        private static CaseLine trueCaseLine(IVar variable)
        {
            CaseLine caseLine = new CaseLine();

            NuSMV.Rule rule = new NuSMV.Rule();
            rule.Condition = new TruthValue(Truth.TRUE);
            IExp exp = null;

            if (variable.Behaviour == VariableBehaviour.COMMUNICATION || variable.Behaviour == VariableBehaviour.DIVISION)
            {
                exp = new InstancedExp(variable.Name);
            }
            else
            {
                exp = new Expression(variable.Name);
            }
            caseLine.Rule   = rule;
            caseLine.Result = exp;
            return(caseLine);
        }
Exemple #4
0
        /// <summary>
        /// Translates KPRule to NUSMV rule, it ignores guards for ARB and MAX strategies, because the guards are
        /// represented by _arb0 and _max0 custom variables.
        /// </summary>
        /// <param name="kpRule"></param>
        /// <returns></returns>
        public static NuSMV.Rule extractStandardRuleFromKPRule(KpCore.Rule kpRule, Module module, int strategyIndex)
        {
            NuSMV.Rule smvRule = new NuSMV.Rule();
            smvRule.Type = SMVRuleType.REWRITING;
            Strategy ex = module.ExecutionStrategies.ElementAt(strategyIndex);

            if (kpRule is ConsumerRule)
            {
                ConsumerRule consumerRule = (ConsumerRule)kpRule;
                // If strategy is ARB or MAX then ignore guards for regular rules
                if (!(ex.Type == StrategyTypes.ARBITRARY || ex.Type == StrategyTypes.MAX))
                {
                    if (kpRule.IsGuarded)
                    {
                        ICondition guardCondition = extractGuardConditionFromKPRule(kpRule);
                        smvRule.Condition = guardCondition;
                    }
                }


                foreach (var multiset in consumerRule.Lhs)
                {
                    BoolExp ruleConditions = new BoolExp();

                    ruleConditions.Left = new Expression(multiset.Key);
                    ruleConditions.RelationalOperator.Operator = NuSMV.RelationalOperator.GEQ;
                    ruleConditions.Right = new Expression(multiset.Value.ToString());
                    if (smvRule.Condition == null)
                    {
                        smvRule.Condition = ruleConditions;
                    }
                    else
                    {
                        smvRule.AppendBoolExpression(ruleConditions, BinaryOperator.AND);
                    }
                }
            }
            return(smvRule);
        }