Beispiel #1
0
        /// <summary>Check this proposition is conjunction normal form</summary>
        /// <returns>True if CNF</returns>
        public bool IsCNF()
        {
            if (!IsNNF())
            {
                return(false);
            }

            if (op == Operator.Atom)
            {
                return(true);
            }
            else if (op == Operator.Not)
            {
                return(left.op == Operator.Atom);
            }
            else if (op == Operator.And)
            {
                return(left.IsCNF() && right.IsCNF());
            }
            else if (op == Operator.Or)
            {
                return(this.IsClause());
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>Check whether give proposition is tautology</summary>
 /// <param name="expr">Proposition to check</param>
 /// <exception cref="InvaildPropositionException"></exception>
 /// <returns>True if tautology</returns>
 public bool IsTautology(Proposition expr)
 {
     if (expr == null || !expr.IsVaild())
     {
         throw new InvalidPropositionException("INVAILD");
     }
     if (!expr.IsCNF())
     {
         expr = ConvertToCNF(ConvertToNNF(expr));
     }
     return(IsTautologyCore(expr));
 }