prove(Fact, Cert):-
	if_then(Conditions,Fact),
	infer_each(Conditions, Cert).
prove(Fact, Cert):-
	ask(Fact, Cert).

infer_each([], 1).
infer_each([Fact|Rest], Cert):-
	prove(Fact, C1),
	infer_each(Rest, C2),
	min(C1, C2, Cert).

min(X, Y, X):- X < Y, !.
min(X, Y, Y).

ask(Fact, Cert):-
	write('Please give certainty for '), write(Fact), write('...'), nl,
	read(Cert).

run:-
	retractall(if_then(_,_)),
	write('Select a knowledge base ...'),
	read(KB),
	load_files([KB], [compilation_mode(assert_all)]),
	write('Type in a goal ...'),
	read(Goal),
	prove(Goal, Cert),
	write('Certainty is '), write(Cert), nl, !.

