% reach.pl (in B-Prolog): reachability test % by Neng-Fa Zhou, April 4, 2009 % https://www.mat.unical.it/aspcomp2013/FinalProblemDescriptions/Reachability main => read_file_terms().asp(). go => test. asp(As), cl_facts(As,$[edge(+,-),reaches(-,+),reaches(-,-)]), initialize_table, reaches(X0,_Y0), catch(reach(X0),solution_found,true) => println('ANSWER'), println('yes.'). asp(_As) => println('INCONSISTENT'), println('no.'). table reach(Y), reaches(_,Y) => throw(solution_found). reach(X) => edge(X,Y), reach(Y). test => asp($[edge(1,3),edge(3,4),edge(3,5),edge(4,2),edge(2,5),reaches(1,2)]).