/// <summary> /// Indirectly call for Translate of RephraserType object /// </summary> /// <param name="rootBlock"></param> /// <param name="type"></param> /// <param name="firstBlock"></param> /// <param name="logic"></param> /// <param name="secondBlock"></param> /// <returns></returns> private Block Translation( ref Block rootBlock, RephraserType type, Block firstBlock, PropositionalLogic logic = null, Block secondBlock = null) { var result = type .AddLeftBlock(firstBlock) .AddLogic(logic) .AddRightBlock(secondBlock) .Translate(); // memory of rootBlock is altered after this translation call // so this assignment is a must if (rootBlock.Equals(firstBlock)) { rootBlock = result; } return(result); }
/// <summary> /// /// </summary> /// <param name="logic"></param> /// <param name="rootBlock"></param> /// <param name="currentBlock"></param> private void TranslateToCNF( PropositionalLogic logic, ref Block rootBlock, ref Block currentBlock) { RephraserType type = null; if (logic.IsBiconditional) { type = new BiconditionalElimination(); } else if (logic.IsImplication) { type = new ModusPonens(); } else if (logic.IsDisjunction) { type = new Distribution(); } if (type == null) { throw new System.Exception("Obligatory exception"); } System.Console.WriteLine("{0}, {1}", currentBlock.GetContent(true).ToString(), currentBlock.GetHashCode()); var unAffectedBlock = currentBlock.NextBlock.NextBlock; var newList = Translation( ref rootBlock, type, currentBlock.PreviousBlock, logic, currentBlock.NextBlock); currentBlock = unAffectedBlock.Equals(currentBlock) ? newList : unAffectedBlock.ExtendFront(newList); System.Console.WriteLine("{0}, {1}", currentBlock.GetContent(true).ToString(), currentBlock.GetHashCode()); }
public virtual RephraserType AddLogic(PropositionalLogic logic) { Logic = logic; return(this); }