-
Notifications
You must be signed in to change notification settings - Fork 7
/
configuration.pl
1133 lines (1030 loc) · 42.6 KB
/
configuration.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
:-module(configuration, [clause_limit/1
,encapsulation_predicate/1
,example_clauses/1
,experiment_file/2
,fetch_clauses/1
,fold_recursive/1
,generalise_learned_metarules/1
,invented_symbol_prefix/1
,learner/1
,learning_predicate/1
,listing_limit/1
,max_error/2
,max_invented/1
,metarule/2
,metarule_constraints/2
,metarule_learning_limits/1
,metarule_formatting/1
,recursive_reduction/1
,reduce_learned_metarules/1
,reduction/1
,resolutions/1
,symbol_range/2
,table_meta_interpreter/1
,tautology/1
,theorem_prover/1
,unfold_invented/1
,untable_meta_interpreter/1
,op(100,xfx,metarule)
]).
% Must be loaded before experiment file to allow experiment files to
% use set_configuration_option/2 without errors.
:-use_module(src(auxiliaries), [set_configuration_option/2]).
:-use_module(src/load_experiment_file).
:-reexport(lib(program_reduction/reduction_configuration),
except([resolutions/1])).
:-reexport(lib(evaluation/evaluation_configuration)).
:-reexport(lib/sampling/sampling_configuration).
:-reexport(subsystems(thelma/thelma_configuration)).
/** <module> Configuration options for Louise and associated libraries.
Predicates in this module represent configuration options for Louise,
its auxiliaries, sub-systems and libraries.
Brief description of configurable options
-----------------------------------------
The following is a quick list of configuration options, along with a
quick description of their use.
* :-debug(Subject): enable/disable logging for Subject.
* clause_limit/1: maximum number of clauses learned from one example.
* encapsulation_predicate/1: predicate symbol used in encapsulation.
* example_clauses/1: how to treat examples with bodies.
* experiment_file/2: path to the current experiment file.
* fold_recursive/1: fold overspecial programs to introduce recursion.
* generalise_learned_metarules/1: generalise TOIL-learned metarules.
* invented_symbol_prefix/1: used to compose invented predicate symbols.
* learner/1: name of the current learning system (louise).
* learning_predicate/1: current learning predicate.
* listing_limit/1: maximum lines printed when listing a MIL problem.
* max_error/2: how many negative examples a hypothesis can "cover".
* max_invented/1: maximum number of invented predicates.
* metarule/2: metarules known to the system.
* metarule_constraints/2: metasubstitution constraints for Louise.
* metarule_learning_limits/1: control over-generation in TOIL.
* metarule_formatting/1: how to pretty-print metarules.
* minimal_program_size/2: lower limit for greedy learning; not used.
* recursive_reduction/1: recursively apply Plotkin's reduction.
* reduce_learned_metarules/1: apply Plotkin's reduction to TOIL output.
* reduction/1: how to reduce the Top Program.
* resolutions/1: depth of resolution in Plotkin's reduction.
* table_meta_interpreter/1: whether to use tabling in learning.
* untable_meta_interpreter/1: clear tables between learning attempts.
* symbol_range/2: used to pretty-print metarule variables.
* tautology/1: what Louise considers a tautology.
* theorem_prover/1: resolution or TP operator (doesn't work).
* unfold_invented/1: unfold to remove invented predicates?
Navigating the configuration file
---------------------------------
The quickest way to navigate to a configuration option is as follows.
First, move your cursor at the top of the configuration file, where the
:-module/2 declaration exporting the public predicates of this module
resides. In many systems you can move to the start of a file with
"Ctrl+Home".
Place your cursor on the name of the configuration option you wish to
edit.
In the SWI-Prolog IDE, press Ctrl + . (dot). That will bring up a dialog
titled "Find definition of predicate [in new window]". I don't know why
it says "new window" but the predicate will be listed with arity 0,
always. Correct the arity to the arity of the option you want to
navigate to and press OK.
Alternatively, if you're not in the SWI IDE, you can copy the name of
the option you wish to change and use your favourite editor's search
function to search for it. It's more convenient to search for the name
of the option followed by an opening parenthesis, e.g. "reduction(", so
that you jump straight to the definition of the option, or at least the
start of its structured comment (or precede the search with the
start-of-line character, e.g. "/^reduction(" to avoid the structured
comment).
Editable options
----------------
In general, only configuration options defined as definite clauses
should be changed by the user. Directives (Horn goals of the form
':-Goal') setup the environment required by Louise and its sub-systems
and should be left well enough alone. The only exception to this rule is
the :-debug(Subject) options that enable and disable logging.
Setting configuration options
-----------------------------
When a configuration option in this file is changed, the file must be
reloaded. The simplest way to do this is to call SWI-Prolog's make/0
predicate. Like this:
==
?- make.
% c:/users/.../louise/configuration compiled into configuration 0.03 sec, 0 clauses
true.
==
Note that make/0 only rebuilds the Prolog project. It is _not_ the same
as the unix program "make".
Known errors
------------
Sometimes, editing an experiment file, then editing this configuration
file and then reloading the project with make/0 can cause SWI-Prolog to
throw up a bunch of permission errors. In that case, the safest bet is
to kill the SWI-Prolog session and start a new one. Sorry, not much I
can do about that.
Accessing configuration options
-------------------------------
Modules that require configuration options generally query them by
addressing the configuration option directly through its module
identifier, for example "configuration:clause_limit(K)" etc.
Foreign configuration options
-----------------------------
This configuration file re-exports a number of configuration modules
from the various libraries under louise/lib. Thse can be seen in the
reexport/1 and reexport/2 directives at the start of this file (above
the module structured comment). Those "foreign" configuration options
must be set by editing their corresponding module files (in the lib/
subdirectory where that library resides).
However, some foreign configuration options that are very frequently
used are excepted from re-exporting and are instead re-defined here, to
avoid having to edit multiple configuration files all the time. You can
see those options by eyballing the reexport/2 directives: they're the
ones in the "except" term as resolutions/1 in the example below:
==
:-reexport(lib(program_reduction/reduction_configuration),
except([resolutions/1])).
==
Dynamic options
---------------
Some configuration options defined in this file are declard dynamic.
These can in general be set without editing the configuration file, with
a call to set_configuration_option/2, as shown in the example below:
==
:- auxiliaries:set_configuration_option(max_invented, [3]).
==
Unfortunately, set_configuration_option/2 can often leave behind garbage
in the form of duplicate options (i.e. multiple clauses of the same
option predicate, each with different values). Often this manifests as
nondeterminism in normally deterministic learning predicates (such as
learn/1).
In that case, the user may have to inspect the current values of
configuration options loaded in memory with list_config/0 and then
retract/1 duplicate options by hand. This is a, well, sort of temporary,
solution and a better one will be implemented at some point. The dynamic
database is evil.
Multifile options
-----------------
A couple of configuration options defined in this module file,
particularly metarule/2 and metarule_constraints/2 are declared
multifile so that they can be included in experiment files to keep a
permanent record of those important MIL problem elements. These options
can also be set in the configuration, for example the user doesn't have
to copy metarule/2 clauses in their experiment files everytime and can
instead refer to the ones defined in this module file directly. See the
various example experiment files under louise/data/examples for examples
of setting those configuration options in an experiment file.
*/
% Dynamic configuration options can be manipulated
% by means of set_configuration_option/2 in module auxiliaries.
:- dynamic clause_limit/1
,fetch_clauses/1
,invented_symbol_prefix/1
,max_error/2
,max_invented/1
,minimal_program_size/2
,recursive_reduction/1
,reduction/1
,resolutions/1
,table_meta_interpreter/1
,theorem_prover/1
,unfold_invented/1
,untable_meta_interpreter/1.
% Allows experiment files to define their own, special metarules.
% BUG: Actually, this doesn't work- module quantifiers, again.
% Needs fixing.
:-multifile metarule/2.
/* Debug levels
* Note that some of the debug topics below emit identical messages.
* In particular, 'learn' debugs learn/5 that calls top program
* construction and reduction that are also debugged by 'top_program'
* and 'reduction'.
*/
:-nodebug(_). % Clear all debug topics.
%:-debug(learn). % Debug learning steps.
%:-debug(metasubstitution). % Debug metasubstitutions.
%:-debug(examples). % Debug positive and negative examples.
%:-debug(top_program). % Debug Top program construction.
%:-debug(reduction). % Debug Top program reduction.
%:-debug(predicate_invention). % Debug predicate invention.
%:-debug(learn_metarules). % Debug metarule learning
%:-debug(learned_metarules). % Debug new metarules
%:-debug(metarule_grounding). % Debug metarule template specialisation
%:-debug(examples_invention). % Debug examples invention.
%:-debug(evaluation).
%! clause_limit(?Limit) is semidet.
%
% Limit the number of resolving clauses learned from each example.
%
% Limit should be a natural number, including 0, or the atom 'inf'
% representing positive infinity if a limit is not required.
%
% __What is this clause limit__
%
% Informally, Limit is the maximum number of clauses resolving
% with each other that will be learned from each positive example
% "in one step" of learning.
%
% Louise learns by an SLD-refutation proof of positive examples
% with first-order background knowledge and second-order
% metarules. Accordingly, a more formal definition of Limit is
% that it is the maximum cardinality of the set of clauses in one
% refutation sequence of any one positive example.
%
% A single clause is always assumed as the first clause in a
% refutation sequence, therefore clause_limit(0) is a valid option
% that means a single clause is learned that does not resolve with
% any clauses in a hypothesis (including itself).
%
% Note that the same clause can appear multiple times in a single
% refutation sequence. This is the case, e.g., when a clause is
% "called" recursively. This includes a single, self-resolving
% clause.
%
% __What the clause limit is not__
%
% Limit is _not_ the maximum number of clauses in _hypotheses_.
% Louise learns a hypothesis for a set of examples by "stitching
% together" all "sub-hypotheses" learned from each example. It's
% the size of these sub-hypotheses that is restricted by Limit.
%
% Limit is also _not_ a limit on the resolution steps, or
% recursion depth, of an SLD-refutation of an example.
%
% Louise does not impose any limitation on the size of hypotheses,
% or the depth of resolution and recursion.
%
% __Choosing an appropriate clause limit__
%
% In general, you should set clause_limit/1 to one of the
% following settings:
%
% * clause_limit(0): Set this option if you don't need recursion
% and predicate invention. Louise can still learn some recursive
% clauses this way.
%
% * clause_limit(1): Set this option if your target theory is a
% single, recursive clause resolving with itself any number of
% times.
%
% * clause_limit(K): (where K > 1). Set this option if you want
% Louise to learn arbitrary recursion.
%
% With a clause limit of "0", Louise can still learn a limited
% form of recursion where recursive clauses can only be learned if
% they resolve with a positive example.
%
% With a clause limit of "0" or "1" Louise cannot do predicate
% invention. Invented predicates' clauses must resolve with at
% least one clause of a target predicate in the learned program,
% so a clause limit of 2 or more is necessary: that's one clause
% for the target predicate, one for the invented predicate.
%
% Note that if predicate invention is required, the option
% max_invented/1 must also be set separately to an appropriate
% value (representing the number of predicate symbols that Louise
% will try to define).
%
% Be advised that _for many problems_, if clause_limit/1 is set to
% a number higher than 1, you will also need to provide
% appropriate constraints to avoid Louise trying to prove all
% possible recursive theories, and likely blowing up your RAM in
% the process.
%
% __Usage__
%
% This configuration option is used by prove/6, Louise's inductive
% Prolog meta-interpreter.
%
% __Examples__
%
% See the example files hello_world.pl, yamamoto.pl, recipes.pl
% and ackermann.pl in data/examples for examples demonstrating the
% use of different settings of clause_limit/1 to learn recursion
% and predicate invention.
%
clause_limit(0).
%! encapsulation_predicate(+Symbol) is semidet.
%
% The Symbol used in encapsulation predicates.
%
% Symbol is an atom used as the symbol of encapsulated literals in
% clauses of examples, background knowledge, metarules and
% invented predicates, alike.
%
encapsulation_predicate(m).
%! example_clauses(?What) is semidet.
%
% What to do with example clauses.
%
% This option determines how Louise treats examples that are given
% as definite clauses with one or more body literals (rather than
% ground atoms), i.e. "example clauses".
%
% What is one of [bind,call].
%
% If What is "bind", example clauses are bound to each instance of
% a metarule where that is possible.
%
% If What is "call", the head literal of each example clause is
% bound to the enapsulated head literal of a metarule, then the
% body literals of the example clause are called. This may
% result in the universally quantified variables in the head of
% the clause, and so the encapsulated head literal of the
% metarule, to be bound.
%
% Use "bind" when you have a set of definite clauses that you want
% to transform to instances of a metarule.
%
% Use "call" when you want to use a set of definite clauses with
% bodies to generate examples.
%
%example_clauses(bind).
example_clauses(call).
%! experiment_file(?Path,?Module) is semidet.
%
% The Path and Module name of an experiment file.
%
%experiment_file('data/examples/hello_world.pl',hello_world).
experiment_file('data/examples/tiny_kinship.pl',tiny_kinship).
%experiment_file('data/examples/anbn.pl',anbn).
%experiment_file('data/examples/abduced.pl',abduced).
%experiment_file('data/examples/user_metarules.pl',user_metarules).
%experiment_file('data/examples/constraints.pl',constraints).
%experiment_file('data/examples/mtg_fragment.pl',mtg_fragment).
%experiment_file('data/examples/recipes.pl',recipes).
%experiment_file('data/examples/example_invention.pl',path).
%experiment_file('data/robots/robots.pl',robots).
%experiment_file('data/coloured_graph/coloured_graph.pl',coloured_graph).
%experiment_file('data/examples/multi_pred.pl',multi_pred).
%experiment_file('data/examples/tiny_kinship_toil.pl',tiny_kinship_toil).
%experiment_file('data/examples/yamamoto.pl',yamamoto).
%experiment_file('data/examples/recursive_folding.pl',recursive_folding).
%experiment_file('data/examples/findlast.pl',findlast).
%experiment_file('data/examples/ackermann.pl',ackermann).
%experiment_file('data/examples/list_processing.pl',list_processing).
%experiment_file('data/examples/even_odd.pl',even_odd).
%! fetch_clauses(?Whence) is semidet.
%
% Where to fetch clauses from during meta-interpretation.
%
% Clauses are "fetched" during meta-interpretation by the
% predicate clause/7. A different clause of this predicate fetches
% clauses from different sources and this option is used to
% control which sources will be allowed in a learning attempt.
%
% Whence can be any subset of: [builtins,bk,hypothesis,metarules].
% These are interpreted as follows:
%
% * builtins: clauses will be fetched from built-in and library
% predicates loaded into memory. This option should be needed most
% of the time when built-ins and library predicates are used in
% background knowledge definitions.
%
% * bk: clauses will be fetched from the set of clauses of the
% definitions of predicates listed in the second argument of
% background_knowledge/2 in the current experiment file.
%
% * hypothesis: clauses will be fetched from the set of clauses
% added to a hypothesis so-far. These clauses are stored in the
% metasubstitution accumulator in prove/6 as metasubstitution
% atoms and must be expanded to be used in a proof (this is
% handled internally by prove/6). Enabling this setting allows
% arbitrary recursion between clauses in the learned hypothesis
% and all other sources where clauses are fetched from.
%
% * metarules: clauses will be fetched from the list of metarules
% given to prove/6. Enabling this setting allows construction of
% new clauses by the Vanilla meta-interpreter by resolution with
% metarules. This setting should probably never be removed
% because without it clause construction is not possible. This
% includes clauses of invented predicates.
%
fetch_clauses(all).
%fetch_clauses([builtins,bk,hypothesis,metarules]).
%fetch_clauses([bk,hypothesis,metarules]).
%fetch_clauses([builtins,hypothesis,metarules]).
%fetch_clauses([builtins,bk,metarules]).
%fetch_clauses([builtins,bk,hypothesis]).
%fetch_clauses([hypothesis]).
%fetch_clauses([metarules]).
%! fold_recursive(?Bool) is semidet.
%
% Whether to fold overspecialised programs.
%
% If Bool is set to 'true' Louise will attempt to fold an
% over-specialised program to introduce recursion.
%
% @tbd Currently, only learn/5 and its family recognise this
% option.
%
fold_recursive(false).
%! generalise_learned_metarules(?Bool) is semidet.
%
% Whether to generalise learned metarules.
%
% "Genearlisation" heare means that second-order variables in
% learned metarules are "named apart", so for example a learned
% metarule "P(x,,y):- Q(x,z), P(z,y)" is genealised by replacing
% each instance of the second-order variables P and Q with new,
% free variables, resulting in the metarule "P(x,y):- Q(x,z),
% R(z,y)".
%
% The new metarule is more general than the original in the sense
% that its instances may or may not be recursive clauses- while
% the first metarule forces the head and last body literal to have
% the same predicate symbol.
%
% The motivation of this option is to allow learning metarules
% that better generalise to unseen examples. Set this option to
% true if learn_metarules/[1,2,5] returns overly-specific
% metarules that can only represent the training examples well.
%
%generalise_learned_metarules(true).
generalise_learned_metarules(false).
%! invented_symbol_prefix(?Prefix) is semidet.
%
% Prefix used to form invnented predicates' symbols.
%
% Invented predicate symbols are created automatically by
% prepending Prefix to a number between 1, and the value of the
% configuration option max_invented/1.
%
% The default-ish Prefix for this concatenation is the dollar
% symbol, '$'. This character is also defined as a prefix operator
% with precedence 1 and this can cause trouble in conjunction with
% the tokenisation in SWI-Prolog. This configuration option allows
% the user to set their own invented predicate symbol.
%
invented_symbol_prefix('$').
%! learner(?Name) is semidet.
%
% Name of the learning system this configuration is for.
%
% Name is one of [louise,thelma].
%
% Used to switch context between Louise and Thelma, where this is
% needed. The typical use case is when experiment code must check
% the values of configuration options that are particular to one
% or the other system (e.g. resolutions/1 is not present in
% Thelma etc).
%
learner(louise).
%! learning_predicate(+Learning_Predicate) is semidet.
%
% The Learning_Predicate to be used in list_learning_results/0.
%
% Learning_Predicate is a predicate indicator, the symbol and
% arity of one of the following learning predicates defined in
% Louise:
% * learn/1
% * learn_meta/1
% * learn_metarules/1
% * learn_minimal/1
% * learn_with_examples_invention/2
% * thelma/1
%
% The specified predicate will be used to list the learning
% results for all learning targets defined in an experiment file
% with a call to list_learning_results/0.
%
% learning_predicate/1 is declared as multifile. To specify the
% learning predicate to be used with list_learning_results/0, add
% a clause of learning_predicate/1 to the relevant experiment
% file.
%
% For example, the following clause:
% ==
% configuration:learning_predicate(learn_meta/1).
% ==
%
% Will cause list_learning_results/0 to use learn_meta/1 for
% all predicates in the experiment file containing that clause.
%
% learning_predicate/1 is declared dynamic. You do not have to
% specify a learning predicate for every experiment file.
% list_learning_results/0 will default to learn/1.
%
% Note that learning_predicate/1 will not affect learning by
% calling learning predicates directly. That is, having added a
% clause of learning_predicate/1 like the one above to an
% experiment file you are free to then call learn/1 or any other
% learning predicate on any of the learning targets in that
% experiment file. Only the learning predicate used by
% list_learning_results/0 is affected by this option.
%
% Finally, note that specifying any other predicate than the three
% learning predicates listed above as a learning_predicate will
% cause list_learning_results/0 to raise an error.
%
% @see list_learning_results/0
%
% @tbd learning_predicate/1 is also used in lib/evaluation to
% choose the learning predicate used to evaluate a learning
% result. Predicates in that library default to learn/1 when
% learning_predicate/1 is not defined.
%
:-dynamic learning_predicate/1.
:-multifile learning_predicate/1.
%learning_predicate(learn/1).
%learning_predicate(learn_greedy/1).
% etc.
%! listing_limit(?Limit) is semidet.
%
% Limit the clauses printed when a MIL problem is listed.
%
% Limit is a number, limiting the number of clauses of examples
% and BK that will be printed to the output when a MIL problem is
% listed. Affects list_mil_problem/1 and
% list_encapsulated_problem/1.
%
% Limit should be a positive integer. It can also be the atom
% 'inf' representing positive infinity. If Limit is 'inf', then no
% limit is imposed on the printed information.
%
listing_limit(10).
%! max_invented(?Number) is semidet.
%
% Maximum number of invented predicates.
%
% Assumes clause_limit(K) where K > 1.
%
max_invented(0).
%! max_error(?Hypothesis,?Clause) is det.
%
% Maximum error allowed for a Hypothesis and each Clause in it.
%
% "Error" in this context means the number of negative examples
% entailed by a clause, or a Hypothesis, with respect to
% background knowledge. Errors of that type are more formally
% known as "inconsistencies" in ILP terminology.
%
% Hypothesis takes precedence over Clause. What this means is that
% if Clause > Hypothesis, then the maximum number of negative
% examples a clause is allowed to entail, with respect to
% background knowledge, before it is discarded, is equal to
% Hypothesis, while the maximum number of negative examples
% entailed by a hypothesis remains equal to Hypothesis.
%
% This option allows Louise to behave similar to Aleph, and
% similar systems, with the setting "error" set to something other
% than 0. Its purpose is to allow more natural results when
% learning from datasets designed for propositional learners.
%
% @tbd This option affects specialise/3 but is currently taken
% into account only with clause_limit(K=1). If K > 1, this option
% has no effect. This makes sense because clause_limit(1) is
% sufficient for propositional-style learning problems, whereas
% clause_limit(K > 1) is for more relational-style problems where
% errors are much less tolerable and noise is not that common
% anyway. This may change in a future version if there is a need
% for it.
%
max_error(0,0).
%! metarule(?Id,?P,?Q) is semidet.
%! metarule(?Id,?P,?Q,?R) is semidet.
%
% An encapsulated metarule.
%
% @tbd This representation does not define constraints. For the
% time being this doesn't seem to be necessary but a complete
% representation will need to include constraints.
%
abduce metarule 'P(X,Y)'.
unit metarule 'P(x,y)'.
projection_21 metarule 'P(x,x):- Q(x)'.
projection_12 metarule 'P(x):- Q(x,x)'.
identity metarule 'P(x,y):- Q(x,y)'.
inverse metarule 'P(x,y):- Q(y,x)'.
chain metarule 'P(x,y):- Q(x,z), R(z,y)'.
tailrec metarule 'P(x,y):- Q(x,z), P(z,y)'.
precon metarule 'P(x,y):- Q(x), R(x,y)'.
postcon metarule 'P(x,y):- Q(x,y), R(y)'.
switch metarule 'P(x,y):- Q(x,z), R(y,z)'.
swap metarule 'P(x,y):- Q(z,x), R(z,y)'.
% Metarules with abductible first-order existentially quantified
% variables. Also see abduce metarule above.
chain_abduce_x metarule 'P(X,y):- Q(X,z), R(z,y)'.
chain_abduce_y metarule 'P(x,Y):- Q(x,z), R(z,Y)'.
chain_abduce_z metarule 'P(x,y):- Q(x,Z), R(Z,y)'.
projection_21_abduce metarule 'P(X,X):- Q(X)'.
projection_12_abduce metarule 'P(X):- Q(X,X)'.
precon_abduce metarule 'P(X,y):- Q(X), R(X,y)'.
postcon_abduce metarule 'P(x,Y):- Q(x,Y), R(Y)'.
% Generalised second order metarules (Matrix metarules). Use only with
% toil.pl
%
% WARNING Comment these out when learing with [all] metarules!
%
meta_dyadic metarule 'P(x,y):- Q(z,u), R(v,w)'.
meta_monadic metarule 'P(x,y):- Q(z,u)'.
meta_precon metarule 'P(x,y):- Q(z),R(u,v)'.
meta_postcon metarule 'P(x,y):- Q(z,u),R(v)'.
meta_projection_21 metarule 'P(x,y):- Q(z)'.
meta_projection_12 metarule 'P(x):- Q(y,z)'.
%partially_named metarule 'P(x,y):- member(x,y)'.
% Not yet implemented.
/*
% H22 metarules redundnant given chain and inverse.
% To avoid proliferation of vaguely descriptive names these are named
% by their firts-order, universally quantified variables.
% identity and switch are also in this set (but they are already named)
% TODO: convert to new format.
metarule(xy_xy_xy,P,Q,R):- m(P,X,Y), m(Q,X,Y), m(R,X,Y).
metarule(xy_xy_yx,P,Q,R):- m(P,X,Y), m(Q,X,Y), m(R,Y,X).
%metarule(xy_xz_yz,P,Q,R):- m(P,X,Y), m(Q,X,Z), m(R,Y,Z). % switch
metarule(xy_yx_xy,P,Q,R):- m(P,X,Y), m(Q,Y,X), m(R,X,Y).
metarule(xy_yx_yx,P,Q,R):- m(P,X,Y), m(Q,Y,X), m(R,Y,X).
metarule(xy_yz_xz,P,Q,R):- m(P,X,Y), m(Q,Y,Z), m(R,X,Z).
metarule(xy_yz_zx,P,Q,R):- m(P,X,Y), m(Q,Y,Z), m(R,Z,X).
metarule(xy_zx_yz,P,Q,R):- m(P,X,Y), m(Q,Z,X), m(R,Y,Z).
metarule(xy_zx_zy,P,Q,R):- m(P,X,Y), m(Q,Z,X), m(R,Z,Y).
metarule(xy_zy_xz,P,Q,R):- m(P,X,Y), m(Q,Z,Y), m(R,X,Z).
metarule(xy_zy_zx,P,Q,R):- m(P,X,Y), m(Q,Z,Y), m(R,Z,X).
Converted to new format.
TODO: create new lump category called h22 for all these plus identity
and inverse. And chain. I think chain is missing from this list.
xy_xy_xy metarule 'P(x,y):- Q(x,y), R(x,y)'.
xy_xy_yx metarule 'P(x,y):- Q(x,y), R(y,x)'.
xy_xz_yz metarule 'P(x,y):- Q(x,z), R(y,z)'. % switch
xy_yx_xy metarule 'P(x,y):- Q(y,x), R(x,y)'.
xy_yx_yx metarule 'P(x,y):- Q(y,x), R(y,x)'.
xy_yz_xz metarule 'P(x,y):- Q(y,z), R(x,z)'.
xy_yz_zx metarule 'P(x,y):- Q(y,z), R(z,x)'.
xy_zx_yz metarule 'P(x,y):- Q(z,x), R(y,z)'.
xy_zx_zy metarule 'P(x,y):- Q(z,x), R(z,y)'. % swap
xy_zy_xz metarule 'P(x,y):- Q(z,y), R(x,z)'.
xy_zy_zx metarule 'P(x,y):- Q(z,y), R(z,x)'.
*/
%! metarule_constraints(+Metasubstitution,+Goal) is nondet.
%
% A Goal to be called when Metasubstitution is matched.
%
% This option is declared multifile that constraints may be
% declared individually by experiment files, as needed. A few
% examples are given below.
%
:- dynamic metarule_constraints/2.
:- multifile metarule_constraints/2.
/*
% Simple constraint excluding left-recursive clauses that are instances of
% a metarule with any Id and having two existentially quantified
% variables. Matches e.g. Tailrec and Identity:
%
configuration:metarule_constraints(m(_Id,P,P),fail).
*/
/*
% Simple constraint excluding left-recursive clauses that are instances of
% a metarule with any Id and having three existentially quantified
% variables. Matches e.g. Chain, Switch, Swap:
%
configuration:metarule_constraints(m(_Id,P,P,_),fail).
*/
/*
% Anti-recursion constraint - excludes recursive clauses
% Does not take into account invented or metarules with existentially
% quantified secod-order variables:
%
configuration:metarule_constraints(m(tailrec,_,_),fail).
configuration:metarule_constraints(M,fail):-
M =.. [m,Id,P|Ps]
,\+ memberchk(Id,[abduce
,unit
,projection_21
,projection_12])
,memberchk(P,Ps).
*/
/*
% McCarthyite constraint - excludes left-recursive metasubstitutions
% Named after the other McCarthy. The senator, not the computer
% scientist.
%
configuration:metarule_constraints(M,fail):-
M =.. [m,Id,P,P|_Ps]
,\+ memberchk(Id,[abduce
,unit
,projection_21
,projection_12]).
*/
/*
% Lexicographic order constraint.
% Imposes total ordering on the Herbrand base.
% Calls src/subsystems/thelma/thelma_configuration:order_constraints/5.
% Needs problem-specific ordering of the predicate signature.
%
configuration:metarule_constraints(M,B):-
debug(lex,'Testing constraint for metasub: ~w',M)
,M =.. [m,Id|Ps]
%#REPLACE WITH PROBLEM-SPECIFIC ORDERING OF PREDICATE SIGNATURE#
,PS = [s,a,b] % Example ordering for a^nb^n
,debug(lex,'Predicate signature: ~w',[PS])
,thelma_configuration:order_constraints(Id,Ps,Fs,STs,FTs)
,debug(lex,'Order constraints: ~w-~w',[STs,FTs])
,( thelma:order_tests(PS,Fs,STs,FTs)
-> B = true
,debug(lex,'Passed constraint test!',[])
; B = false
,debug(lex,'Failed constraint test!',[])
).
*/
%! metarule_learning_limits(?Limits) is semidet.
%
% Limits on metarule learning.
%
metarule_learning_limits(none).
%metarule_learning_limits(coverset).
%metarule_learning_limits(sampling(0.5)).
%metarule_learning_limits(metasubstitutions(1)).
%! metarule_formatting(?How) is semidet.
%
% How to print metarules learned with new_metarules/1.
%
% How is one of: [quantified, user_friendly, expanded].
%
% Option "quantified" prints metarules with quantifiers and in
% formal notation found in the MIL literature. Use this option to
% compare metarules with the ones in the literature, or just to
% get a more clear explanation of a metarule.
%
% Option "user_friendly" prints metarules in Louise's user-level,
% and user-friendly format of metarules in experiment files. Use
% this option when you want to copy a metarule and later paste it
% to an experiment file. For example, this option is handy when
% you learn metarules with TOIL and you want to reuse them in an
% experiment file.
%
% Option "expanded" prints metarules in Louise's internal format,
% encapsulated and expanded, with an encapsulated metasubstitution
% atom in the head. Use this option to inspect what Louise
% actually sees when you declare a metarule.
%
% Note that the metarules printed with option "expanded" cannot be
% directly copy/pasted into an experiment file. Or, well, sure
% they can... but they won't be picked up by experiment_data/5 and
% you will probably see errors.
%
metarule_formatting(quantified).
%metarule_formatting(user_friendly).
%metarule_formatting(expanded).
%! minimal_program_size(?Minimum,?Maximum) is semidet.
%
% Minimum and Maximum cardinality of a minimal program.
%
% Each of Minimum, Maximum should be an integer between 1 and
% positive infinity ('inf' in Prolog).
%
% @tbd Currently unused.
%
minimal_program_size(2,inf).
%! recursive_reduction(?Bool) is semidet.
%
% Whether to reduce the Top program recursively or not.
%
% Setting Bool to true enables recursie reduction of the Top
% program. Recursive reduction means that the result of each
% reduction step is given as input to the reduction algorithm in
% the next step (also known as "doing the feedbacksies").
%
% Recursive reduction can result in a stronger reduction in less
% time, with a lower setting for resolutions/1 (in fact, the same
% amount of reduction can take less time exactly because the
% resolutions/1 setting can be set to a lower value).
%
% Recursive reduction is more useful when the Top program is large
% and many resolution steps are required to remove all redundancy
% from it.
%
recursive_reduction(false).
%recursive_reduction(true).
%! reduce_learned_metarules(?Bool) is semidet.
%
% Whether to reduce learned metarules.
%
% Reduction is by application of Plotkin's program reduction,
% only.
%
reduce_learned_metarules(false).
%reduce_learned_metarules(true).
%! reduction(?Method) is semidet.
%
% Select a Method for Top program reduction.
%
% One of:
% * none: no reduction.
% * plotkins: discard logically redundant clauses by application
% of Plotkin's program reduction.
% * subhypothesis: select one hypothesis entailed by the Top
% program.
%
%reduction(none).
reduction(plotkins).
%reduction(subhypothesis).
%! resolutions(?Resolutions) is semidet.
%
% Maximum number of resolutions.
%
% Used with solve_to_depth/3.
%
%resolutions(500_000_000_000).
%resolutions(20_500_000).
%resolutions(10_500_000).
%resolutions(5_500_000).
%resolutions(500_000).
%resolutions(250_000).
%resolutions(30_000).
%resolutions(10_000).
resolutions(5000).
%resolutions(100).
%resolutions(15).
%resolutions(0).
%! symbol_range(?Type,?Symbols) is semidet.
%
% A list of Symbols to pretty-print predicates or variables.
%
% Type is one of [predicate,variable], denoting the type of
% symbols in the currenr range.
%
% Symbols is a list of symbols of the given Type.
%
% The atoms in list Symbols is used to assign names to the
% variables in a metarule for pretty-printing.
%
% Warning:
% --------
%
% symbol_range/2 must have exactly two clauses: one for the
% symbols to be used as names for second-order existentially
% quantified variables, and one to be used as names for
% first-order existentially and universally quantified variables.
%
% You can change each Symbols list as you see fit, but _do not
% remove or add clauses_ to symbol_range/2!
%
% Used by
% -------
%
% This predicate is used by predicates in the transitive closure
% of print_metarules/1 and print_metarule/1, in particular,
% numbered_symbol/3, which uses this to generate lists of
% predicate symbols to be assigned to variables in metarules
% according with their (first- or second-) order.
%
symbol_range(predicate, ['P','Q','R','S','T']).
symbol_range(variable, ['X','Y','Z','U','V','W']).
% Silly. Don't use.
%symbol_range(predicate, ['Alice','Bob','Carol']).
%symbol_range(variable, ['Smith','Brown','Carpenter','Miller','Green']).
%! table_meta_interpreter(?Bool) is semidet.
%
% Whether to table the Vanilla meta-interpreter, or not.
%
% Checked by refresh_tables/1 to decide whether to table or
% untable the prove/6 Vanilla meta-interpreter, or not.
%
% This option and untable_meta_interpreter/1 are made available so
% that the user doesn't have to edit the source code of learning
% predicates to control tabling and untabling behaviour.
%
% See refresh_tables/1 for more context.
%
table_meta_interpreter(true).
%! tautology(+Clause) is det.
%
% True when Clause is a tautology.
%
% This configuration option formalises the concept of a
% tautological clause as it is used in Louise. In short, a clause
% is a tautology if it is a definite clause with one or more body
% literals and all its literals are identical.
%
% For example, the following clause is considered to be a
% tautology:
% ==
% p(A,B):- p(A,B), p(A,B)
% ==
%
% Whereas the following clauses are not considered to be
% tautologies:
% ==
% p(a,b)
% p(A,B):- p(B,A)
% ==