AIMA.Core.Logic.Propositional.Visitors.CNFTransformer.transformNotSentence C# (CSharp) Method

transformNotSentence() private method

private transformNotSentence ( UnarySentence us ) : Sentence
us AIMA.Core.Logic.Propositional.Parsing.Ast.UnarySentence
return AIMA.Core.Logic.Propositional.Parsing.Ast.Sentence
        private Sentence transformNotSentence(UnarySentence us)
        {
            if (us.getNegated() is UnarySentence)
            {
                return (Sentence)((UnarySentence)us.getNegated()).getNegated()
                        .accept(this, null);
            }
            else if (us.getNegated() is BinarySentence)
            {
                BinarySentence bs = (BinarySentence)us.getNegated();
                if (bs.isAndSentence())
                {
                    Sentence first = new UnarySentence((Sentence)bs.getFirst()
                            .accept(this, null));
                    Sentence second = new UnarySentence((Sentence)bs.getSecond()
                            .accept(this, null));
                    return new BinarySentence("OR", first, second);
                }
                else if (bs.isOrSentence())
                {
                    Sentence first = new UnarySentence((Sentence)bs.getFirst()
                            .accept(this, null));
                    Sentence second = new UnarySentence((Sentence)bs.getSecond()
                            .accept(this, null));
                    return new BinarySentence("AND", first, second);
                }
                else
                {
                    return (Sentence)base.visitNotSentence(us, null);
                }
            }
            else
            {
                return (Sentence)base.visitNotSentence(us, null);
            }
        }