def test_path(self): model = BmcModel(self.fsm) noinit = model.path(3, with_init=False) w_init = model.path(3) self.assertEqual(w_init, (noinit & model.init[0])) self.assertEqual(noinit, model.unrolling(0, 3))
def generate_path(offset, length): """ Returns a boolean expression representing a path of length `length` in the fsm described by the loaded model. :param length: the length of the path in the fsm :param offset: the offset at which the path should be starting :return: a boolean expression representing a path of length `length` in the loaded fsm. """ model = BmcModel() path = model.init[offset] & model.unrolling(offset, offset + length) return path
def test_generate_inductive_step(self): # INDUCT = (P0 and R01) -> P1 for prop in prop_database(): expr = utils.make_nnf_boolean_wff(prop.expr) gen = invarspec.generate_inductive_step(self.fsm, expr) # model = BmcModel() r01 = model.unrolling(0, 1) # recall: the prop has to be shifted to time 0 p = expr.to_be(self.fsm.encoding) p0 = self.fsm.encoding.shift_to_time(p, 0) p1 = self.fsm.encoding.shift_to_time(p, 1) manual= (p0 & r01).imply(p1) self.assertEqual(gen.to_cnf().vars_list, manual.to_cnf().vars_list)
def test_generate_inductive_step(self): # INDUCT = (P0 and R01) -> P1 for prop in prop_database(): expr = utils.make_nnf_boolean_wff(prop.expr) gen = invarspec.generate_inductive_step(self.fsm, expr) # model = BmcModel() r01 = model.unrolling(0, 1) # recall: the prop has to be shifted to time 0 p = expr.to_be(self.fsm.encoding) p0 = self.fsm.encoding.shift_to_time(p, 0) p1 = self.fsm.encoding.shift_to_time(p, 1) manual = (p0 & r01).imply(p1) self.assertEqual(gen.to_cnf().vars_list, manual.to_cnf().vars_list)
def test_unrolling(self): # comparing the clauses list is not feasible because of the formula # literal which is embedded in the clauses and vary from one implem # to the next # Thus, this test lets us at least get some confidence about the # equivalence between the two Be's def manual_unrolling(j, bound): trans = Be.true(self.enc.manager) for k in range(j, bound): trans = trans & self.enc.shift_to_time(self.fsm.trans, k) return trans model = BmcModel(self.fsm) manual = manual_unrolling(4, 5) tested = model.unrolling(4,5) # because the var ordering does not matter at all manual_set = set(manual.to_cnf().vars_list) tested_set = set(tested.to_cnf().vars_list) self.assertEqual(manual_set, tested_set)