def show_used_relations(self, clauses, both=False):
     self.current_concept_graph.clear_edges()
     rels = self.current_concept_graph.g.relations
     used = set(
         il.normalize_symbol(s)
         for s in lu.used_constants(clauses.to_formula()))
     for rel in rels:
         fmla = rel.formula
         if any(c in used and not c.name.startswith('@')
                for c in lu.used_constants(fmla)):
             self.current_concept_graph.show_relation(rel,
                                                      '+',
                                                      update=False)
             if both and not il.is_enumerated(fmla):
                 self.current_concept_graph.show_relation(rel,
                                                          '-',
                                                          update=False)
     need_update_relations = False
     for app in ilu.apps_clauses(clauses):
         if len(app.args) == 3 and il.is_numeral(app.args[0]):
             fmla = app.rep(app.args[0], il.Variable('X', app.args[1].sort),
                            il.Variable('Y', app.args[2].sort))
             concept = self.current_concept_graph.g.formula_to_concept(fmla)
             self.current_concept_graph.g.new_relation(concept)
             need_update_relations = True
             self.current_concept_graph.show_relation(concept,
                                                      '+',
                                                      update=False)
             if both:
                 self.current_concept_graph.show_relation(concept,
                                                          '-',
                                                          update=False)
     if need_update_relations:
         self.current_concept_graph.update_relations()
     self.current_concept_graph.update()
예제 #2
0
파일: ivy_solver.py 프로젝트: odedp/ivy
def model_facts(h, ignore, clauses1, upclose=False):
    # define the universe for each sort:
    uc = [fact for s in h.sorts() for fact in model_universe_facts(h, s, upclose)]
    # values of constants in formula
    temp = [
        [(ivy_logic.Constant(c), get_model_constant(h.model, ivy_logic.Constant(c)))]
        for c in used_constants_clauses(clauses1)
        if not ignore(c) and c not in ivy_logic.sig.constructors
    ]
    #    print "temp = {}".format(temp)
    vc = [
        [ivy_logic._eq_lit(ivy_logic.Constant(c), get_model_constant(h.model, ivy_logic.Constant(c)))]
        for c in used_constants_clauses(clauses1)
        if not ignore(c) and c not in ivy_logic.sig.constructors
    ]
    #    print "model_facts vc = {}".format(vc)
    # values of relations in formula
    #    print "used_relations_clauses = {}".format(used_relations_clauses(clauses1))
    urc = dict((ivy_logic.normalize_symbol(r), n) for r, n in used_relations_clauses(clauses1).iteritems())
    vr = [[l] for (r, n) in urc.iteritems() if not ignore(r) for l in relation_model_to_clauses(h, r, n)]
    # values of functions in formula
    fns = set(f for (f, arity) in functions_clauses(clauses1) if not ignore(f) and arity >= 1)
    vf = [[l] for f in fns for l in function_model_to_clauses(h, f)]
    res = uc + vc + vr + vf
    return Clauses(res)
예제 #3
0
파일: ivy_solver.py 프로젝트: JpHolmen/ivy
def model_facts(h, ignore, clauses1, upclose=False):
    # define the universe for each sort:
    uc = [
        fact for s in h.sorts()
        for fact in model_universe_facts(h, s, upclose)
    ]
    # values of constants in formula
    temp = [[(ivy_logic.Constant(c),
              get_model_constant(h.model, ivy_logic.Constant(c)))]
            for c in used_constants_clauses(clauses1)
            if not ignore(c) and c not in ivy_logic.sig.constructors]
    #    print "temp = {}".format(temp)
    vc = [[
        ivy_logic._eq_lit(ivy_logic.Constant(c),
                          get_model_constant(h.model, ivy_logic.Constant(c)))
    ] for c in used_constants_clauses(clauses1)
          if not ignore(c) and c not in ivy_logic.sig.constructors]
    #    print "model_facts vc = {}".format(vc)
    # values of relations in formula
    #    print "used_relations_clauses = {}".format(used_relations_clauses(clauses1))
    urc = dict((ivy_logic.normalize_symbol(r), n)
               for r, n in used_relations_clauses(clauses1).iteritems())
    vr = [[l] for (r, n) in urc.iteritems() if not ignore(r)
          for l in relation_model_to_clauses(h, r, n)]
    # values of functions in formula
    fns = set(f for (f, arity) in functions_clauses(clauses1)
              if not ignore(f) and arity >= 1)
    vf = [[l] for f in fns for l in function_model_to_clauses(h, f)]
    res = uc + vc + vr + vf
    return Clauses(res)
예제 #4
0
파일: ivy_graph.py 프로젝트: yotamfe/ivy
 def state_changed(self,recomp=True):
     cs = self.concept_session
     cs.cache.clear()
     vocab = list(ilu.used_symbols_asts([c.formula for c in self.nodes]))
     fsyms = list(s for s in ilu.used_symbols_ast(cs._to_formula()) if not s.is_skolem())
     vocab += list(all_symbols()) + fsyms
     vocab = [il.normalize_symbol(s) for s in vocab]
     cs.domain = replace_concept_domain_vocabulary(cs.domain,set(vocab))
     for concept in self.new_relations:
         add_domain_concept(self.concept_domain.concepts,concept)
     if recomp:
         self.recompute()
예제 #5
0
 def state_changed(self, recomp=True):
     cs = self.concept_session
     cs.cache.clear()
     vocab = list(ilu.used_symbols_asts([c.formula for c in self.nodes]))
     fsyms = list(s for s in ilu.used_symbols_ast(cs._to_formula())
                  if not s.is_skolem())
     vocab += list(all_symbols()) + fsyms
     vocab = [il.normalize_symbol(s) for s in vocab]
     cs.domain = replace_concept_domain_vocabulary(cs.domain, set(vocab))
     for concept in self.new_relations:
         add_domain_concept(self.concept_domain.concepts, concept)
     if recomp:
         self.recompute()
예제 #6
0
파일: ivy_ui_cti.py 프로젝트: odedp/ivy
 def show_used_relations(self,clauses,both=False):
     self.current_concept_graph.clear_edges()
     rels = self.current_concept_graph.g.relations
     used = set(il.normalize_symbol(s) for s in lu.used_constants(clauses.to_formula()))
     for rel in rels:
         if any(c in used and not c.name.startswith('@')
                for c in lu.used_constants(rel.formula)):
             self.current_concept_graph.show_relation(rel,'+',update=False)
             if both:
                 self.current_concept_graph.show_relation(rel,'-',update=False)
     need_update_relations = False
     for app in ilu.apps_clauses(clauses):
         if len(app.args) == 3 and il.is_numeral(app.args[0]):
             fmla = app.rep(app.args[0],il.Variable('X',app.args[1].sort),il.Variable('Y',app.args[2].sort))
             concept = self.current_concept_graph.g.formula_to_concept(fmla)
             self.current_concept_graph.g.new_relation(concept)
             need_update_relations = True
             self.current_concept_graph.show_relation(concept,'+',update=False)
             if both:
                 self.current_concept_graph.show_relation(concept,'-',update=False)
     if need_update_relations:
         self.current_concept_graph.update_relations()
     self.current_concept_graph.update()