public void TestBiConditionalTransformation() { Sentence bic = parser.Parse("A <=> B"); ConjunctionOfClauses transformedBic = ConvertToConjunctionOfClauses.Convert(bic); Assert.AreEqual("{{~A, B}, {~B, A}}", transformedBic.ToString()); }
public void TestFourSuccessiveNotsTransformation() { Sentence fourNots = parser.Parse("~~~~A"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(fourNots); Assert.AreEqual("{{A}}", transformed.ToString()); }
public void TestNested() { Sentence nested = parser.Parse("A | (B | (C | (D & E)))"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(nested); Assert.AreEqual("{{A, B, C, D}, {A, B, C, E}}", transformed.ToString()); nested = parser.Parse("A | (B | (C & (D & E)))"); transformed = ConvertToConjunctionOfClauses.Convert(nested); Assert.AreEqual("{{A, B, C}, {A, B, D}, {A, B, E}}", transformed.ToString()); nested = parser.Parse("A | (B | (C & (D & (E | F))))"); transformed = ConvertToConjunctionOfClauses.Convert(nested); Assert.AreEqual("{{A, B, C}, {A, B, D}, {A, B, E, F}}", transformed.ToString()); nested = parser.Parse("(A | (B | (C & D))) | E | (F | (G | (H & I)))"); transformed = ConvertToConjunctionOfClauses.Convert(nested); Assert.AreEqual("{{A, B, C, E, F, G, H}, {A, B, D, E, F, G, H}, {A, B, C, E, F, G, I}, {A, B, D, E, F, G, I}}", transformed.ToString()); nested = parser.Parse("(((~P | ~Q) => ~(P | Q)) => R)"); transformed = ConvertToConjunctionOfClauses.Convert(nested); Assert.AreEqual("{{~P, ~Q, R}, {P, Q, R}}", transformed.ToString()); nested = parser.Parse("~(((~P | ~Q) => ~(P | Q)) => R)"); transformed = ConvertToConjunctionOfClauses.Convert(nested); Assert.AreEqual("{{P, ~P}, {Q, ~P}, {P, ~Q}, {Q, ~Q}, {~R}}", transformed.ToString()); }
public void TestImplicationTransformation() { Sentence impl = parser.Parse("A => B"); ConjunctionOfClauses transformedImpl = ConvertToConjunctionOfClauses.Convert(impl); Assert.AreEqual("{{~A, B}}", transformedImpl.ToString()); }
public void TestSymbolTransform() { Sentence symbol = parser.Parse("A"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(symbol); Assert.AreEqual("{{A}}", transformed.ToString()); }
public void TestAimaExample() { Sentence aimaEg = parser.Parse("B11 <=> P12 | P21"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(aimaEg); Assert.AreEqual("{{~B11, P12, P21}, {~P12, B11}, {~P21, B11}}", transformed.ToString()); }
public void TestOrDistribution2() { Sentence or = parser.Parse("A | B & C"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(or); Assert.AreEqual("{{A, B}, {A, C}}", transformed.ToString()); }
public void TestDeMorgan2() { Sentence dm = parser.Parse("~(A | B)"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(dm); Assert.AreEqual("{{~A}, {~B}}", transformed.ToString()); }
public void TestIssue78() { // ( ( NOT J1007 ) OR ( NOT ( OR J1008 J1009 J1010 J1011 J1012 J1013 J1014 J1015 ) ) ) Sentence issue78Eg = parser.Parse("( ( ~ J1007 ) | ( ~ ( J1008 | J1009 | J1010 | J1011 | J1012 | J1013 | J1014 | J1015 ) ) )"); ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(issue78Eg); Assert.AreEqual("{{~J1007, ~J1008}, {~J1007, ~J1009}, {~J1007, ~J1010}, {~J1007, ~J1011}, {~J1007, ~J1012}, {~J1007, ~J1013}, {~J1007, ~J1014}, {~J1007, ~J1015}}", transformed.ToString()); }
/** * Añade la sentencia específica a la BC. * * @param aSentence * hecho para ser añadido a la BC. */ public void Tell(Sentence aSentence) { if (!(sentences.Contains(aSentence))) { sentences.Add(aSentence); _asCNF = _asCNF.Extend(ConvertToConjunctionOfClauses.Convert(aSentence).GetClauses()); symbols.UnionWith(SymbolCollector.GetSymbolsFrom(aSentence)); // UnionWith de ISet en vez del método addAll de Set } }
public void TestBasicSentenceTransformation() { Sentence and = parser.Parse("A & B"); ConjunctionOfClauses transformedAnd = ConvertToConjunctionOfClauses.Convert(and); Assert.AreEqual("{{A}, {B}}", transformedAnd.ToString()); Sentence or = parser.Parse("A | B"); ConjunctionOfClauses transformedOr = ConvertToConjunctionOfClauses.Convert(or); Assert.AreEqual("{{A, B}}", transformedOr.ToString()); Sentence not = parser.Parse("~C"); ConjunctionOfClauses transformedNot = ConvertToConjunctionOfClauses.Convert(not); Assert.AreEqual("{{~C}}", transformedNot.ToString()); }