/* TEST.
Test Examples for Paper
Alan Bundy 15.6.81 */

/* Test run with timings */
run :- checklist(stats, [test1,test2,test3,test4,test5,test6,test7,
				test8,test9]).

/* Tests */

test1(I) :- int_apply( sin, [i(open,30,90,closed)], I).		% I = (1/2,1]
test2(I) :- int_apply( sin, [i(open,30,150,closed)], I).	% I = [1/2,1]
test3(I) :- int_apply( abs, [i(open,(-1),1,closed)], I).	% I = [0,1]
test4(I) :-		% I = [-oo,-2/3)
	int_apply( /, [i(open,2,3,closed), i(closed,(-3),-(0),closed)], I).
test5(I) :-		% I = [-3,3]
	int_apply( *, [i(closed,(-3),-(0),open), i(closed,(-1),1,closed)], I).
test6(I) :-		% I = [1/2,2]
	int_apply( ^, [i(open,1,2,closed), i(closed,(-1),1,closed)], I).
test7(I) :- find_int( (-m1)*g/(m1+m2) , I).		% I = (-oo,0)
test8(I) :- find_int( (sin(theta)+2)/cos(phi) , I).	% I = (-oo,oo)
test9(I) :- find_int( log(2,sin(theta)), I).		% I = (-oo,0)



quantity(m1q).		measure(m1q,m1).	% m1 is positive
quantity(m2q).		measure(m2q,m2).	% m2 is positive

quantity(thetaq).	measure(thetaq,theta).
quantity(phiq).		measure(phiq,phi).

incline(path3,thetaq,point).	slope(path3,right).	concavity(path3,stline).
	% Hence theta is acute

angle(point,phiq,semi).	partition(semi,[path1,path2]).
			slope(path1,left).		concavity(path1,right).
			slope(path2,right).		concavity(path2,right).
	% Hence phi is obtuse


/*Run problem with statistics*/

stats(Name) :- Problem=..[Name,Arg], statistics(runtime,_),
		call(Problem), !, statistics(runtime,[ _, Time]),
		trace('\n%t took %t milliseconds and produced answer %t\n\n', 
			[Name,Time,Arg], 0).

stats(Name) :- statistics(runtime,[ _, Time]),
  trace('\nSorry I could not prove %t and I spent %t not doing it \n\n', 
	[Name, Time], 0).
