/** * Distribute and (&) over or (|). * * @param sentence * a propositional logic sentence. This sentence should already * have biconditionals, and implications removed and negations * moved inwards. * @return an equivalent Sentence to the input with and's distributed over * or's. */ public static Sentence distribute(Sentence sentence) { Sentence result = null; DistributeAndOverOr distributeAndOverOr = new DistributeAndOverOr(); result = sentence.accept(distributeAndOverOr, null); return(result); }
/** * Returns the specified sentence in its logically equivalent disjunction * normal form. * * @param s * a propositional logic sentence * * @return the input sentence converted to it logically equivalent * disjunction normal form. */ public static Sentence convert(Sentence s) { Sentence result = null; Sentence nnfSentence = ConvertToNNF.convert(s); Sentence dnfSentence = DistributeAndOverOr.distribute(nnfSentence); result = dnfSentence; return(result); }