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() { Quantifier quantifier = null; if (Data == UniversalQuantifier.SYMBOL) { quantifier = new UniversalQuantifier(boundVariable); } else { quantifier = new ExistentialQuantifier(boundVariable); } foreach (char appliedVariable in alreadyAppliedReplacementCharacters) { quantifier.AddAppliedReplacementVariable(appliedVariable); } quantifier.LeftSuccessor = LeftSuccessor.Copy(); return(quantifier); }