-
Notifications
You must be signed in to change notification settings - Fork 0
/
s0123456789.m
1603 lines (1276 loc) · 49.4 KB
/
s0123456789.m
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 s0123456789.
:- interface.
:- import_module bool.
:- import_module list.
:- import_module set.
:- import_module io.
:- type mrs_instance ---> mrs_instance(mrs_carg) ; mrs_conj(set(mrs_instance)).
:- type mrs_carg ---> mrs_carg(string).
:- type mrs_event ---> mrs_event(int,int).
:- type mrs_unknown ---> mrs_unknown(int,int).
:- pred main(io::di, io::uo) is det.
:- pred proper_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode proper_q(out, in, in) is nondet.
:- pred some_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode some_q(out, in, in) is nondet.
:- pred udef_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode udef_q(out, in, in) is nondet.
:- pred the_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode the_q(out, in, in) is nondet.
:- pred def_explicit_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode def_explicit_q(out, in, in) is nondet.
:- pred pronoun_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode pronoun_q(out, in, in) is nondet.
:- pred a_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode a_q(out, in, in) is nondet.
:- pred no_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode no_q(out, in, in) is nondet.
:- pred every_q(mrs_instance, (func) = list(mrs_instance), (func) = bool).
:- mode every_q(out, in, in) is nondet.
:- pred named(mrs_instance, mrs_carg).
:- mode named(out, in) is det.
:- pred therefore_a_1(mrs_instance, (func) = bool).
:- mode therefore_a_1(in, in) is semidet.
:- pred colon_p_namely(mrs_event, (func) = bool, (func) = bool).
:- mode colon_p_namely(in, in,in) is semidet.
:- pred in_p_loc(mrs_event, mrs_event, mrs_instance).
:- mode in_p_loc(in, in, in) is det.
:- pred compound(mrs_event, mrs_instance, mrs_instance).
:- mode compound(in, in, in) is det.
:- pred kill_v_1(mrs_event, mrs_instance, mrs_instance).
:- mode kill_v_1(in, in, in) is semidet.
:- pred implicit_conj(mrs_instance, mrs_instance, mrs_instance).
:- mode implicit_conj(out, in, in) is semidet.
:- pred live_v_1(mrs_event, mrs_instance).
:- mode live_v_1(in, in) is det.
:- pred only_a_1(mrs_event, mrs_instance).
:- mode only_a_1(in, in) is det.
:- pred be_v_id(mrs_event, mrs_instance, mrs_instance).
:- mode be_v_id(in, in, out) is det.
:- pred person(mrs_instance).
:- mode person(out) is nondet.
:- pred and_c_e(mrs_event, mrs_event, mrs_event).
:- mode and_c_e(in,in,in) is det.
:- pred and_c_x(mrs_instance, mrs_instance, mrs_instance).
:- mode and_c_x(out,in,in) is nondet.
:- pred butler_n_1(mrs_instance).
:- mode butler_n_1(out) is nondet.
:- pred killer_n_1(mrs_instance).
:- mode killer_n_1(out) is nondet.
:- pred people_n_of(mrs_instance,mrs_instance).
:- mode people_n_of(in,in) is det.
:- pred therein_p_dir(mrs_event,mrs_event).
:- mode therein_p_dir(in,in) is det.
:- pred poss(mrs_event, mrs_instance, mrs_instance).
:- mode poss(in, in, in) is det.
:- pred victim_n_of(mrs_instance, mrs_instance).
:- mode victim_n_of(out, in) is nondet.
:- pred always_a_1(mrs_instance, mrs_event).
:- mode always_a_1(in, in) is det.
:- pred hate_v_1(mrs_event, mrs_instance, mrs_instance).
:- mode hate_v_1(in, in, in) is semidet.
:- pred never_a_1(mrs_instance, (func) = bool).
:- mode never_a_1(in, in) is semidet.
:- pred pron(mrs_instance).
:- mode pron(in) is det.
:- pred more_comp(mrs_event, mrs_event, mrs_instance).
:- mode more_comp(in, in, in) is semidet.
:- pred rich_a_in(mrs_event, mrs_instance, mrs_instance).
:- mode rich_a_in(in, in, in) is semidet.
:- pred card(mrs_event, mrs_instance, mrs_carg).
:- mode card(in,in,in) is det.
:- pred generic_entity(mrs_instance).
:- mode generic_entity(out) is det.
:- pred aunt_n_of(mrs_instance,mrs_instance).
:- mode aunt_n_of(out,in) is nondet.
:- pred except_p(mrs_event, mrs_instance, mrs_instance).
:- mode except_p(in, in, in) is semidet.
:- pred neg(mrs_event, (func) = bool).
:- mode neg(in, in) is semidet.
:- pred unknown(mrs_unknown, mrs_event).
:- mode unknown(in, in) is det.
:- pred coref(mrs_instance, mrs_instance).
:- mode coref(in,in) is semidet.
:- implementation.
:- import_module solutions.
:- import_module string.
:- import_module unsafe.
:- import_module pretty_printer.
% ERG predicate definitions
named(Inst, Carg) :- Inst = mrs_instance(Carg).
:- pred namedPeople(mrs_instance).
:- mode namedPeople(out) is nondet.
namedPeople(Person) :- Person = mrs_instance(mrs_carg("Agatha")); Person = mrs_instance(mrs_carg("Charles")).
butler_n_1(Person) :- Person = mrs_instance(mrs_carg("The Butler")) ; namedPeople(Person).
killer_n_1(Person) :-
Person = mrs_instance(mrs_carg("The Killer")) ;
Person = mrs_instance(mrs_carg("The Butler")) ;
namedPeople(Person).
person(Person) :- butler_n_1(Person); namedPeople(Person).
generic_entity(I) :- I = mrs_instance(mrs_carg("generic")).
the_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
proper_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
udef_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
some_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
def_explicit_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
pronoun_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
a_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
no_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
every_q(Inst, FuncR, FuncB) :- list.member(Inst,apply(FuncR)).
:- pragma promise_pure(in_p_loc/3).
in_p_loc(E0, E1, Inst) :-
impure unsafe_perform_io(io.print({"in_p_loc",E0,E1,Inst})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(compound/3).
compound(E, Inst0, Inst1) :-
impure unsafe_perform_io(io.print({"compound",E,Inst0,Inst1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(live_v_1/2).
live_v_1(E, Inst0) :-
impure unsafe_perform_io(io.print({"live_v_1",E,Inst0})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(only_a_1/2).
only_a_1(E, Inst0) :-
impure unsafe_perform_io(io.print({"only_a_1",E,Inst0})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(be_v_id/3).
be_v_id(E, Inst0, Inst1) :-
impure unsafe_perform_io(io.print({"be_v_id",E,"Inst1 = ",Inst0})),
impure unsafe_perform_io(io.nl),
Inst1 = Inst0.
:- pragma promise_pure(kill_v_1/3).
kill_v_1(E, Inst0, Inst1) :-
impure unsafe_perform_io(io.print({"kill_v_1",E,Inst0,Inst1})),
impure unsafe_perform_io(io.nl),
true.
:- pred mkConj(mrs_instance,mrs_instance,mrs_instance).
:- mode mkConj(out,in,in).
:- pragma promise_pure(mkConj/3).
mkConj(I0,I1,I2) :-
(if mrs_conj(I1s) = I1 then
(if mrs_conj(I2s) = I2 then
set.is_empty(set.intersect(I1s,I2s))
else
not set.member(I2,I1s))
else
(if mrs_conj(I2s) = I2 then
not set.member(I1,I2s)
else
not I1 = I2)),
I0set = (if mrs_conj(I1sL) = I1 then
(if mrs_conj(I2sL) = I2 then
set.intersect(I1sL,I2sL)
else
set.insert(I1sL,I2))
else
(if mrs_conj(I2sL) = I2 then
set.insert(I2sL,I1)
else
set.list_to_set([I1,I2]))),
I0 = mrs_conj(I0set).
:- pragma promise_pure(implicit_conj/3).
implicit_conj(I0,I1,I2) :- mkConj(I0,I1,I2).
:- pragma promise_pure(and_c_x/3).
and_c_x(I0, I1, I2) :- mkConj(I0,I1,I2).
:- pragma promise_pure(and_c_e/3).
and_c_e(E0, E1, E2) :-
true.
:- pragma promise_pure(therein_p_dir/2).
therein_p_dir(E0, E1) :-
impure unsafe_perform_io(io.print({"therein_p_dir",E0,E1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(poss/3).
poss(E, I0, I1) :-
impure unsafe_perform_io(io.print({"poss",E,I0,I1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(always_a_1/2).
always_a_1(I, E) :-
impure unsafe_perform_io(io.print({"always_a_1",I,E})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(hate_v_1/3).
hate_v_1(E, I0, I1) :-
impure unsafe_perform_io(io.print({"hate_v_1",I0,I1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(never_a_1/2).
never_a_1(I23s2, Func) :-
impure unsafe_perform_io(io.print({"never_a_1",I23s2,Func})),
impure unsafe_perform_io(io.nl),
apply(Func) = no.
:- pragma promise_pure(neg/2).
neg(E, Func) :-
impure unsafe_perform_io(io.print({"neg",E,Func})),
impure unsafe_perform_io(io.nl),
apply(Func) = no.
:- pragma promise_pure(pron/1).
pron(X16s2) :-
impure unsafe_perform_io(io.print({"pron",X16s2})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(more_comp/3).
more_comp(E0, E1, X0) :-
impure unsafe_perform_io(io.print({"more_comp",E0,E1,X0})),
impure unsafe_perform_io(io.nl),
false.
:- pragma promise_pure(rich_a_in/3).
rich_a_in(E0, I0, I1) :-
impure unsafe_perform_io(io.print({"rich_a_in",E0,I0,I1})),
impure unsafe_perform_io(io.nl),
false.
:- pragma promise_pure(card/3).
card(E, I, C) :-
impure unsafe_perform_io(io.print({"card",E,I,C})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(aunt_n_of/2).
aunt_n_of(I0,I1) :-
impure unsafe_perform_io(io.print({"Testing aunt_n_of",I1})),
impure unsafe_perform_io(io.nl),
person(I0),
impure unsafe_perform_io(io.print({"OK: aunt_n_of",I0,I1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(victim_n_of/2).
victim_n_of(I0, I1) :-
impure unsafe_perform_io(io.print({"Testing victim_n_of",I1})),
impure unsafe_perform_io(io.nl),
person(I0),
impure unsafe_perform_io(io.print({"OK: victim_n_of",I0,I1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(people_n_of/2).
people_n_of(I0, I1) :-
impure unsafe_perform_io(io.print({"people_n_of",I1})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(except_p/3).
except_p(E0, I0, I1) :-
impure unsafe_perform_io(io.print({"except_p",E0,I0,I1})),
impure unsafe_perform_io(io.nl),
not I0 = I1.
:- pragma promise_pure(unknown/2).
unknown(U, E) :-
impure unsafe_perform_io(io.print({"unknown",U,E})),
impure unsafe_perform_io(io.nl),
true.
:- pragma promise_pure(therefore_a_1/2).
therefore_a_1(I, Func) :-
impure unsafe_perform_io(io.print({"therefore_a_1",I,Func})),
impure unsafe_perform_io(io.nl),
apply(Func) = yes.
:- pragma promise_pure(colon_p_namely/3).
colon_p_namely(E, FuncA, FuncB) :-
impure unsafe_perform_io(io.print({"colon_p_namely",E,FuncA,FuncB})),
impure unsafe_perform_io(io.nl),
apply(FuncA) = yes, apply(FuncB) = yes.
:- pragma promise_pure(coref/2).
coref(A,B) :-
impure unsafe_perform_io(io.print({"coref",A,B})),
impure unsafe_perform_io(io.nl),
A = B.
% Sentence 0
% "Someone who lives in Dreadbury Mansion killed Aunt Agatha." 0
:- pred h20s0(mrs_instance). % Dreadbury
:- mode h20s0(out) is det.
:- pred h14s0_1(mrs_instance). % Mansion
:- mode h14s0_1(out) is det.
:- pred h33s0(mrs_instance). % Aunt
:- mode h33s0(out) is det.
:- pred h27s0_1(mrs_instance). % Agatha
:- mode h27s0_1(out) is det.
:- pred h17s0(mrs_instance). % proper Dreadbury
:- mode h17s0(out) is nondet.
:- pred h30s0(mrs_instance).
:- mode h30s0(out) is nondet. % proper Agatha
:- pred h25s0(mrs_instance, mrs_instance). % Agatha predicates
:- mode h25s0(out,in) is nondet.
:- pred h12s0(mrs_instance, mrs_instance). % Dreadbury predicates
:- mode h12s0(out,in) is nondet.
:- pred h6s0(mrs_instance, mrs_instance). % in_p_loc, live_v_1, person
:- mode h6s0(in,out) is nondet.
:- pred h11s0(mrs_instance, mrs_instance). % proper Dreadbury Mansion
:- mode h11s0(out,in) is nondet.
:- pred h24s0(mrs_instance, mrs_instance). % proper Aunt Agatha
:- mode h24s0(out,in) is nondet.
:- pred h14s0_0(mrs_instance, mrs_instance). % Dreadbury Mansion compound
:- mode h14s0_0(in,in) is det.
:- pred h27s0_0(mrs_instance, mrs_instance). % Aunt Agatha compound
:- mode h27s0_0(in,in) is det.
:- pred h4s0_0(mrs_instance). % in_p_loc
:- mode h4s0_0(in) is det.
:- pred h4s0_1(mrs_instance). % live_v_1
:- mode h4s0_1(in) is det.
:- pred h4s0_2(mrs_instance). % person
:- mode h4s0_2(out) is nondet.
:- pred h5s0(mrs_instance, mrs_instance). % find persons in Mansion
:- mode h5s0(in,out) is nondet.
:- pred h1s0(mrs_instance, mrs_instance). % kill_v_1
:- mode h1s0(in,in) is semidet.
:- pred h13s0.
:- mode h13s0 is det.
:- pred h19s0.
:- mode h19s0 is det.
:- pred h26s0.
:- mode h26s0 is det.
:- pred h32s0.
:- mode h32s0 is det.
:- pred h7s0.
:- mode h7s0 is det.
:- func e15s0 = mrs_event.
:- func e2s0 = mrs_event.
:- func e28s0 = mrs_event.
:- func e8s0 = mrs_event.
:- func e9s0 = mrs_event.
:- pred combined0(mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance).
:- mode combined0(out,out,out,out,out) is nondet.
e15s0 = mrs_event(0,15).
e2s0 = mrs_event(0,2).
e28s0 = mrs_event(0,28).
e8s0 = mrs_event(0,8).
e9s0 = mrs_event(0,9).
h12s0(X10s0, X16s0) :- h14s0_0(X10s0, X16s0), h14s0_1(X10s0).
h20s0(X16s0) :- named(X16s0, mrs_carg("Dreadbury")).
h25s0(X23s0, X29s0) :- h27s0_0(X23s0, X29s0), h27s0_1(X23s0).
h33s0(X29s0) :- named(X29s0, mrs_carg("Aunt")).
h6s0(X10s0, X3s0) :- h4s0_0(X10s0), h4s0_1(X3s0), h4s0_2(X3s0).
h11s0(X10s0, X16s0) :- proper_q(X10s0,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h12s0(Val,X16s0)),
(func) = Ret :- Ret = (if h13s0 then yes else no)).
h14s0_0(X10s0, X16s0) :- compound(e15s0, X10s0, X16s0).
h14s0_1(X10s0) :- named(X10s0, mrs_carg("Mansion")).
h17s0(X16s0) :- proper_q(X16s0,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h20s0(Val)),
(func) = Ret :- Ret = (if h19s0 then yes else no)).
h1s0(X23s0, X3s0) :- kill_v_1(e2s0, X3s0, X23s0).
h24s0(X23s0, X29s0) :- proper_q(X23s0,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h25s0(Val,X29s0)),
(func) = Ret :- Ret = (if h26s0 then yes else no)).
h27s0_0(X23s0, X29s0) :- compound(e28s0, X23s0, X29s0).
h27s0_1(X23s0) :- named(X23s0, mrs_carg("Agatha")).
h30s0(X29s0) :- proper_q(X29s0,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h33s0(Val)),
(func) = Ret :- Ret = (if h32s0 then yes else no)).
h4s0_0(X10s0) :- in_p_loc(e9s0, e8s0, X10s0).
h4s0_1(X3s0) :- live_v_1(e8s0, X3s0).
h4s0_2(X3s0) :- person(X3s0).
h5s0(X10s0, X3s0) :-
some_q(X3s0, (func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h6s0(X10s0,Val)),
(func) = Ret :- Ret = (if h7s0 then yes else no)).
h13s0 :- true.
h19s0 :- true.
h26s0 :- true.
h32s0 :- true.
h7s0 :- true.
combined0(X10s0, X16s0, X23s0, X29s0, X3s0) :-
h1s0(X23s0, X3s0),
h11s0(X10s0, X16s0),
h17s0(X16s0),
h24s0(X23s0, X29s0),
h30s0(X29s0),
h5s0(X10s0, X3s0).
% Sentence 1
% "Agatha, the butler, and Charles live in Dreadbury Mansion, and are the only people who live therein." 1
:- pred h0s1(mrs_instance,mrs_instance,mrs_instance).
:- mode h0s1(in,out,in).
:- pred h11s1(mrs_instance).
:- mode h11s1(out) is semidet.
:- pred h28s1(mrs_instance).
:- mode h28s1(out) is semidet.
:- pred h34s1(mrs_instance,mrs_instance).
:- mode h34s1(out,in) is semidet.
:- pred h42s1(mrs_instance).
:- mode h42s1(out) is semidet.
:- pred h48s1(mrs_instance,mrs_instance).
:- mode h48s1(in,in) is nondet.
:- pred h13s1(mrs_instance,mrs_instance,mrs_instance).
:- mode h13s1(out,in,in) is nondet.
:- pred h17s1(mrs_instance,mrs_instance,mrs_instance).
:- mode h17s1(in,out,in) is semidet.
:- pred h18s1(mrs_instance).
:- mode h18s1(out) is nondet.
:- pred h1s1_0.
:- mode h1s1_0 is det.
:- pred h1s1_1(mrs_instance,mrs_instance).
:- mode h1s1_1(in,out) is det.
:- pred h1s1_2(mrs_instance).
:- mode h1s1_2(in) is det.
:- pred h1s1_3(mrs_instance).
:- mode h1s1_3(in) is det.
:- pred h22s1(mrs_instance).
:- mode h22s1(out) is nondet.
:- pred h23s1(mrs_instance, mrs_instance, mrs_instance).
:- mode h23s1(out, in, in) is nondet.
:- pred h25s1(mrs_instance).
:- mode h25s1(out).
:- pred h33s1(mrs_instance, mrs_instance).
:- mode h33s1(out,in).
:- pred h36s1_0(mrs_instance, mrs_instance).
:- mode h36s1_0(in,in).
:- pred h36s1_1(mrs_instance).
:- mode h36s1_1(out).
:- pred h39s1(mrs_instance).
:- mode h39s1(out).
:- pred h47s1(mrs_instance,mrs_instance).
:- mode h47s1(in,in).
:- pred h4s1(mrs_instance,mrs_instance,mrs_instance).
:- mode h4s1(in,in,in).
:- pred h50s1_0(mrs_instance).
:- mode h50s1_0(in).
:- pred h50s1_1(mrs_instance).
:- mode h50s1_1(in) is semidet.
:- pred h50s1_2(mrs_instance,mrs_instance).
:- mode h50s1_2(in,in) is nondet.
:- pred h50s1_3.
:- mode h50s1_3 is det.
:- pred h7s1(mrs_instance).
:- mode h7s1(out).
:- pred h16s1.
:- mode h16s1 is det.
:- pred h12s1.
:- mode h12s1 is det.
:- pred h27s1.
:- mode h27s1 is det.
:- pred h35s1.
:- mode h35s1 is det.
:- pred h41s1.
:- mode h41s1 is det.
:- pred h49s1.
:- mode h49s1 is det.
:- pred h6s1.
:- mode h6s1 is det.
:- pred h10s1.
:- mode h10s1 is det.
:- pred combined1(mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance).
:- mode combined1(out,out,out,out,out,out,out,out,out) is nondet.
:- func e2s1 = mrs_event.
:- func e30s1 = mrs_event.
:- func e31s1 = mrs_event.
:- func e37s1 = mrs_event.
:- func e45s1 = mrs_event.
:- func e51s1 = mrs_event.
:- func e53s1 = mrs_event.
:- func e54s1 = mrs_event.
e2s1 = mrs_event(1,2).
e30s1 = mrs_event(1,30).
e31s1 = mrs_event(1,31).
e37s1 = mrs_event(1,37).
e45s1 = mrs_event(1,45).
e51s1 = mrs_event(1,51).
e53s1 = mrs_event(1,53).
e54s1 = mrs_event(1,54).
h0s1(X3s1, X46s1, X32s1) :- h1s1_0, h1s1_1(X3s1, X46s1), h1s1_2(X32s1), h1s1_3(X3s1).
h11s1(X8s1) :- named(X8s1, mrs_carg("Agatha")).
h28s1(X24s1) :- named(X24s1, mrs_carg("Charles")).
h34s1(X32s1, X38s1) :- h36s1_0(X32s1, X38s1), h36s1_1(X32s1).
h42s1(X38s1) :- named(X38s1, mrs_carg("Dreadbury")).
h48s1(X46s1,I52s1) :- h50s1_0(X46s1), h50s1_1(X46s1), h50s1_2(X46s1,I52s1), h50s1_3.
h13s1(X14s1,X19s1,X24s1) :- udef_q(X14s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h23s1(Val, X19s1, X24s1)),
(func) = Ret :- Ret = (if h16s1 then yes else no)).
h17s1(X14s1, X3s1, X8s1) :- implicit_conj(X3s1, X8s1, X14s1).
h18s1(X19s1) :- the_q(X19s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h22s1(Val)),
(func) = Ret :- Ret = (if h12s1 then yes else no)).
h1s1_0 :- and_c_e(e2s1, e30s1, e45s1).
h1s1_1(X3s1, X46s1) :- be_v_id(e45s1, X3s1, X46s1).
h1s1_2(X32s1) :- in_p_loc(e31s1, e30s1, X32s1).
h1s1_3(X3s1) :- live_v_1(e30s1, X3s1).
h22s1(X19s1) :- butler_n_1(X19s1).
h23s1(X14s1, X19s1, X24s1) :- and_c_x(X14s1, X19s1, X24s1).
h25s1(X24s1) :- proper_q(X24s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h28s1(Val)),
(func) = Ret :- Ret = (if h27s1 then yes else no)).
h33s1(X32s1, X38s1) :- proper_q(X32s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h34s1(Val,X38s1)),
(func) = Ret :- Ret = (if h35s1 then yes else no)).
h36s1_0(X32s1, X38s1) :- compound(e37s1, X32s1, X38s1).
h36s1_1(X32s1) :- named(X32s1, mrs_carg("Mansion")).
h39s1(X38s1) :- proper_q(X38s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h42s1(Val)),
(func) = Ret :- Ret = (if h41s1 then yes else no)).
h47s1(X46s1,I52s1) :- the_q(X46s1,
(func) = Ret :- Ret = [X46s1],
(func) = Ret :- Ret = (if h49s1 then yes else no)).
h4s1(X14s1, X3s1, X8s1) :- udef_q(X3s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h17s1(X14s1,Val,X8s1)),
(func) = Ret :- Ret = (if h6s1 then yes else no)).
h50s1_0(X46s1) :- live_v_1(e53s1, X46s1).
h50s1_1(X46s1) :- only_a_1(e51s1, X46s1).
h50s1_2(X46s1,I52s1) :- people_n_of(X46s1, I52s1).
h50s1_3 :- therein_p_dir(e54s1, e53s1).
h7s1(X8s1) :- proper_q(X8s1,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h11s1(Val)),
(func) = Ret :- Ret = (if h10s1 then yes else no)).
h16s1 :- true.
h12s1 :- true.
h27s1 :- true.
h35s1 :- true.
h41s1 :- true.
h49s1 :- true.
h6s1 :- true.
h10s1 :- true.
person(mrs_instance(mrs_carg("Charles"))).
combined1(X14s1, X19s1, X24s1, X32s1, X38s1, X3s1, X46s1, X8s1, I52s1) :-
h7s1(X8s1),
h39s1(X38s1),
h33s1(X32s1, X38s1),
h0s1(X3s1, X46s1, X32s1),
h25s1(X24s1),
h22s1(X19s1),
h18s1(X19s1),
h13s1(X14s1, X19s1, X24s1),
h13s1(X14s1,X19s1,X24s1),
h17s1(X14s1, X3s1, X8s1),
I52s1 = mrs_instance(mrs_carg("1")),
h47s1(X46s1,I52s1),
h4s1(X14s1, X3s1, X8s1).
% Sentence 2
% "A killer always hates his victim, and is never richer than his victim."
:- pred h0s2(mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance).
:- mode h0s2(in,in,in,in,in,in) is semidet.
:- pred h12s2(mrs_instance,mrs_instance,mrs_instance).
:- mode h12s2(in,out,in) is nondet.
:- pred h24s2(mrs_instance, mrs_instance,mrs_instance).
:- mode h24s2(in,in,in) is semidet.
:- pred h30s2(mrs_instance, mrs_instance, mrs_instance).
:- mode h30s2(out,in,in) is nondet.
:- pred h11s2(mrs_instance, mrs_instance, mrs_instance).
:- mode h11s2(in,out,in) is nondet.
:- pred h14s2_0(mrs_instance, mrs_instance).
:- mode h14s2_0(in, in) is det.
:- pred h14s2_1(mrs_instance,mrs_instance).
:- mode h14s2_1(out,in) is nondet.
:- pred h17s2(mrs_instance).
:- mode h17s2(in) is nondet.
:- pred h1s2_0(mrs_instance).
:- mode h1s2_0(in) is det.
:- pred h1s2_1.
:- mode h1s2_1 is det.
:- pred h1s2_2(mrs_instance, mrs_instance).
:- mode h1s2_2(in,in) is semidet.
:- pred h1s2_3(mrs_instance,mrs_instance,mrs_instance, mrs_instance).
:- mode h1s2_3(in,in,in,in) is semidet.
:- pred h20s2(mrs_instance).
:- mode h20s2(in) is nondet.
:- pred h25s2_0(mrs_instance).
:- mode h25s2_0(in) is semidet.
:- pred h25s2_1(mrs_instance,mrs_instance).
:- mode h25s2_1(in,in) is semidet.
:- pred h29s2(mrs_instance, mrs_instance, mrs_instance).
:- mode h29s2(out,in,in) is nondet.
:- pred h32s2_0(mrs_instance,mrs_instance).
:- mode h32s2_0(in,in) is det.
:- pred h32s2_1(mrs_instance,mrs_instance).
:- mode h32s2_1(out,in) is nondet.
:- pred h35s2(mrs_instance).
:- mode h35s2(in) is semidet.
:- pred h38s2(mrs_instance).
:- mode h38s2(in) is det.
:- pred h4s2(mrs_instance).
:- mode h4s2(out) is nondet.
:- pred h7s2(mrs_instance).
:- mode h7s2(out) is nondet.
:- pred combined2(mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance).
:- mode combined2(out,out,out,out,out,out,out,out,out) is nondet.
:- pred h13s2.
:- mode h13s2 is det.
:- pred h19s2.
:- mode h19s2 is det.
:- pred h31s2.
:- mode h31s2 is det.
:- pred h37s2.
:- mode h37s2 is det.
:- pred h6s2.
:- mode h6s2 is det.
:- func e2s2 = mrs_event.
:- func e9s2 = mrs_event.
:- func e15s2 = mrs_event.
:- func e22s2 = mrs_event.
:- func e27s2 = mrs_event.
:- func e33s2 = mrs_event.
e2s2 = mrs_event(2,2).
e9s2 = mrs_event(9,2).
e15s2 = mrs_event(15,2).
e22s2 = mrs_event(22,2).
e27s2 = mrs_event(27,2).
e33s2 = mrs_event(33,2).
h0s2(I8s2, I23s2, I26s2, X10s2, X3s2, X28s2) :- h1s2_0(I8s2), h1s2_1, h1s2_2(X10s2, X3s2), h1s2_3(I23s2,I26s2,X28s2,X3s2).
h12s2(I21s2, X10s2, X16s2) :-
h14s2_1(X10s2,I21s2),
h14s2_0(X10s2, X16s2).
h24s2(X28s2, X3s2, I26s2) :- h25s2_0(X28s2), h25s2_1(X3s2,I26s2).
h30s2(X28s2, X34s2, I39s2) :- h32s2_1(X28s2,I39s2), h32s2_0(X28s2, X34s2).
h11s2(I21s2, X10s2, X16s2) :- def_explicit_q(X10s2,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h12s2(I21s2,Val,X16s2)),
(func) = Ret :- Ret = (if h13s2 then yes else no)).
h14s2_0(X10s2, X16s2) :- poss(e15s2, X10s2, X16s2).
h14s2_1(X10s2,I21s2) :- victim_n_of(X10s2, I21s2).
h17s2(X16s2) :- pronoun_q(X16s2,
(func) = Ret :- Ret = (if h20s2(X16s2) then [X16s2] else []),
(func) = Ret :- Ret = (if h19s2 then yes else no)).
h1s2_0(I8s2) :- always_a_1(I8s2, e9s2).
h1s2_1 :- and_c_e(e2s2, e9s2, e22s2).
h1s2_2(X10s2, X3s2) :- hate_v_1(e9s2, X3s2, X10s2).
h1s2_3(I23s2, I26s2, X28s2, X3s2) :- X28s2 = X3s2, never_a_1(I23s2, (func) = Ret :- Ret = (if h24s2(I26s2, X28s2, X3s2) then yes else no)).
h20s2(X16s2) :- pron(X16s2).
h25s2_0(X28s2) :- more_comp(e27s2, e22s2, X28s2).
h25s2_1(X3s2,I26s2) :- rich_a_in(e22s2, X3s2, I26s2).
h29s2(X28s2, X34s2, I39s2) :- def_explicit_q(X28s2,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h30s2(Val,X34s2,I39s2)),
(func) = Ret :- Ret = (if h31s2 then yes else no)).
h32s2_0(X28s2, X34s2) :- poss(e33s2, X28s2, X34s2).
h32s2_1(X28s2,I39s2) :- victim_n_of(X28s2, I39s2).
h35s2(X34s2) :- pronoun_q(X34s2,
(func) = Ret :- Ret = (if h38s2(X34s2) then [X34s2] else []),
(func) = Ret :- Ret = (if h37s2 then yes else no)).
h38s2(X34s2) :- pron(X34s2).
h4s2(X3s2) :- a_q(X3s2,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h7s2(Val)),
(func) = Ret :- Ret = (if h6s2 then yes else no)).
h7s2(X3s2) :- killer_n_1(X3s2).
combined2(I8s2, I23s2, I26s2, I39s2, X10s2, X16s2, X28s2, X34s2, X3s2) :-
I8s2 = mrs_instance(mrs_carg("I8s2")),
I21s2 = mrs_instance(mrs_carg("I21s2")),
I23s2 = mrs_instance(mrs_carg("I23s2")),
I26s2 = mrs_instance(mrs_carg("I26s2")),
I39s2 = mrs_instance(mrs_carg("I39s2")),
h4s2(X3s2),
X16s2 = X3s2,
X34s2 = X3s2,
h11s2(I21s2, X10s2, X16s2),
h0s2(I8s2, I23s2, I26s2, X10s2, X3s2, X28s2),
h17s2(X16s2),
h20s2(X16s2),
h29s2(X28s2, X34s2, I39s2),
h35s2(X34s2),
h38s2(X34s2),
h7s2(X3s2).
h13s2 :- true.
h19s2 :- true.
h31s2 :- true.
h37s2 :- true.
h6s2 :- true.
% Sentence 3
% "Charles hates no one that Aunt Agatha hates."
:- pred h11s3(mrs_instance, mrs_instance).
:- mode h11s3(out,in) is nondet.
:- pred h18s3(mrs_instance, mrs_instance).
:- mode h18s3(out, in) is nondet.
:- pred h7s3(mrs_instance).
:- mode h7s3(out) is det.
:- pred h10s3(mrs_instance, mrs_instance).
:- mode h10s3(in, out) is nondet.
:- pred h13s3_0(mrs_instance).
:- mode h13s3_0(in) is det.
:- pred h13s3_1(mrs_instance).
:- mode h13s3_1(out) is det.
:- pred h13s3_2(mrs_instance, mrs_instance).
:- mode h13s3_2(in, in) is semidet.
:- pred h16s3(mrs_instance, mrs_instance).
:- mode h16s3(out, in) is nondet.
:- pred h20s3_0(mrs_instance, mrs_instance).
:- mode h20s3_0(in, in) is semidet.
:- pred h20s3_1(mrs_instance).
:- mode h20s3_1(out) is det.
:- pred h23s3(mrs_instance,mrs_instance).
:- mode h23s3(out,in) is nondet.
:- pred h26s3(mrs_instance,mrs_instance).
:- mode h26s3(out,in) is nondet.
:- pred h4s3(mrs_instance).
:- mode h4s3(out) is nondet.
:- pred h1s3(mrs_instance, mrs_instance).
:- mode h1s3(in,in) is semidet.
:- pred combined3(mrs_instance, mrs_instance, mrs_instance, mrs_instance, mrs_instance).
:- mode combined3(out, out, out, out, out) is nondet.
:- pred h6s3.
:- mode h6s3 is det.
:- pred h12s3.
:- mode h12s3 is det.
:- pred h19s3.
:- mode h19s3 is det.
:- pred h25s3.
:- mode h25s3 is det.
:- func e2s3 = mrs_event.
:- func e15s3 = mrs_event.
:- func e21s3 = mrs_event.
:- func e29s3 = mrs_event.
e2s3 = mrs_event(2,3).
e15s3 = mrs_event(15,3).
e21s3 = mrs_event(21,3).
e29s3 = mrs_event(29,3).
h11s3(X9s3, X17s3) :- h13s3_1(X9s3), h13s3_0(X9s3), h13s3_2(X17s3, X9s3).
h18s3(X17s3, X22s3) :- h20s3_0(X17s3, X22s3), h20s3_1(X17s3).
h7s3(X3s3) :- named(X3s3, mrs_carg("Charles")).
h10s3(X17s3, X9s3) :- no_q(X9s3,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h11s3(Val,X17s3)),
(func) = Ret :- Ret = (if h12s3 then yes else no)).
h13s3_0(X9s3) :- card(e15s3, X9s3, mrs_carg("1")).
h13s3_1(X9s3) :- generic_entity(X9s3).
h13s3_2(X17s3, X9s3) :- hate_v_1(e29s3, X17s3, X9s3).
h16s3(X17s3, X22s3) :- proper_q(X17s3,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h18s3(Val,X22s3)),
(func) = Ret :- Ret = (if h19s3 then yes else no)).
h20s3_0(X17s3, X22s3) :- compound(e21s3, X17s3, X22s3).
h20s3_1(X17s3) :- named(X17s3, mrs_carg("Agatha")).
h23s3(X22s3,I27s3) :- udef_q(X22s3,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h26s3(Val,I27s3)),
(func) = Ret :- Ret = (if h25s3 then yes else no)).
h26s3(X22s3,I27s3) :- aunt_n_of(X22s3, I27s3).
h4s3(X3s3) :- proper_q(X3s3,
(func) = Ret :- Ret = solutions(pred(Val::out) is nondet :- h7s3(Val)),
(func) = Ret :- Ret = (if h6s3 then yes else no)).
h1s3(X3s3, X9s3) :- hate_v_1(e2s3, X3s3, X9s3).
combined3(X17s3, X22s3, X3s3, X9s3, I27s3) :-
I27s3 = mrs_instance(mrs_carg("i27s3")),
h23s3(X22s3,I27s3),
h16s3(X17s3,X22s3),
h10s3(X17s3,X9s3),
h26s3(X22s3,I27s3),
h4s3(X3s3),
h1s3(X3s3, X9s3),
X22s3 = X17s3. % aunt_n_of should always be Agatha
h6s3 :- true.
h12s3 :- true.
h19s3 :- true.
h25s3 :- true.
% Sentence 4
% "Agatha hates everyone except the butler."
:- pred h12s4(mrs_instance, mrs_instance).
:- mode h12s4(in,out) is nondet.
:- pred h7s4(mrs_instance).
:- mode h7s4(out) is det.
:- pred h10s4_0(mrs_instance, mrs_instance).
:- mode h10s4_0(in, in) is semidet.
:- pred h10s4_1(mrs_instance).
:- mode h10s4_1(out) is nondet.
:- pred h11s4(mrs_instance, mrs_instance).
:- mode h11s4(in, out) is nondet.
:- pred h16s4(mrs_instance).
:- mode h16s4(out) is nondet.
:- pred h19s4(mrs_instance).
:- mode h19s4(out) is nondet.
:- pred h4s4(mrs_instance).
:- mode h4s4(out) is nondet.
:- pred h1s4(mrs_instance, mrs_instance).
:- mode h1s4(in, in) is semidet.
:- pred combined4(mrs_instance, mrs_instance, mrs_instance).
:- mode combined4(out, out, out) is nondet.
:- pred h6s4.
:- mode h6s4 is det.
:- pred h13s4.
:- mode h13s4 is det.
:- pred h18s4.
:- mode h18s4 is det.
:- func e2s4 = mrs_event.
:- func e14s4 = mrs_event.
e2s4 = mrs_event(2,4).