/* Inductive Logic Programming in Picat v3. This is a port of the program hyper.pl in I. Bratko, "Prolog Programming for Artificial Intelligence", 4th edn., Pearson Education / Addison-Wesley 2012 Page 507ff (Figure 21.7 and 21.3) The module hyper_v3 is here http://hakank.org/picat/hyper_v3.pi Result (0.04s): """ Hypotheses generated: 401 Hypotheses refined: 35 To be refined: 109 path(A,A,A). path(A,C,[A,B|E]):- link(A,B), path(B,C,[D|E]). """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import hyper_v3. main => go. go ?=> induce(H), show_hyp(H), nl. go => true. % Moved from from hyper_v3.pi max_proof_length( 6). % Max. proof length, counting calls to preds. in hypothesis max_clauses( 4). % Max. number of clauses in hypothesis max_clause_length( 5). % Max. number of literals in a clause % Example % Figure 21.9 Learning about a path in a graph. % Learning about path: path(StartNode,GoalNode,Path) % A directed graph link(a,b). link(a,c). link(b,c). link(b,d). link(d,e). backliteral( link(X,Y), [ type(X,item)], [ type(Y,item)]). backliteral( path(X,Y,L), [ type(X,item)], [ type(Y,item), type(L,list)]). term( list, [X|L], [ type(X,item), type(L,list)]). term( list, [], []). prolog_predicate( link(X,Y)). start_clause( [ path(X,Y,L)] / [type(X,item),type(Y,item),type(L,list)] ). % Examples ex( path( a, a, [a])). ex( path( b, b, [b])). ex( path( e, e, [e])). ex( path( f, f, [f])). ex( path( a, c, [a,c])). ex( path( b, e, [b,d,e])). ex( path( a, e, [a,b,d,e])). nex( path( a, a, [])). nex( path( a, a, [b])). nex( path( a, a, [b,b])). nex( path( e, d, [e,d])). nex( path( a, d, [a,b,c])). nex( path( a, c, [a])). nex( path( a, c, [a,c,a,c])). nex( path( a, d, [a,d])).