Exemple #1
0
def build_proof_rec (searcher, p, restrs, hyps):
	trace ('doing build proof rec with restrs = %r, hyps = %r' % (restrs, hyps))

	(kind, details) = searcher (p, restrs, hyps)
	last_searcher_results.append ((p, restrs, hyps, kind, details))
	del last_searcher_results[:-10]
	trace ('proof searcher found %s, %s' % (kind, details))
	if kind == 'Restr':
		(restr_kind, restr_points) = details
		return build_proof_rec_with_restrs (restr_points, restr_kind,
			searcher, p, restrs, hyps)
	elif kind == 'Leaf':
		return ProofNode ('Leaf', None, ())
	assert kind in ['CaseSplit', 'Split']
	split = details
	[(_, hyps1, _), (_, hyps2, _)] = check.proof_subproblems (p, kind,
		split, restrs, hyps, '')
	if kind == 'CaseSplit':
		return ProofNode ('CaseSplit', split,
			[build_proof_rec (searcher, p, restrs, hyps1),
				build_proof_rec (searcher, p, restrs, hyps2)])
	split_points = check.split_heads (split)
	no_loop_proof = build_proof_rec_with_restrs (split_points,
		'Number', searcher, p, restrs, hyps1)
	loop_proof = build_proof_rec_with_restrs (split_points,
		'Offset', searcher, p, restrs, hyps2)
	return ProofNode ('Split', split,
		[no_loop_proof, loop_proof])
Exemple #2
0
def use_split_searcher (p, split):
	xs = set ([p.loop_id (h) for h in check.split_heads (split)])
	def searcher (p, restrs, hyps):
		ys = set ([p.loop_id (h)
			for h in init_loops_to_split (p, restrs)])
		if xs <= ys:
			return ('Split', split)
		else:
			return default_searcher (p, restrs, hyps)		
	return searcher
Exemple #3
0
def build_proof_rec (searcher, p, restrs, hyps, name = "problem"):
	trace ('doing build proof rec with restrs = %r, hyps = %r' % (restrs, hyps))

	(kind, details) = searcher (p, restrs, hyps)
	last_searcher_results.append ((p, restrs, hyps, kind, details, name))
	del last_searcher_results[:-10]
	if kind == 'Restr':
		(restr_kind, restr_points) = details
		printout ("Discovered that points [%s] can be bounded"
			% ', '.join ([restr_point_name (p, n)
				for n in restr_points]))
		printout ("  (in %s)" % name)
		return build_proof_rec_with_restrs (restr_points, restr_kind,
			searcher, p, restrs, hyps, name = name)
	elif kind == 'Leaf':
		return ProofNode ('Leaf', None, ())
	assert kind in ['CaseSplit', 'Split']
	split = details
	if kind == 'CaseSplit':
		(split, hints) = details
	[(_, hyps1, nm1), (_, hyps2, nm2)] = check.proof_subproblems (p, kind,
		split, restrs, hyps, name)
	if kind == 'CaseSplit':
		printout ("Decided to case split at %s" % str (split))
		printout ("  (in %s)" % name)
		restr_points = hints
		kinds = ['Number', 'Number']
	else:
		restr_points = check.split_heads (split)
		kinds = ['Number', 'Offset']
		printout ("Discovered a loop relation for split points %s"
			% list (restr_points))
		printout ("  (in %s)" % name)
	subpfs = [build_proof_rec_with_restrs (restr_points, k,
			searcher, p, restrs, hyps_i, must_find = False,
			name = nm)
		for (nm, hyps_i, k)
		in [(nm1, hyps1, kinds[0]), (nm2, hyps2, kinds[1])]]
	return ProofNode (kind, split, subpfs)