def test_next_no_loop(self): with Configure(self, __file__, "/models/flipflops.smv"): fsm = self.befsm formula = self.nnf("X (a <-> !b)") # bound 0 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # ---- other offset ---- # bound 0 offset = 1 ref_expr= Be.false(fsm.encoding.manager) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 1 ref_expr= Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding) ref_expr= fsm.encoding.shift_to_time(ref_expr, offset+1) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
def test_globally_no_loop(self): with Configure(self, __file__, "/models/flipflops.smv"): fsm = self.befsm formula = self.nnf("G (a <-> !b)") # bound 0 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # ---- other offset ---- # bound 0 offset = 1 ref_expr= Be.false(fsm.encoding.manager) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 1 ref_expr= Be.false(fsm.encoding.manager) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
def test_releases(self): with Configure(self, __file__, "/models/flipflops.smv"): fsm = self.befsm formula = self.nnf("(a V b)") # bound 0 offset = 0 bound = 0 ref_expr= ltlspec.bounded_semantics(fsm, formula, bound) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 0 bound = 1 ref_expr= ltlspec.bounded_semantics(fsm, formula, bound) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset) # VERIFIED manually, complains only about the CNF clauses literals and that's OK. # self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # ---- other offset ---- # bound 2 offset = 2 bound = 1 # because of the way the loop condition is encoded ! ref_expr= ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset)\ | ( ltlspec.bounded_semantics_with_loop_at_offset(fsm, formula, 0, bound, 0, offset) & bmcutils.loop_condition(self.enc, offset+bound, offset+0)) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset)
def test_releases_no_loop(self): with Configure(self, __file__, "/models/flipflops.smv"): fsm = self.befsm formula = self.nnf("(a V b)") # bound 0 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 2 -- verification must be done by hand because the different # cnf literals mess the comparison ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 2) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 2, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # ---- other offset ---- # bound 0 offset = 1 bound = 0 left = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding) right = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding) ref_expr= self.enc.shift_to_time(right, offset) & self.enc.shift_to_time(left, offset) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 1 bound = 1 left = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding) right = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding) ref_expr= self.enc.shift_to_time(right, offset) & ( self.enc.shift_to_time(left, offset) \ | (self.enc.shift_to_time(right, 1+offset) & self.enc.shift_to_time(left, 1+offset))) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
def test_until_no_loop(self): with Configure(self, __file__, "/models/flipflops.smv"): fsm = self.befsm formula = self.nnf("(a U b)") # bound 0 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 2 -- verification must be done by hand because the different # cnf literals mess the comparison # ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 2) # expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 2, 0) # self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # ---- other offset ---- # bound 0 offset = 1 ref_expr= Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding) ref_expr= fsm.encoding.shift_to_time(ref_expr, offset) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 1 cdr = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding) car = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding) ref_expr= fsm.encoding.shift_to_time(cdr, offset) \ | ( fsm.encoding.shift_to_time(car, offset) \ & fsm.encoding.shift_to_time(cdr, offset+1)) expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
def test_globally(self): with Configure(self, __file__, "/models/flipflops.smv"): fsm = self.befsm formula = self.nnf("G (a <-> !b)") # bound 0 offset = 0 bound = 0 ref_expr= ltlspec.bounded_semantics(fsm, formula, bound) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 0 bound = 1 ref_expr= ltlspec.bounded_semantics(fsm, formula, bound) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # ---- other offset ---- # bound 0 offset = 2 bound = 0 ref_expr= Be.false(self.enc.manager) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr)) # bound 1 offset = 2 bound = 1 ref_expr= ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset) \ |( ltlspec.bounded_semantics_with_loop_at_offset(fsm, formula, 0, bound, 0, offset) \ & bmcutils.loop_condition(self.enc, bound+offset, offset)) expr = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset) self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))