コード例 #1
0
        /// <summary>
        /// Visits and performs a property count on forall expression.
        /// </summary>
        /// <param name="expression">Forall expression.</param>
        /// <returns>Tuple (property satisfied count, property not satisfied count).</returns>
        public Tuple <double, double> Visit(ForallExpression expression)
        {
            double positiveValue = 0;
            double negativeValue = 0;

            IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters);

            foreach (var localSubstitution in localSubstitutions)
            {
                Substitution.AddLocalSubstitution(localSubstitution);
                var childPropertyCounts = expression.Child.Accept(this);
                Substitution.RemoveLocalSubstitution(localSubstitution);

                if (EvaluationStrategy == ForwardCostEvaluationStrategy.ADDITIVE_VALUE)
                {
                    positiveValue += childPropertyCounts.Item1;
                    negativeValue += childPropertyCounts.Item2;
                }
                else
                {
                    positiveValue = Math.Max(positiveValue, childPropertyCounts.Item1);
                    negativeValue = Math.Max(negativeValue, childPropertyCounts.Item2);
                }
            }

            return(Tuple.Create(positiveValue, negativeValue));
        }
コード例 #2
0
        /// <summary>
        /// Checks the equality of objects.
        /// </summary>
        /// <param name="obj">Object to be checked.</param>
        /// <returns>True if the objects are equal, false otherwise.</returns>
        public override bool Equals(object obj)
        {
            ForallExpression other = obj as ForallExpression;

            if (other == null)
            {
                return(false);
            }
            return(Parameters.Equals(other.Parameters) && Child.Equals(other.Child));
        }
コード例 #3
0
        /// <summary>
        /// Visits and transforms the expression.
        /// </summary>
        /// <param name="expression">Source expression.</param>
        /// <returns>Transformed expression.</returns>
        public override IExpression Visit(ForallExpression expression)
        {
            List <IExpression> arguments = TransformQuantifiedSubExpression(expression.Parameters, expression.Child);

            if (IsNegating)
            {
                return(new OrExpression(arguments));
            }
            return(new AndExpression(arguments));
        }
コード例 #4
0
        /// <summary>
        /// Visits the expression.
        /// </summary>
        /// <param name="expression">Expression.</param>
        public void Visit(ForallExpression expression)
        {
            expression.Child.Accept(this);

            foreach (var parameter in expression.Parameters)
            {
                if (CollectedParameters.Contains(parameter.ParameterNameId))
                {
                    CollectedParameters.Remove(parameter.ParameterNameId);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Visits and evaluates forall expression.
        /// </summary>
        /// <param name="expression">Forall expression.</param>
        /// <returns>True if the specified expression evaluates as true, false otherwise.</returns>
        public bool Visit(ForallExpression expression)
        {
            IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters);

            foreach (var localSubstitution in localSubstitutions)
            {
                Substitution.AddLocalSubstitution(localSubstitution);
                bool subExpressionResult = expression.Child.Accept(this);
                Substitution.RemoveLocalSubstitution(localSubstitution);

                if (!subExpressionResult)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #6
0
        /// <summary>
        /// Visits and performs a property count on forall expression.
        /// </summary>
        /// <param name="expression">Forall expression.</param>
        /// <returns>Tuple (property satisfied count, property not satisfied count).</returns>
        public Tuple <int, int> Visit(ForallExpression expression)
        {
            int fulfilled    = 0;
            int notFulfilled = 0;

            IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters);

            foreach (var localSubstitution in localSubstitutions)
            {
                Substitution.AddLocalSubstitution(localSubstitution);
                var childPropertyCounts = expression.Child.Accept(this);
                Substitution.RemoveLocalSubstitution(localSubstitution);

                fulfilled    += childPropertyCounts.Item1;
                notFulfilled += childPropertyCounts.Item2;
            }

            return(Tuple.Create(fulfilled, notFulfilled));
        }
コード例 #7
0
 /// <summary>
 /// Visits and transforms the expression.
 /// </summary>
 /// <param name="expression">Source expression.</param>
 /// <returns>Transformed expression.</returns>
 public override IExpression Visit(ForallExpression expression)
 {
     return(new ForallExpression(expression.Parameters, expression.Child.Accept(this)));
 }