def setUp(self): self.t1 = terms.string2Term("f(X, g(Y))") self.t2 = terms.string2Term("a") self.t3 = terms.string2Term("b") self.t4 = terms.string2Term("f(a, g(a))") self.t5 = terms.string2Term("f(a, g(b))") self.sigma1 = Substitution([("X", self.t2), ("Y", self.t2)]) self.sigma2 = Substitution([("X", self.t2), ("Y", self.t3)])
def testBacktrack(self): """ Test backtrackable substitutions. """ sigma = BTSubst() state = sigma.getState() sigma.addBinding(('X', terms.string2Term("f(Y)"))) res = sigma.backtrackToState(state) self.assertEqual(res, 1) res = sigma.backtrack() self.assertTrue(not res)