Ejemplo n.º 1
0
def eval_assert_rhs(rhs, domain):
    if not isinstance(rhs, act.RME):
        rhs = act.RME(log.And(), [], rhs)
    return itp.eval_state(rhs, act.ActionContext(domain))
Ejemplo n.º 2
0
def eval_assert_rhs(rhs,domain):
    if not isinstance(rhs,act.RME):
        rhs = act.RME(log.And(),[],rhs)
    return itp.eval_state(rhs,act.ActionContext(domain))
Ejemplo n.º 3
0
        rhs = act.RME(log.And(), [], rhs)
    return itp.eval_state(rhs, act.ActionContext(domain))


if __name__ == "__main__":
    ag = ivy.ivy_init()
    ac = AC(ag.assertions, ag.actions, ag.domain)
    with utl.ErrorPrinter():
        for ass in ag.assertions:
            lhs = ass.args[0].rep
            rhs = ass.args[1]
            rhs_state = eval_assert_rhs(rhs, ag.domain)
            try:
                if lhs in ag.predicates:
                    with ac:
                        lhs_state = itp.eval_state(ag.predicates[lhs], ac)
                elif lhs in ag.actions:
                    with ac:
                        lhs_state = itp.eval_state(
                            act.entry(lg.Not(rhs_state.precond)), ac)
                        lhs_state = itp.apply_action(ass, lhs, ag.actions[lhs],
                                                     lhs_state)
                else:
                    raise utl.IvyError(ass, "{} undefined".format(lhs))
                print "lhs_state: %s" % lhs_state.clauses
                print "rhs_fmla: %s" % rhs_state.clauses
                cex = ag.domain.order(lhs_state, rhs_state)
                if not cex:
                    print repr(utl.IvyError(ass, "assertion does not hold"))
                    analyze_state(ag, lhs_state, cex.clauses)
            except itp.IvyActionFailedError as err:
Ejemplo n.º 4
0
    if not isinstance(rhs,act.RME):
        rhs = act.RME(log.And(),[],rhs)
    return itp.eval_state(rhs,act.ActionContext(domain))

if __name__ == "__main__":
    ag = ivy.ivy_init()
    ac = AC(ag.assertions,ag.actions,ag.domain)
    with utl.ErrorPrinter():
        for ass in ag.assertions:
            lhs = ass.args[0].rep
            rhs = ass.args[1]
            rhs_state = eval_assert_rhs(rhs,ag.domain)
            try:
                if lhs in ag.predicates:
                    with ac:
                        lhs_state = itp.eval_state(ag.predicates[lhs],ac)
                elif lhs in ag.actions:
                    with ac:
                        lhs_state = itp.eval_state(act.entry(lg.Not(rhs_state.precond)),ac)
                        lhs_state = itp.apply_action(ass,lhs,ag.actions[lhs],lhs_state)
                else:
                    raise utl.IvyError(ass,"{} undefined".format(lhs))
                print "lhs_state: %s" %  lhs_state.clauses
                print "rhs_fmla: %s" %  rhs_state.clauses
                cex = ag.domain.order(lhs_state,rhs_state)
                if not cex:
                    print repr(utl.IvyError(ass,"assertion does not hold"))
                    analyze_state(ag,lhs_state,cex.clauses)
            except itp.IvyActionFailedError as err:
                print repr(err)
                print err.error_state.clauses