示例#1
0
文件: ivy_ui.py 项目: ZZHGit/ivy
    def reverse_update_concrete_clauses(self, state, clauses):
        with RunContext(self):
            try:
                if state.pred != None:
                    print "reverse from %s to %s: post_state = %s" % (
                        state.id, state.pred.id, clauses)
                    next_state = state.pred
                    clauses = reverse_update_concrete_clauses(state, clauses)
                    return (clauses, state.pred)

                elif hasattr(state, 'join_of') and state.join_of:
                    next_state = state
                    return reverse_join_concrete_clauses(
                        state, state.join_of, clauses)

                return None

            except UnsatCoreWithInterpolant as ici:
                #                print "core: %s" % ici.core
                #                print "interp: %s" % ici.interp
                if ici.interp != None:
                    used_names = used_symbols_clauses(
                        Clauses([[Literal(0, a)]
                                 for a, d in self.g.domain.concept_spaces]))
                    name = unused_name_with_base(
                        'itp', set(s.name for s in used_names))
                    concept = clauses_to_concept(name, ici.interp)
                    dlg = Toplevel(self)
                    Label(
                        dlg,
                        text=
                        "The pre-state is vacuous. The following concept can be used to prove your goal in the post-state:"
                    ).pack()
                    S = Scrollbar(dlg)
                    T = Text(dlg, height=4, width=100)
                    S.pack(side=RIGHT, fill=Y)
                    T.pack(side=LEFT, fill=Y)
                    S.config(command=T.yview)
                    T.config(yscrollcommand=S.set)
                    T.insert(
                        END, 'concept ' + repr(concept[0]) + ' = ' + repr(
                            concept[1]))
                    b = Button(dlg, text="OK", command=dlg.destroy)
                    b.pack(padx=5, side=TOP)
                    b = Button(
                        dlg,
                        text="Refine",
                        command=functools.partial(self.refine, concept, dlg))
                    b.pack(padx=5, side=TOP)
                    uu.center_window_on_window(dlg, self.root)
                    self.tk.wait_window(dlg)
                    return (false_clauses(), next_state)
                raise IvyError(None,
                               "UNSAT, but interpolant could not be computed")
        return ([[]], next_state)
示例#2
0
文件: ivy_ui.py 项目: asyaf/ivy
    def reverse_update_concrete_clauses(self, state, clauses):
        with RunContext(self):
            try:
                if state.pred != None:
                    print "reverse from %s to %s: post_state = %s" % (
                        state.id, state.pred.id, clauses)
                    next_state = state.pred
                    clauses = reverse_update_concrete_clauses(state, clauses)
                    return (clauses, state.pred)

                elif hasattr(state, 'join_of') and state.join_of:
                    next_state = state
                    return reverse_join_concrete_clauses(
                        state, state.join_of, clauses)

                return None

            except UnsatCoreWithInterpolant as ici:
                #                print "core: %s" % ici.core
                #                print "interp: %s" % ici.interp
                if ici.interp != None:
                    used_names = used_symbols_clauses(
                        Clauses([[Literal(0, a)]
                                 for a, d in self.g.domain.concept_spaces]))
                    name = unused_name_with_base(
                        'itp', set(s.name for s in used_names))
                    concept = clauses_to_concept(name, ici.interp)
                    dlg = Toplevel(self)
                    Label(
                        dlg,
                        text=
                        "The pre-state is vacuous. The following concept can be used to prove your goal in the post-state:"
                    ).pack()
                    S = Scrollbar(dlg)
                    T = Text(dlg, height=4, width=100)
                    S.pack(side=RIGHT, fill=Y)
                    T.pack(side=LEFT, fill=Y)
                    S.config(command=T.yview)
                    T.config(yscrollcommand=S.set)
                    T.insert(
                        END, 'concept ' + repr(concept[0]) + ' = ' +
                        repr(concept[1]))
                    b = Button(dlg, text="OK", command=dlg.destroy)
                    b.pack(padx=5, side=TOP)
                    b = Button(dlg,
                               text="Refine",
                               command=functools.partial(
                                   self.refine, concept, dlg))
                    b.pack(padx=5, side=TOP)
                    uu.center_window_on_window(dlg, self.root)
                    self.tk.wait_window(dlg)
                    return (false_clauses(), next_state)
                raise IvyError(None,
                               "UNSAT, but interpolant could not be computed")
        return ([[]], next_state)
示例#3
0
文件: ivy_ui.py 项目: appcoreopc/ivy
 def interp_to_refinement(self,interp):
     used_names = used_symbols_clauses(Clauses([[Literal(0,a)] for a,d in self.g.domain.concept_spaces]))
     name = unused_name_with_base('itp',set(s.name for s in used_names))
     return clauses_to_concept(name,interp)