public void ClauseNegationTest()
 {
     Clause clause = new Clause();
     Literal a = new Literal("","A");
     Literal b = new Literal("~", "B");
     clause.AddLiteral(a);
     clause.AddLiteral(b);
     Sentence s = clause.GetNegation();
     Assert.AreEqual(s.ToString(), "( ~A ) ^ ( B )", "Negated clause incorrect");
 }
        public static void basicTests()
        {
            Console.WriteLine("******************** start basicTests ********************");
            Sentence theSentence = new Sentence();

            Clause tempClause = new Clause();

            Literal tempLiteral = new Literal("", "A");
            Console.WriteLine("tempLiteral (should be 'A')\n" + tempLiteral);
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("~", "B");
            Console.WriteLine("tempLiteral (should be '~B')\n" + tempLiteral);
            tempClause.AddLiteral(tempLiteral);
            Console.WriteLine("tempClause (should be '( A v ~B )')\n" + tempClause);

            theSentence.AddClause(tempClause);
            Console.WriteLine("theSentence (should be '( A v ~B )')\n" + theSentence);

            tempClause = new Clause();
            tempLiteral = new Literal("", "B");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("~", "D");
            tempClause.AddLiteral(tempLiteral);

            theSentence.AddClause(tempClause);
            Console.WriteLine("theSentence (should be '( A v ~B ) ^ ( B v ~D )'\n" + theSentence);

            tempClause = new Clause();
            tempLiteral = new Literal("", "E");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("~", "F");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("~", "A");
            tempClause.AddLiteral(tempLiteral);

            theSentence.AddClause(tempClause);

            Console.WriteLine("theSentence (should be '( A v ~B ) ^ ( B v ~D ) ^ ( E v ~F v ~A )'\n" + theSentence);

            tempLiteral = new Literal("", "A");
            Console.WriteLine("tempLiteral (should be 'A')\n" + tempLiteral);
            tempLiteral = tempLiteral.GetNegation();
            Console.WriteLine("negation of tempLiteral (should be '~A')\n" + tempLiteral);
            tempLiteral = tempLiteral.GetNegation();
            Console.WriteLine("negation of negation of tempLiteral (should be 'A')\n" + tempLiteral);

            tempClause = new Clause();
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("", "B");
            tempClause.AddLiteral(tempLiteral);

            Console.WriteLine("tempClause   (should be '( A v B )'\n" + tempClause);

            Sentence negatedTempClause = tempClause.GetNegation();
            Console.WriteLine("negatedTempClause   (should be '( ~A ) ^ ( ~B )'\n" + negatedTempClause);

            Sentence negatedSentence = negatedTempClause.GetNegation();

            Console.WriteLine("negatedSentence   (should be '( A v B )'\n" + tempClause);

            Console.WriteLine("=======");
            Console.WriteLine("=======");

            Sentence testerSentence = new Sentence();

            tempClause = new Clause();
            tempLiteral = new Literal("~", "A");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("", "B");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("~", "C");
            tempClause.AddLiteral(tempLiteral);

            Console.WriteLine("tempClause   (should be '( ~A v B v ~C )'\n" + tempClause);

            testerSentence.AddClause(tempClause);
            Console.WriteLine("testerSentence   (should be '( ~A v B v ~C )'\n" + testerSentence);

            tempClause = new Clause();
            tempLiteral = new Literal("", "C");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("", "D");
            tempClause.AddLiteral(tempLiteral);
            tempLiteral = new Literal("", "E");
            tempClause.AddLiteral(tempLiteral);

            Console.WriteLine("tempClause   (should be '( C v D v E )'\n" + tempClause);

            testerSentence.AddClause(tempClause);
            Console.WriteLine("testerSentence   (should be '( ~A v B v ~C ) ^ ( C v D v E )'\n" + testerSentence);

            //WE START WITH     ( ~A v B v ~C ) ^ ( C v D v E )

            //NEGATE IT        ~ ( ( ~A v B v ~C ) ^ ( C v D v E ) )
            //DeMorgan's gives us   ~ ( ~A v B v ~C ) v ~ ( C v D v E )
            //DeMorgan's again      ( A ^ ~B ^ C ) v (~C ^ ~D ^ ~E )

            //now do distribution to arrive at CNF

            ///  ( A v ~C) ^ ( A v ~D ) ^ ( A v ~E ) ^ ( ~B v ~C ) ^ ( ~B v ~D ) ^ ( ~B v ~E ) ^ ( C v ~C ) ^ ( C v ~D ) ^ ( C v ~E )

            Sentence negatedTesterSentence = testerSentence.GetNegation();

            Console.WriteLine("negatedTesterSentence   (should be '( A v ~C ) ^ ( A v ~D ) ^ ( A v ~E ) ^ ( ~B v ~C ) ^ ( ~B v ~D ) ^ ( ~B v ~E ) ^ ( C v ~C ) ^ ( C v ~D ) ^ ( C v ~E ) \n" +
            "        '\n" + negatedTesterSentence);

            Console.WriteLine("******************** end basicTests ********************");
        }