Exemplo n.º 1
0
	def test_equal(self):
		expr = Exists(x, qepcad.Equal(x, x + 1))
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, FALSE)

		expr = Exists(x, qepcad.Equal(x, 2 * x))
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, TRUE)
Exemplo n.º 2
0
	def test_less(self):
		expr = Exists(x, StrictLessThan(x + 1, x))
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, FALSE)

		# Sympy simplifies simple expressions. Make it a bit
		# more complicated to test "<"
		expr = Exists(x, Exists(y, sp.And(x + 1 < y, sp.Eq(x, y))))
		out = run_qepcad(expr, [], [x, y])
		self.assertEqual(out, FALSE)
Exemplo n.º 3
0
	def test_for_all_but_finitely_many(self):
		expr = ForAllButFinitelyMany(x,
		       ForAll(y,
		       Exists(z, sp.Eq(y, z * x))))
		out = run_qepcad(expr, [], [x, y, z])
		self.assertEqual(out, TRUE)

		expr = ForAll(x,
		       ForAll(y,
		       Exists(z, sp.Eq(y, z * x))))
		out = run_qepcad(expr, [], [x, y, z])
		self.assertEqual(out, FALSE)
Exemplo n.º 4
0
	def test_a_b_c(self):
		expr = Exists(x, sp.Eq(a * x**2 + b*x + c, 0))
		out = run_qepcad(expr, [a, b, c], [x])

		# We expect And(4*a*c - b**2 <= 0, Or(4*a*c - b**2 < 0, a != 0, c == 0))
		self.assertTrue(out.subs(c, 0).subs(b, 1))
		self.assertFalse(out.subs(b, 0).subs(a, 0).subs(c, 1))
Exemplo n.º 5
0
	def test_a_b(self):
		expr = Exists(x, sp.Eq(x**2 + a*x + b, 0))
		out = run_qepcad(expr, [a, b], [x])

		# We expect 4b - a^2 <= 0
		self.assertFalse(out.subs(b,1).subs(a,1))
		self.assertTrue(out.subs(b,1).subs(a,100))
		self.assertTrue(out.subs(b,100).subs(a,100))
		self.assertFalse(out.subs(b,100).subs(a,1))
Exemplo n.º 6
0
	def test_for_infinitely_many(self):
		expr = ForInfinitelyMany(x, x >= 22)
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, TRUE)

		expr = ForInfinitelyMany(x, sp.Eq(x, 22))
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, FALSE)

		expr = Exists(x, sp.Eq(x, 22))
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, TRUE)
Exemplo n.º 7
0
	def test_forall_does_not_exist(self):
		expr = ForAll(x, Exists(y, sp.Eq(x, y**2)))
		out = run_qepcad(expr, [], [x, y])
		self.assertEqual(out, FALSE)
Exemplo n.º 8
0
	def test_forall_exists(self):
		expr = ForAll(x, Exists(y, sp.Eq(x, 2 * y)))
		out = run_qepcad(expr, [], [x, y])
		self.assertEqual(out, TRUE)
Exemplo n.º 9
0
	def test_multiple_exists(self):
		expr = Exists(x, Exists(y, x >= 22))
		out = run_qepcad(expr, [], [x, y])
		self.assertEqual(out, TRUE)
Exemplo n.º 10
0
	def test_exists(self):
		expr = Exists(x, x >= 22)
		out = run_qepcad(expr, [], [x])
		self.assertEqual(out, TRUE)