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

distributeOrOverAnd() private method

private distributeOrOverAnd ( BinarySentence bs ) : Sentence
bs AIMA.Core.Logic.Propositional.Parsing.Ast.BinarySentence
return AIMA.Core.Logic.Propositional.Parsing.Ast.Sentence
        private Sentence distributeOrOverAnd(BinarySentence bs)
        {
            BinarySentence andTerm = bs.firstTermIsAndSentence() ? (BinarySentence)bs
                    .getFirst()
                    : (BinarySentence)bs.getSecond();
            Sentence otherterm = bs.firstTermIsAndSentence() ? bs.getSecond() : bs
                    .getFirst();
            // (alpha or (beta and gamma) = ((alpha or beta) and (alpha or gamma))
            Sentence alpha = (Sentence)otherterm.accept(this, null);
            Sentence beta = (Sentence)andTerm.getFirst().accept(this, null);
            Sentence gamma = (Sentence)andTerm.getSecond().accept(this, null);
            Sentence distributed = new BinarySentence("AND", new BinarySentence(
                    "OR", alpha, beta), new BinarySentence("OR", alpha, gamma));
            return distributed;
        }
    }