Exemplo n.º 1
0
 /// <summary>
 /// If the passed atom matches one of the atoms in the Equivalent pair, returns the other atom, with its variable
 /// names modified to match the ones of the passed atom.
 /// </summary>
 /// <param name="atom">The atom that is potentially equivalent to one of the atoms of the Equivalent pair.</param>
 /// <returns>The atom equivalent to the passed one, or null if none of the atom pair is matching it.</returns>
 public Atom Get(Atom atom)
 {
     if (firstAtom.Matches(atom))
     {
         return(RulesUtil.TranslateVariables(atom, firstAtom, secondAtom));
     }
     return(secondAtom.Matches(atom) ? RulesUtil.TranslateVariables(atom, secondAtom, firstAtom) : null);
 }
Exemplo n.º 2
0
        public void VariableTranslation()
        {
            Atom template = new Atom("own", new Variable("person"), new Variable("object"));
            Atom source   = new Atom("own", new Variable("person"), new Variable("stuff"));
            Atom target   = new Atom("belongs", new Variable("person"), new Variable("stuff"));
            Atom expected = new Atom("belongs", new Variable("person"), new Variable("object"));

            Assert.AreEqual(expected, RulesUtil.TranslateVariables(template, source, target));
        }