示例#1
0
文件: ivy_solver.py 项目: odedp/ivy
def model_if_none(clauses1, implied, model):
    h = model
    if h == None:
        s = z3.Solver()
        z3c = clauses_to_z3(clauses1)
        s.add(z3c)
        if implied != None:
            s.add(not_clauses_to_z3(implied))
        sort_size = 1
        while True:
            s.push()
            for sort in ivy_logic.uninterpreted_sorts():
                s.add(formula_to_z3(sort_size_constraint(sort, sort_size)))
            if s.check() != z3.unsat:
                m = get_model(s)
                print "model = {}, size = {}".format(m, sort_size)
                ##        print "clauses1 = {}".format(clauses1)
                ##        print "z3c = {}".format(str(z3c))
                syms = used_symbols_clauses(clauses1)
                if implied != None:
                    syms.update(used_symbols_clauses(implied))
                h = HerbrandModel(s, m, syms)
                s.pop()
                return h
            sort_size += 1
            s.pop()
    return h
示例#2
0
文件: ivy_solver.py 项目: xornand/ivy
def model_if_none(clauses1, implied, model):
    h = model
    if h == None:
        s = z3.Solver()
        z3c = clauses_to_z3(clauses1)
        s.add(z3c)
        if implied != None:
            s.add(not_clauses_to_z3(implied))
        sort_size = 1
        while True:
            s.push()
            for sort in ivy_logic.uninterpreted_sorts():
                s.add(formula_to_z3(sort_size_constraint(sort, sort_size)))
            if s.check() != z3.unsat:
                m = get_model(s)
                print "model = {}, size = {}".format(m, sort_size)
                ##        print "clauses1 = {}".format(clauses1)
                ##        print "z3c = {}".format(str(z3c))
                syms = used_symbols_clauses(clauses1)
                if implied != None:
                    syms.update(used_symbols_clauses(implied))
                h = HerbrandModel(s, m, syms)
                s.pop()
                return h
            sort_size += 1
            s.pop()
    return h
示例#3
0
文件: ivy_trace.py 项目: hannesm/ivy
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
示例#4
0
文件: ivy_trace.py 项目: odedp/ivy
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
def small_model_clauses(cls, final_cond=None, shrink=True):
    # Don't try to shrink the integers!
    return get_small_model(cls,
                           ivy_logic.uninterpreted_sorts(), [],
                           final_cond=final_cond,
                           shrink=shrink)
示例#6
0
文件: ivy_transrel.py 项目: odedp/ivy
def small_model_clauses(cls,final_cond=None):
    # Don't try to shrink the integers!
    return get_small_model(cls,ivy_logic.uninterpreted_sorts(),[],final_cond=final_cond)