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
|
--# -path=.:../abstract:../common:../../prelude
--1 Interlingua auxiliary operations.
-- This module contains operations that are needed to make the
-- resource syntax work. To define everything that is needed to
-- implement $Test$, it moreover contains regular lexical
-- patterns needed for $Lex$.
resource ResIna = ParamX ** open Prelude in {
flags optimize=all ;
-- Some parameters, such as $Number$, are inherited from $ParamX$.
--2 For $Noun$
-- This is the worst-case $Case$ needed for pronouns.
param
Case = Nom | Acc | Gen | Dat | Abl ;
-- Why do we need so many cases?
-- Interlingua has (optional) contractions:
-- "a le" -> "al"
-- "de le" -> "del"
-- so, we can't get away with mere prepositions "a" and "de"
-- but use Dative and Ablative to represent those.
-- Pronouns have different forms in Nominative and Accusative.
-- Genitive is used for possesives (which can also be pronominalized)
oper
casePrep : Str -> Case -> Str = \prep,cas -> case cas of {
Dat => "a";
Gen | Abl => "de";
_ => prep
};
--2 For $Verb$
-- These 7 forms are more than we need. (esser is irregular
-- only in pres, past, fut, cond so we could do with 5, but it makes
-- easy to reason about what happens.)
param
VForm
= VInf
| VPres
| VPPart
| VPresPart
| VPast --# notpresent
| VFut --# notpresent
| VCond --# notpresent
;
param
VVariant
= VMono -- "creava"
| VSplit -- "ha create" -- !!! This is not implemented. One reason is that the split forms overlap with aux verb + participle as ajective. (Anterior form)
;
-- The order of sentence is needed already in $VP$.
Order = ODir | OQuest ;
--2 For $Adjective$
AForm = AAdj Degree | AAdv ;
--2 For $Relative$
-- RAgr = RNoAg | RAg {n : Number ; p : Person} ;
-- RCase = RPrep | RC Case ;
--2 For $Numeral$
CardOrd = NCard | NOrd ;
DForm = unit | ten ;
--2 Transformations between parameter types
oper
Agr = {n : Number ; p : Person} ;
-- This is the agreement record for verb phrases, which is needed only for reflexive verbs.
agrP3 : Number -> Agr = \n ->
{n = n ; p = P3} ;
conjAgr : Agr -> Agr -> Agr = \a,b -> {
n = conjNumber a.n b.n ;
p = conjPerson a.p b.p
} ;
-- For each lexical category, here are the worst-case constructors.
mkAdjective : (_,_,_ : Str) -> {s : AForm => Str} =
\bon,melior,optime ->
let mente = case last bon of
{"c" => "amente";
_ => "mente"
}
in {
s = table {
AAdj Posit => bon ;
AAdj Compar => melior ;
AAdj Superl => optime ;
AAdv => bon + mente
}
} ;
mkVerb : Str -> Verb = \crear->
let crea = init crear
in {isRefl = False;
s = table {
VInf => crear;
VPres => crea;
VPast => crea + "va";
VFut => crear + "a";
VCond => crear + "ea";
VPPart => case crear of {
rid + "er" => rid + "ite";
_ => crea + "te"
};
VPresPart => case crear of {
aud + "ir" => aud + "iente";
_ => crea + "nte"
}}};
-- + The 3 (optionally) irregular verbs. (we only need haberV in this module)
esserV : Verb =
let reg = mkVerb "esser"
in {isRefl = False;
s = \\form=> case form of {
VPres => variants {"es"; "esse"};
VFut => variants {"sera"; "essera"};
VCond => variants {"serea"; "esserea"};
VPast => variants {"era"; "esseva"};
_ => reg.s!form}};
haberV : Verb =
let reg = mkVerb "haber"
in {isRefl = False;
s = \\form=> case form of {
VPres => variants {"ha"; "habe"};
_ => reg.s!form}};
vaderV : Verb =
let reg = mkVerb "vader"
in {isRefl = False;
s = \\form=> case form of {
VPres => variants {"va"; "vade"};
_ => reg.s!form}};
mkIP : Str -> Number -> {s : Case => Str ; n : Number} = \qui,n -> {s = \\c=>casePrep [] c ++ qui; n = n};
mkPron : (io,me,mi : Str) -> Agr -> NP ** {possForm : Str} =
\io,me,mi,a ->
let mie = case last mi of {
"e" => mi;
_ => mi + "e"
} in
{
a = a;
s = table {
Nom => io ;
Gen => mie ;
_ => me
} ;
possForm = mi;
isPronoun = True
} ;
Sp1 : Agr = {n = Sg ; p = P1};
Sp2 : Agr = {n = Sg ; p = P2};
Sp3 : Agr = {n = Sg ; p = P3};
Pp1 : Agr = {n = Pl ; p = P1};
Pp2 : Agr = {n = Pl ; p = P2};
Pp3 : Agr = {n = Pl ; p = P3};
-- make an invariant NP (not inflected)
mkInvarNP : Str -> NP = \str -> {a = Sp3; isPronoun = False; s = \\_=> str};
regNP : Str -> NP = mkInvarNP;
artIndef = "un";
artDef = "le" ;
-- For $Verb$.
Verb : Type = {
s : VForm => Str ;
isRefl : Bool
} ;
-- Dependency on Agr is there only because of reflexive pronouns!
VP : Type = {
s : Anteriority => Tense => {fin, inf : Str} ;
rest : Agr => Str; -- comes after the infinite part
clitics : Agr => Str; -- can be placed just before the finite or right after the infinite
prp : Str ; -- present participle (unused at the moment ???)
inf : Str ; -- the infinitive form ; VerbForms would be the logical place
} ;
NP : Type = {
isPronoun : Bool;
s : Case => Str;
a : Agr;
};
-- Noun phrase that can be declined in person and number. (for reflexive pronouns)
NP' : Type = {
isPronoun : Bool;
s : Agr => Case => Str;
};
predV : Verb -> VP = \verb -> {
clitics = \\_ => [];
rest = \\_ => [];
s = table
{Simul => \\t=> {fin = verb.s ! (tenseToVFrom!t); inf = []};
Anter => \\t=> {fin = haberV.s ! (tenseToVFrom!t); inf = verb.s!VPPart}
};
prp = verb.s ! VPresPart;
inf = verb.s ! VInf;
};
tenseToVFrom = table {
Pres => VPres
;Past => VPast; --# notpresent
Fut => VFut; --# notpresent
Cond => VCond --# notpresent
};
insertInvarObj : Str -> VP -> VP = \obj -> insertObj "" Acc (mkInvarNP obj);
insertObj : Str -> Case -> NP -> VP -> VP
= \prep,c,obj,vp -> insertReflObj prep c {isPronoun = obj.isPronoun; s = \\agr => obj.s} vp;
insertReflObj : Str -> Case -> NP' -> VP -> VP = \prep,c,obj,vp -> case obj.isPronoun of
{
-- !!! if the preposition is not empty, or
-- if the case is not [Dat, Acc]
-- then the pronoun cannot be inserted as a clitic.
True => {
inf = vp.inf;
prp = vp.prp;
s = vp.s;
clitics = \\agr => obj.s!agr!c ++ vp.clitics!agr; -- clitics are inserted in reverse order.
rest = vp.rest};
False => {
inf = vp.inf;
prp = vp.prp;
s = vp.s;
clitics = vp.clitics;
rest = \\agr => vp.rest!agr ++ prep ++ obj.s!agr!c;
} };
infVP : VP -> Str = \vp -> variants {
vp.clitics ! Sp3 ++ vp.inf ++ vp.rest ! Sp3 ;
vp.inf ++ vp.clitics ! Sp3 ++ vp.rest ! Sp3 ;
};
posneg : Polarity -> Str = \b -> case b of {
Pos => [] ;
Neg => "non"
} ;
reflPron : Agr => Str = table {
{n = Sg ; p = P1} => "me" ;
{n = Sg ; p = P2} => "te" ;
{n = Sg ; p = P3} => "se" ;
{n = Pl ; p = P1} => "nos" ;
{n = Pl ; p = P2} => "vos" ;
{n = Pl ; p = P3} => "se"
} ;
---- For $Sentence$.
--
Clause = {s : Tense => Anteriority => Polarity => Order => Str} ;
mkClause : Str -> Agr -> VP -> Clause =
\subj,agr,vp ->
{
s = \\t,anter,b =>let v = vp.s!anter!t
in table {
ODir => variants {
subj ++ posneg b ++ v.fin ++ v.inf ++ vp.clitics!agr ++ vp.rest!agr;
subj ++ posneg b ++ vp.clitics!agr ++ v.fin ++ v.inf ++ vp.rest!agr
};
OQuest => variants {
posneg b ++ v.fin ++ subj ++ v.inf ++ vp.clitics!agr ++ vp.rest!agr;
posneg b ++ vp.clitics!agr ++ v.fin ++ subj ++ v.inf ++ vp.rest!agr;
}
}
};
mkQuestion :
{s : Str} -> Clause -> Clause = \qu,cl ->
{s=\\t,a,p,o => qu.s ++ cl.s ! t ! a ! p ! o};
-- For $Numeral$.
oper mkNum : Str -> Str -> Str -> Str -> {s : DForm => CardOrd => Str} =
\duo,vinti,secunde,vintesime->
{s = table { unit => table {
NCard => duo ;
NOrd => secunde};
ten => table {
NCard => vinti;
NOrd => vintesime}}} ;
oper regNum : Str -> Str -> {s : DForm => CardOrd => Str} =
\cinque,quinte ->
let cinqu : Str = case cinque of {
nov + "em"=> nov;
cinq_ + "e" => cinq_;
cinq_ + "o" => cinq_;
sex => sex}
in mkNum cinque quinte (cinqu + "anta") (cinqu + "esime");
regOrd : Str -> Str = \cent -> case cent of {
mill + "e" => mill + "esime";
_ => cent + "esime"};
regCardOrd : Str -> {s : CardOrd => Str} = \ten ->
{s = table {NCard => ten ; NOrd => regOrd ten}} ;
mkCard : CardOrd -> Str -> Str = \c,ten ->
(regCardOrd ten).s ! c ;
}
|