Ejemplo n.º 1
0
        public void RunMain()
        {
            Proposition expr;
            string      result;

            //string s = "( p -> ( q & r ) ) <-> y";
            //string s = "(A ->( B -> C )) <-> ( C -> D ) & ( D -> E) ";
            //string s = "p<->p";
            //string s = "p <-> a & b";
            //string s = "((p | q) & (~p | r)) -> (q | r)";
            //string s = "(P|(S&T))|R";
            //string s = "(A&B)|(~A)|(~B)";
            //string s = "(~p)<->(p->F)";
            //string s = "(~((a&b)|c)&d)|(((a&b)|c)&(~d))";
            string      s           = "(a&b)|(c&d)|(e&f)";
            ParseEngine parseEngine = new ParseEngine();

            parseEngine.TryParse(out expr, out result, s);

            LogicEngine logicEng = new LogicEngine();
            Proposition nnfExpr  = logicEng.ConvertToNNF(expr);

            Proposition cnfExpr = logicEng.ConvertToCNF(nnfExpr);
            bool        b       = logicEng.IsTautology(cnfExpr);

            WriteFile(cnfExpr.ToString());
        }
Ejemplo n.º 2
0
 /// <summary>Check whether give proposition is tautology</summary>
 /// <exception cref="InvaildPropositionException"></exception>
 /// <returns>True if tautology</returns>
 public static bool IsTautology(this Proposition expr)
 {
     return(logEngine.IsTautology(expr));
 }