Esempio n. 1
0
def decompose_action_app(state2,expr):
    assert is_action_app(expr)
    action = eval_action(expr.rep)
    state1 = eval_state(expr.args[0])
    comps = action.decompose(state1.value,state2.value)
    bg = state1.domain.background_theory(state1.in_scope)
    for pre,acts,post in comps:
        print "pre core: {} ".format(unsat_core(and_clauses(pre[1],bg),true_clauses()))
        print "post core: {} ".format(unsat_core(and_clauses(post[1],bg),true_clauses()))
        upds = [act.update(state1.domain,state1.in_scope) for act in acts]
        h = History(pre)
#        print "h.post: {}".format(h.post)
        for upd in upds:
#            print "upd: {}".format(upd)
            h = h.forward_step(bg,upd)
#            print "h.post: {}".format(h.post)
        h = h.assume(post)
#        print "h.post: {}".format(h.post)
        bmc_res = h.satisfy(bg)
        if bmc_res == None:
            continue
        universe,path = bmc_res
        states = []
        for i,value in enumerate(path):
#            print "core: {} ".format(unsat_core(and_clauses(value[1],bg),true_clauses()))
            state = new_state(value)
            if i != 0:
                state.expr = action_app(acts[i-1],states[-1])
                state.update = upds[i-1]
                state.pred = states[-1]
            state.label = None
            state.universe = universe
            states.append(state)
        return state
    return None
Esempio n. 2
0
def decompose_action_app(state2, expr):
    assert is_action_app(expr)
    action = eval_action(expr.rep)
    state1 = eval_state(expr.args[0])
    comps = action.decompose(state1.value, state2.value)
    bg = state1.domain.background_theory(state1.in_scope)
    for pre, acts, post in comps:
        upds = [act.update(state1.domain, state1.in_scope) for act in acts]
        h = History(pre)
        #        print "h.post: {}".format(h.post)
        for upd in upds:
            #            print "upd: {}".format(upd)
            h = h.forward_step(bg, upd)


#            print "h.post: {}".format(h.post)
        h = h.assume(post)
        #        print "h.post: {}".format(h.post)
        bmc_res = h.satisfy(bg)
        if bmc_res == None:
            continue
        universe, path = bmc_res
        states = []
        for i, value in enumerate(path):
            state = new_state(value)
            if i != 0:
                state.expr = action_app(acts[i - 1], states[-1])
                state.update = upds[i - 1]
                state.pred = states[-1]
            state.label = None
            state.universe = universe
            states.append(state)
        return state
    return None
Esempio n. 3
0
def new_history(state):
    return History(state.value)