Ejemplo n.º 1
0
    def eval(self,cond):
        if il.is_false(cond):
            res = False
        elif il.is_true(cond):
            res =  True
        else:
            res = il.is_true(self.aiger.get_sym(cond))
#        print 'eval: {} = {}'.format(cond,res)
        return res
Ejemplo n.º 2
0
 def eval(self, cond):
     truth = self.model.eval_to_constant(cond)
     if lg.is_false(truth):
         return False
     elif lg.is_true(truth):
         return True
     assert False, truth
Ejemplo n.º 3
0
 def eval(self,cond):
     if il.is_false(cond):
         return False
     if il.is_true(cond):
         return True
     print 'assuming: {}'.format(cond)
     return True
Ejemplo n.º 4
0
def aiger_witness_to_ivy_trace(aiger,witnessfilename,action,stvarset,ext_act,annot,consts,decoder):
    with open(witnessfilename,'r') as f:
        res = f.readline().strip()
        if res != '1':
            badwit()
        tr = None
        aiger.sub.reset()
        lines = []
        for line in f:
            if line.endswith('\n'):
                line = line[:-1]
            lines.append(line)
        print '\nCounterexample follows:'
        print 80*'-'
        current = dict()
        count = 0
        for line in lines:
            if tr:
                print ''
            cols = line.split(' ')
#            iu.dbg('cols')
            if len(cols) != 4:
                badwit()
            pre,inp,out,post = cols
            aiger.sub.step(inp)
            count += 1
            if count == len(lines):
                invar_fail = il.Symbol('invar__fail',il.find_sort('bool'))
                if il.is_true(aiger.get_sym(invar_fail)):
                    break
            # print 'inputs:'
            # for v in aiger.inputs:
            #     if v in decoder:
            #         print '    {} = {}'.format(decoder[v],aiger.get_sym(v))
            print 'path:'
            match_annotation(action,annot,AigerMatchHandler(aiger,decoder,consts,stvarset,current))
            aiger.sub.next()
            post = aiger.sub.latch_vals()  # use this, since file can be wrong!
            stvals = []
            stmap = aiger.get_state(post)                     
#            iu.dbg('stmap')
            current = dict()
            for v in aiger.latches: # last two are used for encoding
                if v in decoder and v.name != '__init':
                    val = stmap[v]
                    if val is not None:
                        stvals.append(il.Equals(decoder[v],val))
                        current[decoder[v]] = val
            print 'state:'
            for stval in stvals:
                print '    {}'.format(stval)
            if not tr:
                tr = IvyMCTrace(stvals) # first transition is initialization
            else:
                tr.add_state(stvals,ext_act) # remainder are exported actions
        print 80*'-'
        if tr is None:
            badwit()
        return tr
Ejemplo n.º 5
0
def vcgen(self,decls,proof):
    goal = decls[0]
    conc = pr.goal_conc(goal)
    decls = decls[1:]
    if not isinstance(conc,tm.TemporalModels) or not lg.is_true(conc.fmla):
        raise iu.IvyError(self,'vcgen tactic applies only to safety properties')
    model = conc.model
    goal1 = triple_to_goal(proof.lineno,'initiation',model.init,postcond=model.invars)
    goal2 = triple_to_goal(proof.lineno,'consecution',tm.env_action(model.bindings),
                           precond=model.invars+model.asms,postcond=model.invars)
    return [goal1,goal2] + decls[1:]
Ejemplo n.º 6
0
def check_subgoals(goals):
    mod = im.module
    for goal in goals:
        # print 'goal: {}'.format(goal)
        conc = ivy_proof.goal_conc(goal)
        if isinstance(conc, itmp.TemporalModels):
            model = conc.model
            fmla = conc.fmla
            if not lg.is_true(fmla):
                raise IvyError(
                    goal,
                    """The temporal subgoal {} has not been reduced to an invariance property. 
                     Try using a tactic such as l2s.""")
            mod = im.module.copy()
            mod.isolate_proof = None
            # mod.labeled_axioms.extend(proved)
            mod.labeled_props = []
            mod.concept_spaces = []
            mod.labeled_conjs = model.invars
            mod.public_actions = set(model.calls)
            mod.actions = model.binding_map
            mod.initializers = [('init', model.init)]
            mod.labeled_axioms = list(mod.labeled_axioms)
            mod.assumed_invars = model.asms
            for prem in ivy_proof.goal_prems(goal):
                if prem.temporal:
                    mod.labeled_axioms.append(prem)
            # ivy_printer.print_module(mod)
        else:
            goal = ivy_compiler.theorem_to_property(goal)
            mod = im.module.copy()
            # mod.labeled_axioms.extend(proved)
            mod.labeled_props = [goal]
            mod.concept_spaces = []
            mod.labeled_conjs = []
            mod.public_actions = set()
            mod.actions = dict()
            mod.initializers = []
            mod.isolate_proof = None
            mod.isolate_info = None
        with mod:
            check_isolate()