public static BinaryConnective CreateBinaryConnectiveWithRandomSymbols(char binaryConnectiveSymbol) { BinaryConnective binaryConnective; switch (binaryConnectiveSymbol) { case Conjunction.SYMBOL: binaryConnective = new Conjunction(); break; case BiImplication.SYMBOL: binaryConnective = new BiImplication(); break; case Disjunction.SYMBOL: binaryConnective = new Disjunction(); break; case Implication.SYMBOL: binaryConnective = new Implication(); break; case Nand.SYMBOL: binaryConnective = new Nand(); break; default: throw new ArgumentNullException("Could not convert symbol into a connective!"); } binaryConnective.LeftSuccessor = GetRandomPropositionSymbol(); binaryConnective.RightSuccessor = GetRandomPropositionSymbol(); return(binaryConnective); }
private void CreateConnective(char connective) { Proposition result = null; // 'GetCorrespondingConnective' switch (connective) { case Negation.SYMBOL: result = new Negation(); break; case Implication.SYMBOL: result = new Implication(); break; case BiImplication.SYMBOL: result = new BiImplication(); break; case Conjunction.SYMBOL: result = new Conjunction(); break; case Disjunction.SYMBOL: result = new Disjunction(); break; case Nand.SYMBOL: result = new Nand(); break; case UniversalQuantifier.SYMBOL: result = new UniversalQuantifier(PopBoundVariable()); break; case ExistentialQuantifier.SYMBOL: result = new ExistentialQuantifier(PopBoundVariable()); break; } // 'CreateExpression' // The symbols[symbols.Count - 1] can always be done. Placement is dependent on Unary or Binary connective. if (result is BinaryConnective) { ((BinaryConnective)result).LeftSuccessor = symbols[symbols.Count - 2]; ((BinaryConnective)result).RightSuccessor = symbols[symbols.Count - 1]; symbols.RemoveAt(symbols.Count - 1); symbols.RemoveAt(symbols.Count - 1); } else { ((UnaryConnective)result).LeftSuccessor = symbols[symbols.Count - 1]; symbols.RemoveAt(symbols.Count - 1); } // Now the expression is a symbol in case a nested connective needs to use it // as right or left successor. symbols.Add(result); }
public override Proposition Copy() { BiImplication copy = new BiImplication(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }