示例#1
0
 public static bool?Evaluate(ExpressionSyntacticElement exp, PredicateList state)
 {
     if (exp.GetType() == typeof(NotExpression))
     {
         return(ExpressionExecutive.Evaluate((NotExpression)exp, state));
     }
     if (exp.GetType() == typeof(AndExpression))
     {
         return(ExpressionExecutive.Evaluate((AndExpression)exp, state));
     }
     if (exp.GetType() == typeof(OrExpression))
     {
         return(ExpressionExecutive.Evaluate((OrExpression)exp, state));
     }
     if (exp.GetType() == typeof(XorExpression))
     {
         return(ExpressionExecutive.Evaluate((XorExpression)exp, state));
     }
     if (exp.GetType() == typeof(PredicateExpression))
     {
         return(ExpressionExecutive.Evaluate((PredicateExpression)exp, state));
     }
     if (exp.GetType() == typeof(ImplicationSyntacticExpression))
     {
         return(ExpressionExecutive.Evaluate((ImplicationSyntacticExpression)exp, state));
     }
     if (exp.GetType() == typeof(IfAndOnlyIfSyntacticExpression))
     {
         return(ExpressionExecutive.Evaluate((IfAndOnlyIfSyntacticExpression)exp, state));
     }
     throw new UnknownExpressionException();
 }
示例#2
0
        /// <summary>
        /// Implies when run, evaluates left hand side and right hand side then sets itself
        /// this is the a result, True, the argument is valid and false it is not valid.
        /// Unknown will have to be taken as invalid. If all steps in the argument are valid
        /// then we should have a good argument
        /// implies testing
        /// p --> q
        /// 1  1  1
        /// 1  0  0
        /// 0  1  1
        /// 0  1  0
        /// X  1  1
        /// X  0  X
        /// 1  X  X
        /// 0  X  1
        /// X  X  X
        /// </summary>
        /// <param name="element"></param>
        /// <param name="predicateState"></param>
        /// <returns></returns>
        public static PredicateList execute(ImplicationSyntacticExpression element, PredicateList predicateState)
        {
            bool?lhs = ExpressionExecutive.Evaluate(element.lhs, predicateState);
            bool?rhs = ExpressionExecutive.Evaluate(element.rhs, predicateState);

            element.Value = ImpliesTruthTable(lhs, rhs);
            return(predicateState);
        }
示例#3
0
        public static bool?Evaluate(NotExpression exp, PredicateList state)
        {
            bool?val = ExpressionExecutive.Evaluate(exp.expression, state);

            if (val == true)
            {
                return(false);
            }
            if (val == false)
            {
                return(true);
            }
            if (val == null)
            {
                return(null);
            }
            throw new NotImplementedException();
        }
示例#4
0
        public static bool?Evaluate(IfAndOnlyIfSyntacticExpression exp, PredicateList state)
        {
            bool?lhs = ExpressionExecutive.Evaluate(exp.lhs, state);
            bool?rhs = ExpressionExecutive.Evaluate(exp.rhs, state);

            if (lhs == true && rhs == true)
            {
                return(true);
            }
            if (lhs == true && rhs == false)
            {
                return(false);
            }
            if (lhs == true && rhs == null)
            {
                return(null);
            }
            if (lhs == false && rhs == true)
            {
                return(false);
            }
            if (lhs == false && rhs == false)
            {
                return(true);
            }
            if (lhs == false && rhs == null)
            {
                return(null);
            }
            if (lhs == null && rhs == true)
            {
                return(null);
            }
            if (lhs == null && rhs == false)
            {
                return(null);
            }
            if (lhs == null && rhs == null)
            {
                return(null);
            }
            throw new NotImplementedException();
        }
示例#5
0
 /// <summary>
 /// each of the following expressions all rely on expressions either unary or binary
 /// these are defined in the evaluate function, these can only really be worked out when all predicate suppositions
 /// are made. For propositions like p and not p must be run
 /// </summary>
 /// <param name="element"></param>
 /// <param name="predicateState"></param>
 /// <returns></returns>
 public static PredicateList execute(ThereforeSyntacticElement element, PredicateList predicateState)
 {
     // for of a therefore are
     element.Value = ExpressionExecutive.Evaluate(element.expression, predicateState);
     return(predicateState);
 }