def _simplify_summary(self, f: MySet[Expr], p: Phase) -> None: l = [] for c in reversed(f.l): f_minus_c = [x for x in f.l if x in f.s and x is not c] if c not in phases.phase_safety(p) and \ logic.check_implication(self.solver, f_minus_c, [c], minimize=False) is None: utils.logger.debug('removed %s' % c) f.s.remove(c) else: l.append(c) l.reverse() f.l = l
def safety_property_checker( p: Phase) -> Optional[Tuple[Phase, Diagram]]: res = logic.check_implication(self.solver, f.summary_of(p), (inv.expr for inv in phases.phase_safety(p))) if res is None: utils.logger.debug( "Frontier frame phase %s implies safety, summary is %s" % (p.name(), f.summary_of(p))) return None utils.logger.debug("Frontier frame phase %s cex to safety" % p.name()) z3m: z3.ModelRef = res mod = Trace.from_z3([KEY_ONE], z3m) self.record_state(mod) diag = mod.as_diagram() return (p, diag)
def push_conjunct(self, frame_no: int, c: Expr, p: Phase, frame_old_count: Optional[int] = None) -> None: is_safety = c in phases.phase_safety(p) f = self.fs[frame_no] while True: with utils.LogTag(utils.logger, 'pushing-conjunct-attempt', lvl=logging.DEBUG, frame=str(frame_no), conj=str(c)): utils.logger.debug('frame %s phase %s attempting to push %s' % (frame_no, p.name(), c)) res = self.clause_implied_by_transitions_from_frame( f, p, c, minimize=is_safety or utils.args.block_may_cexs) if res is None: utils.logger.debug('frame %s phase %s managed to push %s' % (frame_no, p.name(), c)) if utils.args.smoke_test and utils.logger.isEnabledFor( logging.DEBUG): utils.logger.debug('smoke testing...') # TODO: phases logic.check_bmc(self.solver, c, frame_no + 1) # assert self.clause_implied_by_transitions_from_frame(f, p, c) is None self[frame_no + 1].strengthen(p, c) self.debug_assert_inductive_trace() break pre_phase, (m, t) = res mod = Trace.from_z3([KEY_OLD, KEY_NEW], m) self.record_state(mod) diag = mod.as_diagram(i=0) if utils.logger.isEnabledFor(logging.DEBUG): utils.logger.debug( 'frame %s failed to immediately push %s due to ' 'transition %s' % (frame_no, c, t.pp())) # utils.logger.debug(str(mod)) if is_safety: utils.logger.debug( 'note: current clause is safety condition') self.block(diag, frame_no, pre_phase, [(None, c), (t, diag)], safety_goal=True) else: if utils.args.block_may_cexs: ans = self.block(diag, frame_no, pre_phase, [(None, c), (t, diag)], safety_goal=False) if isinstance(ans, CexFound): break else: break