
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HotLog (Higher-order TopLog)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:-['HotLog.pl'].


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Data set
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*--------- Toy Example ---------*/

/*--------- Real-world ---------*/

/*--------- Higher-order Predicate Invention ---------*/
%:-['datasets/regular_grammar/running.pl'].
:-['datasets/context_free_grammar/running.pl']. %cf_bot
%:-['datasets/context_free_grammar/cf_bot.pl']. 
%:-['datasets/unified_version/running.pl']. 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output Version Information
hotLog_version(1).
hotLog_manual('http://ilp.doc.ic.ac.uk/hotLog/user_manual.html').

versionInfo:-
	nl, nl,
	write('MC-TopLog Version '), 
	hotLog_version(Version), write(Version), nl,
	hotLog_manual(Man),
	write('Manual: '),
	write(Man), nl, nl.


o:- overall_run.


% use for pa.script
pa:-	yap_flag(argv,[InputFile1,InputFile2]),
	consult(InputFile2),
	atom_chars(InputFile2,InputFile2Chars),
	%append(Pre,[e,x,'_',ProblemSize,'_',Index,'.',p,l],InputFile2Chars),
	append(Pre,[e,x,'_'|Rest],InputFile2Chars),
	append(Problem_infoChars,['.',p,l],Rest),
	atom_chars(Problem_info,Problem_infoChars),
	%write({ProblemSize,Index}),
	%nl.
	asserta(problem_info(Problem_info,Index)),
	it,
	retract(problem_info(Problem_info,Index)).


sg:-
	yap_flag(argv,[Index0]),
	atom_number(Index0,Index),%write(Index),
	%Index=1,
	srandom(Index),
	Rand is random,
	srandom(Index),X is random,%write('%----------test'),write(X),nl,
	sample(parse(Seq,G)),%write('%Another sample:'),write(G),nl,
	\+filter(Seq,G),
	remove_duplicates(G,G0),
	reduce_clause([start(s)|G0],NonRedundantG),%write(' Reduced Successfully '),
	length(NonRedundantG,GrammarSize),
	extract_nonTerminals(NonRedundantG,NTs),length(NTs,NumNTs),%write('Parameters: '),write({NumNTs,GrammarSize}), %%***Different from RG
	portray_clause(cfg(NumNTs-GrammarSize,NonRedundantG)).


