Example #1
0
def implies(s1, s2):
    assert isinstance(s1, SemValue) and type(s1) is type(s2)
    op = s1.op
    axioms = im.background_theory()
    u1, c1, p1 = s1.comps
    u2, c2, p2 = s2.comps
    if u1 == None and u2 != None:
        return False


#    print "c1: {}".format(c1)
#    print "axioms: {}".format(axioms)
#    print "df: {}".format(diff_frame(u1,u2,relations,op))
    c1 = and_clauses(c1, axioms, diff_frame(u1, u2, op))
    if isinstance(c2, Clauses):
        if not c2.is_universal_first_order(
        ) or not p2.is_universal_first_order():
            return False
        c2 = and_clauses(c2, diff_frame(u2, u1, op))
        return clauses_imply(p1, p2) and clauses_imply(c1, c2)
    else:
        if not is_prenex_universal(c2) or not is_prenex_universal(p2):
            return False
        c2 = And(c2, clauses_to_formula(diff_frame(u2, u1, op)))
        return clauses_imply_formula_cex(p1, p2) and clauses_imply_formula_cex(
            c1, c2)
    def autodetect_transitive(self):
        import logic as lg
        from ivy_logic_utils import Clauses
        from ivy_solver import clauses_imply
        from concept import Concept

        #        self.edge_display_checkboxes['=']['transitive'].value = True
        #        self.edge_display_checkboxes['=']['all_to_all'].value = True

        self.transitive_relations = []
        self.transitive_relation_concepts = []

        axioms = im.module.background_theory()
        for c in il.all_symbols():
            if (type(c.sort) is lg.FunctionSort and c.sort.arity == 2
                    and c.sort.domain[0] == c.sort.domain[1]
                    and c.sort.range == lg.Boolean):
                X = lg.Var('X', c.sort.domain[0])
                Y = lg.Var('Y', c.sort.domain[0])
                Z = lg.Var('Z', c.sort.domain[0])
                transitive = lg.ForAll([X, Y, Z],
                                       lg.Or(lg.Not(c(X, Y)), lg.Not(c(Y, Z)),
                                             c(X, Z)))
                defined_symmetry = lg.ForAll([X, Y],
                                             lg.Or(c(X, X), lg.Not(c(Y, Y))))
                t = Clauses([transitive, defined_symmetry])
                if clauses_imply(axioms, t):
                    self.transitive_relations.append(c.name)
                    concept = self.current_concept_graph.g.formula_to_concept(
                        c(X, Y))
                    self.transitive_relation_concepts.append(concept)
                    self.current_concept_graph.show_relation(concept, 'T')
        if self.transitive_relations:
            self.current_concept_graph.update()
Example #3
0
    def autodetect_transitive(self):
        import logic as lg
        from ivy_logic_utils import Clauses
        from ivy_solver import clauses_imply
        from concept import Concept

#        self.edge_display_checkboxes['=']['transitive'].value = True
#        self.edge_display_checkboxes['=']['all_to_all'].value = True

        self.transitive_relations = []
        self.transitive_relation_concepts = []

        axioms = im.module.background_theory()
        for c in il.sig.symbols.values():
            if (type(c.sort) is lg.FunctionSort and
                c.sort.arity == 2 and
                c.sort.domain[0] == c.sort.domain[1] and
                c.sort.range == lg.Boolean):
                X = lg.Var('X', c.sort.domain[0])
                Y = lg.Var('Y', c.sort.domain[0])
                Z = lg.Var('Z', c.sort.domain[0])
                transitive = lg.ForAll([X, Y, Z], lg.Or(lg.Not(c(X,Y)), lg.Not(c(Y,Z)), c(X,Z)))
                defined_symmetry = lg.ForAll([X, Y], lg.Or(c(X,X), lg.Not(c(Y,Y))))
                t = Clauses([transitive, defined_symmetry])
                if clauses_imply(axioms, t):
                    self.transitive_relations.append(c.name)
                    concept = self.current_concept_graph.g.formula_to_concept(c(X,Y))
                    self.transitive_relation_concepts.append(concept)
                    self.current_concept_graph.show_relation(concept,'T')
        if self.transitive_relations:
            self.current_concept_graph.update()
