def exist_quant_map(syms, clauses):
    used = used_symbols_clauses(clauses)
    rn = UniqueRenamer('__', used)
    map1 = dict()
    for s in syms:
        map1[s] = rename(s, rn)
    return map1, rename_clauses(clauses, map1)
Esempio n. 2
0
def compose_updates(update1, axioms, update2):
    updated1, clauses1, pre1 = update1
    updated2, clauses2, pre2 = update2
    clauses2 = rename_distinct(clauses2, clauses1)
    pre2 = rename_distinct(pre2, clauses1)
    #    print "clauses2 = {}".format(clauses2)
    us1 = set(updated1)
    us2 = set(updated2)
    mid = us1.intersection(us2)
    mid_ax = clauses_using_symbols(mid, axioms)
    used = used_symbols_clauses(and_clauses(clauses1, clauses2))
    rn = UniqueRenamer('__m_', used)
    map1 = dict()
    map2 = dict()
    for v in updated1:
        map2[v] = new(v)
    for mv in mid:
        mvf = rename(mv, rn)
        map1[new(mv)] = mvf
        map2[mv] = mvf
    clauses1 = rename_clauses(clauses1, map1)
    new_clauses = and_clauses(
        clauses1, rename_clauses(and_clauses(clauses2, mid_ax), map2))
    new_updated = list(us1.union(us2))
    #    print "pre1 before = {}".format(pre1)
    pre1 = and_clauses(
        pre1, diff_frame(updated1, updated2, None,
                         new))  # keep track of post-state of assertion failure
    #    print "pre1 = {}".format(pre1)
    new_pre = or_clauses(
        pre1,
        and_clauses(clauses1, rename_clauses(and_clauses(pre2, mid_ax), map2)))
    #    print "new_pre = {}".format(new_pre)
    return (new_updated, new_clauses, new_pre)
def rename_distinct(clauses1, clauses2):
    """ rename skolems in clauses1 so they don't occur in clauses2.
    """
    #    print "rename_distinct clauses1 = {}".format(clauses1)
    #    print "rename_distinct clauses2 = {!r}".format(clauses2)
    used1 = used_symbols_clauses(clauses1)
    used2 = used_symbols_clauses(clauses2)
    rn = UniqueRenamer('', used2)
    map1 = dict()
    for s in used1:
        if is_skolem(s) and not is_global_skolem(s):
            map1[s] = rename(s, rn)
    return rename_clauses(clauses1, map1)
Esempio n. 4
0
def compose_updates(update1, axioms, update2):
    updated1, clauses1, pre1 = update1
    updated2, clauses2, pre2 = update2
    clauses2 = rename_distinct(clauses2, clauses1)
    pre2 = rename_distinct(pre2, clauses1)
    #    print "clauses2 = {}".format(clauses2)
    us1 = set(updated1)
    us2 = set(updated2)
    mid = us1.intersection(us2)
    mid_ax = clauses_using_symbols(mid, axioms)
    used = used_symbols_clauses(and_clauses(clauses1, clauses2))
    used.update(symbols_clauses(pre1))
    used.update(symbols_clauses(pre2))
    rn = UniqueRenamer('__m_', used)
    map1 = dict()
    map2 = dict()
    for v in updated1:
        map2[v] = new(v)
    for mv in mid:
        mvf = rename(mv, rn)
        map1[new(mv)] = mvf
        map2[mv] = mvf


#    iu.dbg('clauses1')
#    iu.dbg('clauses1.annot')
    clauses1 = rename_clauses(clauses1, map1)
    annot_op = lambda x, y: x.compose(
        y) if x is not None and y is not None else None
    new_clauses = and_clauses(clauses1,
                              rename_clauses(and_clauses(clauses2, mid_ax),
                                             map2),
                              annot_op=annot_op)
    new_updated = list(us1.union(us2))
    #    print "pre1 before = {}".format(pre1)
    #    iu.dbg('pre1.annot')
    #    iu.dbg('pre1')
    pre1 = and_clauses(pre1, diff_frame(
        updated1, updated2, new,
        axioms))  # keep track of post-state of assertion failure
    #    print "pre1 = {}".format(pre1)
    temp = and_clauses(clauses1,
                       rename_clauses(and_clauses(pre2, mid_ax), map2),
                       annot_op=my_annot_op)
    #    iu.dbg('temp.annot')
    new_pre = or_clauses(pre1, temp)
    #    iu.dbg('new_pre.annot')
    #    print "new_pre = {}".format(new_pre)
    #    iu.dbg('new_clauses')
    #    iu.dbg('new_clauses.annot')
    return (new_updated, new_clauses, new_pre)
Esempio n. 5
0
def distinct_variable_renaming(vars1, vars2):
    rn = UniqueRenamer('', (v.rep for v in vars2))
    return dict((v.rep, rename_variable(v, rn(v.rep))) for v in vars1)