Example #1
0
    def testCheckProofMacro(self):
        """Proof checking with simple macro."""
        thy = Theory.EmptyTheory()
        thy.add_proof_macro("beta_conv_rhs", beta_conv_rhs_macro())
        
        t = Comb(Abs("x", Ta, Bound(0)), x)

        prf = Proof()
        prf.add_item(0, "reflexive", args=t)
        prf.add_item(1, "beta_conv_rhs", prevs=[0])
        th = Thm.mk_equals(t,x)

        # Check obtaining signature
        self.assertEqual(thy.get_proof_rule_sig("beta_conv_rhs"), Term)

        # Check proof without trusting beta_conv_rhs
        rpt = ProofReport()
        self.assertEqual(thy.check_proof(prf, rpt), th)
        self.assertEqual(rpt.steps_stat(), (0, 3, 0))
        self.assertEqual(rpt.macros_expand, {"beta_conv_rhs"})

        # Check proof while trusting beta_conv_rhs
        rpt = ProofReport()
        self.assertEqual(thy.check_proof(prf, rpt, check_level=1), th)
        self.assertEqual(rpt.steps_stat(), (0, 1, 1))
        self.assertEqual(rpt.macros_eval, {"beta_conv_rhs"})
Example #2
0
    def testCheckProof5(self):
        """Empty instantiation."""
        theory.thy.add_theorem("trivial", Thm([], Implies(A,A)))

        x_eq_y = Eq(x,y)
        prf = Proof()
        prf.add_item(0, "theorem", args="trivial")
        prf.add_item(1, "substitution", args=Inst(), prevs=[0])

        rpt = ProofReport()
        th = Thm([], Implies(SVar('A', BoolType), SVar('A', BoolType)))
        self.assertEqual(theory.check_proof(prf, rpt), th)
        self.assertEqual(rpt.steps_stat(), (1, 1, 0))
        self.assertEqual(rpt.th_names, {"trivial"})
Example #3
0
 def testStepCount(self):
     rpt = ProofReport()
     self.assertEqual(rpt.steps, 0)
     for i in range(10):
         rpt.apply_primitive_deriv()
     rpt.apply_theorem("th1")
     rpt.apply_theorem("th2")
     rpt.expand_macro("macro1")
     rpt.eval_macro("macro2")
     self.assertEqual(rpt.steps, 13)
     self.assertEqual(rpt.steps_stat(), (2, 10, 1))
     self.assertEqual(rpt.th_names, {"th1", "th2"})
     self.assertEqual(rpt.macros_expand, {"macro1"})
     self.assertEqual(rpt.macros_eval, {"macro2"})
Example #4
0
    def testCheckProof5(self):
        """Empty instantiation."""
        thy = Theory.EmptyTheory()
        thy.add_theorem("trivial", Thm.mk_implies(A,A))

        x_eq_y = Term.mk_equals(x,y)
        prf = Proof()
        prf.add_item(0, "theorem", args="trivial")
        prf.add_item(1, "substitution", args={}, prevs=[0])

        rpt = ProofReport()
        th = Thm.mk_implies(A,A)
        self.assertEqual(thy.check_proof(prf, rpt), th)
        self.assertEqual(rpt.steps_stat(), (1, 1, 0))
        self.assertEqual(rpt.th_names, {"trivial"})