/* 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 Final result (39ms): """ Hypotheses generated: 85 Hypotheses refined: 16 To be refined: 29 even([]). even([A,B|C]):- even(C). odd([A|B]):- even(B). """ 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 % Figure 21.8 Learning about odd-length and even-length simultaneously. % Inducing odd and even length for lists backliteral( even( L), [ type(L,list)], []). backliteral( odd( L), [ type(L,list)], []). term( list, [X|L], [ type(X,item), type(L,list)]). term( list, [], []). prolog_predicate( fail). start_clause([ odd( L) ] / [ type(L,list)]). start_clause([ even( L) ] / [ type(L,list)]). ex( even( [])). ex( even( [a,b])). ex( odd( [a])). ex( odd( [b,c,d])). ex( odd( [a,b,c,d,e])). ex( even( [a,b,c,d])). nex( even( [a])). nex( even( [a,b,c])). nex( odd( [])). nex( odd( [a,b])). nex( odd( [a,b,c,d])).