Example #4
0
def filter_conjectures(state1,model):
    keep = []
    lose = []
    for c in state1.conjs:
        if clauses_imply(model,c):
            keep.append(c)
        else:
            lose.append(c)
    state1.conjs = keep
    return lose
Example #5
0
def implies(s1,s2,axioms,relations,op):
    u1,c1,p1 = s1
    u2,c2,p2 = s2
    if u1 == None and u2 != None:
        return False
#    print "c1: {}".format(c1)
#    print "axioms: {}".format(axioms)
#    print "df: {}".format(diff_frame(u1,u2,relations,op))
    c1 = and_clauses(c1,axioms,diff_frame(u1,u2,relations,op))
    if isinstance(c2,Clauses):
        if not c2.is_universal_first_order() or not p2.is_universal_first_order():
            return False
        c2 = and_clauses(c2,diff_frame(u2,u1,relations,op))
        return clauses_imply(p1,p2) and clauses_imply(c1,c2)
    else:
        if not is_prenex_universal(c2) or not is_prenex_universal(p2):
            return False
        c2 = And(c2,clauses_to_formula(diff_frame(u2,u1,relations,op)))
        return clauses_imply_formula_cex(p1,p2) and clauses_imply_formula_cex(c1,c2)
Example #6
0
def filter_conjectures(state1, model):
    keep = []
    lose = []
    for c in state1.conjs:
        if clauses_imply(model, c):
            keep.append(c)
        else:
            lose.append(c)
    state1.conjs = keep
    return lose
Example #7
0
def reverse_join_concrete_clauses(state,join_of,clauses=None):
    if clauses == None:
        clauses = state.clauses
    for s in join_of:
        if not clauses_imply(and_clauses(s.clauses,clauses),false_clauses()):
            return (and_clauses(s.clauses,clauses),s)
    pre = or_clauses(*[s.clauses for s in join_of])
    itp = interpolant(pre,clauses,state.domain.functions)
    if itp:
        raise UnsatCoreWithInterpolant(*itp)
    raise IvyError(None,"decision procedure incompleteness")
Example #8
0
def reverse_join_concrete_clauses(state, join_of, clauses=None):
    if clauses == None:
        clauses = state.clauses
    for s in join_of:
        if not clauses_imply(and_clauses(s.clauses, clauses), false_clauses()):
            return (and_clauses(s.clauses, clauses), s)
    pre = or_clauses(*[s.clauses for s in join_of])
    itp = interpolant(pre, clauses, state.domain.functions)
    if itp:
        raise UnsatCoreWithInterpolant(*itp)
    raise IvyError(None, "decision procedure incompleteness")
Example #9
0
def implies(s1,s2):
    assert isinstance(s1,SemValue) and type(s1) is type(s2)
    op = s1.op
    axioms = im.background_theory()
    u1,c1,p1 = s1.comps
    u2,c2,p2 = s2.comps
    if u1 == None and u2 != None:
        return False
#    print "c1: {}".format(c1)
#    print "axioms: {}".format(axioms)
#    print "df: {}".format(diff_frame(u1,u2,relations,op))
    c1 = and_clauses(c1,axioms,diff_frame(u1,u2,op))
    if isinstance(c2,Clauses):
        if not c2.is_universal_first_order() or not p2.is_universal_first_order():
            return False
        c2 = and_clauses(c2,diff_frame(u2,u1,op))
        return clauses_imply(p1,p2) and clauses_imply(c1,c2)
    else:
        if not is_prenex_universal(c2) or not is_prenex_universal(p2):
            return False
        c2 = And(c2,clauses_to_formula(diff_frame(u2,u1,op)))
        return clauses_imply_formula_cex(p1,p2) and clauses_imply_formula_cex(c1,c2)
Example #10
0
def undecided_conjectures(state1):
    clauses1 = and_clauses(state1.clauses,state1.domain.background_theory(state1.in_scope))
    return [c for c in state1.conjs if not clauses_imply(clauses1,c)]
Example #11
0
def undecided_conjectures(state1):
    clauses1 = and_clauses(state1.clauses,
                           state1.domain.background_theory(state1.in_scope))
    return [c for c in state1.conjs if not clauses_imply(clauses1, c)]