示例#1
0
        public override BooleanExpression ToNNF()
        {
            if (InnerExpression is Negation neg)
            {
                return(neg.InnerExpression.ToNNF());
            }
            else if (InnerExpression is NAryOperator nary)
            {
                List <BooleanExpression> newOperands = nary.GetOperands().Select(op => new Negation(op).ToNNF()).ToList();

                if (nary is Disjunction)
                {
                    return(new Conjunction(newOperands));
                }
                else // nary is Conjunction
                {
                    return(new Disjunction(newOperands));
                }
            }
            else if (InnerExpression.Equals(FALSE))
            {
                return(TRUE);
            }
            else if (InnerExpression.Equals(TRUE))
            {
                return(FALSE);
            }
            else
            {
                return(new Negation(this.InnerExpression.Simplify()));
            }
        }