-
Notifications
You must be signed in to change notification settings - Fork 7
/
example.tex
executable file
·444 lines (352 loc) · 14.7 KB
/
example.tex
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
\documentclass[11pt]{article}
% Use of CCG latex commands --cem bozsahin 2017
\usepackage{mathptmx} % this font is for demo. CM fonts look ugly.
\usepackage{ccg-latex}
\begin{document}
\noindent{\Large\bf Using the \verb|ccg-latex.sty| file}\hfill{\small Cem Boz\c{s}ahin}\hfill\today\medskip\bigskip
\noindent This is a \LaTeX 3e package for laying out CCG grammar derivations.
To use this CCG style, please include the following line somewhere in the \LaTeX\,preamble:\medskip
\begin{verbatim}
\usepackage{ccg-latex}
\end{verbatim}\medskip
The style file \verb|ccg-latex.sty| neither loads nor requires packages or fonts. Kerning controls for typesetting the CCG slashes, the LF's colon, and rule decorations in CCG derivations are in the \verb|pt| unit, without the \verb|\!| command. This is because the eye-pleasing slash distance seems to be independent of font size, at least to my eyes.
If you feel like changing it, just look for the \verb|\kern| command.
All math is introduced by \verb|\ensuremath| in \verb|ccg-latex.sty|;
there is no \verb|$..$| unless you introduce it manually. I don't recommend
using math without \verb|\ensuremath| in \verb|ccg-latex.sty|.
The short form \verb|\mymath{..}|, for `bare math', is for that.
I demonstrate examples with increasingly high-level \verb|ccg-latex| code, from lowest
level \verb|\cgex| to \verb|\begin{ccg}| and \verb|\begin{ccgg}|.\bigskip
An Example with the \verb|\cgex{n}{derivations}| command. The \verb|\lf{}| is already in math mode.
Lexical assumption lines are drawn by one command.
\bigskip
\cgex{3}{John & likes & Mary\\
\cglines{3}\\
\cgf{S\fs(S\bs NP)} & \cgf{(S\bs\cgs{NP}{3s})\fs NP} & \cgf{(S\bs NP)\bs((S\bs NP)\fs NP)}\\
\lf{\lambda p.p\,\so{john}} & \lf{\lambda x\lambda y.\so{like}xy} & \lf{\lambda p.p\,\so{mary}}\\
&\cgline{2}{\cgba}\\
&\cgres{2}{S\bs NP \lf{\lambda y.\so{like}\so{mary}y}}\\
\cgline{3}{\cgfa}\\
\cgres{3}{S \lf{\so{like}\so{mary}\so{john}}}
}\medskip\bigskip
The \verb|ccg-latex| code is:
\begin{verbatim}
\cgex{3}{John & likes & Mary\\
\cglines{3}\\
\cgf{S\fs(S\bs NP)} & \cgf{(S\bs\cgs{NP}{3s})\fs NP}
& \cgf{(S\bs NP)\bs((S\bs NP)\fs NP)}\\
\lf{\lambda p.p\,\so{john}}
& \lf{\lambda x\lambda y.\so{like}xy} & \lf{\lambda p.p\,\so{mary}}\\
&\cgline{2}{\cgba}\\
&\cgres{2}{S\bs NP \lf{\lambda y.\so{like}\so{mary}y}}\\
\cgline{3}{\cgfa}\\
\cgres{3}{S \lf{\so{like}\so{mary}\so{john}}}
}
\end{verbatim}
\newpage
You will notice that the result of `likes Mary' was typeset in a different font.
That's because \verb|\cgres| command typesets its input in default font.
Use the \verb|\cat| command inside it to avoid that (or \verb|\cgf|):
\cgex{3}{John & likes & Mary\\
\cglines{3}\\
\cgf{S\fs(S\bs NP)} & \cgf{(S\bs\cgs{NP}{3s})\fs NP} & \cgf{(S\bs NP)\bs((S\bs NP)\fs NP)}\\
\lf{\lambda p.p\,\so{john}} & \lf{\lambda x\lambda y.\so{like}xy} & \lf{\lambda p.p\,\so{mary}}\\
&\cgline{2}{\cgba}\\
&\cgres{2}{\cat{S\bs NP}\lf{\lambda y.\so{like}\so{mary}y}}\\ % note that \cgres is by default in \cgf font
\cgline{3}{\cgfa}\\
\cgres{3}{\cat{S}\lf{\so{like}\so{mary}\so{john}}}
}\medskip\bigskip
The \verb|ccg-latex| code is:
\begin{verbatim}
\cgex{3}{John & likes & Mary\\
\cglines{3}\\
\cgf{S\fs(S\bs NP)} & \cgf{(S\bs\cgs{NP}{3s})\fs NP}
& \cgf{(S\bs NP)\bs((S\bs NP)\fs NP)}\\
\lf{\lambda p.p\,\so{john}}
& \lf{\lambda x\lambda y.\so{like}xy} & \lf{\lambda p.p\,\so{mary}}\\
&\cgline{2}{\cgba}\\
&\cgres{2}{\cat{S\bs NP}\lf{\lambda y.\so{like}\so{mary}y}}\\
% note that \cgres is by default in \cgf font
\cgline{3}{\cgfa}\\
\cgres{3}{\cat{S}\lf{\so{like}\so{mary}\so{john}}}
}
\end{verbatim}
Checking line layouts in short material:
\cgex{3}{I & like & Mo\\
\cglines{3}\\
\cgf{NP} & \cgf{(S\bs\cgs{NP}{3s})\fs NP} & \cgf{NP}\\
&\cgline{2}{\cgfa}\\
&\cgres{2}{\cat{S\bs NP}}\\ % note that \cgres is by default in \cgf font
\cgline{3}{\cgba}\\
\cgres{3}{\cat{S}}
}
The code is: \begin{verbatim}
\cgex{3}{I & like & Mo\\
\cglines{3}\\
\cgf{NP} & \cgf{(S\bs\cgs{NP}{3s})\fs NP} & \cgf{NP}\\
&\cgline{2}{\cgfa}\\
&\cgres{2}{\cat{S\bs NP}}\\ % note that \cgres is by default in \cgf font
\cgline{3}{\cgba}\\
\cgres{3}{\cat{S}}
}
\end{verbatim}
\newpage
An example of using lower-level \verb|ccg-latex| commands for lexical assumption lines, and with shorthanded
type-raising notation using subscript and superscript. NB. they are typeset in math mode without needing \verb|$..$|.\bigskip
\cgex{3}{John & likes & Mary\\ % uses the alias \cat rather than \cgf above--same result
\cgul & \cgul & \cgul\\ % manually repeats the columns for comparison with \cglines above
\cat{\cgss{NP}{3s}{\uparrow}} & \cat{(S\bs\cgs{NP}{3s})\fs NP} & \cat{S\bs(S\fs NP)}\\
\lf{\lambda p.p\,\so{john}}
& \lf{\lambda x\lambda y.\so{like}xy} & \lf{\lambda p.p\,\so{mary}}\\
\cgline{2}{\cgfc}\\
\cgres{2}{\cat{S\fs NP}\lf{\lambda x.\so{like}x\so{john}}}\\ % note that \cgres is by default in \cgf font
\cgline{3}{\cgfa}\\
\cgres{3}{\cat{S}\lf{\so{like}\so{mary}\so{john}}} % using \cat inside \cgres is nae problem
}\bigskip
The ccg-latex code is:
\begin{verbatim}
\cgex{3}{John & likes & Mary\\
% uses the alias \cat rather than \cgf above--same result
\cgul & \cgul & \cgul\\
% manually repeats the columns for comparison with \cglines above
\cat{\cgss{NP}{3s}{\uparrow}}
& \cat{(S\bs\cgs{NP}{3s})\fs NP} & \cat{S\bs(S\fs NP)}\\
\lf{\lambda p.p\,\so{john}}
& \lf{\lambda x\lambda y.\so{like}xy} & \lf{\lambda p.p\,\so{mary}}\\
\cgline{2}{\cgfc}\\
\cgres{2}{\cat{S\fs NP}\lf{\lambda x.\so{like}x\so{john}}}\\
% note that \cgres is by default in \cgf font
\cgline{3}{\cgfa}\\
\cgres{3}{\cat{S} \lf{\so{like}\so{mary}\so{john}}}
% using \cat inside \cgres is nae problem
}
\end{verbatim}
Although the top line produced by \verb|\cgex| command seems like it is meant for lexical assumptions only, because of its font, you can override that for example using the \verb|\cat| command:
\cgex{2}{\cat{X\fs Y} & ~~\cat{Y}\\
\cgline{2}{\cgfa}\\
\cgres{2}{\cat{X}}
}\medskip
Here is the \verb|ccg-latex| code for it:
\begin{verbatim}
\cgex{2}{\cat{X\fs Y} & ~~~\cat{Y}\\
\cgline{2}{\cgfa}\\
\cgres{2}{\cat{X}}
}
\end{verbatim}
\newpage
An example with double slashes (for morphology, etc.)\bigskip
\cgex{3}{dismiss& -ed\\
\cglines{2}\\
\cgf{\cgs{VP}{inf}\fs\cgs{NP}{}}
$:\lambda x\lambda y.\so{dismiss}\,x\,y$&
\cgf{((\cgs{S}{}\bs\cgs{NP}{agr})\fs NP)\bss(\cgs{VP}{inf}\fs NP)}
$:\lambda p\lambda x\lambda y.\so{past}(P\,xy)$\\
\cgline{2}{\cgba}\\
\cgres{2}{\cgf{(\cgs{S}{}\bs\cgs{NP}{agr})\fs\cgs{NP}{}}
\lf{\lambda x\lambda y.\so{past}(\so{dismiss}\,x\,y)}}
}
\bigskip
The ccg-latex code is below (using \verb|\cgf| instead of \verb|\cat|, which do the same, and native latex math for LF, which does the same as \verb|\lf{..})|. NB. empty subscripts with no effect, if you keep changing the categories as I do).
The last \verb|\cgres| is a painful reminder that if you put inline math
in it using \verb|$..$|, you will get a warning from \LaTeX. Use \verb|\lf{..}| or \verb|\mymath{..}| instead.\medskip
\begin{verbatim}
\cgex{3}{dismiss& -ed\\
\cglines{2}\\
\cgf{\cgs{VP}{inf}\fs\cgs{NP}{}}
$:\lambda x\lambda y.\so{dismiss}\,x\,y$&
\cgf{((\cgs{S}{}\bs\cgs{NP}{agr})\fs NP)\bss(\cgs{VP}{inf}\fs NP)}
$:\lambda p\lambda x\lambda y.\so{past}(P\,xy)$\\
\cgline{2}{\cgba}\\
\cgres{2}{\cgf{(\cgs{S}{}\bs\cgs{NP}{agr})\fs\cgs{NP}{}}
\lf{\lambda x\lambda y.\so{past}(\so{dismiss}\,x\,y)}}
}
\end{verbatim}
\newpage
Here is one example with features galore, from Emmon Bach:\bigskip
{\footnotesize
Mary \cgex{6}{musn't & have & been & being & arrest & -ed\\
\cglines{6}\\
\cgf{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{1sg-pl}}
& \cgf{\cgs{VP}{1sg-pl}\fs\cgs{VP}{en}}
&\cgf{\cgs{VP}{en,ing}\fs\cgs{VP}{ing}}
&\cgf{\cgs{VP}{pass,ing}\fs\cgs{VP}{pass}}
&\cgf{\cgs{VP}{inf}\fds NP}
&\cgf{\cgs{VP}{pass}\lds(\cgs{VP}{inf}\fs NP)}\\
\cgline{2}{\cgfc} &&&\cgline{2}{\cgba}\\
\cgres{2}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{en}}} &&&\cgres{2}{\cgs{VP}{pass}}\\
\cgline{3}{\cgfc}\\
\cgres{3}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{ing}}}\\
\cgline{4}{\cgfc}\\
\cgres{4}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{pass}}}\\
\cgline{6}{\cgfa}\\
\cgres{6}{\cat{\cgs{S}{pres}\bs NP}}
}}\bigskip
Here is the ccg-latex code:\bigskip
\begin{verbatim}
{\footnotesize
Mary \cgex{6}{musn't & have & been & being & arrest & -ed\\
\cglines{6}\\
\cgf{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{1sg-pl}}
& \cgf{\cgs{VP}{1sg-pl}\fs\cgs{VP}{en}}
&\cgf{\cgs{VP}{en,ing}\fs\cgs{VP}{ing}}
&\cgf{\cgs{VP}{pass,ing}\fs\cgs{VP}{pass}}
&\cgf{\cgs{VP}{inf}\fds NP}
&\cgf{\cgs{VP}{pass}\lds(\cgs{VP}{inf}\fs NP)}\\
\cgline{2}{\cgfc} &&&\cgline{2}{\cgba}\\
\cgres{2}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{en}}}
&&&\cgres{2}{\cgs{VP}{pass}}\\
\cgline{3}{\cgfc}\\
\cgres{3}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{ing}}}\\
\cgline{4}{\cgfc}\\
\cgres{4}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{pass}}}\\
\cgline{6}{\cgfa}\\
\cgres{6}{\cat{\cgs{S}{pres}\bs NP}}
}}
\end{verbatim}
\newpage
Same example with \verb|\begin{ccg}{n}{data}{derivations}\end{ccg}|.
No gloss line, and lexical assumption lines are drawn by default.\bigskip
{\footnotesize
Mary
\begin{ccg}{6}{musn't & have & been & being & arrest & -ed}
{\cgf{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{1sg-pl}}
& \cgf{\cgs{VP}{1sg-pl}\fs\cgs{VP}{en}}
&\cgf{\cgs{VP}{en,ing}\fs\cgs{VP}{ing}}
&\cgf{\cgs{VP}{pass,ing}\fs\cgs{VP}{pass}}
&\cgf{\cgs{VP}{inf}\fds NP}
&\cgf{\cgs{VP}{pass}\lds(\cgs{VP}{inf}\fs NP)}\\
\cgline{2}{\cgfc} &&&\cgline{2}{\cgba}\\
\cgres{2}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{en}}}
&&&\cgres{2}{\cgs{VP}{pass}}\\
\cgline{3}{\cgfc}\\
\cgres{3}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{ing}}}\\
\cgline{4}{\cgfc}\\
\cgres{4}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{pass}}}\\
\cgline{6}{\cgfa}\\
\cgres{6}{\cat{\cgs{S}{pres}\bs NP}}
}
\end{ccg}
}\bigskip
Here is the ccg-latex code:\bigskip
\begin{verbatim}
{\footnotesize
Mary
\begin{ccg}{6}{musn't & have & been & being & arrest & -ed}
{\cgf{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{1sg-pl}}
& \cgf{\cgs{VP}{1sg-pl}\fs\cgs{VP}{en}}
&\cgf{\cgs{VP}{en,ing}\fs\cgs{VP}{ing}}
&\cgf{\cgs{VP}{pass,ing}\fs\cgs{VP}{pass}}
&\cgf{\cgs{VP}{inf}\fds NP}
&\cgf{\cgs{VP}{pass}\lds(\cgs{VP}{inf}\fs NP)}\\
\cgline{2}{\cgfc} &&&\cgline{2}{\cgba}\\
\cgres{2}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{en}}}
&&&\cgres{2}{\cgs{VP}{pass}}\\
\cgline{3}{\cgfc}\\
\cgres{3}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{ing}}}\\
\cgline{4}{\cgfc}\\
\cgres{4}{\cat{(\cgs{S}{pres}\bs NP)\fs\cgs{VP}{pass}}}\\
\cgline{6}{\cgfa}\\
\cgres{6}{\cat{\cgs{S}{pres}\bs NP}}
}
\end{ccg}
}
\end{verbatim}
\newpage
\noindent Another example, to show glossing in the beginning. The end gloss is typeset by \verb|\mc|, for multi-column, centered.
It uses
\verb|\begin{ccgg}{n}{data}{gloss}{derivations}\end{ccgg}|.
\bigskip
\begin{ccgg}{3}{ver-dir & -t & -ti.}{give{-caus} & {-caus} & {-past}}
{
\cgf{\cgs{VP}{inf}\bs\cgs{NP}{dat}\bs\cgs{NP}{dat}\bs\cgs{NP}{acc}}
& \cgf{(S\bs\cgs{NP}{nom}\bs\cgs{NP}{case})\bs\cgs{VP}{inf}}\\
\lf{\lambda x\lambda y\lambda z.\so{give}yxz} & \lf{\lambda p\lambda x\lambda y.\so{cause}(px)y}\\
\cgline{2}{\cgbc$^3$}\\ \cgres{2}{\cat{S\bs\cgs{NP}{nom}\bs\cgs{NP}{dat}\bs\cgs{NP}{dat}\bs\cgs{NP}{dat}\bs\cgs{NP}{acc}}}\\
\cgres{2}{\lf{\lambda x_1\lambda x_2\lambda x_3\lambda x_4\lambda x_5.\so{cause_{1,2}}(\sos{cause}{1,2}(\so{give}x_1x_2x_3)x_4)x_5}}\\[1ex]
\mc{3}{`made to let give', from Turkish}
}
\end{ccgg}\bigskip
Here is the ccg-latex code:\bigskip
\begin{verbatim}
\begin{ccgg}{3}{ver-dir & -t & -ti.}{give{-caus} & {-caus} & {-past}}
{
\cgf{\cgs{VP}{inf}\bs\cgs{NP}{dat}\bs\cgs{NP}{dat}\bs\cgs{NP}{acc}}
& \cgf{(S\bs\cgs{NP}{nom}\bs\cgs{NP}{case})\bs\cgs{VP}{inf}}\\
\lf{\lambda x\lambda y\lambda z.\so{give}yxz}
& \lf{\lambda p\lambda x\lambda y.\so{cause}(px)y}\\
\cgline{2}{\cgbc$^3$}\\
\cgres{2}{\cat{S\bs\cgs{NP}{nom}\bs\cgs{NP}{dat}\bs
\cgs{NP}{dat}\bs\cgs{NP}{dat}\bs\cgs{NP}{acc}}}\\
\cgres{2}{\lf{\lambda x_1\lambda x_2\lambda x_3\lambda x_4\lambda x_5.
\so{cause_{1,2}}
(\sos{cause}{1,2}(\so{give}x_1x_2x_3)x_4)x_5}}\\[1ex]
\mc{3}{`made to let give', from Turkish}
}
\end{ccgg}
\end{verbatim}\bigskip
Note that subscripted semantic objects such as \so{cause_{1,2}} are better typeset
as \sos{cause}{1,2} using \verb|\sos| (for `semantic object, subscripted'), rather than \verb|\so|.
\newpage
An example with slash modalities and the non-derivability indicator (*):\bigskip
\begin{ccg}{4}{*I~will& give& flowers& my~very~heavy~friends.}
{
&\cat{(VP\fs NP)\fds NP}&\cat{VP\bs(VP\fs NP)}&\cat{VP\bs(VP\fs NP)}\\
&\badline{2}{\cgbx}
}
\end{ccg}\bigskip
Code:\bigskip
\begin{verbatim}
\begin{ccg}{4}{*I~will& give& flowers& my~very~heavy~friends.}
{
&\cat{(VP\fs NP)\fds NP}&\cat{VP\bs(VP\fs NP)}&\cat{VP\bs(VP\fs NP)}\\
&\badline{2}{\cgbx}
}
\end{ccg}
\end{verbatim}
\newpage
Some examples to show slash distancing by \verb|pt| unit for categories in subscript:\medskip
If you use \verb|ccg-latex| for category name spacing you will get:\bigskip
John [should]\mymath{_{\mbox{\scriptsize\cat{(S\bs NP)\rds IV}}}} walk the dog.
John [wants]\mymath{_{\mbox{\scriptsize\cat{(S\lds NP)\fs VP}}}} to walk the dog.
Mary [believes]\mymath{_{\mbox{\scriptsize\cat{(S\bs NP)\fds S}}}} that John walked the dog.\bigskip
And some big ones by ccg-latex:\bigskip
{\large
\cat{(S\bxs NP)\fds IV}\smallskip
\cat{(S\lds NP)\fs VP}\smallskip
\cat{(S\bs NP)\rds S}\smallskip
}\bigskip
and bigger ones:\bigskip
{\Large
\cat{(S\bxs NP)\fds IV}\smallskip
\cat{(S\lds NP)\fs VP}\smallskip
\cat{(S\bs NP)\rds S}
}\bigskip
Here is the native \LaTeX\, math rendering of above without \verb|ccg-latex| to compare spacing in various sizes:\bigskip
{\Large
$(S\backslash_\times NP)/_{\diamond}IV$\medskip
$(S\backslash\backslash NP)/VP$\medskip
$(S\backslash NP)// S$}\bigskip
John [should]$_{\scriptstyle (S\backslash NP)//IV}$ walk the dog.
John [wants]$_{\scriptstyle (S\backslash\backslash NP)/ VP}$ to walk the dog.
Mary [believes]$_{\scriptstyle (S\backslash NP)/_{\diamond}S}$ that John walked the dog.
\newpage
Check the code:\footnotesize
\begin{verbatim}
{\Large
$(S\backslash_\times NP)/_{\diamond}IV$\medskip
$(S\backslash\backslash NP)/VP$\medskip
$(S\backslash NP)// S$}\bigskip
John [should]$_{\scriptstyle (S\backslash NP)//IV}$ walk the dog.
John [wants]$_{\scriptstyle (S\backslash\backslash NP)/ VP}$ to walk the dog.
Mary [believes]$_{\scriptstyle (S\backslash NP)/_{\diamond}S}$ that John walked the dog.
\end{verbatim}\bigskip
\normalsize It generates. \bigskip
{\Large
$(S\backslash_\times NP)/_{\diamond}IV$\medskip
$(S\backslash\backslash NP)/VP$\medskip
$(S\backslash NP)// S$}\bigskip
John [should]$_{\scriptstyle (S\backslash NP)//IV}$ walk the dog.
John [wants]$_{\scriptstyle (S\backslash\backslash NP)/ VP}$ to walk the dog.
Mary [believes]$_{\scriptstyle (S\backslash NP)/_{\diamond}S}$ that John walked the dog.\bigskip\bigskip
Not pretty.
\end{document}