예제 #1
0
def derive_case_split (rep, n_vcs, checks):
	last_derive_case_split[0] = (rep.p, n_vcs, checks)
	# remove duplicate pcs
	n_vcs_uniq = dict ([(rep.get_pc (n_vc), (i, n_vc))
		for (i, n_vc) in enumerate (n_vcs)]).values ()
	n_vcs = [n_vc for (i, n_vc) in sorted (n_vcs_uniq)]
	assert n_vcs
	tag = rep.p.node_tags[n_vcs[0][0]][0]
	keep_n_vcs = []
	test_n_vcs = n_vcs
	mk_thyps = lambda n_vcs: [rep_graph.pc_true_hyp ((n_vc, tag))
		for n_vc in n_vcs]
	while len (test_n_vcs) > 1:
		i = len (test_n_vcs) / 2
		test_in = test_n_vcs[:i]
		test_out = test_n_vcs[i:]
		checks2 = [(hyps + mk_thyps (test_in + keep_n_vcs), hyp, nm)
			for (hyps, hyp, nm) in checks]
		(verdict, _) = check.test_hyp_group (rep, checks2)
		if verdict:
			# forget n_vcs that were tested out
			test_n_vcs = test_in
		else:
			# focus on n_vcs that were tested out
			test_n_vcs = test_out
			keep_n_vcs.extend (test_in)
	[(n, vc)] = test_n_vcs
	return ('CaseSplit', ((n, tag), [n]))
예제 #2
0
    def do_checks (eqs):
        checks = (linear_eq_induct_step_checks (p, restrs, hyps, tag, split, eqs)
            + linear_eq_induct_base_checks (p, restrs, hyps, tag, split, eqs))

        groups = check.proof_check_groups (checks)
        for group in groups:
            (res, _) = check.test_hyp_group (rep, group)
            if not res:
                return False
        return True
예제 #3
0
    def do_checks(eqs_assume, eqs):
        checks = (check.single_loop_induct_step_checks(
            p, restrs, hyps, tag, split, 1, eqs, eqs_assume=eqs_assume) +
                  check.single_loop_induct_base_checks(p, restrs, hyps, tag,
                                                       split, 1, eqs))

        groups = check.proof_check_groups(checks)
        for group in groups:
            (res, _) = check.test_hyp_group(rep, group)
            if not res:
                return False
        return True
예제 #4
0
def proof_failed_groups(p=None, proof=None):
    if p == None:
        p = problem.last_problem[0]
    if proof == None:
        proof = search.last_proof[0]
    checks = check.proof_checks(p, proof)
    groups = check.proof_check_groups(checks)
    failed = []
    for group in groups:
        rep = rep_graph.mk_graph_slice(p)
        (res, el) = check.test_hyp_group(rep, group)
        if not res:
            failed.append(group)
            print "Failed element: %s" % el
    failed_nms = set([s for group in failed for (_, _, s) in group])
    print "Failed: %s" % failed_nms
    return failed
예제 #5
0
def proof_failed_groups(p=None, proof=None):
    if p == None:
        p = problem.last_problem[0]
    if proof == None:
        proof = search.last_proof[0]
    checks = check.proof_checks(p, proof)
    groups = check.proof_check_groups(checks)
    failed = []
    for group in groups:
        rep = rep_graph.mk_graph_slice(p)
        (res, el) = check.test_hyp_group(rep, group)
        if not res:
            failed.append(group)
            print 'Failed element: %s' % el
    failed_nms = set([s for group in failed for (_, _, s) in group])
    print 'Failed: %s' % failed_nms
    return failed
예제 #6
0
 j_seq_opts = [(0, 1), (0, 2), (1, 1)]
 tags = [p.node_tags[asm_split][0], c_tag]
 try:
     split = search.find_split(rep, asm_split, restrs, hyps, i_seq_opts, j_seq_opts, 5, tags=[asm_tag, c_tag])
 except solver.SolverFailure, e:
     return None
 if not split or split[0] != "Split":
     trace("no split found (%s)." % repr(split))
     return None
 (_, split) = split
 rep = rep_graph.mk_graph_slice(p)
 checks = check.split_checks(p, (), hyps, split, tags=[asm_tag, c_tag])
 groups = check.proof_check_groups(checks)
 try:
     for group in groups:
         (res, el) = check.test_hyp_group(rep, group)
         if not res:
             trace("split check failed!")
             trace("failed at %s" % el)
             return None
 except solver.SolverFailure, e:
     return None
 (as_details, c_details, _, n, _) = split
 (c_split, (seq_start, step), _) = c_details
 c_bound = dict(c_bounds).get(p.loop_id(c_split))
 if not c_bound:
     trace("key split was not bounded (%r, %r)." % (c_split, c_bounds))
     return None
 (c_bound, _) = c_bound
 max_it = (c_bound - seq_start) / step
 assert max_it > n, (max_it, n)
예제 #7
0
                               i_seq_opts,
                               j_seq_opts,
                               5,
                               tags=[asm_tag, c_tag])
 except solver.SolverFailure, e:
     return None
 if not split or split[0] != 'Split':
     trace('no split found (%s).' % repr(split))
     return None
 (_, split) = split
 rep = rep_graph.mk_graph_slice(p)
 checks = check.split_checks(p, (), hyps, split, tags=[asm_tag, c_tag])
 groups = check.proof_check_groups(checks)
 try:
     for group in groups:
         (res, el) = check.test_hyp_group(rep, group)
         if not res:
             trace('split check failed!')
             trace('failed at %s' % el)
             return None
 except solver.SolverFailure, e:
     return None
 (as_details, c_details, _, n, _) = split
 (c_split, (seq_start, step), _) = c_details
 c_bound = dict(c_bounds).get(p.loop_id(c_split))
 if not c_bound:
     trace('key split was not bounded (%r, %r).' % (c_split, c_bounds))
     return None
 (c_bound, _) = c_bound
 max_it = (c_bound - seq_start) / step
 assert max_it > n, (max_it, n)