def check_fcs_in_state(mod,ag,post,fcs): # iu.dbg('"foo"') history = ag.get_history(post) # iu.dbg('history.actions') gmc = lambda cls, final_cond: itr.small_model_clauses(cls,final_cond,shrink=diagnose.get()) axioms = im.module.background_theory() if opt_trace.get(): clauses = history.post clauses = lut.and_clauses(clauses,axioms) ffcs = filter_fcs(fcs) model = itr.small_model_clauses(clauses,ffcs,shrink=True) if model is not None: # iu.dbg('history.actions') mclauses = lut.and_clauses(*([clauses] + [c.cond() for c in ffcs if c.failed])) vocab = lut.used_symbols_clauses(mclauses) handler = MatchHandler(mclauses,model,vocab) assert all(x is not None for x in history.actions) # work around a bug in ivy_interp actions = [im.module.actions[a] if isinstance(a,str) else a for a in history.actions] # iu.dbg('actions') action = act.Sequence(*actions) act.match_annotation(action,clauses.annot,handler) handler.end() exit(0) else: res = history.satisfy(axioms,gmc,filter_fcs(fcs)) if res is not None and diagnose.get(): show_counterexample(ag,post,res) return not any(fc.failed for fc in fcs)
def check_final_cond(ag, post, final_cond, rels_to_min=[], shrink=False, handler_class=None): history = ag.get_history(post) axioms = im.module.background_theory() clauses = history.post clauses = lut.and_clauses(clauses, axioms) model = slv.get_small_model(clauses, lg.uninterpreted_sorts(), rels_to_min, final_cond=final_cond, shrink=shrink) if model is not None: failed = ([final_cond] if not isinstance(final_cond, list) else [c.cond() for c in ffcs if c.failed]) mclauses = lut.and_clauses(*([clauses] + failed)) vocab = lut.used_symbols_clauses(mclauses) handler = (handler_class(mclauses, model, vocab) if handler_class is not None else Trace(mclauses, model, vocab)) assert all(x is not None for x in history.actions) # work around a bug in ivy_interp actions = [ im.module.actions[a] if isinstance(a, str) else a for a in history.actions ] action = act.Sequence(*actions) act.match_annotation(action, clauses.annot, handler) handler.end() return handler return None
def check_fcs_in_state(mod, ag, post, fcs): # iu.dbg('"foo"') history = ag.get_history(post) # iu.dbg('history.actions') gmc = lambda cls, final_cond: itr.small_model_clauses( cls, final_cond, shrink=diagnose.get()) axioms = im.module.background_theory() if opt_trace.get() or diagnose.get(): clauses = history.post clauses = lut.and_clauses(clauses, axioms) ffcs = filter_fcs(fcs) model = itr.small_model_clauses(clauses, ffcs, shrink=True) if model is not None: # iu.dbg('history.actions') failed = [c for c in ffcs if c.failed] mclauses = lut.and_clauses(*([clauses] + [c.cond() for c in failed])) vocab = lut.used_symbols_clauses(mclauses) # handler = MatchHandler(mclauses,model,vocab) if opt_trace.get() else ivy_trace.Trace(mclauses,model,vocab) handler = ivy_trace.Trace(mclauses, model, vocab) thing = failed[-1].get_annot() if thing is None: assert all(x is not None for x in history.actions) # work around a bug in ivy_interp actions = [ im.module.actions[a] if isinstance(a, str) else a for a in history.actions ] action = act.Sequence(*actions) annot = clauses.annot else: action, annot = thing act.match_annotation(action, annot, handler) handler.end() ff = failed[0] handler.is_cti = (lut.formula_to_clauses(ff.lf.formula) if isinstance(ff, ConjChecker) else None) if not opt_trace.get(): gui_art(handler) else: print str(handler) exit(0) else: res = history.satisfy(axioms, gmc, filter_fcs(fcs)) if res is not None and diagnose.get(): show_counterexample(ag, post, res) return not any(fc.failed for fc in fcs)
def check_vc(clauses, action, final_cond=None, rels_to_min=[], shrink=False, handler_class=None): model = slv.get_small_model(clauses, lg.uninterpreted_sorts(), rels_to_min, final_cond=final_cond, shrink=shrink) if model is not None: failed = ([] if final_cond is None else [final_cond] if not isinstance(final_cond, list) else [c.cond() for c in ffcs if c.failed]) mclauses = lut.and_clauses(*([clauses] + failed)) vocab = lut.used_symbols_clauses(mclauses) handler = (handler_class(mclauses, model, vocab) if handler_class is not None else Trace(mclauses, model, vocab)) act.match_annotation(action, clauses.annot, handler) handler.end() return handler return None