Esempio n. 1
0
    def eval(self, args, prevs):
        if self.with_inst:
            name, inst = args
        else:
            name = args
            inst = Inst()
        th = theory.get_theorem(name)
        As, C = th.prop.strip_implies()

        assert len(prevs) <= len(As), "apply_theorem: too many prevs."

        # First attempt to match type variables
        svars = th.prop.get_svars()
        for v in svars:
            if v.name in inst:
                v.T.match_incr(inst[v.name].get_type(), inst.tyinst)

        pats = As[:len(prevs)]
        ts = [prev_th.prop for prev_th in prevs]
        inst = matcher.first_order_match_list(pats, ts, inst)

        As, C = th.prop.subst_norm(inst).strip_implies()
        new_prop = Implies(*(As[len(prevs):] + [C]))

        prev_hyps = sum([prev.hyps for prev in prevs], ())
        th = Thm(th.hyps + prev_hyps, new_prop)

        assert len(new_prop.get_stvars()) == 0, "apply_theorem: unmatched type variables."
        vars = new_prop.get_svars()
        for v in reversed(vars):
            th = Thm.forall_intr(v, th)
        return th
Esempio n. 2
0
 def testForallIntr2(self):
     """Also OK if the variable does not appear in theorem."""
     th = Thm.mk_equals(x, y)
     t_res = Term.mk_all(z, Term.mk_equals(x, y))
     self.assertEqual(Thm.forall_intr(z, th), Thm([], t_res))
Esempio n. 3
0
 def testForallIntr(self):
     th = Thm.mk_equals(x, y)
     t_res = Term.mk_all(x, Term.mk_equals(x, y))
     self.assertEqual(Thm.forall_intr(x, th), Thm([], t_res))
Esempio n. 4
0
 def testForallIntr(self):
     th = Thm([], Eq(x,y))
     t_res = Forall(x, Eq(x, y))
     self.assertEqual(Thm.forall_intr(x, th), Thm([], t_res))