Esempio n. 1
0
 def extra_concepts(self):
     tn = self.text_name()
     X, Y = self.variable('X'), self.variable('Y')
     c = [
         Literal(1, Atom(tn, [X])), ~eq_lit(X, Y),
         Literal(1, Atom(tn, [Y]))
     ]
     cs = [ProductSpace([NamedSpace(x) for x in c])]
     w = get_witness(self)
     if w:
         cls = [[~lit, eq_lit(X, w)] for lit in self.fmla]
         cs += [ProductSpace([NamedSpace(x) for x in c]) for c in cls]
     return cs
Esempio n. 2
0
    def get_solver_clauses(self):
        #        expr = self.state_as_z3_expr
        if use_ivy_alpha:
            d = ProgressiveDomain(verbose=True)
            self.post = d
            sorts = sorted(set(n.sort for n in self.all_nodes))
            concepts = []
            for s in sorts:
                nconcepts = [n.to_concept_space() for n in self.all_nodes]
                nconcepts.append(
                    (node_concept(s, 'X').atom,
                     SumSpace(
                         [NamedSpace(Literal(1, x)) for x, y in nconcepts])))
                nconcepts.append(
                    (xtra_concept(s, 'X', 'Y').atom,
                     SumSpace([
                         x for n in self.all_nodes for x in n.extra_concepts()
                     ])))
                concepts += nconcepts
            concepts = concepts + self.relation_concepts([
                r for r in self.relations if r.name() in self.enabled_relations
            ])
            d.concept_spaces = concepts
            #    #        print "concepts: %s" % concepts
            d.post_init(self.state, [], {}, [])
            clauses = self.compile_concepts(concepts)
#    #        print "clauses: %s" % clauses
        else:
            clauses = self.state
#        print "graph solver clauses = {}".format(clauses)
        s_add(self.solver, clauses_to_z3(clauses))
        self.solver_clauses = and_clauses(self.solver_clauses, clauses)
Esempio n. 3
0
def clauses_to_concept(name, clauses):
    vars = used_variables_clauses(clauses)
    ps = [
        ProductSpace([NamedSpace(~lit) for lit in clause])
        for clause in clauses
    ]
    ss = ps[0] if len(ps) == 1 else SumSpace(ps)
    return (Atom(name, vars), ss)
Esempio n. 4
0
 def relation_concepts(self, relations):
     rcons = [r.to_concept_space() for r in relations]
     rprods = [
         ProductSpace([
             NamedSpace(x) for x in [
                 node_concept(r.sorts[0], 'X'),
                 Literal(1, cs[0]),
                 node_concept(r.sorts[1], 'Y')
             ]
         ]) for (r, cs) in zip(relations, rcons)
     ]
     rsp = to_atom('__rsp(X,Y)'), SumSpace(rprods)
     return rcons + [rsp]
Esempio n. 5
0
def p_expr_exprterm_tildaeq_exprterm(p):
    "expr : exprterm TILDAEQ exprterm"
    p[0] = NamedSpace(Literal(0, Atom("=", [p[1], p[3]])))
    p[0].lineno = get_lineno(p, 2)
Esempio n. 6
0
def p_expr_exprterm_relop_exprterm(p):
    "expr : exprterm relop exprterm"
    p[0] = NamedSpace(Literal(1, Atom(p[2], [p[1], p[3]])))
    p[0].lineno = get_lineno(p, 2)
Esempio n. 7
0
def p_expr_tilda_atom(p):
    'expr : TILDA expr'
    p[0] = NamedSpace(~p[2].lit)
Esempio n. 8
0
def p_expr_exprterm_tildaeq_exprterm(p):
    'expr : exprterm TILDAEQ exprterm'
    p[0] = NamedSpace(Literal(0, Atom('=', [p[1], p[3]])))
    p[0].lineno = get_lineno(p, 2)
Esempio n. 9
0
def p_expr_exprterm_relop_exprterm(p):
    'expr : exprterm relop exprterm'
    p[0] = NamedSpace(Literal(1, Atom(p[2], [p[1], p[3]])))
    p[0].lineno = get_lineno(p, 2)
Esempio n. 10
0
def p_expr_exprterm(p):
    'expr : exprterm'
    p[0] = NamedSpace(Literal(1, app_to_atom(p[1])))
Esempio n. 11
0
def p_expr_fmla(p):
    'expr : LCB fmla RCB'
    p[0] = NamedSpace(Literal(1, p[2]))
Esempio n. 12
0
 def to_concept_space(self):
     rel_lit = self.rel_lit
     return Atom('__' + rel_lit.atom.rep, rel_lit.atom.args), SumSpace(
         [NamedSpace(rel_lit), NamedSpace(~rel_lit)])
Esempio n. 13
0
 def to_concept_space(self):
     return Atom(self.text_name(), [self.variable('X')]), ProductSpace(
         [NamedSpace(x) for x in self.fmla])
Esempio n. 14
0
def p_expr_exprterm_tildaeq_exprterm(p):
    'expr : exprterm TILDAEQ exprterm'
    p[0] = NamedSpace(Literal(0,Atom('=',[p[1],p[3]])))
    p[0].lineno = p.lineno(2)
Esempio n. 15
0
def p_expr_exprterm_relop_exprterm(p):
    'expr : exprterm relop exprterm'
    p[0] = NamedSpace(Literal(1,Atom(p[2],[p[1],p[3]])))
    p[0].lineno = p.lineno(2)