-
Notifications
You must be signed in to change notification settings - Fork 3
/
english.gram
3143 lines (2764 loc) · 239 KB
/
english.gram
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
# english.gram
# Author: asaparov
#
# Examples of sentences as well as broad strokes of the grammar were found in:
# Huddleston, R. D. & Pullum, G. K. (2002). The Cambridge Grammar of the English Language. Cambridge University Press.
#
# We use neo-Davidsonian/event semantics to represent meaning in logical form.
# Thus, all verbs, nouns, adjectives, adverbs, etc are expressed as quantified
# variables. A "head" of any logical form is the scope `y` such that there is
# no other scope `x` in the logical form with an edge `argn(x)=y` and `y` is
# not a set variable.
#
# We also chose to order the terms in the logical forms to match the order of
# the words/complements/arguments in the sentence as close as possible. This is
# so that, for each nonterminal, when selecting which production rule to
# expand, we only want to inspect one term (or a constant number of terms) in
# the logical form in order to make the decision. However, if the order of `n`
# terms in the head scope of the logical form is canonical, then we would need
# to inspect all `n` terms to capture the correct distribution.
#
# "cats are mammals."
# ![x]:(U(0,x) & cat(x) => ?[m]:(U(2,m) & mammal(m) & ?[s]:(arg1(s)=x & U(1,s) & same(s) & present(s) & arg2(s)=m)))
# where `present` is relative to the deictic origo, so it could be defined as
# something like ![x]:(present(x) = time(x)(T)) where time(x) returns the set
# of times at which the event x is true, and T is the current time in the
# discourse model (deictic origo). Also, `U` is the current universe of
# discourse. `U` can either contain the entire universe, as a default,
# U=^[x]:T, or it could change dynamically according to the discourse model.
# The first argument to `U` is an index that increases by one each time `U`
# function is invoked (and so its semantics can differ even within a sentence).
#
# Generally, every event that corresponds to a verb is modified with
# information about the time at which the event occurs. We can do this with the
# following axioms:
# ![x,t]:(progressive(x,t) = ?[r]:(r>0 & ![s]:(s>(t-r) & s<(t+r) => time(x)(t))))
# ![x,t]:(perfect(x,t) = ![r]:(time(x)(r) => r<t))
# ![x,t]:(perfect_progressive(x,t) = (perfect(x,t) & ?[r]:(r>0 & ![s]:(s>(t-r) & s<t => time(x)(t)))))
# ![x]:(present(x) = time(x)(T))
# ![x]:(present_progressive(x) = progressive(x,T))
# ![x]:(present_perfect(x) = perfect(x,T))
# ![x]:(present_perfect_progressive(x) = perfect_progressive(x,T))
# ![x]:(past(x) = ?[t]:(t<T & time(x)(t)))
# ![x]:(past_progressive(x) = ?[t]:(t<T & progressive(x,t)))
# ![x]:(past_perfect(x) = ?[t]:(t<T & perfect(x,t)))
# ![x]:(past_perfect_progressive(x) = ?[t]:(t<T & perfect_progressive(x,t)))
# ![x]:(future(x) = ?[t]:(t>T & time(x)(t)))
# ![x]:(future_progressive(x) = ?[t]:(t>T & progressive(x,t)))
# ![x]:(future_perfect(x) = ?[t]:(t>T & perfect(x,t)))
# ![x]:(future_perfect_progressive(x) = ?[t]:(t>T & perfect_progressive(x,t)))
#
# "4 cats sleep."
# ?[X]:(subset(X,^[x]:(U(0,x) & cat(x))) & size(X)=4 & ![x]:(X(x) => ?[s]:(arg1(s)=x & U(1,s) & sleep(s) & present(s))))
#
# "4 cats slept."
# ?[X]:(subset(X,^[x]:(U(0,x) & cat(x))) & size(X)=4 & ![x]:(X(x) => ?[s]:(arg1(s)=x & U(1,s) & sleep(s) & past(s))))
#
# "4 cats will have been sleeping."
# ?[X]:(subset(X,^[x]:(U(0,x) & cat(x))) & size(X)=4 & ![x]:(X(x) => ?[s]:(arg1(s)=x & U(1,s) & sleep(s) & future_perfect_progressive(s))))
#
# "there is a cat."
# ?[x]:(U(0,x) & cat(x))
# [OR]
# ?[e]:(U(0,e) & exist(e) & present(e) & ?[c]:(U(1,c) & cat(c) & arg1(e)=c))
# [OR]
# ?[x]:(U(0,x) & cat(x) & ?[l]:(arg1(l)=x & U(1,l) & location(l) & present(l) & arg2(l)=L))
# where L is the current discourse location (location of deictic origo). There
# is a problem if we go with the first approach and we want to express a
# different tense, such as "there were dinosaurs", or "there will be an
# election".
#
# "3 teachers grade 6 exams."
# ?[X]:(subset(X,^[x]:(U(0,x) & teacher(x))) & size(X)=3 & ?[Y]:(subset(Y,^[y]:(U(1,y) & exam(y))) & size(Y)=6 & ![x,y]:(X(x) & Y(y) => ?[g]:(arg1(g)=x & U(2,g) & grade(g) & present(g) & arg2(g)=y))))
# ?[X]:(subset(X,^[x]:(U(0,x) & teacher(x))) & size(X)=3 & ?[Y]:(subset(Y,^[y]:(U(1,y) & exam(y))) & size(Y)=6 & !W[x,y]:(X(x) & Y(y) => ?[g]:(arg1(g)=x & U(2,g) & grade(g) & present(g) & arg2(g)=y))))
# ?[X]:(subset(X,^[x]:(U(0,x) & teacher(x))) & size(X)=3 & ![x]:(X(x) => ?[Y]:(subset(Y,^[y]:(U(1,y) & exam(y))) & size(Y)=6 & ![y]:(Y(y) => ?[g]:(arg1(g)=x & U(2,g) & grade(g) & present(g) & arg2(g)=y)))))
# where !W is the weak universal quantifier, which is defined as:
# !W[x1,...,xn]:(X1(x1) & ... & Xn(xn) => f(x1,...,xn)) =
# ![x1]:(X1(x1) => ?[x2,...,xn]:(X2(x2) & ... & Xn(xn) & f(x1,...,xn)))
# & ![x2]:(X2(x2) => ?[x1,x3,...,xn]:(X1(x1) & X3(x3) & ... & Xn(xn) & f(x1,...,xn)))
# & ![x3]:(X3(x3) => ?[x1,...,x2,x4,...,xn]:(X1(x1) & ... & X2(x2) & X4(x4) & ... & Xn(xn) & f(x1,...,xn)))
# & ![x4]:(X4(x4) => ?[x1,...,x3,x5,...,xn]:(X1(x1) & ... & X3(x3) & X5(x5) & ... & Xn(xn) & f(x1,...,xn)))
# & ... & ![xn]:(Xn(xn) => ?[x1,...,x(n-1)]:(X1(x1) & ... & X(n-1)(x(n-1)) & f(x1,...,xn)))
#
# "a dog likes every cat."
# ?[d]:(U(0,d) & dog(d) & ![c]:(U(1,c) & cat(c) => ?[l]:(arg1(l)=d & U(2,l) & like(l) & present(l) & arg2(l)=c)))
# ![c]:(U(0,c) & cat(c) => ?[d]:(U(1,d) & dog(d) & ?[l]:(arg1(l)=d & U(2,l) & like(l) & present(l) & arg2(l)=c)))
#
# "a dog is liked by every cat."
# ?[d]:(U(0,d) & dog(d) & ![c]:(U(1,c) & cat(c) => ?[l]:(arg1(l)=d & U(2,l) & inverse(like)(l) & present(l) & arg2(l)=c)))
# ![c]:(U(0,c) & cat(c) => ?[d]:(U(1,d) & dog(d) & ?[l]:(arg1(l)=d & U(2,l) & inverse(like)(l) & present(l) & arg2(l)=c)))
# where we can have an axiom like:
# ![e,t,x,y]:((inverse(t)(e) & arg1(e)=x & arg2(e)=y) = (t(e) & arg1(e)=y & arg2(e)=x))
# In fact, the passive voice is always realized in semantics using the
# `inverse` function.
#
# "Noah entertained and was reviewed."
# ?[e]:(arg1(e)=noah & U(0,e) & entertain(e) & past(e)) & ?[r]:(arg1(r)=noah & U(1,r) & inverse(review)(r) & past(r))
# NOTE: We originally labeled this sentence with the following logical form:
# ?[X]:(?[e]:(U(0,e) & entertain(e) & past(e) & ?[r]:(U(1,r) & inverse(review)(r) & past(r) & X=^[x]:(x=e | x=r))) & ^[x]:(X(x) => arg1(x)=noah))
# However, putting events into sets is problematic if one of the events is
# itself a set of events. See the later example "she made a big cake, and hung
# up some balloons".
#
# "not every cat is a tabby."
# "not all cats are tabbies."
# ~![c]:(U(0,c) & cat(c) => ?[s]:(arg1(s)=c & U(1,s) & same(s) & present(s) & ?[t]:(U(2,t) & tabby(t) & arg2(s)=t))
#
# "every cat isn't a tabby."
# "all cats aren't tabbies."
# ~![c]:(U(0,c) & cat(c) => ?[s]:(arg1(s)=c & U(1,s) & same(s) & present(s) & ?[t]:(U(2,t) & tabby(t) & arg2(s)=t))
# ![c]:(U(0,c) & cat(c) => ~?[s]:(arg1(s)=c & U(1,s) & same(s) & present(s) & ?[t]:(U(2,t) & tabby(t) & arg2(s)=t))
#
# "a cat and dog are sleeping."
# ?[X]:(?[c]:(U(0,c) & cat(c) & ?[d]:(U(1,d) & dog(d) & X=^[x]:(x=c | x=d))) & ![x]:(X(x) => ?[s]:(arg1(s)=x & U(2,s) & sleep(s) & present(s))))
#
# "4 cats, 2 dogs, and a bird are sleeping."
# ?[X]:(?[C]:(subset(C,^[x]:(U(0,x) & cat(x))) & size(C)=4 & ?[D]:(subset(D,^[x]:(U(1,x) & dog(x))) & size(D)=2 & ?[b]:(U(2,b) & bird(b) & X=^[x]:(x=C | x=D | x=^[y]:y=b)))) & ![Y]:(X(Y) => ![x]:(Y(x) => ?[s]:(arg1(s)=x & U(3,s) & sleep(s) & present(s)))))
#
# "a man and his dog were walking in the park."
# ?[X]:(?[m]:(U(0,m) & man(m) & ?[h]:(U(1,h) & male_ref(0,h) & ?[d]:(U(2,d) & dog(d) & ?[o]:(arg1(o)=h & U(3,o) & has(o) & arg2(o)=d) & X=^[x]:(x=m | x=d)))) & ![x]:(X(x) => ?[w]:(arg1(w)=x & U(4,w) & walk(w) & past_progressive(w) & ?[p]:(U(5,p) & park(p) & arg2(w)=p))))
# where `male_ref` is defined in the pragmatics model. We could supervise the
# pragmatics model by specifying that h and m refer to the same object. We
# similarly define `female_ref` for grammatically female anaphora and `ref` for
# anaphora whose grammatical gender is either neutral or unspecified. The first
# argument of `male_ref` is an index parameter so that multiple uses of "he" in
# the same sentence can potentially refer to different objects (just as the
# first argument of `U`).
#
# "10 girls and boys are in class."
# ?[X]:(?[G]:(G=^[x]:(U(0,x) & girl(x)) & ?[B]:(B=^[x]:(U(1,x) & boy(x)) & X=^[x]:(x=G | x=B))) & ![Y]:(X(Y) => size(Y)=10) & ![Y]:(X(Y) => ![x]:(Y(x) => ?[p]:(arg1(p)=x & U(2,p) & location(p) & ?[c]:(U(3,c) & class(c) & arg2(p)=c)))))
# ?[X]:(?[G]:(G=^[x]:(U(0,x) & girl(x)) & ?[B]:(B=^[x]:(U(1,x) & boy(x)) & X=^[x]:(x=G | x=B))) & sum(X,^[Y]:size(Y))=10 & ![Y]:(X(Y) => ![x]:(Y(x) => ?[p]:(arg1(p)=x & U(2,p) & location(p) & present(p) & ?[c]:(U(3,c) & class(c) & arg2(p)=c)))))
#
# "a cat is not currently but will be in the room."
# ?[c]:(U(0,c) & cat(c) & ?[r]:(U(1,r) & room(r) & ?[l]:(arg1(l)=c & U(2,l) & location(l) & present(l) & arg2(l)=r & ?[c]:(U(3,c) & currently(c) & arg1(c)=l)) & ?[l]:(arg1(l)=c & U(4,l) & location(l) & future(l) & arg2(l)=r)))
#
# "Jane is the only doctor."
# ?[o]:(arg1(o)=jane & U(0,o) & only(o) & present(o) & arg2(o)=^[x]:(U(1,x) & doctor(x)))
# [or maybe we should do]
# ?[o]:(arg1(o)=jane & U(0,o) & only(o) & present(o) & ?[D]:(D=^[x]:(U(1,x) & doctor(x)) & arg2(o)=D))
#
# "i did not get much money."
# ?[m]:(U(0,m) & money(m) & ?[l]:(U(1,l) & large_amount(l) & arg1(l)=m) & ~?[r]:(arg1(r)=me & U(2,r) & receive(r) & past(r) & arg2(r)=m))
#
# "i did not get very much money."
# ?[m]:(U(0,m) & money(m) & ?[l]:(U(1,l) & very(large_amount)(l) & arg1(l)=m) & ~?[r]:(arg1(r)=me & U(2,r) & receive(r) & past(r) & arg2(r)=m))
# [OR]
# ?[m]:(U(0,m) & money(m) & ?[l]:(?[v]:(U(1,v) & very(v) & arg1(v)=l) & U(2,l) & large_amount(l) & arg1(l)=m) & ~?[r]:(arg1(r)=me & U(3,r) & receive(r) & past(r) & arg2(r)=m))
#
# "i don't like Ralph's destroying the barn."
# "i don't like Ralph's destruction of the barn."
# ?[d]:(arg1(d)=ralph & U(0,d) & destroy(d) & progressive(d) & ?[b]:(U(1,b) & barn(b) & arg2(d)=b) & ~?[l]:(arg1(l)=me & U(2,l) & like(l) & present(l) & arg2(l)=d))
# NOTE: We could require constant arguments (e.g. `ralph` and `me`) to be part
# of U in the discourse model.
#
# "i don't like the destruction of the barns by the teenagers."
# ![x]:(U(0,x) & teenager(x) => ![y]:(U(1,y) & barn(y) => ?[d]:(arg1(d)=x & U(2,d) & destroy(d) & arg2(d)=y & ~?[l]:(U(3,l) & like(l) & arg2(l)=d & arg1(l)=me))))
# [OR]
# ?[X]:(X=^[x]:(U(0,x) & teenager(x)) & ?[Y]:(Y=^[y]:(U(1,y) & barn(y)) & ![x]:(X(x) => ![y]:(Y(y) => ?[d]:(arg1(d)=x & U(2,d) & destroy(d) & arg2(d)=y & ~?[l]:(arg1(l)=me & U(3,l) & like(l) & arg2(l)=d))))))
#
# "the cat's purring is soothing."
# ?[p]:(?[c]:(U(0,c) & cat(c) & arg1(p)=c) & U(1,p) & purr(p) & progressive(p) & ?[s]:(arg1(s)=p & U(2,s) & sooth(s) & progressive(s)))
#
# "Joan's pen is good."
# ?[p]:(U(0,p) & pen(p) & ?[o]:(arg1(o)=joan & U(1,o) & has(o) & arg2(o)=p) & ?[g]:(arg1(g)=p & U(2,g) & good(g) & present(g)))
#
# "Joan's pens are good."
# ![x]:(U(0,x) & pen(x) & ?[o]:(arg1(o)=joan & U(1,o) & has(o) & arg2(o)=x) => ?[g]:(arg1(g)=x & U(2,g) & good(g) & present(g)))
# [OR]
# ?[X]:(X=^[p]:(U(0,p) & pen(p) & ?[o]:(arg1(o)=joan & U(1,o) & has(o) & arg2(o)=p)) & ![x]:(X(x) => ?[g]:(arg1(g)=x & U(2,g) & good(g) & present(g))))
#
# "the students' pens are good."
# ?[X]:(?[Y]:(Y=^[y]:(U(0,y) & student(y)) & X=^[x]:(U(1,x) & pen(x) & ?[y]:(Y(y) & ?[o]:(U(2,o) & has(o) & arg2(o)=x & arg1(o)=y)))) & ![x]:(X(x) => ?[g]:(arg1(g)=x & U(3,g) & good(g) & present(g))))
#
# "i saw the trees by all the cats."
# ?[X]:(X=^[x]:(U(0,x) & cat(x)) & ?[Y]:(Y=^[y]:(U(1,y) & tree(y) & ![x]:(X(x) => ?[n]:(U(2,n) & near(n) & arg2(n)=y & arg1(n)=x))) & ![y]:(Y(y) => ?[s]:(arg1(s)=me & U(3,s) & see(s) & past(s) & arg2(s)=y))))
# [OR]
# ![y]:(U(0,y) & tree(y) & ![x]:(U(1,x) & cat(x) => ?[n]:(U(2,n) & near(n) & arg2(n)=y & arg1(n)=x)) => ?[s]:(arg1(s)=me & U(3,s) & see(s) & past(s) & arg2(s)=y))
#
# "he works a lot to earn money for school."
# ?[h]:(U(0,h) & male_ref(0,h) & ?[w]:(arg1(w)=h & U(1,w) & work(w) & present(w) & ?[l]:(U(2,l) & large_duration(l) & arg1(l)=w) & ?[p]:(U(3,p) & purpose(p) & ?[e]:(U(4,e) & earn(e) & ?[m]:(U(5,m) & money(m) & arg2(e)=m) & arg2(p)=e) & arg1(p)=w)))
#
# "the ladder collapsed because it was old."
# ?[l]:(U(0,l) & ladder(l) & ?[c]:(arg1(c)=l & U(1,c) & collapse(c) & past(c) & ?[r]:(U(2,r) & reason(r) & ?[i]:(U(3,i) & ref(0,i) & ?[o]:(U(4,o) & old(o) & past(o) & arg1(o)=i & arg2(r)=o)) & arg1(r)=c)))
#
# "Mr. Bibby wrote the letter with a pencil."
# ?[p]:(U(0,p) & pencil(p) & ?[l]:(U(1,l) & letter(l) & ?[w]:(arg1(x)=w & U(2,w) & write(w) & arg2(w)=l & arg1(w)=bibby & ?[x]:(U(3,x) & with(x) & arg2(x)=p))))
#
# "the students wrote the letters with the pencils."
# ?[S]:(S=^[s]:(U(0,s) & student(s)) & ?[L]:(L=^[l]:(U(1,l) & letter(l)) & ?[P]:(P=^[p]:(U(2,p) & pencil(p)) & !W[s,l,p]:(S(s) & L(l) & P(p) => ?[w]:(arg1(w)=s & U(3,w) & wrote(w) & past(w) & arg2(w)=l & ?[x]:(U(4,x) & with(x) & arg2(x)=p & arg1(x)=w))))))
#
# "she sat on the table."
# ?[x]:(U(0,x) & female_ref(0,x) & ?[s]:(arg1(s)=x & U(1,s) & sit(s) & past(s) & ?[o]:(U(2,o) & on_top_of(o) & ?[t]:(U(3,t) & table(t) & arg2(o)=t) & arg1(o)=s)))
#
# "the birds hear each other."
# ?[X]:(X=^[x]:(U(0,x) & bird(x)) & ![x,y]:(X(x) & Y(x) & ~(x=y) => ?[h]:(arg1(h)=x & U(1,h) & hear(h) & arg2(h)=y)))
#
# "some relative of each villager and some relative of each townsman hate each other."
# ?[a]:(U(0,a) & ![x]:(U(1,x) & villager(x) => ?[r]:(U(2,r) & related_to(r) & arg2(r)=x & arg1(r)=a)) & ?[b]:(U(3,b) & ![x]:(U(4,x) & townsman(x) => ?[r]:(U(5,r) & related_to(r) & arg2(r)=x & arg1(r)=b)) & ?[X]:(X=^[x]:(x=a | x=b) & ![x,y]:(X(x) & Y(x) & ~(x=y) => ?[h]:(arg1(h)=x & U(6,h) & hate(h) & arg2(h)=y)))))
#
# "in either case, i am going."
# ?[X]:(subset(X,^[x]:(U(0,x) & case(x))) & size(X)=2 & ![x]:(X(x) => (true(x) => ?[g]:(arg1(g)=me & U(1,g) & go(g) & progressive(g)))))
#
# "if it rains, the grass will be wet."
# "the grass, if it rains, will be wet."
# ?[i]:(U(0,i) & ref(0,i) & ?[r]:(U(1,r) & rain(r) & present(r) & arg1(r)=i)) => ?[g]:(U(2,g) & grass(g) & ?[w]:(U(3,w) & wet(w) & future(w) & arg1(w)=g))
#
# "he ran with difficulty."
# ?[h]:(U(0,h) & male_ref(0,h) & ?[r]:(arg1(r)=h & U(1,r) & run(r) & past(r) & ?[d]:(U(2,d) & difficult(d) & arg1(d)=r)))
#
# "he stood in silence."
# ?[h]:(U(0,h) & male_ref(0,h) & ?[s]:(arg1(s)=h & U(1,s) & stand(s) & past(s) & ?[x]:(U(2,x) & while(is_silent)(x) & arg1(x)=s)))
# where we could define ![x,p]:(while(p)(x) = ?[s]:(p(s) & arg1(s)=arg1(x) & ![t]:(time(x)(t) => time(s)(t))))
#
# "she helped me with my homework."
# ?[s]:(U(0,s) & female_ref(0,s) & ?[h]:(arg1(h)=s & U(1,h) & help(h) & past(h) & arg2(h)=me & ?[o]:(U(2,o) & has(o) & arg2(o)=x & arg1(o)=me) & ?[w]:(U(3,w) & with(w) & ?[x]:(U(4,x) & homework(x) & arg2(w)=x & arg1(w)=h))))
#
# "he stayed for two weeks."
# ?[h]:(U(0,h) & male_ref(0,h) & ?[s]:(arg1(s)=h & U(1,s) & stay(s) & past(s) & ?[d]:(U(2,d) & duration(d) & arg2(d)=(2*week) & arg1(d)=s)))
#
# "it is under the bush."
# ?[i]:(U(0,i) & ref(0,i) & ?[u]:(arg1(u)=i & U(1,u) & is_under(u) & present(u) & ?[b]:(U(2,b) & bush(b) & arg2(u)=b)))
#
# "the party is at seven o'clock."
# ?[p]:(U(0,p) & party(p) & ?[s]:(arg1(s)=p & U(1,s) & start_time(s) & present(s) & arg2(s)=(7:00pm)))
# where we could define ![x,t]:((start_time(x)=t) = ![s]:(time(x)(s) => t<=s)),
# or perhaps `start_time` and `end_time` should be the elementary event time
# predicates rather than `time`.
# TODO: how do we represent date/time constants?
#
# "she will leave after she has had breakfast."
# ?[s]:(U(0,s) & female_ref(0,s) & ?[l]:(arg1(l)=s & U(1,l) & leave(l) & future(l) & ?[a]:(arg1(a)=l & U(2,a) & after(a) & ?[r]:(U(3,r) & female_ref(1,r) & ?[e]:(U(4,e) & eat(e) & ?[b]:(U(5,b) & breakfast(b) & arg2(e)=b) & arg1(e)=r & arg2(a)=e)))))
# where we could define ![a,x,y]:((after(a) & arg1(a)=x & arg2(a)=y) = ~?[s,t]:(time(x)(s) & time(y)(t) & s<t))
#
# "the ball rotated quickly and heated up slowly."
# ?[b]:(U(0,b) & ball(b) & ?[r]:(arg1(r)=b & U(1,r) & rotate(r) & past(r) & ?[q]:(U(2,q) & quick(q) & arg1(q)=r)) & ?[h]:(arg1(h)=b & U(3,h) & heat_up(h) & past(h) & ?[s]:(U(4,s) & slowly(s) & arg1(s)=h)))
# NOTE: We originally labeled this sentence with the following logical form:
# ?[b]:(U(0,b) & ball(b) & ?[r]:(rotate(r) & past(r) & ?[q]:(quick(q) & arg1(q)=r) & ?[h]:(heat_up(h) & past(h) & ?[s]:(slowly(s) & arg1(s)=h) & ?[X]:(X=^[x]:(x=r | x=h) & ![x]:(X(x) => arg1(x)=b)))))
# However, putting events into sets is problematic if one of the events is
# itself a set of events. See the later example "she made a big cake, and hung
# up some balloons".
#
# "the ball rotated and heated up slowly."
# ?[b]:(U(0,b) & ball(b) & ?[r]:(arg1(r)=b & U(1,r) & rotate(r) & past(r) & ?[s]:(U(2,s) & slowly(s) & arg1(s)=r)) & ?[h]:(arg1(h)=b & U(3,h) & heat_up(h) & past(h) & ?[s]:(U(4,s) & slowly(s) & arg1(s)=h)))
# NOTE: We originally labeled this sentence with the following logical form:
# ?[b]:(U(0,b) & ball(b) & ?[r]:(rotate(r) & past(r) & ?[h]:(heat_up(h) & past(h) & ?[X]:(X=^[x]:(x=r | x=h) & ![x]:(X(x) => ?[s]:(slowly(s) & arg1(s)=x) & arg1(x)=b)))))
# However, putting events into sets is problematic if one of the events is
# itself a set of events. See the later example "she made a big cake, and hung
# up some balloons".
#
# "slowly, the ball rotated and heated up."
# ?[b]:(U(0,b) & ball(b) & ?[r]:(?[s]:(U(1,s) & slowly(s) & arg1(s)=r) & arg1(r)=b & U(2,r) & rotate(r) & past(r)) & ?[h]:(?[s]:(U(3,s) & slowly(s) & arg1(s)=h) & arg1(h)=b & U(4,h) & heat_up(h) & past(h)))
#
# "Emma and Noah met."
# ?[X]:(X=^[x]:(x=emma | x=noah) & ?[m]:(arg1(m)=X & U(0,m) & collective_meet(m) & past(m)))
#
# "Emma and Noah lifted the stone."
# ?[X]:(X=^[x]:(x=emma | x=noah) & ?[s]:(U(0,s) & stone(s) & ?[l]:(U(1,l) & lift(l) & past(l) & arg2(l)=s & arg1(l)=X)))
# Here, "Emma and Noah" has a *collective* interpretation, which also occurs in
# many other sentences in English.
#
# "i think there is a unicorn."
# ?[t]:(arg1(t)=me & U(0,t) & think(t) & present(t) & arg2(t)=possibility(?[e]:(U(1,e) & exist(e) & present(e) & ?[u]:(U(2,u) & unicorn(u) & arg1(e)=u))))
# This is why we need the `true` predicate, since it provides a uniform way to
# handle modality, and to talk about objects and events that may not actually
# exist or be true, but may exist as thoughts or suppositions (the Platonic
# universe). All events have the property that if they are true, then all of
# its arguments are true, with a handful of specified exceptions, including
# `think`, `capable_of`, `want`, `purpose`, etc.
#
# "i can swim."
# "i am capable of swimming."
# ?[c]:(arg1(c)=me & U(0,c) & capable_of(c) & present(c) & arg2(c)=possibility(?[s]:(arg1(s)=me & U(1,s) & swim(s))))
#
# "i could swim."
# "i was capable of swimming."
# ?[c]:(arg1(c)=me & U(0,c) & capable_of(c) & past(c) & arg2(c)=possibility(?[s]:(arg1(s)=me & U(1,s) & swim(s))))
#
# "she made a big cake, and hung up some balloons."
# ?[s]:(U(0,s) & female_ref(0,s) & ?[B]:(subset(B,^[b]:(U(1,b) & balloon(b))) & ?[m]:(arg1(m)=s & U(2,m) & make(m) & past(m) & ?[c]:(U(3,c) & cake(c) & ?[b]:(U(4,b) & is_big(b) & arg1(b)=c) & arg2(m)=c)) & ![b]:(B(b) => ?[h]:(arg1(h)=s & U(5,h) & hang(h) & past(h) & arg2(h)=b))))
#
# "the doctor watched everyone sleep."
# ?[d]:(U(0,d) & doctor(d) & ?[X]:(X=^[x]:(U(1,x) & animate/anthropomorphic(x)) & ![x]:(X(x) => ?[w]:(arg1(w)=d & watch(w) & past(w) & arg2(w)=x))))
# NOTE: We model pragmatic domain restriction implicitly. In this example,
# `^[x]:U(0,x)` contains the doctor but `^[x]:U(1,x)` contains everyone being
# monitored by the doctor but does not contain the doctor.
#
# "John can play the guitar, and Mary, the violin."
# ?[c]:(arg1(c)=john & U(0,c) & capable_of(c) & present(c) & arg2(c)=possibility(?[p]:(U(1,p) & play(p) & ?[g]:(U(2,g) & guitar(g) & arg2(p)=g)))) & ?[e]:(arg1(e)=mary & U(3,e) & empty_ref(0,e) & ?[v]:(U(4,v) & violin(v) & arg2(e)=v))
#
# "John can play his guitar. Mary, too."
# ?[c]:(arg1(c)=john & U(0,c) & capable_of(c) & present(c) & arg2(c)=possibility(?[p]:(U(1,p) & play(p) & ?[g]:(U(2,g) & guitar(g) & arg2(p)=g)))) & ?[e]:(arg1(e)=mary & U(3,e) & empty_ref(0,e) & too(e))
#
# "she walked and sat under every tree and near every rock."
# ?[s]:(U(0,s) & female_ref(0,s) & ?[T]:(T=^[x]:(U(1,x) & tree(x)) & ?[R]:(R=^[y]:(U(2,y) & rock(y)) & ![x]:(T(x) => ![y]:(R(y) => ?[w]:(arg1(w)=s & U(3,w) & walk(w) & past(w) & ?[u]:(U(4,u) & under(u) & arg1(u)=w & arg2(u)=x) & ?[n]:(U(5,n) & near(n) & arg1(n)=w & arg2(n)=y)) & ?[a]:(arg1(a)=s & U(6,a) & sit(a) & past(a) & ?[u]:(U(7,u) & under(u) & arg1(u)=a & arg2(u)=x) & ?[n]:(U(8,n) & near(n) & arg1(n)=a & arg2(n)=y)))))))
#
# "John wants and is able to swim and dance."
# "John wants to and is able to swim and dance."
# ?[w]:(arg1(w)=john & U(0,w) & want(w) & present(w) & arg2(w)=possibility(?[s]:(U(1,s) & swim(s)) & ?[d]:(U(2,s) & dance(d)))) & ?[c]:(arg1(c)=john & U(3,c) & capable_of(c) & present(c) & arg2(c)=possibility(?[s]:(U(4,s) & swim(s)) & ?[d]:(U(5,s) & dance(d))))
#
# "the house is Kim's."
# ?[h]:(U(0,h) & house(h) & ?[o]:(arg1(o)=h & U(1,o) & inverse(has)(o) & present(o) & arg2(o)=kim))
#
# "the pencils are the students'."
# ?[X]:(X=^[x]:(U(0,x) & pencil(x)) & ?[Y]:(Y=^[y]:(Y(1,y) & student(y)) & ![x,y]:(X(x) & Y(y) => ?[o]:(arg1(o)=x & U(2,o) & inverse(has)(o) & present(o) & arg2(o)=y))))
#
# "flower seller has carnations."
# ?[C]:(subset(C,^[x]:(U(0,x) & carnation(x))) & ?[x]:(?[s]:(?[f]:(U(1,f) & flower(f) & arg2(s)=f) & U(2,s) & sell(s) & arg1(s)=x) & U(3,x) & ![c]:(C(c) => ?[o]:(arg1(o)=x & U(4,o) & has(o) & present(o) & arg2(o)=c))))
#
# "John swam extremely quickly."
# ?[s]:(arg1(s)=john & U(0,s) & swim(s) & past(s) & ?[q]:(?[e]:(U(1,e) & extreme(e) & arg1(e)=q) & U(2,q) & quick(q) & arg1(q)=s))
#
# "John arrived 10 minutes late."
# ?[a]:(arg1(s)=john & U(0,a) & arrive(a) & past(a) & ?[l]:(arg2(l)=(10*minute) & U(1,l) & late(l) & arg1(l)=a))
#
# "they ran away from the house and from the tree."
# ?[T]:(U(0,T) & plural_ref(0,T) & ![x]:(T(x) => ?[r]:(arg1(r) & U(1,r) & run(r) & past(r) & ?[a]:(U(2,a) & away(a) & arg1(a)=r & ?[h]:(U(3,h) & house(h) & arg2(a)=h)) & ?[a]:(U(4,a) & away(a) & arg1(a)=r & ?[t]:(U(5,t) & tree(t) & arg2(a)=t)))))
#
# "they ran away from the house and the tree."
# ?[T]:(U(0,T) & plural_ref(0,T) & ![x]:(T(x) => ?[r]:(arg1(r) & U(1,r) & run(r) & past(r) & ?[X]:(?[h]:(U(2,h) & house(h) & ?[t]:(U(3,t) & tree(t) & Y=^[y]:(y=h | y=t))) & ![y]:(Y(y) => ?[a]:(U(4,a) & away(a) & arg1(a)=r & arg2(a)=y))))))
#
# "that Constance is smart is not surprising."
# ~?[x]:(arg1(x)=possibility(?[s]:(arg1(s)=constance & U(0,s) & smart(s) & present(s))) & U(1,x) & surprise(x) & present_progressive(x))
#
# "that all cats are mammals is not surprising."
# ~?[x]:(arg1(x)=possibility(![x]:(U(0,x) & cat(x) => ?[s]:(arg1(s)=x & U(1,s) & same(s) & present(s) & ?[m]:(U(2,m) & mammal(m) & arg2(s)=m)))) & U(3,x) & surprise(x) & present_progressive(x))
#
# "i am glad that you arrived."
# ?[h]:(arg1(h)=me & U(0,h) & happy(h) & present(h) & ?[a]:(arg1(a)=you & U(1,a) & arrive(a) & past(a) & arg2(h)=a))
#
# "i will buy what she wants."
# "i will buy whatever she wants."
# ?[b]:(arg1(b)=me & U(0,b) & buy(b) & future(b) & ?[x]:(U(1,x) & ?[w]:(?[h]:(U(2,h) & female_ref(0,h) & arg1(w)=h) & U(3,w) & want(w) & arg2(w)=x) & arg2(b)=x))
#
# "are you generous?"
# "you are generous?"
# ^[x]:(x=?[g]:(arg1(g)=you & U(0,g) & generous(g) & present(g)))
#
# "how generous are you?"
# ^[x]:?[g]:(?[d]:(U(0,d) & degree(d) & arg1(d)=g & arg2(d)=x) & arg1(g)=you & U(1,g) & generous(g) & present(g))
#
# "did they see her?"
# ^[x]:x=?[T]:(U(0,T) & plural_ref(0,T) & ?[h]:(U(1,h) & female_ref(0,h) & ?[t]:(T(t) & ?[s]:(arg1(s)=t & U(2,s) & see(s) & past(s) & arg2(s)=h))))
#
# "did they all see her?"
# ^[x]:x=?[T]:(U(0,T) & plural_ref(0,T) & ?[h]:(U(1,h) & female_ref(0,h) & ![t]:(T(t) => ?[s]:(arg1(s)=t & U(2,s) & see(s) & past(s) & arg2(s)=h))))
#
# "which store did Jason run to?"
# "to which store did Jason run?"
# "Jason ran to which store?"
# "what store did Jason run to?"
# "to what store did Jason run?"
# "Jason ran to what store?"
# ^[x]:(?[S]:(S=^[s]:(U(s,0) & store(s)) & S(x) & ?[r]:(arg1(r)=jason & U(1,r) & run(r) & past(r) & arg2(r)=x)))
#
# "which stores did Jason run to?"
# "to which stores did Jason run?"
# "Jason ran to which stores?"
# "what stores did Jason run to?"
# "to what stores did Jason run?"
# "Jason ran to what stores?"
# ^[X]:(subset(X,^[s]:(U(s,0) & store(s))) & ![x]:(X(x) => ?[r]:(arg1(r)=jason & U(1,r) & run(r) & past(r) & arg2(r)=x)))
#
# "is it red or blue?"
# ^[x]:?[i]:(U(0,i) & ref(0,i) & true(x) & (x=possibility(?[r]:(arg1(r)=i & U(1,r) & red(r) & present(r))) | x=possibility(?[b]:(arg1(b)=i & U(2,b) & blue(b) & present(b)))))
#
# "how big is the earth?"
# ^[x]:?[b]:(?[d]:(U(0,d) & degree(d) & arg1(d)=b & arg2(d)=x) & arg1(b)=earth & U(1,b) & big(b))
#
# "Kim knows whether the earth is big."
# ?[k]:(arg1(k)=kim & U(0,k) & know(k) & present(k) & arg2(k)=^[x]:x=?[b]:(arg1(b)=earth & U(1,b) & big(b) & present(b)))
#
# "Kim knows how big the earth is."
# ?[k]:(arg1(k)=kim & U(0,k) & know(k) & present(k) & arg2(k)=^[x]:?[b]:(?[d]:(U(1,d) & degree(d) & arg1(d)=b & arg2(d)=x) & arg1(b)=earth & U(2,b) & big(b)))
#
# "how to make an omelet?"
# ^[x]:?[m]:(?[y]:(U(0,y) & manner(y) & arg1(y)=m & arg2(y)=x) & U(1,m) & make(m) & ?[o]:(U(2,o) & omelet(o) & arg2(m)=o))
#
# "Jason knows how to make an omelet."
# ?[k]:(arg1(k)=jason & U(0,k) & know(k) & present(k) & arg2(k)=^[x]:?[m]:(?[y]:(U(1,y) & manner(y) & arg1(y)=m & arg2(y)=x) & U(2,m) & make(m) & ?[o]:(U(3,o) & omelet(o) & arg2(m)=o)))
#
# "whether running or swimming, Emma is quick."
# (?[r]:(arg1(r)=emma & U(0,r) & run(r) & present_progressive(r)) | ?[s]:(arg1(s)=emma & U(1,s) & swim(s) & present_progressive(s))) => ?[q]:(arg1(q)=emma & U(2,q) & quick(q))
#
# "Noah was intrigued by what strange people inhabited this place."
# TODO: label this and ensure the grammar can handle it
#
# "the necklace which Emma gave to her is in the safe."
# "the necklace, which Emma gave to her, is in the safe."
# ?[l]:(?[n]:(U(0,n) & necklace(n) & ?[g]:(arg1(g)=emma & U(1,g) & give(g) & past(g) & ?[h]:(U(2,n) & female_ref(0,h) & arg3(g)=h) & arg2(g)=n) & arg1(l)=n) & U(3,l) & location(l) & present(l) & ?[s]:(U(4,s) & safe(s) & arg2(l)=s))
#
# "Jason, who is my brother, is here."
# ?[l]:(?[j]:(j=jason & ?[b]:(arg1(b)=me & U(0,b) & brother_of(b) & present(b) & arg2(b)=j) & arg1(l)=j) & U(1,l) & location(l) & present(l) & arg2(l)=here)
#
# "a person walked into the room who looked like Emma."
# ?[p]:(U(0,p) & person(p) & ?[w]:(arg1(w)=p & U(1,w) & walk(w) & past(w) & ?[r]:(U(2,r) & room(r) & arg2(w)=r)) & ?[v]:(arg1(v)=p & U(3,v) & visually_similar(v) & arg2(v)=emma))
#
# "Sirius is brighter."
# ?[g]:(arg1(g)=sirius & U(0,g) & greater(brightness)(g) & present(g))
#
# "Sirius is brighter than Vega."
# ?[g]:(arg1(g)=sirius & U(0,g) & greater(brightness)(g) & present(g) & arg2(g)=vega)
# where we can add an axiom such as ![x,y,f]:(?[g]:(greater(f)(g) & arg1(g)=x & arg2(g)=y) & ~is_real_number(y) & ?[b]:(f(b) & arg1(b)=y) = ?[g]:(greater(f)(g) & arg1(g)=x & ?[b]:(f(b) & arg1(b)=y & arg2(g)=arg2(b))))
#
# "i see a brighter star than Vega."
# ?[s]:(arg1(s)=me & U(0,s) & see(s) & present(s) & ?[x,r]:(?[g]:(U(1,g) & greater(brightness)(g) & arg1(g)=x & arg2(g)=r) & U(2,x) & star(x) & r=vega & arg2(s)=x))
#
# "i see a star brighter than Vega."
# ?[s]:(arg1(s)=me & U(0,s) & see(s) & present(s) & ?[x]:(U(1,x) & star(x) & ?[g]:(U(2,g) & greater(brightness)(g) & arg1(g)=x & arg2(g)=vega) & arg2(s)=x))
#
# "Sirius is brighter than we thought."
# ?[X]:(X=us & ![x]:(X(x) => ?[g]:(arg1(g)=sirius & U(0,g) & greater(brightness)(g) & ?[t]:(arg1(t)=x & U(1,t) & think(t) & past(t) & arg2(t)=arg2(g)))))
#
# "Sirius is the brightest star."
# ?[s]:(arg1(s)=sirius & U(0,s) & same(s) & present(s) & ?[X]:(?[g]:(U(1,g) & greatest(brightness)(g) & arg2(s)=arg1(g) & arg2(g)=X) & X=^[x]:(U(2,x) & star(x))))
#
# "Sirius is the brightest."
# ?[s]:(arg1(s)=sirius & U(0,s) & same(s) & present(s) & ?[g]:(U(1,g) & greatest(brightness)(g) & arg2(s)=arg1(g)))
#
# "a brighter star could be seen with the telescope than without it"
# ?[x,r]:(?[g]:(greater(brightness)(g) & arg1(g)=x & arg2(g)=r) & U(0,x) & star(x) & ?[c]:(U(1,c) & capable_of(c) & arg2(c)=possibility(?[s]:(arg1(s)=x & U(2,s) & inverse(see)(s) & ?[w]:(U(3,w) & with(w) & ?[t]:(U(4,t) & telescope(t) & arg1(w)=t)) & ?[y]:(U(5,y) & arg1(y)=r & ~?[w]:(U(6,w) & with(w) & ?[t]:(U(7,t) & telescope(t) & arg1(w)=t)))))))
#
# "brighter stars could be seen with the telescope than without it"
# ?[X,R]:(subset(X,^[x]:(![r]:(R(r) => ?[g]:(U(0,g) & greater(brightness)(g) & arg1(g)=x & arg2(g)=r)) & U(1,x) & star(x))) & ![x]:(X(x) => ?[c]:(U(2,c) & capable_of(c) & arg2(c)=possibility(?[s]:(arg1(s)=x & U(3,s) & inverse(see)(s) & ?[w]:(U(4,w) & with(w) & ?[t]:(U(5,t) & telescope(t) & arg1(w)=t)) & R=^[r]:?[y]:(U(6,y) & arg1(y)=r & ~?[w]:(U(7,w) & with(w) & ?[t]:(U(8,t) & telescope(t) & arg1(w)=t))))))))
#
# "you can see brighter stars with the telescope than without it"
# ?[X,R]:(subset(X,^[x]:(![r]:(R(r) => ?[g]:(U(0,g) & greater(brightness)(g) & arg1(g)=x & arg2(g)=r)) & U(1,x) & star(x))) & ![x]:(X(x) => ?[c]:(arg1(c)=you & U(2,c) & capable_of(c) & arg2(c)=possibility(?[s]:(arg1(s)=x & U(3,s) & inverse(see)(s) & ?[w]:(U(4,w) & with(w) & ?[t]:(U(5,t) & telescope(t) & arg1(w)=t)) & R=^[r]:?[y]:(U(6,y) & arg1(y)=r & ~?[w]:(U(7,w) & with(w) & ?[t]:(U(8,t) & telescope(t) & arg1(w)=t))))))))
#
# "last time i went to campus, i took the bus"
# ?[t]:(?[l]:(U(0,l) & last_time(l) & arg1(l)=t & arg2(l)=^[g]:(arg1(g)=me & U(1,g) & go(g) & past(g) & ?[c]:(U(2,c) & campus(c) & arg2(g)=c))) & arg1(t)=me & U(3,t) & take(t) & past(t) & ?[b]:(U(4,b) & bus(b) & arg2(t)=b))
# [OR]
# ?[t]:(?[l]:(U(0,l) & last_time(l) & arg1(l)=t & ?[S]:(S=^[g]:(arg1(g)=me & U(1,g) & go(g) & past(g) & ?[c]:(U(2,c) & campus(c) & arg2(g)=c)) & arg2(l)=S)) & arg1(t)=me & U(3,t) & take(t) & past(t) & ?[b]:(U(4,b) & bus(b) & arg2(t)=b))
# where we could have an axiom like ![x,S]:(?[l]:(last_time(l) & arg1(l)=x & arg2(l)=S) = ~?[y]:(S(y) & start_time(y)>end_time(x) & start_time(y)<now))
#
# "last time, i took the bus"
# ?[t]:(?[l]:(U(0,l) & last_time(l) & arg1(l)=t) & arg1(t)=me & U(1,t) & take(t) & past(t) & ?[b]:(U(2,b) & bus(b) & arg2(t)=b))
#
# "i took the same bus as i took yesterday."
# ?[t]:(arg1(t)=me & U(0,t) & take(t) & past(t) & ?[b,r]:(?[s]:(U(1,s) & same(s) & arg1(s)=b & arg2(s)=r) & U(2,b) & bus(b) & ?[y]:(arg1(y)=me & U(3,y) & take(y) & past(y) & arg2(y)=r & ?[z]:(U(4,z) & yesterday(z) & arg1(z)=y)) & arg2(t)=b))
#
# "i took the same bus as i took last time."
# ?[t]:(arg1(t)=me & U(0,t) & take(t) & past(t) & ?[b,r]:(?[s]:(U(1,s) & same(s) & arg1(s)=b & arg2(s)=r) & U(2,b) & bus(b) & ?[y]:(arg1(y)=me & U(3,y) & take(y) & past(y) & arg2(y)=r & ?[z]:(U(4,z) & last_time(z) & arg1(z)=y)) & arg2(t)=b))
#
# "i took the same bus as last time."
# ?[t]:(arg1(t)=me & U(0,t) & take(t) & past(t) & ?[b,r]:(?[s]:(U(1,s) & same(s) & arg1(s)=b & arg2(s)=r) & U(2,b) & bus(b) & ?[y]:(U(3,y) & arg2(y)=r & ?[z]:(U(4,z) & last_time(z) & arg1(z)=y)) & arg2(t)=b))
#
# "Sirius is as bright as Vega."
# ?[g]:(arg1(g)=sirius & U(0,g) & greater_than_or_equal(brightness)(g) & present(g) & arg2(g)=vega)
#
# "last time i had a party, 7 people came"
# ?[P]:(subset(P,^[p]:(U(0,p) & person(p))) & size(P)=7 & ![p]:(P(p) => ?[g]:(?[l]:(U(1,l) & last_time(l) & arg1(l)=g & arg2(l)=^[h]:(arg1(h)=me & U(2,h) & have(h) & past(h) & ?[p]:(U(3,p) & party(p) & arg2(h)=p))) & arg1(g)=p & U(4,g) & go(g) & past(g))))
#
# "more people came to the party than people came last time i had a party."
# ?[P,R]:(size(P)>size(R) & subset(P,^[p]:(U(0,p) & person(p))) & ![p]:(P(p) => ?[g]:(arg1(g)=p & U(1,g) & go(g) & past(g) & R=^[r]:(U(2,r) & person(r) & ?[g]:(arg1(g)=r & U(3,g) & go(g) & past(g) & ?[l]:(U(4,l) & last_time(l) & arg1(l)=g & arg2(l)=^[h]:(arg1(h)=me & U(5,h) & have(h) & ?[p]:(U(6,p) & party(p) & arg2(h)=p))))))))
#
# "more people came than people came last time."
# ?[P,R]:(size(P)>size(R) & subset(P,^[p]:(U(0,p) & person(p))) & ![p]:(P(p) => ?[g]:(arg1(g)=p & U(1,g) & go(g) & past(g) & R=^[r]:(U(2,r) & person(r) & ?[g]:(arg1(g)=r & U(3,g) & go(g) & past(g) & ?[l]:(U(4,l) & last_time(l) & arg1(l)=g))))))
#
# "more people came than last time."
# ?[P,R]:(size(P)>size(R) & subset(P,^[p]:(U(0,p) & person(p))) & ![p]:(P(p) => ?[g]:(arg1(g)=p & U(1,g) & go(g) & past(g) & R=^[r]:(U(2,r) & ?[g]:(U(3,g) & arg1(g)=r & ?[l]:(U(4,l) & last_time(l) & arg1(l)=g))))))
#
# "more girls but fewer boys came than last time."
# ?[P,R]:(?[G,R1]:(size(G)>size(R1) & subset(G,^[g]:(U(0,g) & girl(g))) & ?[B,R2]:(size(B)<size(R2) & subset(B,^[b]:(U(1,b) & boy(b))) & P=^[s]:(s=G | s=B) & R=^[s]:(s=R1 | s=R2))) & ![s]:(P(s) => ![p]:(s(p) => ?[g]:(arg1(g)=p & U(2,g) & go(g) & past(g) & ![Ri]:(R(Ri) => Ri=^[r]:(U(3,r) & ?[g]:(U(4,g) & arg1(g)=r & ?[l]:(U(5,l) & last_time(l) & arg1(l)=g))))))))
#
# "a taller person came than last time."
# ?[x,r]:(?[g]:(U(0,g) & greater(height)(g) & arg1(g)=x & arg2(g)=r) & U(1,x) & person(x) & ?[g]:(arg1(g)=x & U(2,g) & go(g) & past(g) & ?[g]:(U(3,g) & arg1(g)=r & ?[l]:(U(4,l) & last_time(l) & arg1(l)=g))))
#
# "taller people came than last time."
# ?[X,R]:(subset(X,^[x]:(![r]:(R(r) => ?[g]:(U(0,g) & greater(height)(g) & arg1(g)=x & arg2(g)=r)) & U(1,x) & person(x))) & ?[g]:(arg1(g)=x & U(2,g) & go(g) & past(g) & R=^[r]:(?[g]:(U(3,g) & arg1(g)=r & ?[l]:(U(4,l) & last_time(l) & arg1(l)=g)))))
#
# "she is older than i am."
# ?[g]:(?[h]:(U(0,h) & female_ref(0,h) & arg1(g)=h) & U(1,g) & greater(age)(g) & ?[y]:(U(2,y) & arg1(y)=me & arg2(g)=y))
# where `y` could have type `age_of`.
#
# "she wrote more plays than i wrote novels."
# ?[h]:(U(0,h) & female_ref(0,h) & ?[P,N]:(size(P)>size(N) & subset(P,^[p]:(U(1,p) & play(p))) & ![p]:(P(p) => ?[w]:(arg1(w)=h & U(2,w) & write(w) & past(w) & arg2(w)=p & N=^[n]:(U(3,n) & novel(n) & ?[w]:(arg1(w)=me & U(4,w) & write(w) & past(w) & arg2(w)=n))))))
#
# "we spend more time in France than in Germany."
# ?[X]:(X=us & ![x]:(X(x) => ?[s]:(arg1(s)=x & U(0,s) & spend_time(s) & present(s) & ?[g]:(U(1,g) & greater(time)(g) & arg1(g)=s & ?[l]:(U(2,l) & location(l) & arg1(l)=s & arg2(l)=france) & ?[y]:(U(3,y) & ?[l]:(U(4,l) & location(l) & arg1(l)=y & arg2(l)=germany) & arg2(g)=y)))))
# TODO: implement this in the grammar
#
# "he plays better drunk than sober."
# ?[p]:(?[h]:(U(0,h) & male_ref(0,h) & arg1(p)=h) & U(1,p) & play(p) & present(p) & ?[g]:(U(2,g) & greater(skill)(g) & arg1(g)=p & ?[d]:(U(3,d) & drunk(d) & arg1(d)=p) & ?[y]:(U(4,y) & ?[s]:(U(5,s) & sober(s) & arg1(s)=y) & arg2(g)=y)))
#
# "it is better to try and fail than to not try at all."
# ?[b]:(U(0,b) & better(b) & arg1(b)=possibility(?[t]:(U(1,t) & try(t)) & ?[f]:(U(2,f) & fail(f))) & arg2(b)=possibility(~?[t]:(U(3,t) & try(t))))
#
# "it is better that he tried and failed than not try at all."
# ?[b]:(U(0,b) & better(b) & arg1(b)=possibility(?[t]:(U(1,t) & try(t) & past(t)) & ?[f]:(U(2,f) & fail(f) & past(f))) & arg2(b)=possibility(~?[t]:(U(3,t) & try(t))))
#
# "the flower is more red than pink."
# ?[f]:(U(0,f) & flower(f) & ?[g]:(U(1,g) & greater(degree)(g) & ?[r]:(arg1(r)=f & U(2,r) & red(r) & arg1(g)=r & ?[p]:(U(3,p) & pink(p) & arg2(g)=p))))
#
# "i saw four times as many cats as i saw dogs."
# ?[C,D]:(size(C)=4*size(D) & C=^[x]:(U(0,x) & cat(c)) & ![x]:(C(x) => ?[s]:(arg1(s)=me & U(1,s) & see(s) & past(s) & arg2(s)=x & D=^[y]:(?[z]:(arg1(z)=me & U(2,z) & see(z) & past(z) & U(3,y) & dog(y) & arg2(z)=y)))))
#
# "i saw four times as many cats as dogs."
# ?[C,D]:(size(C)=4*size(D) & C=^[x]:(U(0,x) & cat(c)) & ![x]:(C(x) => ?[s]:(arg1(s)=me & U(1,s) & see(s) & past(s) & arg2(s)=x & D=^[y]:(?[z]:(U(2,z) & U(3,y) & dog(y) & arg2(z)=y)))))
#
# "i earn four times as much as Ned earns."
# ?[X,R]:(size(X)=4*size(R) & ![x]:(X(x) => ?[e]:(arg1(e)=me & U(0,e) & earn(e) & present(e) & arg2(e)=x & R=^[r]:(U(1,r) & ?[y]:(arg1(y)=ned & U(2,y) & earn(y) & present(y) & arg2(y)=r)))))
#
# "they work harder the more we pay them."
# ?[t]:(U(0,t) & plural_ref(0,t) & ![x]:(t(x) => ?[p]:(?[i]:(U(1,i) & increase(quantity)(i) & arg1(i)=p) & arg1(p)=we & U(2,p) & pay(p) & present(p) & arg2(p)=x))) => ?[t]:(U(3,t) & plural_ref(1,t) & ![x]:(t(x) => ?[w]:(arg1(w)=x & U(4,w) & work(w) & present(w) & ?[i]:(U(5,i) & increase(effort)(i) & arg1(i)=w))))
#
# "they work harder if we pay them more."
# ?[t]:(U(0,t) & plural_ref(0,t) & ![x]:(t(x) => ?[p]:(arg1(p)=we & U(1,p) & pay(p) & present(p) & arg2(p)=x & ?[i]:(U(2,i) & increase(quantity)(i) & arg1(i)=p)))) => ?[t]:(U(3,t) & plural_ref(1,t) & ![x]:(t(x) => ?[w]:(arg1(w)=x & U(4,w) & work(w) & present(w) & ?[i]:(U(5,i) & increase(effort)(i) & arg1(i)=w))))
#
# "the more we pay them, the harder they work."
# ?[t]:(U(0,t) & plural_ref(0,t) & ![x]:(t(x) => ?[p]:(?[i]:(U(1,i) & increase(quantity)(i) & arg1(i)=p) & arg1(p)=we & U(2,p) & pay(p) & present(p) & arg2(p)=x))) => ?[t]:(U(3,t) & plural_ref(1,t) & ![x]:(t(x) => ?[w]:(?[i]:(U(4,i) & increase(effort)(i) & arg1(i)=w) & arg1(w)=x & U(5,w) & work(w) & present(w))))
#
# "the more money we pay them, the harder they work."
# ?[t]:(U(0,t) & plural_ref(0,t) & ![x]:(t(x) => ?[p]:(?[i]:(U(1,i) & increase(quantity)(i) & ?[m]:(U(2,m) & money(m) & arg1(i)=m & arg3(p)=m)) & arg1(p)=we & U(3,p) & pay(p) & present(p) & arg2(p)=x))) => ?[t]:(U(4,t) & plural_ref(1,t) & ![x]:(t(x) => ?[w]:(?[i]:(U(5,i) & increase(effort)(i) & arg1(i)=w) & arg1(w)=x & U(6,w) & work(w) & present(w))))
#
# "he is richer."
# ?[h]:(U(0,h) & male_ref(0,h) & ?[i]:(arg1(i)=h & U(1,i) & increase(wealth)(i) & present(i)))
#
# "he became richer."
# ?[h]:(U(0,h) & male_ref(0,h) & ?[i]:(arg1(i)=h & U(1,i) & increase(wealth)(i) & past(i)))
#
# "it is a difficult book to understand."
# ?[i]:(U(0,i) & ref(0,i) & ?[s]:(arg1(s)=i & U(1,s) & same(s) & present(s) & ?[b]:(?[d]:(U(2,d) & difficult(d) & arg1(d)=b & arg2(d)=possibility(?[u]:(arg2(u)=b & U(3,u) & understand(u)))) & U(4,b) & book(b) & arg2(s)=b)))
#
# "i saw the cats, but not the dogs."
# but(?[C]:(C=^[c]:(U(0,c) & cat(c)) & ![c]:(C(c) => ?[s]:(arg1(s)=me & U(1,s) & see(s) & past(s) & arg2(s)=c))), ?[D]:(D=^[d]:(U(2,d) & dog(d)) & ![d]:(D(d) => ~?[e]:(empty_ref(0,e) & arg2(e)=d))))
# NOTE: We model this the same way as we model ellipsis. But if we were to
# model it as coordination, their logical forms would be as follows:
# ?[C]:(C=^[c]:(U(0,c) & cat(c)) & ?[D]:(D=^[d]:(U(1,d) & dog(d)) & ![c,d]:(C(c) & D(d) => ?[s]:(arg1(s)=me & U(2,s) & see(s) & past(s) & arg2(s)=c) & ~?[s]:(arg1(s)=me & U(3,s) & see(s) & past(s) & arg2(s)=d))))
#
# "i saw the cats, not the dogs."
# instead_of(?[C]:(C=^[c]:(U(0,c) & cat(c)) & ![c]:(C(c) => ?[s]:(arg1(s)=me & U(1,s) & see(s) & past(s) & arg2(s)=c))) & ?[D]:(D=^[d]:(U(2,d) & dog(d)), ![d]:(D(d) => ~?[e]:(empty_ref(0,e) & arg2(e)=d))))
# NOTE: We model this the same way as we model ellipsis. But if we were to
# model it as coordination, their logical forms would be as follows:
# ?[C]:(C=^[c]:(U(0,c) & cat(c)) & ?[D]:(D=^[d]:(U(1,d) & dog(d)) & ![c,d]:(C(c) & D(d) => instead_of(?[s]:(arg1(s)=me & U(2,s) & see(s) & past(s) & arg2(s)=c),?[s]:(arg1(s)=me & U(3,s) & see(s) & past(s) & arg2(s)=d)))))
# where `instead_of` is a special function like `possibility` where
# `instead_of(A,B)` implies `A & ~B` but before this sentence, `A | B` and
# `~(A & B)` are true. (this function is special because its truth-functional
# definition depends not on a particular model/structure, but rather that
# before this logical form is incorporated into the theory, both `A | B` and
# `~(A & B)` are provable)
#
# "a cat, not a dog, was walking in the park."
# ?[c]:(U(0,c) & cat(c) & ~dog(c) & ?[w]:(arg1(w)=c & U(2,w) & walk(w) & past(w) & ?[p]:(U(3,p) & park(p) & arg2(w)=p)))
#
# "4 cats, not dogs, were walking in the park."
# ?[C]:(C=^[c]:(U(0,c) & cat(c) & ~dog(c)) & size(C)=4 & ![c]:(C(c) => ?[w]:(arg1(w)=c & U(1,w) & walk(w) & past(w) & ?[p]:(U(2,p) & park(p) & arg2(w)=p))))
#
# "4 cats, not 4 dogs, were walking in the park."
# ?[C]:(C=^[c]:(U(0,c) & cat(c)) & size(C)=4 & ~(C=^[d]:(U(1,d) & dog(d)) & size(C)=4) & ![c]:(C(c) => ?[w]:(arg1(w)=c & U(2,w) & walk(w) & past(w) & ?[p]:(U(3,p) & park(p) & arg2(w)=p))))
#
# "he not only photocopied it, but had even read it."
# ?[h]:(U(0,h) & male_ref(h) & but(?[p]:(~?[o]:(U(1,o) & only(o) & arg1(o)=p) & arg1(p)=h & U(2,p) & photocopy(p) & past(p) & ?[i]:(U(3,i) & ref(0,i) & arg2(p)=i)),?[r]:(arg1(r)=h & U(4,r) & read(r) & past(r) & ?[i]:(U(5,i) & ref(1,i) & arg2(r)=i))))
#
# "i saw a dog rather than a cat."
# "rather than a cat, i saw a dog."
# ?[d]:(instead_of(U(0,d) & dog(d), U(1,c) & cat(c)) & ?[s]:(arg1(s)=me & U(2,s) & see(s) & past(s) & arg2(s)=d))
# TODO: implement this in the grammar
#
# "i like to walk rather than run."
# "rather than run, i like to walk."
# ?[l]:(arg1(l)=me & U(0,l) & like(l) & present(l) & instead_of(?[w]:(U(1,w) & walk(w) & arg2(l)=w),?[r]:(U(2,r) & run(r) & arg2(l)=r)))
#
# "he didn't wake up, let alone go to school."
# TODO: implement this in the grammar
#
# coordination of determinatives
# "i made little or no money."
# TODO: implement this in the grammar
#
# coordination of determinatives
# "there were one or two mistakes."
# TODO: implement this in the grammar
#
# coordination of determinatives
# "some or all cats were sleeping."
# TODO: implement this in the grammar
#
# coordination of prepositions
# "i slept before and after dinner."
# TODO: implement this in the grammar
#
# coordination of prepositions
# "i am at or near the tree."
# TODO: implement this in the grammar
#
# "Kim and Pat's children are cute."
# "Kim's and Pat's children are cute."
# ?[X]:(X=^[x]:(?[P]:(P=^[p]:(p=kim | p=pat) & ![p]:(P(p) => ?[o]:(arg1(o)=p & U(0,o) & has(o) & arg2(o)=x))) & U(1,x) & child(x)) & ![x]:(X(x) => ?[c]:(arg1(c)=x & U(2,c) & cute(c) & present(c))))
# TODO: implement this in the grammar
#
# "in the tree and afraid, the cat and dog are."
# ?[c](U(0,c) & cat(c) & ?[d]:(U(1,d) & dog(d) & ?[X]:(X=^[x]:(x=c | x=d) & ![x]:(X(x) => ?[l]:(U(2,l) & location(l) & present(l) & arg1(l)=x & ?[t]:(U(3,t) & tree(t) & arg2(l)=t)) & ?[a]:(U(4,a) & afraid(a) & present(a) & arg1(a)=x)))))
S nonterminal {} {1.0} {1.0} {} 10 1.0 {}
S -> S':require_no_lambda,mark_wide_scope PERIOD
# for closed interrogatives that are essentially declarative with a question mark
# S {^[x]:x=A} -> S' {A}
# S {^[x]:(... & true(x) & (x=possibility(A1) | ... | x=possibility(An)))} -> S' {... & (A1 | ... | An)}
# e.g. "it is red?", "it is red or blue?"
#S -> S':remove_closed_lambda_equality,mark_wide_scope QUESTION
#S -> S':remove_lambda_possibilities,mark_wide_scope QUESTION
# for all other interrogatives
# S {^[x]:A} -> S' {^[x]:A}
S -> S':require_lambda,mark_wide_scope QUESTION
# This is the root nonterminal for declarative sentences.
S' nonterminal {} {1.0} {1.0} {} 10 1.0 {}
S' -> S'':try_add_singular,require_no_conjunction,try_remove_is_adjunct
S' -> S'':try_add_plural,require_no_conjunction,try_remove_is_adjunct
# for subordinate clauses
S' -> THAT S':try_remove_correlated,try_remove_is_adjunct,remove_that
S' -> WHETHER:require_no_wh_minus S':try_remove_correlated,try_remove_is_adjunct,remove_whether
S' -> WHETHER:require_no_wh_minus OR NOT S':try_remove_correlated,try_remove_is_adjunct,remove_whether
S' -> IF S':try_remove_correlated,try_remove_is_adjunct,remove_if
S' -> BECAUSE S':try_remove_correlated,try_remove_is_adjunct,remove_because
S' -> FOR S':try_remove_correlated,try_remove_is_adjunct,remove_for
# (non-predicative) preposed VP complements/adjuncts
# S' {... & (~)?[y1]:(g1(y1) & f(y1)) & ... & (~)?[yn]:(gn(yn) & f(yn))}
# -> V_ADJUNCT {... & ?[y1]:(p1(y1) & f(y1)) & ... & ?[yn]:(pn(yn) & f(yn))}
# (COMMA) S' {... & (~)?[y1]:g1(y1) & ... & (~)?[yn]:gn(yn)}
#S' -> V_ADJUNCT:try_remove_nullable_subject,require_no_conjunction,try_remove_is_adjunct,require_no_correlator,try_remove_wh_minus,select_right_conjunct S':try_remove_correlated,try_remove_is_adjunct,remove_right_conjunct
#S' -> V_ADJUNCT:try_remove_nullable_subject,require_no_conjunction,try_remove_is_adjunct,require_no_correlator,try_remove_wh_minus,select_right_conjunct COMMA S':try_remove_correlated,try_remove_is_adjunct,remove_right_conjunct
# (predicative) preposed VP complements/adjuncts
# S' {... & (~)?[y1]:(U(i1,y1) & p1(y1) & f(y1) & h1(y1)) & ... & (~)?[yn]:(U(in,yn) & pn(yn) & f(yn) & hn(yn))}
# -> V_ADJUNCT {... & ?[y1]:(U(i1,y1) & p1(y1) & h1(y1)) & ... & ?[yn]:(U(in,yn) & pn(yn) & hn(yn))}
# (COMMA) S' {... & (~)?[y]:f(y)}
# This rule removes the predicate `p` from the event corresponding to the verb
# (and so the verb is semantically empty) such as in "blue, the cat is" and "in
# the tree, the cat is". `f` contains verb-specific terms such as `present` as
# well as any adjuncts or other arguments of y whereas `h` contains everything
# else, such as the argument.
#S' -> V_ADJUNCT:try_remove_nullable_subject,require_no_conjunction,try_remove_is_adjunct,require_no_correlator,try_remove_wh_minus,select_right_conjunct S':try_remove_correlated,try_remove_is_adjunct,remove_right_conjunct,remove_left_predicate,factor
#S' -> V_ADJUNCT:try_remove_nullable_subject,require_no_conjunction,try_remove_is_adjunct,require_no_correlator,try_remove_wh_minus,select_right_conjunct COMMA S':try_remove_correlated,try_remove_is_adjunct,remove_right_conjunct,remove_left_predicate,factor
# preposed coordination
# TODO: coordinates from other levels can be moved here to (as well as to other levels), such as NP, NOMINAL_R, N_ADJUNCT
# S' {... & (~)?[y]:(... & (A1 & ... & An))}
# -> AS WELL AS/IN ADDITION TO/PLUS V_ADJUNCT {?[y]:(p(y) & A1)}
# COMMA S' {... & (~)?[y]:(... & (A2 & ... & An))}
#S' -> AS WELL AS V_ADJUNCT:select_left_conjunct_in_right_conjunct COMMA S':remove_left_conjunct_in_right_conjunct
#S' -> IN ADDITION TO V_ADJUNCT:select_left_conjunct_in_right_conjunct COMMA S':remove_left_conjunct_in_right_conjunct
#S' -> PLUS V_ADJUNCT:select_left_conjunct_in_right_conjunct COMMA S':remove_left_conjunct_in_right_conjunct
# S' {... & (~)?[y]:(... & instead_of(A1, A2))}
# -> RATHER THAN V_ADJUNCT {?[y]:(p(y) & A2)}
# COMMA S' {... & (~)?[y]:(... & A1)}
#S' -> RATHER THAN V_ADJUNCT:select_right_in_right_instead_of,try_remove_wh_minus COMMA S':remove_right_in_right_instead_of
# S' {?[X]:(f(X) & ![x]:(X(x) => (true(x) => g(x))))}
# -> S' {g(x)}
# (COMMA) IF
# PP {?[X]:(f(X) & ![x]:(X(x) => true(x)))}
# NOTE: We don't allow other adjuncts here to avoid the spurious ambiguity
# where the PP could also attach at VP.
#S' -> S':require_no_conjunction,try_remove_is_adjunct,select_consequent_in_cases PP:try_remove_nullable_subject,try_remove_correlated,try_remove_correlator,try_remove_is_adjunct,remove_consequent_in_cases
#S' -> S':require_no_conjunction,try_remove_is_adjunct,select_consequent_in_cases COMMA PP:try_remove_nullable_subject,try_remove_correlated,try_remove_correlator,try_remove_is_adjunct,remove_consequent_in_cases
# S' {A => B} -> IF/WHETHER S' {A} (COMMA) (THEN) S' {B}
# S' {^[x]:x=(A => B)} -> IF/WHETHER S' {A} (COMMA) (THEN) S' {^[x]:x=B}
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,select_antecedent,mark_wide_scope S':try_remove_correlated,try_remove_correlator,try_remove_is_adjunct,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,select_antecedent,mark_wide_scope COMMA S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,select_antecedent,mark_wide_scope THEN S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,select_antecedent,mark_wide_scope COMMA THEN S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_whether,select_antecedent,mark_wide_scope S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_whether,select_antecedent,mark_wide_scope COMMA S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,add_subjunctive,select_antecedent,mark_wide_scope S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,add_subjunctive,select_antecedent,mark_wide_scope COMMA S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,add_subjunctive,select_antecedent,mark_wide_scope THEN S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_if,add_subjunctive,select_antecedent,mark_wide_scope COMMA THEN S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_whether,add_subjunctive,select_antecedent,mark_wide_scope S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
S' -> S':require_no_conjunction,try_remove_is_adjunct,try_remove_wh_minus,add_whether,add_subjunctive,select_antecedent,mark_wide_scope COMMA S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_consequent
# (not preposed) correlative comparative constructions
# S' {... & ?[y]:(?[i]:f(i) & g(y)) => B}
# -> S' {B}
# THE ADJP_L/ADVP_L {... & ?[i]:f(i)}
# S' {... & ?[y]:g(y)}
# S' {... & ?[i]:(U(j,i) & p(i) & f(i)) => B}
# -> S' {B}
# THE ADJP_L/ADVP_L {... & ?[i]:(U(k,i) & p(i))}
# S' {... & ?[i]:f(i)}
# e.g. "they work harder the more (money) we pay them.", "he becomes more cynical the older he gets."
#S' -> S':require_no_conjunction,select_consequent THE ADJP_L:try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_antecedent,remove_left_conjunct
#S' -> S':require_no_conjunction,select_consequent THE ADVP_L:try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,try_remove_correlator,select_antecedent,remove_left_conjunct
# (preposed) correlative comparative constructions
# S' {... & ?[y]:(?[i]:f1(i) & g1(y)) => ... & ?[y]:(?[i]:f2(i) & g2(y))}
# -> THE ADJP_L/ADVP_L {... & ?[i]:f1(i)}
# S' {... & ?[y]:g1(y)}
# COMMA THE ADJP_L/ADVP_L {... & ?[i]:f2(i)}
# S' {... & ?[y]:g2(y)}
# S' {... & ?[i]:(p1(i) & f1(y)) => ... & ?[y]:(?[i]:f2(i) & g2(y))}
# -> THE ADJP_L/ADVP_L {... & ?[i]:p1(i)}
# S' {... & ?[y]:f1(y)}
# COMMA THE ADJP_L/ADVP_L {... & ?[i]:f2(i)}
# S' {... & ?[y]:g2(y)}
# NOTE: The consequent could also be predicative in the same way as the antecedent.
# e.g. "the more (money) we pay them, the harder they work.", "the older he gets, the more cynical he becomes."
#S' -> THE ADJP_L:try_remove_correlated,try_remove_is_adjunct,try_remove_wh_minus,select_antecedent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,require_no_conjunction,require_no_correlator,select_antecedent,remove_left_conjunct COMMA THE ADJP_L:try_remove_correlated,try_remove_is_adjunct,select_consequent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,select_consequent,remove_left_conjunct
#S' -> THE ADJP_L:try_remove_correlated,try_remove_is_adjunct,try_remove_wh_minus,select_antecedent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,require_no_conjunction,require_no_correlator,select_antecedent,remove_left_conjunct COMMA THE ADVP_L:try_remove_correlated,try_remove_is_adjunct,select_consequent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,select_consequent,remove_left_conjunct
#S' -> THE ADVP_L:try_remove_correlated,try_remove_is_adjunct,try_remove_wh_minus,select_antecedent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,require_no_conjunction,require_no_correlator,select_antecedent,remove_left_predicate,factor COMMA THE ADJP_L:try_remove_correlated,try_remove_is_adjunct,select_consequent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,select_consequent,remove_left_conjunct
#S' -> THE ADVP_L:try_remove_correlated,try_remove_is_adjunct,try_remove_wh_minus,select_antecedent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,require_no_conjunction,require_no_correlator,remove_left_predicate,factor COMMA THE ADVP_L:try_remove_correlated,try_remove_is_adjunct,select_consequent,select_left_conjunct_without_head S':try_remove_correlated,try_remove_is_adjunct,select_consequent,remove_left_conjunct
S' -> EITHER S':require_not_adjunct,remove_either
# for correlated coordination
# NOTE: For the following rules, the coordination doesn't have to be at head
# scope, it can be the left-most coordination that is a descendant of the head
# scope as well, so long as there is no negation between the coordination and
# the root. However, we need some measure of "distance" between the
# coordination and the head scope to be a feature to decide between the rules
# at this nonterminal (e.g. "both" moves left much less often than "either").
# S' {A1 | ... | An} -> EITHER S' {A1 | ... | An}
#S' -> S':require_not_correlated,require_not_adjunct,add_either,add_correlated_by_either,require_disjunction # this transformation requires the coordination is at the head
#S' -> EITHER S':require_not_correlated,require_not_adjunct,add_correlated_by_either,require_disjunction # this transformation requires the coordination is a descendant of the head
# NOTE: In the below rules, we require that none of the Ai are themselves
# coordinations with the coordinator (unless Ai is negated).
# S' {(~)A1 & ... & (~)An} -> S' {(~)A1} S_COORDINATION {(~)A2 & ... & (~)An}
S' -> S':require_conjunction,select_left_operand,mark_wide_scope S_COORDINATION:try_remove_correlator,remove_left_operand,add_and
S' -> S':require_conjunction,select_left_operand,mark_wide_scope S_COORDINATION:try_remove_correlator,remove_left_operand,add_and,add_comma
# S' {(~)A1 | ... | (~)An} -> S' {(~)A1} S_COORDINATION {(~)A2 | ... | (~)An}
S' -> S':require_disjunction,select_left_operand,mark_wide_scope S_COORDINATION:try_remove_correlator,remove_left_operand,add_or
S' -> S':require_disjunction,select_left_operand,mark_wide_scope S_COORDINATION:try_remove_correlator,remove_left_operand,add_or,add_comma
# S' {~A1 & ... & ~An} -> S' {~A1} S_COORDINATION {~A2 & ... & ~An}
# TODO: We need to store information in the source logical form that there was
# originally a negation (that this is a negative context), and "nor" can only
# appear in negative contexts.
S' -> S':require_negative_conjunction,select_left_operand,mark_wide_scope S_COORDINATION:try_remove_correlator,remove_left_operand,add_nor
S' -> S':require_negative_conjunction,select_left_operand,mark_wide_scope S_COORDINATION:try_remove_correlator,remove_left_operand,add_nor,add_comma
# S' {but((~)A1,(~)A2)} -> S' {(~)A1} (COMMA) BUT S' {(~)A2}
#S' -> S':require_not_adjunct,select_left_in_but BUT S':try_remove_correlator,select_right_in_but
#S' -> S':require_not_adjunct,select_left_in_but COMMA BUT S':try_remove_correlator,select_right_in_but
S_COORDINATION nonterminal {} {1.0} {1.0} {} 10 1.0 {}
# S_COORDINATION {(~)A1 & ... & (~)An} -> (COMMA) S' {(~)A1} S_COORDINATION {(~)A2 & ... & (~)An}
# S_COORDINATION {(~)A1 | ... | (~)An} -> (COMMA) S' {(~)A1} S_COORDINATION {(~)A2 | ... | (~)An}
S_COORDINATION -> COMMA S':remove_comma,select_left_operand,remove_coord,mark_wide_scope S_COORDINATION:remove_left_operand
# S_COORDINATION {(~)A1} -> (COMMA) S' {(~)A1}
S_COORDINATION -> COMMA S':remove_coord,remove_comma
# S_COORDINATION {(~)A1 & ... & (~)An} -> (COMMA) AND S' {(~)A1} S_COORDINATION {(~)A2 & ... & (~)An}
S_COORDINATION -> AND S':require_no_comma,select_left_operand,remove_and,mark_wide_scope S_COORDINATION:remove_left_operand
S_COORDINATION -> COMMA AND S':remove_comma,select_left_operand,remove_and,mark_wide_scope S_COORDINATION:remove_left_operand
# S_COORDINATION {(~)A1} -> (COMMA) AND S' {(~)A1}
S_COORDINATION -> AND S':remove_and,require_no_comma
S_COORDINATION -> COMMA AND S':remove_and,remove_comma
# S_COORDINATION {(~)A1 & ... & (~)An} -> (COMMA) OR S' {(~)A1} S_COORDINATION {(~)A2 & ... & (~)An}
S_COORDINATION -> OR S':require_no_comma,select_left_operand,remove_or,mark_wide_scope S_COORDINATION:remove_left_operand
S_COORDINATION -> COMMA OR S':remove_comma,select_left_operand,remove_or,mark_wide_scope S_COORDINATION:remove_left_operand
# S_COORDINATION {(~)A1} -> (COMMA) OR S' {(~)A1}
S_COORDINATION -> OR S':remove_or,require_no_comma
S_COORDINATION -> COMMA OR S':remove_or,remove_comma
# S_COORDINATION {~A1 & ... & (~)An} -> (COMMA) NOR VP_R {~A1} S_COORDINATION {(~)A2 & ... & (~)An}
S_COORDINATION -> NOR VP_R:add_req_aux,require_no_comma,add_negative,select_left_operand,remove_nor,mark_wide_scope,require_no_predicate_empty,has_arg2 S_COORDINATION:remove_left_operand
S_COORDINATION -> COMMA NOR VP_R:add_req_aux,remove_comma,add_negative,select_left_operand,remove_nor,mark_wide_scope,require_no_predicate_empty,has_arg2 S_COORDINATION:remove_left_operand
# S_COORDINATION {~A1} -> (COMMA) NOR S' {~A1}
S_COORDINATION -> NOR VP_R:remove_nor,add_req_aux,require_no_comma,add_negative,require_no_predicate_empty,has_arg2
S_COORDINATION -> COMMA NOR VP_R:remove_nor,add_req_aux,remove_comma,add_negative,require_no_predicate_empty,has_arg2
S'' nonterminal {left_arg} {1000.0, 0.001} {0.0001, 1000.0} {} 10 1.0 {}
# S'' {(~)?[e]:(U(i,e) & exist(e) & ...)} -> THERE VP_R {(~)?[e]:(U(i,e) & exist(e) & ...)}
# NOTE: This above rule is only really useful if we choose to represent "there
# is a cat" as something like ?[x]:(U(0,x) & cat(x)).
S'' -> THERE VP_R:try_remove_nullable_subject,try_remove_correlated,require_no_correlator,require_left_predicate_exist,require_no_subset_arg1,set_predicate_empty,has_arg2
# S'' {... & (~)?[y1]:(f(y1) & g1(y1)) & ... & (~)?[yn]:(f(yn) & gn(yn))}
# -> V_ADJUNCT {... & ?[y1]:(p1(y1) & f(y1)) & ... & ?[yn]:(pn(yn) & f(yn))}
# VP_R {... & (~)?[y1]:g1(y1) & ... & (~)?[yn]:gn(yn)}
# where `f` contains the `arg1` term.
# TODO: why do we have this rule? it's identical to the one below it
#S'' -> V_ADJUNCT:try_remove_nullable_subject,require_no_subordinate,try_remove_correlator,try_remove_wh_minus,select_left_conjunct VP_R:try_remove_nullable_subject,try_remove_correlated,remove_left_conjunct,require_no_predicate_empty,has_arg2
# S'' {... & (~)?[x]:(f(x) & ?[y1]:(... & arg1/arg2(y1)=x) & ... & ?[yn]:(... & arg1/arg2(yn)=x))}
# -> V_ADJUNCT {... & ?[x]:(f(x) & ?[y1]:(p1(y1) & arg1/arg2(y1)=x) & ... & ?[yn]:(pn(yn) & arg1/arg2(yn)=x))}
# VP_R {... & (~)?[y1]:(...) & ... & (~)?[yn]:(...)}
# S'' {... & (~)![x]:(f(x) => ... & ?[y1]:(... & arg1/arg2(y1)=x) & ... & ?[yn]:(... & arg1/arg2(yn)=x))}
# -> V_ADJUNCT {... & ![x]:(f(x) => ... & ?[y1]:(p1(yn) & arg1/arg2(y1)=x) & ... & ?[yn]:(pn(yn) & arg1/arg2(yn)=x))}
# VP_R {... & (~)?[y1]:(...) & ... & (~)?[yn]:(...)}
# S'' {... & ?[X]:(f(X) & (~)![x]:(X(x) => ... & ?[y1]:(... & arg1/arg2(y1)=x) & ... & ?[yn]:(... & arg1/arg2(yn)=x)))}
# -> V_ADJUNCT {... & ?[X]:(f(X) & ![x]:(X(x) => ... & ?[y1]:(p1(y1) & arg1/arg2(y1)=x) & ... & ?[yn]:(pn(yn) & arg1/arg2(yn)=x)))}
# VP_R {... & (~)?[y1]:(...) & ... & (~)?[yn]:(...)}
# NOTE: This rule also handles open interrogatives but only when the unknown
# variable is in the logical form for the V_ADJUNCT. In the logical forms of
# some interrogatives, X may be declared as a lambda variable.
# NOTE: The `arg2` version of the rule is for preposing.
# NOTE: In comparative constructions where sizes of sets are compared, this
# requires that the quantified variables are used in the same way in both
# consequents. That is, in:
# ?[X]:(... & ?[R]:(f(size(X),size(R)) & ... & ![r]:(R(r) => ?[y]:(arg1/arg2/arg3(y)=r & ...))) & ... & ![x]:(X(x) => ?[y]:(arg1/arg2/arg3(y)=x & ...)))
# This rule requires that `arg1(y)=r` and `arg1(y)=x` appear in both
# consequents (or `arg2(y)=r` and `arg2(y)=x`, etc).
S'' -> V_ADJUNCT:try_remove_nullable_subject,require_no_subordinate,try_remove_correlator,try_remove_wh_minus,select_left_conjunct VP_R:try_remove_nullable_subject,try_remove_correlated,remove_left_conjunct,require_no_predicate_empty,has_arg2
#S'' -> V_ADJUNCT:try_remove_nullable_subject,require_no_subordinate,try_remove_correlator,try_remove_wh_minus,select_left_conjunct_and_negation VP_R:try_remove_nullable_subject,try_remove_correlated,remove_left_conjunct_and_negation,require_no_predicate_empty,has_arg2
# TODO: do we need an arg2 version of this rule?
# S'' {... & ?[a]:(u(a) & ?[f]:(f=^[x,y]:?[z]:((arg1(z)=x) & F(?[h]:(... & (arg2(h)=y)))) & ?[m]:(greatest(f)(m) & (arg1(f)=A) & (arg2_of(x)=b))))}
# -> V_ADJUNCT {... & ?[z]:(p(z) & arg1/arg2(z)=b)}
# VP_R {... & ?[z]:F(?[h]:(... & <TRACE>))}
# NOTE: The `h` and `z` scopes could be the same, and A may not necessarily be
# defined. In fact, the term `arg1(f)=A` is defined iff b is a lambda variable
# (such as in an interrogative clause) and there is a `A(a)` term.
# e.g. "the antenna of the northern building is the tallest", "what state that borders the Mississippi has the tallest mountain shorter than 5000 ft"
S'' -> V_ADJUNCT:try_remove_genitive,require_left_greatest,select_function_with_substitution,select_left_conjunct VP_R:try_remove_correlated,try_remove_wh_minus,try_remove_measure,add_superlative,select_function_with_substitution,remove_left_conjunct,has_arg2
# open interrogative clauses with movement
# S'' {^[x]:(... ?[X]:(... & X(x) & ... & ?[r]:(f(r) & arg1/arg2/arg3(r)=x)))} note that X is not quantified here; `X(x)` kind of plays the role of a quantifier
# -> V_ADJUNCT {^[x]:(... ?[X]:(... & X(x) & ... & ?[r]:(p(r) & arg1/arg2/arg3(r)=x)))}
# VP_R {... & ?[r]:f(r)}
# S'' {^[X]:(... & ![x]:(X(x) => ?[r]:(f(r) & arg1/arg2/arg3(r)=x)))}
# -> V_ADJUNCT {^[X]:(... & ![x]:(X(x) => ?[r]:(p(r) & arg1/arg2/arg3(r)=x)))}
# VP_R {... & ?[r]:f(r)}
# S'' {^[x]:(... & ?[r]:(f(r) & arg1/arg2/arg3(r)=x))}
# -> V_ADJUNCT {^[x]:(... & ?[r]:(p(r) & arg1/arg2/arg3(r)=x))}
# VP_R {... & ?[r]:f(r)}
# e.g. "which store did Jason run to?", "what store did Jason run to?", "who is she speaking with?"
# e.g. "to which store did Jason run?", "with whom is she speaking?" (for the rules with add_preposition)
#S'' -> V_ADJUNCT:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,remove_right_of_lambda,require_no_predicate_empty,has_arg2 # requires do-support unless subordinate
#S'' -> V_ADJUNCT:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,remove_right_of_lambda,require_no_predicate_empty,has_arg2,add_to_infinitive # requires do-support unless subordinate
#S'' -> V_ADJUNCT:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,add_preposition,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,add_preposition,remove_right_of_lambda,require_no_predicate_empty,has_arg2 # requires do-support unless subordinate
#S'' -> V_ADJUNCT:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,add_preposition,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,add_preposition,remove_right_of_lambda,require_no_predicate_empty,has_arg2,add_to_infinitive # requires do-support unless subordinate
# for predicative subjects
# S'' {^[x]:(... ?[r]:(f(r) & U(i,r) & p(r) & g(x,r)))}
# -> V_ADJUNCT {^[x]:?[r]:(p(r) & U(i,r) & g(x,r))}
# VP_R {^[x]:(... ?[r]:(f(r) & p(r) & U(i,r) & gap))}
# e.g. "how big is the earth?"
# NOTE: `r` does not have to be the head of the logical form. But it must be in
# the "right-most" path (i.e. if a scope `x` is in the right-most path, where
# `x` is some quantifier of `R(argn(x)=y)`, then `y` is also on the right-most
# path).
# NOTE: `r` can also be any scope that is an ancestor of x.
#S'' -> V_ADJUNCT:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,remove_right_and_predicate_of_lambda,require_no_predicate_empty,has_arg2 # requires do-support unless subordinate
#S'' -> V_ADJUNCT:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,remove_right_and_predicate_of_lambda,require_no_predicate_empty,has_arg2,add_to_infinitive # requires do-support unless subordinate
# open interrogative clauses with movement
# S'' {^[x]:(... ?[r]:(g(r) & U(i,r) & p(r) & f(r)))}
# -> ADJP {^[x]:?[r]:(g(r) & U(i,r) & p(r))}
# VP_R {^[x]:(... ?[r]:f(r))}
# NOTE: `r` does not have to be the head of the logical form.
# This rule removes the predicate `p` from the event corresponding to the verb
# (and so the verb is semantically empty).
# TODO: is this not subsumed by the above rules?
#S'' -> ADJP:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,remove_right_and_predicate_of_lambda,require_no_predicate_empty,has_arg2 # requires do-support unless subordinate
#S'' -> ADJP:try_remove_nullable_subject,try_remove_subordinate,try_remove_correlator,require_no_wh_minus,select_lambda VP_R:try_remove_nullable_subject,try_add_req_aux,try_remove_subordinate,try_remove_correlated,add_wh_minus,remove_right_and_predicate_of_lambda,require_no_predicate_empty,has_arg2,add_to_infinitive # requires do-support unless subordinate
# subject-less infinitival closed interrogative clauses
# S'' {^[x]:x=A} -> VP_R {A}
# S'' {^[x]:(... & true(x) & (x=possibility(A1) | ... | x=possibility(An)))} -> VP_R {... & (A1 | ... | An)}
#S'' -> VP_R:remove_subordinate,require_no_arg1,require_to_infinitive,require_no_predicate_empty,has_arg2,remove_closed_lambda_equality
#S'' -> VP_R:remove_subordinate,require_no_arg1,require_to_infinitive,require_no_predicate_empty,has_arg2,remove_lambda_possibilities
# subject-less infinitival open interrogative clauses
# S'' {^[x]:A} -> VP_R {^[x]:A}
#S'' -> VP_R:try_remove_subordinate,require_no_arg1,add_to_infinitive,require_lambda,require_no_predicate_empty,has_arg2
# closed interrogative clauses, which require subject-auxiliary inversion
# (excluding closed interrogative clauses we handle at the nonterminal S)
# S'' {^[x]:x=A} -> VP_R {A}
# S'' {^[x]:(... & true(x) & (x=possibility(A1) | ... | x=possibility(An)))} -> VP_R {... & (A1 | ... | An)}
#S'' -> VP_R:try_add_req_aux,require_no_predicate_empty,has_arg2,remove_closed_lambda_equality # requires do-support unless subordinate
#S'' -> VP_R:try_add_req_aux,require_no_predicate_empty,has_arg2,remove_lambda_possibilities # requires do-support unless subordinate
# comparative constructions
# S'' {... & ?[x,r]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x & arg2(gn)=r) & ... & ?[y]:(... & arg1(y)=x & ... & h(r) & ...))}
# -> NP {^[P]:(... & ?[X]:(X=^[x]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x) & ...) & ?[x]:(X(x) & P(x))))}
# VP_R {... & ?[r]:(?[g]:(U(i,g) & p(fn)(g) & arg2(g)=r) & ... & ?[y]:(... & h(r) & ...))}
# where h(r) could either be `r=a` if r is a constant or it can define a new object like `U(i,r) & p(r) & ...`.
# S'' {... & ?[X,R]:(... & p_comp(size(X),size(R)) & ... & F(X=^[x]:(![r]:(R(r) => ?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x & arg2(gn)=r)) & ...)) & ... & ![x]:(X(x) => ?[y]:(... & arg1(y)=x & ... & R=^[r]:(...) & ...)))}
# -> NP {^[P]:(... & ?[X]:(... & p_comp(size(X)) & ... & F(X=^[x]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x))) & ... & ![x]:(X(x) => P(x))))}
# VP_R {... & ?[R]:(p_comp(size(R)) & ... & ![r]:(R(r) => ?[g]:(U(i,g) & p(fn)(g) & arg2(g)=r)) & ... & ?[y]:(... & R=^[r]:(...) & ...))}
# S'' {... & ?[X,R]:(?[X1,R1]:(... & p_comp(size(X1),size(R1)) & ... & F(X1=^[x]:(![r]:(R1(r) => ?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x & arg2(gn)=r)) & ...)) & ?[X2,R2]:(... & p_comp(size(X2),size(R2)) & ... & F(X2=^[x]:(...)) & ... & X=^[S]:(S=X1 | ... | S=Xn) & R=^[S]:(S=R1 | ... | S=Rn))) & ... & ![S]:(X(S) => ![x]:(S(x) => ?[y]:(... & arg1(y)=x & ... & ![Ri]:(R(Ri) => Ri=^[r]:(...)) & ...))))}
# -> NP {^[P]:(... & ?[X]:(?[X1]:(... & p_comp(size(X1)) & ... & F(X1=^[x]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x) & ...)) & ?[X2]:(... & p_comp(size(X2)) & ... & F(X2=^[x]:(...)) & ... & X=^[S]:(S=X1 | ... | S=Xn))) & ... & ![S]:(X(S) => ![x]:(S(x) => P(x)))))}
# VP_R {... & ?[Rn]:(p_comp(size(Rn)) & ... & ![r]:(Rn(r) => ?[g]:(U(i,g) & p(fn)(g) & arg2(g)=r)) & ... & ?[y]:(... & Rn=^[r]:(...) & ...))}
# NOTE: The predicate could also be a simple `p` rather than `p(f)`. The terms
# `p_comp(size(X),size(R))` and `?[gi]:(...)` are optional (but there must be
# at least one). The term `p_comp(size(X),size(R))` handles comparative
# constructions where sizes of sets are compared.
# e.g. "a brighter star could be seen with the telescope than without it", "more people came than last time", "more girls but fewer boys came to the event than last time"
#S'' -> NP:require_no_subordinate,select_left_comparator_predicative,has_arg2_in_set,try_remove_nullable_subject,try_remove_correlator,try_remove_wh_minus VP_R:remove_left_comparator,try_remove_nullable_subject,try_remove_correlated,require_no_predicate_empty,has_arg2
# S'' {A} -> VP_R {A}
S'' -> VP_R:remove_nullable_subject,require_no_predicate_empty,has_arg2
VP_R nonterminal {head_predicate} {100.0, 10.0} {0.1, 1.0} {} 10 1.0 {}
# VP_R {... & (~)?[y1]:(g1(y1) & f(y1)) & ... & (~)?[yn]:(gn(yn) & f(yn))}
# -> VP_R {... & (~)?[y1]:g1(y1) & ... & (~)?[yn]:gn(yn)}
# V_ADJUNCT {... & ?[y1]:(p1(y1) & f(y1)) & ... & ?[yn]:(pn(yn) & f(yn))}
VP_R -> VP_R:remove_right_conjunct V_ADJUNCT:select_right_conjunct,try_remove_correlated,try_remove_correlator,try_remove_wh_minus,try_remove_number,try_remove_coordinated_be
VP_R -> VP_R:remove_right_conjunct,add_preposition V_ADJUNCT:select_right_conjunct,try_remove_correlated,try_remove_correlator,try_remove_wh_minus,try_remove_number,try_remove_coordinated_be,add_preposition
VP_R -> VP_L:remove_be,remove_progressive,add_present_participle # progressive aspect
VP_R -> VP_R:remove_be,require_no_progressive,remove_inverse,add_past_participle,add_passive # passive voice
# VP_R {... & (~)?[y1]:(U(i1,y1) & p(y1) & f1(y1) & f(y1)) & ... & (~)?[yn]:(U(in,yn) & p(yn) & fn(yn) & f(yn))}
# -> VP_R {... & (~)?[y1]:f1(y1) & ... & (~)?[yn]:fn(yn)}
# V_ADJUNCT {... & ?[y]:(U(i,y) & p(y) & f(y))}
# This rule removes the predicate `p` from the event corresponding to the verb
# (and so the verb is semantically empty) such as in "the cat is blue" and "the
# cat is in the tree". `fi` contains verb-specific terms such as `present` as
# well as any adjuncts or other arguments of y whereas `f` contains everything
# else, such as the argument.
#VP_R -> VP_R:select_left_predicate_and_tense,set_predicate_empty,factor V_ADJUNCT:remove_second_left_conjunct,try_remove_correlated,try_remove_correlator,try_remove_wh_minus,try_remove_number,add_empty_verb
# for subject-auxiliary inversion where the main verb precedes the subject
VP_R -> VP_L:require_no_future,require_no_perfect,require_no_progressive,require_no_inverse,require_no_to_infinitive,set_predicate_empty,remove_left_conjunct,factor V_ADJUNCT:try_remove_correlated,try_remove_correlator,remove_req_aux,try_remove_wh_minus,try_remove_number,add_empty_verb,select_left_conjunct
# The above rules wouldn't work in coordination over mixed-type verb phrases.
# e.g. "Bob is a child, talking to everyone, and treated with condescension."
# and "Is Bob a child, talking to everyone, and treated with condescension?"
VP_R -> V_ADJUNCT:remove_be,require_no_head_array,require_left_predicate_same,require_no_progressive,require_no_inverse,require_no_req_subject,require_no_req_aux,require_no_to_infinitive,require_no_correlator,remove_second_left_conjunct,require_one_or_two_conjuncts,try_remove_number
VP_R -> V_ADJUNCT:remove_be,require_no_head_array,require_left_predicate_property,require_no_progressive,require_no_inverse,require_no_req_subject,require_no_req_aux,require_no_to_infinitive,require_no_correlator,remove_second_left_conjunct,require_one_or_two_conjuncts,try_remove_number
VP_R -> V_ADJUNCT:remove_be,require_no_progressive,require_no_inverse,require_no_req_subject,require_no_req_aux,require_no_to_infinitive,require_no_correlator,remove_second_left_conjunct,require_one_or_two_conjuncts,try_remove_number,add_empty_verb
# comparative constructions
# VP_R {... & ?[x,r]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x & arg2(gn)=r) & ... & ?[y]:(... & arg1(y)=x & ... & h(r) & ...))}
# -> VP_R {... & ?[x]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x) & ... & ?[y]:(... & arg1(y)=x & ... ))}
# V_ADJUNCT {... & ?[r]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg2(gn)=r) & ... & ?[y]:(p(y) & h(r)))}
# VP_R {... & ?[X,R]:(... & f(size(X),size(R)) & ... & F(X=^[x]:(![r]:(R(r) => ?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x & arg2(gn)=r)) & ...)) & ... & ![x]:(X(x) => ?[y]:(... & arg1(y)=x & ... & R=^[r]:h(r) & ...)))}
# -> VP_R {... & ?[X]:(... & f(size(X)) & ... & F(X=^[x]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x) & ...)) & ... & ![x]:(X(x) => ?[y]:(... & arg1(y)=x & ...)))}
# V_ADJUNCT {... & ?[R]:(... & f(size(R)) & ... & ![r]:(R(r) => ?[g1]:(U(i1,g1) & p(f1)(g1) & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg2(gn)=r)) & ... & ?[y]:(p(y) & R=^[r]:h(r)))}
# VP_R {... & ?[X,R]:(?[X1,R1]:(... & f(size(X1),size(R1)) & ... & F(X1=^[x]:(![r]:(R(r) => ?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x & arg2(gn)=r)) & ...)) & ?[X2,R2]:(... & f(size(X2),size(R2)) & ... & F(X2=^[x]:(...)) & ... & X=^[S]:(S=X1 | ... | S=Xn) & R=^[S]:(S=R1 | ... | S=Rn))) & ... & ![S]:(X(S) => ![x]:(S(x) => ?[y]:(... & arg1(y)=x & ... & ![Ri]:(R(Ri) => Ri=^[r]:h(r)) & ...))))}
# -> VP_R {... & ?[X]:(?[X1]:(... & f(size(X1)) & ... & F(X1=^[x]:(?[g1]:(U(i1,g1) & p(f1)(g1) & arg1(g1)=x) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg1(gn)=x) & ...)) & ?[X2]:(... & f(size(X2)) & ... & F(X2=^[x]:(...)) & ... & X=^[S]:(S=X1 | ... | S=Xn))) & ... & ![S]:(X(S) => ![x]:(S(x) => ?[y]:(... & arg1(y)=x & ...))))}
# V_ADJUNCT {... & ?[R]:(?[R1]:(... & f(size(R1)) & ... & ![r]:(R(r) => ?[g1]:(U(i1,g1) & p(f1)(g1) & arg2(g1)=r) & ... & ?[gn]:(U(in,gn) & p(fn)(gn) & arg2(gn)=r)) & ... & ?[R2]:(... & f(size(R2)) & ... & R=^[S]:(S=R1 | ... | S=Rn))) & ... & ?[y]:(p(y) & ![Ri]:(R(Ri) => Ri=^[r]:h(r))))}
# NOTE: The predicate could also be a simple `p` rather than `p(f)`. The terms
# `f(size(X),size(R))` and `?[gi]:(...)` are optional (but there must be at
# least one). The term `f(size(X),size(R))` handles comparative constructions
# where sizes of sets are compared.
# e.g. "you can see a brighter star with the telescope than without it", "i saw more people at the party than last time", "there were more girls but fewer boys at the event than last time"
#VP_R -> VP_R:require_no_be,select_left_comparator V_ADJUNCT:remove_left_comparator,try_remove_correlated,try_remove_correlator,try_remove_wh_minus
# comparative constructions
# VP_R {... & ?[r]:(?[g]:(U(i,g) & p(f)(g) & arg2(g)=r) & ... & ?[y]:(... & h(r) & ...))}
# -> VP_R {... & ?[y]:(...)}
# V_ADJUNCT {... & ?[r]:(?[g]:(U(i,g) & p(f)(g) & arg2(g)=r) & ... & ?[y]:(p(y) & h(r)))}
# VP_R {... & ?[R]:(f(size(R)) & ... & ![r]:(R(r) => ?[g]:(U(i,g) & p(f)(g) & arg2(g)=r)) & ... & ?[y]:(... & R=^[r]:h(r) & ...))}
# -> VP_R {... & ?[y]:(...)}
# V_ADJUNCT {... & ?[R]:(f(size(R)) & ... & ![r]:(R(r) => ?[g]:(U(i,g) & p(f)(g) & arg2(g)=r)) & ... & ?[y]:(p(y) & R=^[r]:h(r)))}
# NOTE: The predicate could also be a simple `p` rather than `p(f)`. The terms
# `f(size(R))` and `?[gi]:(...)` are optional (but there must be at least one).
# The term `f(size(R))` handles comparative constructions where sizes of sets
# are compared.
# e.g. "a brighter star could be seen with the telescope than without it", "more people came than last time", "more girls but fewer boys came to the event than last time"
#VP_R -> VP_R:require_no_be,remove_right_comparator V_ADJUNCT:select_right_comparator,try_remove_correlated,try_remove_correlator,try_remove_wh_minus
# for (conditional) closed interrogative finite subordinate clauses
# VP_R {A => B} -> VP_R {B} (COMMA) IF/WHETHER S' {A} (COMMA)
# VP_R {^[x]:x=(A => B)} -> VP_R {^[x]:x=B} (COMMA) IF/WHETHER S' {A} (COMMA)
#VP_R -> VP_R:require_no_be,select_consequent S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_whether
#VP_R -> VP_R:require_no_be,select_consequent S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_if
#VP_R -> VP_R:require_no_be,select_consequent COMMA S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_whether COMMA
#VP_R -> VP_R:require_no_be,select_consequent COMMA S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_if COMMA
#VP_R -> VP_R:require_no_be,select_consequent S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_whether,add_subjunctive
#VP_R -> VP_R:require_no_be,select_consequent S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_if,add_subjunctive
#VP_R -> VP_R:require_no_be,select_consequent COMMA S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_whether,add_subjunctive COMMA
#VP_R -> VP_R:require_no_be,select_consequent COMMA S':select_antecedent,try_remove_correlated,add_req_no_aux,try_remove_correlator,try_remove_wh_minus,add_if,add_subjunctive COMMA
# We need this rule for constructions like "she brought down the bed" and "she brought the bed down".
#VP_R -> VP_R:require_no_be,add_particle PARTICLE_PLACEHOLDER
# postposed NP complements/adjuncts
# VP_R {... & ?[x]:(... ?[y1]:(... & arg1/arg2/arg3(y1)=x & ...) & ... & ?[yn]:(... & arg1/arg2/arg3(yn)=x & ...) & ... & f(x))}
# -> VP_R {... & ?[x]:(... ?[y1]:(... & arg1/arg2/arg3(y1)=x & ...) & ... & ?[yn]:(... & arg1/arg2/arg3(yn)=x & ...) & ...)}
# V_ADJUNCT {... & ?[x]:(p(x) & f(x))}
# Note that f(x) may also contain variables which are universally-quantified,
# above the scope of zi, either within the scope of xi (e.g. "i lent the book
# to her with every fact about chemistry") or above it ("i lent a book to her
# from each student").
# In this case, the universal quantifiers are also moved into f'.
# e.g. "i lent the book to Kim with all the information she needs", "Kim lent a book to Ed that contained all the information he needed"
#VP_R -> VP_R:require_no_be V_ADJUNCT:remove_wide_scope,try_remove_correlated,try_remove_correlator,try_remove_wh_minus
# for gapping and stripping
# VP_R {... & (~)?[y1]:(U(i1,y1) & empty_ref(j1,y1) & f(y1)) & ... & (~)?[yn]:(U(in,yn) & empty_ref(jn,yn) & f(yn))}
# -> V_ADJUNCT {... & ?[y1]:(p1(y1) & f(y1)) & ... & ?[yn]:(pn(yn) & f(yn))}
# e.g. "Mary wants to run, and John, swim"
# TODO: What about gapping/stripping predicatives, such as "the cat is orange, and the dog, white"?
#VP_R -> V_ADJUNCT:require_no_be
# VP_R {... & (~)?[y1]:(g1(y1) & gap) & ... & (~)?[yn]:(gn(yn) & gap)}
# -> VP_R {... & (~)?[y1]:g1(y1) & ... & (~)?[yn]:gn(yn)}
#VP_R -> VP_R:require_no_be,remove_wh_minus,require_right_gap,remove_right_conjunct
# TODO: we could require that here are no additional right adjuncts in the head scope
VP_R -> VP_L:require_no_be
# for correlated coordination
# NOTE: For the following rules, the coordination doesn't have to be at head
# scope, it can be the left-most coordination that is a descendant of the head