def _check_invariant(self, syscall, lemma): inv = getattr(spec, 'spec_lemma_{}'.format(lemma)) args = syscall_spec.get_syscall_args(syscall) kwargs = {} if 'syscall' in inspect.getargspec(inv)[0]: kwargs['syscall'] = syscall if 'oldstate' in inspect.getargspec(inv)[0]: kwargs['oldstate'] = self.state pre = z3.And(spec.spec_invariants(self.state), inv(self.state, **kwargs)) self.solver.add(pre) cond, newstate = getattr(spec, syscall)(self.state, *args) model = self._prove(z3.And(spec.spec_invariants(newstate), inv(newstate, **kwargs)), pre=pre, return_model=INTERACTIVE, minimize=MODEL_HI) if INTERACTIVE and model: from ipdb import set_trace set_trace()
def _check_corollary(self, pre, post): pre = getattr(spec, 'spec_lemma_{}'.format(pre)) post = getattr(spec, 'spec_corollary_{}'.format(post)) self._prove(z3.Implies(z3.And(pre(self.state), spec.spec_invariants(self.state)), post(self.state))) self.setUp() self.state = self.state.initial() print "main.py.HV6TopLemmas._check_corollary: self.state:{}".format(self.state) constraints = z3.And(spec.spec_invariants(self.state), post(self.state)) self.solver.add(constraints) self.assertEquals(self.solver.check(), z3.sat)
def _check_initial(self, lemma): self.state = self.state.initial() inv = getattr(spec, 'spec_lemma_{}'.format(lemma)) constraints = z3.And(spec.spec_invariants(self.state), inv(self.state)) self.solver.add(constraints) self.assertEquals(self.solver.check(), z3.sat)