def testExport3(self): """Case with atoms.""" pt1 = ProofTerm.atom(0, Thm.mk_equals(x, y)) pt2 = ProofTerm.atom(1, Thm.mk_equals(y, z)) pt3 = ProofTerm.transitive(pt1, pt2) prf = Proof() prf.add_item(0, rule="sorry", th=Thm.mk_equals(x, y)) prf.add_item(1, rule="sorry", th=Thm.mk_equals(y, z)) pt3.export(prf=prf) self.assertEqual(thy.check_proof(prf), Thm.mk_equals(x, z))
def testTopSweepConv(self): f = Const("f", TFun(natT, natT)) x = Var("x", natT) th0 = eq(x, f(x)) cv = top_sweep_conv(rewr_conv(ProofTerm.atom(0, th0), match_vars=False)) prf = Proof() prf.add_item(0, "sorry", th=th0) cv.get_proof_term(thy, f(x)).export(prf=prf) self.assertEqual(thy.check_proof(prf), eq(f(x), f(f(x))))
def testLargeSum(self): f = Const("f", TFun(natT, natT)) g = Const("g", TFun(natT, natT)) x = Var("x", natT) th0, th1 = eq(one, zero), eq(f(x), g(x)) cv = top_conv( else_conv(rewr_conv(ProofTerm.atom(0, th0)), rewr_conv(ProofTerm.atom(1, th1)))) f1 = f(one) g0 = g(zero) t = plus(*([f1] * 50)) res = plus(*([g0] * 50)) self.assertEqual(cv.eval(thy, t), eq(t, res)) prf = Proof() prf.add_item(0, "sorry", th=th0) prf.add_item(1, "sorry", th=th1) cv.get_proof_term(thy, t).export(prf=prf) self.assertEqual(thy.check_proof(prf, check_level=1), eq(t, res))
def testRewrConvWithAssum(self): x = Const("x", natT) y = Const("y", natT) x_eq_y = Term.mk_equals(x, y) th = Thm([], Term.mk_implies(x_eq_y, x_eq_y)) cv = arg_conv(rewr_conv(ProofTerm.atom(0, th))) f = Const("f", TFun(natT, natT)) res = Thm([x_eq_y], Term.mk_equals(f(x), f(y))) self.assertEqual(cv.eval(thy, f(x)), res) prf = Proof() prf.add_item(0, "sorry", th=th) cv.get_proof_term(thy, f(x)).export(prf=prf) self.assertEqual(thy.check_proof(prf), res)
def testRewrConv(self): f = Const("f", TFun(natT, natT)) g = Const("g", TFun(natT, natT)) x = Var("x", natT) assum0 = eq(one, zero) assum1 = eq(f(x), g(x)) # Test conversion using 1 = 0 cv1 = rewr_conv(ProofTerm.atom(0, assum0)) prf = Proof() prf.add_item(0, "sorry", th=assum0) eq_th = eq(one, zero) cv1.get_proof_term(thy, one).export(prf=prf) self.assertEqual(cv1.eval(thy, one), eq_th) self.assertEqual(thy.check_proof(prf), eq_th) self.assertRaises(ConvException, cv1.eval, thy, zero) self.assertRaises(ConvException, cv1.get_proof_term, thy, zero) # Test conversion using f x = g x cv2 = rewr_conv(ProofTerm.atom(0, assum1)) eq0 = eq(f(zero), g(zero)) eq1 = eq(f(one), g(one)) self.assertEqual(cv2.eval(thy, f(zero)), eq0) self.assertEqual(cv2.eval(thy, f(one)), eq1) prf0 = Proof() prf0.add_item(0, "sorry", th=assum1) cv2.get_proof_term(thy, f(zero)).export(prf=prf0) self.assertEqual(thy.check_proof(prf0), eq0) self.assertRaises(ConvException, cv1.eval, thy, zero) prf1 = Proof() prf1.add_item(0, "sorry", th=assum1) cv2.get_proof_term(thy, f(one)).export(prf=prf1) self.assertEqual(thy.check_proof(prf1), eq1) self.assertRaises(ConvException, cv1.get_proof_term, thy, zero)