/// <summary> /// Decompose this Sentence based on the rules of Truth Trees. /// </summary> /// <returns>The decomposition of this Sentence if it is decomposable, null otherwise.</returns> public Decomposition decompose() { if (!isDecomposable()) { return(null); } Decomposition ret = new Decomposition(); if (type == SentenceType.AND) { ret.left.Add(left); ret.left.Add(right); } else if (type == SentenceType.OR) { ret.left.Add(left); ret.right.Add(right); } else if (type == SentenceType.IF) { ret.left.Add(left.negation()); ret.right.Add(right); } else if (type == SentenceType.IFF) { ret.left.Add(left); ret.left.Add(right); ret.right.Add(left.negation()); ret.right.Add(left.negation()); } else if (type == SentenceType.NOT) { if (left.type == SentenceType.AND) { ret.left.Add(left.left.negation()); ret.right.Add(left.right.negation()); } else if (left.type == SentenceType.OR) { ret.left.Add(left.left.negation()); ret.left.Add(left.right.negation()); } else if (left.type == SentenceType.IF) { ret.left.Add(left.left); ret.left.Add(left.right.negation()); } else if (left.type == SentenceType.IFF) { ret.left.Add(left.left); ret.left.Add(left.right.negation()); ret.right.Add(left.left.negation()); ret.right.Add(left.right); } else if (left.type == SentenceType.NOT) { ret.left.Add(left.left); } } return(ret); }