started a subdir for the book

This commit is contained in:
aarne
2010-11-22 12:55:37 +00:00
parent 8ab5ec00c6
commit 46137ab6a6
97 changed files with 2026 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
concrete Copy of CopyAbs = {
lincat S, AB = Str ;
lin s x = x ++ x ;
end = [] ;
a x = "a" ++ x ;
b x = "b" ++ x ;
}

View File

@@ -0,0 +1,6 @@
abstract CopyAbs = {
cat S ; AB ;
fun s : AB -> S ;
end : AB ;
a,b : AB -> AB ;
}

View File

@@ -0,0 +1,13 @@
abstract Food = {
flags startcat = Comment ;
cat
Comment ; Item ; Kind ; Quality ;
fun
Pred : Item -> Quality -> Comment ;
This, That : Kind -> Item ;
Mod : Quality -> Kind -> Kind ;
Wine, Cheese, Fish : Kind ;
Very : Quality -> Quality ;
Fresh, Warm, Italian,
Expensive, Delicious, Boring : Quality ;
}

View File

@@ -0,0 +1,19 @@
concrete FoodEng of Food = {
lincat
Comment, Item, Kind, Quality = Str ;
lin
Pred item quality = item ++ "is" ++ quality ;
This kind = "this" ++ kind ;
That kind = "that" ++ kind ;
Mod quality kind = quality ++ kind ;
Wine = "wine" ;
Cheese = "cheese" ;
Fish = "fish" ;
Very quality = "very" ++ quality ;
Fresh = "fresh" ;
Warm = "warm" ;
Italian = "Italian" ;
Expensive = "expensive" ;
Delicious = "delicious" ;
Boring = "boring" ;
}

View File

@@ -0,0 +1,24 @@
concrete FoodHin of Food = {
flags coding = utf8 ;
lincat Comment, Item, Kind, Quality = Str ;
lin
Pred item quality = item ++ quality ++ "है" ;
This kind = "यह" ++ kind ;
That kind = "वह" ++ kind ;
Mod quality kind = quality ++ kind ;
Wine = "मदिरा" ;
Cheese = "पनीर" ;
Fish = "मछली" ;
Very quality = "अति" ++ quality ;
Fresh = "ताज़ा" ;
Warm = "गरम" ;
Italian = "इटली" ;
Expensive = "बहुमूल्य" ;
Delicious = "स्वादिष्ट" ;
Boring = "अरुचिकर" ;
}

View File

@@ -0,0 +1,19 @@
concrete FoodIta of Food = {
lincat
Comment, Item, Kind, Quality = Str ;
lin
Pred item quality = item ++ "è" ++ quality ;
This kind = "questo" ++ kind ;
That kind = "quel" ++ kind ;
Mod quality kind = kind ++ quality ;
Wine = "vino" ;
Cheese = "formaggio" ;
Fish = "pesce" ;
Very quality = "molto" ++ quality ;
Fresh = "fresco" ;
Warm = "caldo" ;
Italian = "italiano" ;
Expensive = "caro" ;
Delicious = "delizioso" ;
Boring = "noioso" ;
}

View File

@@ -0,0 +1,8 @@
abstract Letters = {
cat L ;
fun
a, b, c, d, e, f, g, h, i, j, k, l, m,
n, o, p, q, r, s, t, u, v, w, x, y, z : L ;
}

View File

@@ -0,0 +1,31 @@
concrete LettersCnc of Letters = {
lincat L = Str ;
lin
a = "a" ;
b = "b" ;
c = "c" ;
d = "d" ;
e = "e" ;
f = "f" ;
g = "g" ;
h = "h" ;
i = "i" ;
j = "j" ;
k = "k" ;
l = "l" ;
m = "m" ;
n = "n" ;
o = "o" ;
p = "p" ;
q = "q" ;
r = "r" ;
s = "s" ;
t = "t" ;
u = "u" ;
v = "v" ;
w = "w" ;
x = "x" ;
y = "y" ;
z = "z" ;
}

View File

@@ -0,0 +1,7 @@
abstract Strings = Letters ** {
cat S ;
fun
E : S ;
C : L -> S -> S ;
}

View File

@@ -0,0 +1,5 @@
concrete StringsBW of Strings = LettersCnc ** {
lincat S = Str ;
lin E = [] ;
lin C head tail = tail ++ head ;
}

View File

@@ -0,0 +1,5 @@
concrete StringsFW of Strings = LettersCnc ** {
lincat S = Str ;
lin E = [] ;
lin C head tail = head ++ tail ;
}

View File

@@ -0,0 +1,10 @@
abstract Ticket = {
flags startcat = Request ;
cat
Request ; Station ;
fun
Ticket : Station -> Station -> Request ;
Hamburg, Paris : Station ;
}

View File

@@ -0,0 +1,19 @@
concrete TicketEng of Ticket = {
lincat
Request, Station = Str ;
lin
Ticket X Y =
((("I" ++ ("would like" | "want") ++ "to get" |
("may" | "can") ++ "I get" |
"can you give me" |
[]) ++
"a ticket") |
[]) ++
"from" ++ X ++ "to" ++ Y ++
("please" | []) ;
Hamburg = "Hamburg" ;
Paris = "Paris" ;
}

View File

@@ -0,0 +1,118 @@
resource Arabic = {
oper
Root : Type = {F,C,L : Str} ;
Pattern : Type = Root -> Str ;
Filling : Type = {F,FC,CL,L : Str} ;
fill : Filling -> Root -> Str = \p,r ->
p.F + r.F + p.FC + r.C + p.CL + r.L + p.L ;
dfill : Filling -> Root -> Str = \p,r ->
p.F + r.F + p.FC + r.C + r.C + p.CL + r.L + p.L ;
getRoot : Str -> Root = \s -> case s of {
F@? + C@? + L@? => {F = F ; C = C ; L = L} ;
_ => Predef.error ("cannot get root from" ++ s)
} ;
getPattern : Str -> Pattern = \s -> case s of {
F + "F" + FC + "CC" + CL + "L" + L =>
dfill {F = F ; FC = FC ; CL = CL ; L = L} ;
F + "F" + FC + "C" + CL + "L" + L =>
fill {F = F ; FC = FC ; CL = CL ; L = L} ;
_ => Predef.error ("cannot get pattern from" ++ s)
} ;
word : Str -> Str -> Str = \p,r ->
getPattern p (getRoot r) ;
param
Number = Sg | Dl | Pl ;
Gender = Masc | Fem ;
Tense = Perf | Impf ;
VPer = Vp3 Number Gender | Vp2Sg Gender | Vp2Dl | Vp2Pl Gender | Vp1Sg | Vp1Pl ;
oper
Verb : Type = {s : Tense => VPer => Str} ;
pattV_u : Tense -> VPer -> Pattern = \t,v -> getPattern (case t of {
Perf => case v of {
Vp3 Sg Masc => "FaCaLa" ;
Vp3 Sg Fem => "FaCaLat" ;
Vp3 Dl Masc => "FaCaLaA" ;
Vp3 Dl Fem => "FaCaLataA" ;
Vp3 Pl Masc => "FaCaLuwA" ;
Vp3 Pl Fem => "FaCaLona" ;
Vp2Sg Masc => "FaCaLota" ;
Vp2Sg Fem => "FaCaLoti" ;
Vp2Dl => "FaCaLotumaA" ;
Vp2Pl Masc => "FaCaLotum" ;
Vp2Pl Fem => "FaCaLotunv2a" ;
Vp1Sg => "FaCaLotu" ;
Vp1Pl => "FaCaLonaA"
} ;
Impf => case v of {
Vp3 Sg Masc => "yaFoCuLu" ;
Vp3 Sg Fem => "taFoCuLu" ;
Vp3 Dl Masc => "yaFoCuLaAni" ;
Vp3 Dl Fem => "taFoCuLaAni" ;
Vp3 Pl Masc => "yaFoCuLuwna" ;
Vp3 Pl Fem => "yaFoCuLna" ;
Vp2Sg Masc => "taFoCuLu" ;
Vp2Sg Fem => "taFoCuLiyna" ;
Vp2Dl => "taFoCuLaAni" ;
Vp2Pl Masc => "taFoCuLuwna" ;
Vp2Pl Fem => "taFoCuLona" ;
Vp1Sg => "A?aFoCuLu" ;
Vp1Pl => "naFoCuLu"
}
}) ;
u_Verb : Str -> Verb = \s -> {
s = \\t,p => pattV_u t p (getRoot s) ;
} ;
-- for html
tag : Str -> Str = \t -> "<" + t + ">" ;
etag : Str -> Str = \t -> "</" + t + ">" ;
atag : Str -> Str -> Str = \t,a -> "<" + t ++ a + ">" ;
intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ etag t ;
intagAttr : Str -> Str -> Str -> Str = \t,a,s -> atag t a ++ s ++ etag t ;
verbTable : Verb -> Str = \v ->
let
vsp = v.s ! Perf ;
vsi = v.s ! Impf ;
tr : Str -> Str = intag "tr" ;
td : Str -> Str = intag "td" ;
ts : Str -> Str = \s -> td ("\"" ++ s ++ "\"") ;
trs : Str -> Str -> VPer -> Str = \s,n,v ->
tr (td s ++ td n ++ ts (vsp ! v) ++ ts (vsi ! v))
in
intagAttr "table" "border=1" (
tr ((td "Persona") ++ (td "Numerus") ++ (td "Perfectum") ++ (td "Imperfectum")) ++
trs "3. masc." "sing." (Vp3 Sg Masc) ++
trs "3. fem." "sing." (Vp3 Sg Fem) ++
trs "2. masc." "sing." (Vp2Sg Masc) ++
trs "2. fem." "sing." (Vp2Sg Fem) ++
trs "1." "sing." (Vp1Sg) ++
trs "3. masc." "dual." (Vp3 Dl Masc) ++
trs "3. fem." "dual." (Vp3 Dl Fem) ++
trs "2." "dual." (Vp2Dl) ++
trs "3. masc." "plur." (Vp3 Pl Masc) ++
trs "3. fem." "plur." (Vp3 Pl Fem) ++
trs "2. masc." "plur." (Vp2Pl Masc) ++
trs "2. fem." "plur." (Vp2Pl Fem) ++
trs "1." "plur." (Vp1Pl)
) ;
}

View File

@@ -0,0 +1,11 @@
abstract Discont = {
cat
S ; Cl ; NP ; VP ; AP ;
fun
DeclCl : Cl -> S ;
QuestCl : Cl -> S ;
PredVP : NP -> VP -> Cl ;
CompAP : AP -> VP ;
John : NP ;
Old : AP ;
}

View File

@@ -0,0 +1,21 @@
concrete DiscontEng of Discont = {
param
SForm = SDecl | SQuest ;
lincat
S, NP, AP = Str ;
Cl = SForm => Str ;
VP = {verb,comp : Str} ;
lin
DeclCl cl = cl ! SDecl ;
QuestCl cl = cl ! SQuest ;
PredVP np vp = table {
SDecl => np ++ vp.verb ++ vp.comp ;
SQuest => vp.verb ++ np ++ vp.comp
} ;
CompAP ap = {
verb = "is" ;
comp = ap
} ;
John = "John" ;
Old = "old" ;
}

View File

@@ -0,0 +1,13 @@
abstract Foods = {
flags startcat = Comment ;
cat
Comment ; Item ; Kind ; Quality ;
fun
Pred : Item -> Quality -> Comment ;
This, That, These, Those : Kind -> Item ;
Mod : Quality -> Kind -> Kind ;
Wine, Cheese, Fish, Pizza : Kind ;
Very : Quality -> Quality ;
Fresh, Warm, Italian,
Expensive, Delicious, Boring : Quality ;
}

View File

@@ -0,0 +1,40 @@
concrete FoodsEng of Foods = {
lincat
Comment, Quality = {s : Str} ;
Kind = {s : Number => Str} ;
Item = {s : Str ; n : Number} ;
lin
Pred item quality =
{s = item.s ++ copula ! item.n ++ quality.s} ;
This = det Sg "this" ;
That = det Sg "that" ;
These = det Pl "these" ;
Those = det Pl "those" ;
Mod quality kind =
{s = \\n => quality.s ++ kind.s ! n} ;
Wine = regNoun "wine" ;
Cheese = regNoun "cheese" ;
Fish = noun "fish" "fish" ;
Pizza = regNoun "pizza" ;
Very a = {s = "very" ++ a.s} ;
Fresh = adj "fresh" ;
Warm = adj "warm" ;
Italian = adj "Italian" ;
Expensive = adj "expensive" ;
Delicious = adj "delicious" ;
Boring = adj "boring" ;
param
Number = Sg | Pl ;
oper
det : Number -> Str ->
{s : Number => Str} -> {s : Str ; n : Number} =
\n,det,noun -> {s = det ++ noun.s ! n ; n = n} ;
noun : Str -> Str -> {s : Number => Str} =
\man,men -> {s = table {Sg => man ; Pl => men}} ;
regNoun : Str -> {s : Number => Str} =
\car -> noun car (car + "s") ;
adj : Str -> {s : Str} =
\cold -> {s = cold} ;
copula : Number => Str =
table {Sg => "is" ; Pl => "are"} ;
}

View File

@@ -0,0 +1,32 @@
concrete FoodsIta of Foods = open ResIta in {
lincat
Comment = {s : Str} ;
Quality = Adjective ;
Kind = Noun ;
Item = NounPhrase ;
lin
Pred item quality =
{s = item.s ++ copula ! item.n ++
quality.s ! item.g ! item.n} ;
This = det Sg "questo" "questa" ;
That = det Sg "quel" "quella" ;
These = det Pl "questi" "queste" ;
Those = det Pl "quei" "quelle" ;
Mod quality kind = {
s = \\n => kind.s ! n ++ quality.s ! kind.g ! n ;
g = kind.g
} ;
Wine = noun "vino" "vini" Masc ;
Cheese = noun "formaggio" "formaggi" Masc ;
Fish = noun "pesce" "pesci" Masc ;
Pizza = noun "pizza" "pizze" Fem ;
Very qual = {s = \\g,n => "molto" ++ qual.s ! g ! n} ;
Fresh =
adjective "fresco" "fresca" "freschi" "fresche" ;
Warm = regAdj "caldo" ;
Italian = regAdj "italiano" ;
Expensive = regAdj "caro" ;
Delicious = regAdj "delizioso" ;
Boring = regAdj "noioso" ;
}

View File

@@ -0,0 +1,36 @@
resource ResIta = open Prelude in {
param
Number = Sg | Pl ;
Gender = Masc | Fem ;
oper
NounPhrase : Type =
{s : Str ; g : Gender ; n : Number} ;
Noun : Type = {s : Number => Str ; g : Gender} ;
Adjective : Type = {s : Gender => Number => Str} ;
det : Number -> Str -> Str -> Noun -> NounPhrase =
\n,m,f,cn -> {
s = table {Masc => m ; Fem => f} ! cn.g ++
cn.s ! n ;
g = cn.g ;
n = n
} ;
noun : Str -> Str -> Gender -> Noun =
\vino,vini,g -> {
s = table {Sg => vino ; Pl => vini} ;
g = g
} ;
adjective : (nero,nera,neri,nere : Str) -> Adjective =
\nero,nera,neri,nere -> {
s = table {
Masc => table {Sg => nero ; Pl => neri} ;
Fem => table {Sg => nera ; Pl => nere}
}
} ;
regAdj : Str -> Adjective = \nero ->
let ner : Str = init nero
in
adjective nero (ner+"a") (ner+"i") (ner+"e") ;
copula : Number => Str =
table {Sg => "è" ; Pl => "sono"} ;
}

View File

@@ -0,0 +1,5 @@
abstract Clothes = Comments ** {
fun
Shirt, Jacket : Kind ;
Comfortable, Elegant : Quality ;
}

View File

@@ -0,0 +1,10 @@
--# -path=.:present
concrete ClothesEng of Clothes = CommentsEng **
open SyntaxEng, ParadigmsEng in {
lin
Shirt = mkCN (mkN "shirt") ;
Jacket = mkCN (mkN "jacket") ;
Comfortable = mkAP (mkA "comfortable") ;
Elegant = mkAP (mkA "elega") ;
}

View File

@@ -0,0 +1,8 @@
concrete ClothesIta of Clothes = CommentsIta **
open SyntaxIta, ParadigmsIta in {
lin
Shirt = mkCN (mkN "camicia") ;
Jacket = mkCN (mkN "giacca") ;
Comfortable = mkAP (mkA "comodo") ;
Elegant = mkAP (mkA "elegante") ;
}

View File

@@ -0,0 +1,13 @@
abstract Comment = {
flags startcat = Comment ;
cat
Comment ; Item ; Kind ; Quality ;
fun
Pred : Item -> Quality -> Comment ;
This, That, These, Those : Kind -> Item ;
Mod : Quality -> Kind -> Kind ;
Wine, Cheese, Fish, Pizza : Kind ;
Very : Quality -> Quality ;
Fresh, Warm, Italian,
Expensive, Delicious, Boring : Quality ;
}

View File

@@ -0,0 +1,10 @@
abstract Comments = {
flags startcat = Comment ;
cat
Comment ; Item ; Kind ; Quality ;
fun
Pred : Item -> Quality -> Comment ;
This, That, These, Those : Kind -> Item ;
Mod : Quality -> Kind -> Kind ;
Very : Quality -> Quality ;
}

View File

@@ -0,0 +1,4 @@
--# -path=.:present
concrete CommentsEng of Comments = CommentsI with
(Syntax = SyntaxEng) ;

View File

@@ -0,0 +1,15 @@
incomplete concrete CommentsI of Comments = open Syntax in {
lincat
Comment = Cl ;
Item = NP ;
Kind = CN ;
Quality = AP ;
lin
Pred item quality = mkCl item quality ;
This kind = mkNP this_QuantSg kind ;
That kind = mkNP that_QuantSg kind ;
These kind = mkNP these_QuantPl kind ;
Those kind = mkNP those_QuantPl kind ;
Mod quality kind = mkCN quality kind ;
Very quality = mkAP very_AdA quality ;
}

View File

@@ -0,0 +1,4 @@
--# -path=.:present
concrete CommentsIta of Comments = CommentsI with
(Syntax = SyntaxIta) ;

View File

@@ -0,0 +1,5 @@
abstract Computers = Comments ** {
fun
Computer, HardDisk : Kind ;
Efficient, Slow : Quality ;
}

View File

@@ -0,0 +1,10 @@
--# -path=.:present
concrete ComputersEng of Computers = CommentsEng **
open SyntaxEng, ParadigmsEng in {
lin
Computer = mkCN (mkN "computer") ;
HardDisk = mkCN (mkA "hard") (mkN "disk") ;
Efficient = mkAP (mkA "efficient") ;
Slow = mkAP (mkA "slow") ;
}

View File

@@ -0,0 +1,9 @@
concrete ComputersIta of Computers =
CommentsIta ** open ResIta in {
lin
Computer = noun "computer" "computer" Masc ;
HardDisk = noun "disco rigido" "dischi rigidi" Masc ;
Efficient = adjective "efficiente" "efficiente"
"efficienti" "efficienti" ;
Slow = regAdj "lento" ;
}

View File

@@ -0,0 +1,16 @@
resource Exx = {
param DetForm = DSg Gender Case | DPl Case ;
param Gender = Masc | Fem | Neutr ;
param Case = Nom | Acc | Dat | Gen ;
oper artDef : DetForm => Str = table {
DSg Masc Acc | DPl Dat => "den" ;
DSg (Masc | Neutr) Dat => "dem" ;
DSg (Masc | Neutr) Gen => "des" ;
DSg Neutr _ => "das" ;
DSg Fem (Nom | Acc) | DPl (Nom | Acc) => "die" ;
_ => "der"
} ;
}

View File

@@ -0,0 +1,6 @@
abstract Foods = Comments ** {
fun
Wine, Cheese, Fish, Pizza : Kind ;
Fresh, Warm, Italian,
Expensive, Delicious, Boring : Quality ;
}

View File

@@ -0,0 +1,16 @@
--# -path=.:present
concrete FoodsEng of Foods = CommentsEng **
open SyntaxEng, ParadigmsEng in {
lin
Wine = mkCN (mkN "wine") ;
Pizza = mkCN (mkN "pizza") ;
Cheese = mkCN (mkN "cheese") ;
Fish = mkCN (mkN "fish" "fish") ;
Fresh = mkAP (mkA "fresh") ;
Warm = mkAP (mkA "warm") ;
Italian = mkAP (mkA "Italian") ;
Expensive = mkAP (mkA "expensive") ;
Delicious = mkAP (mkA "delicious") ;
Boring = mkAP (mkA "boring") ;
}

View File

@@ -0,0 +1,16 @@
--# -path=.:present
concrete FoodsIta of Foods = CommentsIta **
open SyntaxIta, ParadigmsIta in {
lin
Wine = mkCN (mkN "vino") ;
Pizza = mkCN (mkN "pizza") ;
Cheese = mkCN (mkN "formaggio") ;
Fish = mkCN (mkN "pesce") ;
Fresh = mkAP (mkA "fresco") ;
Warm = mkAP (mkA "caldo") ;
Italian = mkAP (mkA "italiano") ;
Expensive = mkAP (mkA "caro") ;
Delicious = mkAP (mkA "delizioso") ;
Boring = mkAP (mkA "noioso") ;
}

View File

@@ -0,0 +1,2 @@
abstract Shopping = Foods, Clothes ;

View File

@@ -0,0 +1,4 @@
--# -path=.:present
concrete ShoppingEng of Shopping = FoodsEng, ClothesEng ;

View File

@@ -0,0 +1,4 @@
--# -path=.:present
concrete ShoppingIta of Shopping = FoodsIta, ClothesIta ;

View File

@@ -0,0 +1,3 @@
abstract SmallShopping =
Foods - [Wine],
Clothes [Kind,Quality,Shirt,Elegant] ;

View File

@@ -0,0 +1,15 @@
-- (c) 2009 Aarne Ranta under LGPL
abstract Foods = {
flags startcat = Comment ;
cat
Comment ; Item ; Kind ; Quality ;
fun
Pred : Item -> Quality -> Comment ;
This, That, These, Those : Kind -> Item ;
Mod : Quality -> Kind -> Kind ;
Wine, Cheese, Fish, Pizza : Kind ;
Very : Quality -> Quality ;
Fresh, Warm, Italian,
Expensive, Delicious, Boring : Quality ;
}

View File

@@ -0,0 +1,7 @@
--# -path=.:present
-- (c) 2009 Jordi Saludes under LGPL
concrete FoodsCat of Foods = FoodsI with
(Syntax = SyntaxCat),
(LexFoods = LexFoodsCat) ;

View File

@@ -0,0 +1,27 @@
--# -path=.:../foods:minimal:present
concrete FoodsEng of Foods = open SyntaxEng,ParadigmsEng in {
lincat
Phrase = Cl ;
Item = NP ;
Kind = CN ;
Quality = AP ;
lin
Is item quality = mkCl item quality ;
This kind = mkNP this_Quant kind ;
That kind = mkNP that_Quant kind ;
These kind = mkNP this_Quant plNum kind ;
Those kind = mkNP that_Quant plNum kind ;
QKind quality kind = mkCN quality kind ;
Wine = mkCN (mkN "wine") ;
Pizza = mkCN (mkN "pizza") ;
Cheese = mkCN (mkN "cheese") ;
Fish = mkCN (mkN "fish" "fish") ;
Very quality = mkAP very_AdA quality ;
Fresh = mkAP (mkA "fresh") ;
Warm = mkAP (mkA "warm") ;
Italian = mkAP (mkA "Italian") ;
Expensive = mkAP (mkA "expensive") ;
Delicious = mkAP (mkA "delicious") ;
Boring = mkAP (mkA "boring") ;
}

View File

@@ -0,0 +1,7 @@
--# -path=.:present
-- (c) 2009 Aarne Ranta under LGPL
concrete FoodsFin of Foods = FoodsI with
(Syntax = SyntaxFin),
(LexFoods = LexFoodsFin) ;

View File

@@ -0,0 +1,7 @@
--# -path=.:present
-- (c) 2009 Aarne Ranta under LGPL
concrete FoodsGer of Foods = FoodsI with
(Syntax = SyntaxGer),
(LexFoods = LexFoodsGer) ;

View File

@@ -0,0 +1,29 @@
-- (c) 2009 Aarne Ranta under LGPL
incomplete concrete FoodsI of Foods =
open Syntax, LexFoods in {
lincat
Comment = Utt ;
Item = NP ;
Kind = CN ;
Quality = AP ;
lin
Pred item quality = mkUtt (mkCl item quality) ;
This kind = mkNP this_Det kind ;
That kind = mkNP that_Det kind ;
These kind = mkNP these_Det kind ;
Those kind = mkNP those_Det kind ;
Mod quality kind = mkCN quality kind ;
Very quality = mkAP very_AdA quality ;
Wine = mkCN wine_N ;
Pizza = mkCN pizza_N ;
Cheese = mkCN cheese_N ;
Fish = mkCN fish_N ;
Fresh = mkAP fresh_A ;
Warm = mkAP warm_A ;
Italian = mkAP italian_A ;
Expensive = mkAP expensive_A ;
Delicious = mkAP delicious_A ;
Boring = mkAP boring_A ;
}

View File

@@ -0,0 +1,8 @@
--# -path=.:present
-- (c) 2009 Aarne Ranta under LGPL
concrete FoodsIta of Foods = FoodsI with
(Syntax = SyntaxIta),
(LexFoods = LexFoodsIta) ;

View File

@@ -0,0 +1,7 @@
--# -path=.:present
-- (c) 2009 Aarne Ranta under LGPL
concrete FoodsSwe of Foods = FoodsI with
(Syntax = SyntaxSwe),
(LexFoods = LexFoodsSwe) ** {flags language = sv_SE;} ;

View File

@@ -0,0 +1,15 @@
-- (c) 2009 Aarne Ranta under LGPL
interface LexFoods = open Syntax in {
oper
wine_N : N ;
pizza_N : N ;
cheese_N : N ;
fish_N : N ;
fresh_A : A ;
warm_A : A ;
italian_A : A ;
expensive_A : A ;
delicious_A : A ;
boring_A : A ;
}

View File

@@ -0,0 +1,18 @@
-- (c) 2009 Jordi Saludes under LGPL
instance LexFoodsCat of LexFoods =
open SyntaxCat, ParadigmsCat, (M = MorphoCat) in {
flags
coding = utf8 ;
oper
wine_N = mkN "vi" "vins" M.Masc ;
pizza_N = mkN "pizza" ;
cheese_N = mkN "formatge" ;
fish_N = mkN "peix" "peixos" M.Masc;
fresh_A = mkA "fresc" "fresca" "frescos" "fresques" "frescament";
warm_A = mkA "calent" ;
italian_A = mkA "italià" "italiana" "italians" "italianes" "italianament" ;
expensive_A = mkA "car" ;
delicious_A = mkA "deliciós" "deliciosa" "deliciosos" "delicioses" "deliciosament";
boring_A = mkA "aburrit" "aburrida" "aburrits" "aburrides" "aburridament" ;
}

View File

@@ -0,0 +1,20 @@
instance LexFoodsEng of LexFoods = open SyntaxEng, ParadigmsEng, IrregEng in {
oper
wine_N = mkN "wine" ;
pizza_N = mkN "pizza" ;
cheese_N = mkN "cheese" ;
fish_N = mkN "fish" "fish" ;
fresh_A = mkA "fresh" ;
warm_A = mkA "warm" ;
italian_A = mkA "Italian" ;
expensive_A = mkA "expensive" ;
delicious_A = mkA "delicious" ;
boring_A = mkA "boring" ;
eat_V2 = mkV2 eat_V ;
drink_V2 = mkV2 drink_V ;
pay_V2 = mkV2 pay_V ;
lady_N = mkN "lady" ;
gentleman_N = mkN "gentleman" "gentlemen" ;
}

View File

@@ -0,0 +1,20 @@
-- (c) 2009 Aarne Ranta under LGPL
instance LexFoodsFin of LexFoods =
open SyntaxFin, ParadigmsFin in {
oper
wine_N = mkN "viini" ;
pizza_N = mkN "pizza" ;
cheese_N = mkN "juusto" ;
fish_N = mkN "kala" ;
fresh_A = mkA "tuore" ;
warm_A = mkA
(mkN "lämmin" "lämpimän" "lämmintä" "lämpimänä" "lämpimään"
"lämpiminä" "lämpimiä" "lämpimien" "lämpimissä" "lämpimiin"
)
"lämpimämpi" "lämpimin" ;
italian_A = mkA "italialainen" ;
expensive_A = mkA "kallis" ;
delicious_A = mkA "herkullinen" ;
boring_A = mkA "tylsä" ;
}

View File

@@ -0,0 +1,16 @@
-- (c) 2009 Aarne Ranta under LGPL
instance LexFoodsGer of LexFoods =
open SyntaxGer, ParadigmsGer in {
oper
wine_N = mkN "Wein" ;
pizza_N = mkN "Pizza" "Pizzen" feminine ;
cheese_N = mkN "Käse" "Käse" masculine ;
fish_N = mkN "Fisch" ;
fresh_A = mkA "frisch" ;
warm_A = mkA "warm" "wärmer" "wärmste" ;
italian_A = mkA "italienisch" ;
expensive_A = mkA "teuer" ;
delicious_A = mkA "köstlich" ;
boring_A = mkA "langweilig" ;
}

View File

@@ -0,0 +1,16 @@
-- (c) 2009 Aarne Ranta under LGPL
instance LexFoodsIta of LexFoods =
open SyntaxIta, ParadigmsIta in {
oper
wine_N = mkN "vino" ;
pizza_N = mkN "pizza" ;
cheese_N = mkN "formaggio" ;
fish_N = mkN "pesce" ;
fresh_A = mkA "fresco" ;
warm_A = mkA "caldo" ;
italian_A = mkA "italiano" ;
expensive_A = mkA "caro" ;
delicious_A = mkA "delizioso" ;
boring_A = mkA "noioso" ;
}

View File

@@ -0,0 +1,16 @@
-- (c) 2009 Aarne Ranta under LGPL
instance LexFoodsSwe of LexFoods =
open SyntaxSwe, ParadigmsSwe in {
oper
wine_N = mkN "vin" "vinet" "viner" "vinerna" ;
pizza_N = mkN "pizza" ;
cheese_N = mkN "ost" ;
fish_N = mkN "fisk" ;
fresh_A = mkA "färsk" ;
warm_A = mkA "varm" ;
italian_A = mkA "italiensk" ;
expensive_A = mkA "dyr" ;
delicious_A = mkA "läcker" ;
boring_A = mkA "tråkig" ;
}

View File

@@ -0,0 +1,33 @@
abstract Aggregation = {
cat S ; NP ; VP ;
data
PredVP : NP -> VP -> S ;
ConjS : S -> S -> S ;
ConjVP : VP -> VP -> VP ;
ConjNP : NP -> NP -> NP ;
Run, Walk : VP ;
John, Mary : NP ;
fun aggr : S -> S ; -- main aggregation function
def aggr (ConjS (PredVP x X) (PredVP y Y)) =
ifS (eqNP x y)
(PredVP x (ConjVP X Y))
(ifS (eqVP X Y)
(PredVP (ConjNP x y) X)
(ConjS (PredVP x X) (PredVP y Y))) ;
fun ifS : Bool -> S -> S -> S ; -- if b then x else y
def
ifS True x _ = x ;
ifS False _ y = y ;
fun eqNP : NP -> NP -> Bool ; -- x == y
def
eqNP John John = True ;
eqNP Mary Mary = True ;
eqNP _ _ = False ;
fun eqVP : VP -> VP -> Bool ; -- X == Y
def
eqVP Run Run = True ;
eqVP Walk Walk = True ;
eqVP _ _ = False ;
cat Bool ; data True, False : Bool ;
}

View File

@@ -0,0 +1,17 @@
concrete AggregationEng of Aggregation = {
lincat S, NP, VP = Str ;
lin
PredVP x y = x ++ y ;
ConjS a b = a ++ "or" ++ b ;
ConjVP a b = a ++ "or" ++ b ;
ConjNP a b = a ++ "or" ++ b ;
Run = "runs" ;
Walk = "walks" ;
John = "John" ;
Mary = "Mary" ;
}

View File

@@ -0,0 +1,50 @@
abstract Bin = {
cat Nat ; Bin ; Pos ;
data
Zero : Nat ;
Succ : Nat -> Nat ;
BZero : Bin ; -- 0
BPos : Pos -> Bin ; -- p
BOne : Pos ; -- 1
AZero : Pos -> Pos ; -- p0
AOne : Pos -> Pos ; -- p1
fun
bin2nat : Bin -> Nat ;
def
bin2nat BZero = Zero ;
bin2nat (BPos p) = pos2nat p ;
fun
pos2nat : Pos -> Nat ;
def
pos2nat BOne = one ;
pos2nat (AZero p) = twice (pos2nat p) ;
pos2nat (AOne p) = Succ (twice (pos2nat p)) ;
fun one : Nat ;
def one = Succ Zero ;
fun twice : Nat -> Nat ;
def
twice Zero = Zero ;
twice (Succ n) = Succ (Succ (twice n)) ;
fun
nat2bin : Nat -> Bin ;
def
nat2bin Zero = BZero ;
nat2bin (Succ n) = bSucc (nat2bin n) ;
fun
bSucc : Bin -> Bin ;
def
bSucc BZero = BPos BOne ;
bSucc (BPos p) = BPos (pSucc p) ;
fun
pSucc : Pos -> Pos ;
def
pSucc BOne = AZero BOne ;
pSucc (AZero p) = AOne p ;
pSucc (AOne p) = AZero (pSucc p) ;
}

View File

@@ -0,0 +1,28 @@
abstract Classes = {
flags
startcat = Command ;
cat
Command ;
Kind ;
Class ;
Instance Class Kind ;
Action Class ;
Device Kind ;
fun
Act : (c : Class) -> (k : Kind) -> Instance c k -> Action c -> Device k -> Command ;
The : (k : Kind) -> Device k ;
Light, Fan : Kind ;
Switchable, Dimmable : Class ;
SwitchOn, SwitchOff : Action Switchable ;
Dim : Action Dimmable ;
switchable_Light : Instance Switchable Light ;
switchable_Fan : Instance Switchable Fan ;
dimmable_Light : Instance Dimmable Light ;
}

View File

@@ -0,0 +1,29 @@
--# -path=.:present
concrete ClassesEng of Classes = open SyntaxEng, ParadigmsEng in {
lincat
Command = Utt ;
Kind = CN ;
Class = {} ;
Instance = {} ;
Action = V2 ;
Device = NP ;
lin
Act _ _ _ a d = mkUtt (mkImp a d) ;
The k = mkNP the_Det k ;
Light = mkCN (mkN "light") ;
Fan = mkCN (mkN "fan") ;
Switchable, Dimmable = <> ;
SwitchOn = mkV2 (mkV "on" (mkV "switch")) ;
SwitchOff = mkV2 (mkV "off" (mkV "switch")) ;
Dim = mkV2 (mkV "dim") ;
switchable_Light = <> ;
switchable_Fan = <> ;
dimmable_Light = <> ;
}

View File

@@ -0,0 +1,24 @@
abstract DShopping = {
flags startcat = Comment ;
cat
Comment ;
Dom ;
Item Dom ;
Kind Dom ;
Quality Dom ;
fun
DFood, DCloth : Dom ;
Pred : (d : Dom) -> Item d -> Quality d -> Comment ;
This, That : (d : Dom) -> Kind d -> Item d ;
Mod : (d : Dom) -> Quality d -> Kind d -> Kind d ;
Wine, Cheese, Fish : Kind DFood ;
Very : (d : Dom) -> Quality d -> Quality d ;
Fresh, Warm, Delicious, Boring : Quality DFood ;
Shirt, Jacket : Kind DCloth ;
Comfortable : Quality DCloth ;
Italian, Expensive, Elegant : (d : Dom) -> Quality d ;
}

View File

@@ -0,0 +1,33 @@
--# -path=.:present
concrete DShoppingEng of DShopping = open SyntaxEng, ParadigmsEng in {
lincat
Comment = Cl ;
Item = NP ;
Kind = CN ;
Quality = AP ;
lin
Pred _ item quality = mkCl item quality ;
This _ kind = mkNP this_QuantSg kind ;
That _ kind = mkNP that_QuantSg kind ;
Mod _ quality kind = mkCN quality kind ;
Very _ quality = mkAP very_AdA quality ;
Shirt = mkCN (mkN "shirt") ;
Jacket = mkCN (mkN "jacket") ;
Wine = mkCN (mkN "wine") ;
Cheese = mkCN (mkN "cheese") ;
Fish = mkCN (mkN "fish" "fish") ;
Fresh = mkAP (mkA "fresh") ;
Warm = mkAP (mkA "warm") ;
Italian _ = mkAP (mkA "Italian") ;
Expensive _ = mkAP (mkA "expensive") ;
Elegant _ = mkAP (mkA "elegant") ;
Delicious = mkAP (mkA "delicious") ;
Boring = mkAP (mkA "boring") ;
Comfortable = mkAP (mkA "comfortable") ;
DFood, DCloth = {s = []} ;
}

View File

@@ -0,0 +1,22 @@
abstract Nat = {
cat
Prop ; -- proposition
Nat ; -- natural number
data
Zero : Nat ; -- 0
Succ : Nat -> Nat ; -- the successor of x
fun
Even : Nat -> Prop ; -- x is even
And : Prop -> Prop -> Prop ; -- A and B
fun one : Nat ;
def one = Succ Zero ;
fun twice : Nat -> Nat ;
def twice x = plus x x ;
fun plus : Nat -> Nat -> Nat ;
def
plus x Zero = x ;
plus x (Succ y) = Succ (plus x y) ;
}

View File

@@ -0,0 +1,22 @@
abstract Verbs = {
cat
S ; NP ; Subcat ; V Subcat ; Args Subcat ;
fun
cIntr : Subcat ;
cTr : Subcat ;
cS : Subcat ;
aIntr : NP -> Args cIntr ;
aTr : NP -> NP -> Args cTr ;
aS : NP -> S -> Args cS ;
pred : (s : Subcat) -> V s -> Args s -> S ;
john, mary : NP ;
walk : V cIntr ;
love : V cTr ;
know : V cS ;
}

View File

@@ -0,0 +1,22 @@
concrete VerbsEng of Verbs = {
lincat
S, NP, Subcat, V = Str ; Args = Str * Str ;
lin
cIntr = [] ;
cTr = [] ;
cS = [] ;
aIntr su = <su,[]> ;
aTr su ob = <su,ob> ;
aS su s = <su,"that" ++ s> ;
pred _ v xs = xs.p1 ++ v ++ xs.p2 ;
john = "John" ; mary = "Mary" ;
walk = "walks" ;
love = "loves" ;
know = "knows" ;
}

View File

@@ -0,0 +1,12 @@
abstract Query = {
flags startcat=Question ;
cat
Answer ; Question ; Object ;
fun
Even : Object -> Question ;
Odd : Object -> Question ;
Prime : Object -> Question ;
Number : Int -> Object ;
Yes : Answer ;
No : Answer ;
}

View File

@@ -0,0 +1,13 @@
concrete QueryEng of Query = {
lincat
Answer, Question, Object = Str ;
lin
Even = pred "even" ;
Odd = pred "odd" ;
Prime = pred "prime" ;
Number i = i.s ;
Yes = "yes" ;
No = "no" ;
oper
pred : Str -> Str -> Str = \f,x -> "is" ++ x ++ f ;
}

View File

@@ -0,0 +1,13 @@
concrete QueryFin of Query = {
lincat
Answer, Question, Object = Str ;
lin
Even = pred "parillinen" ;
Odd = pred "pariton" ;
Prime = pred "alkuluku" ;
Number i = i.s ;
Yes = "kyllä" ;
No = "ei" ;
oper
pred : Str -> Str -> Str = \f,x -> "onko" ++ x ++ f ;
}

View File

@@ -0,0 +1,7 @@
abstract Calculator = {
flags startcat = Exp ;
cat Exp ;
fun
EPlus, EMinus, ETimes, EDiv : Exp -> Exp -> Exp ;
EInt : Int -> Exp ;
}

View File

@@ -0,0 +1,10 @@
concrete CalculatorC of Calculator = open Formal, Prelude in {
lincat
Exp = TermPrec ;
lin
EPlus = infixl 0 "+" ;
EMinus = infixl 0 "-" ;
ETimes = infixl 1 "*" ;
EDiv = infixl 1 "/" ;
EInt i = constant i.s ;
}

View File

@@ -0,0 +1,13 @@
concrete CalculatorJ of Calculator = open Prelude in {
lincat
Exp = SS ;
lin
EPlus = postfix "iadd" ;
EMinus = postfix "isub" ;
ETimes = postfix "imul" ;
EDiv = postfix "idiv" ;
EInt i = ss ("ldc" ++ i.s) ;
oper
postfix : Str -> SS -> SS -> SS = \op,x,y ->
ss (x.s ++ ";" ++ y.s ++ ";" ++ op) ;
}

View File

@@ -0,0 +1,14 @@
concrete CalculatorP of Calculator = open Prelude in {
lincat
Exp = SS ;
lin
EPlus = infix "+" ;
EMinus = infix "-" ;
ETimes = infix "*" ;
EDiv = infix "/" ;
EInt i = i ;
oper
infix : Str -> SS -> SS -> SS = \f,x,y ->
ss ("(" ++ x.s ++ f ++ y.s ++ ")") ;
}

View File

@@ -0,0 +1,11 @@
concrete CalculatorS of Calculator = open Prelude in {
lin
EPlus = infix "plus" ;
EMinus = infix "minus" ;
ETimes = infix "times" ;
EDiv = infix ["divided by"] ;
EInt i = i ;
oper
infix : Str -> SS -> SS -> SS = \op,x,y ->
ss (x.s ++ op ++ y.s ++ "PAUSE") ;
}

View File

@@ -0,0 +1,7 @@
abstract Geometry = Logic ** {
fun
Line, Point, Circle : Dom ;
Intersect, Parallel : Ind -> Ind -> Atom ;
Vertical : Ind -> Atom ;
Centre : Ind -> Ind ;
}

View File

@@ -0,0 +1,13 @@
--# -path=alltenses
concrete GeometryEng of Geometry = LogicEng **
open SyntaxEng, ParadigmsEng in {
lin
Line = mkCN (mkN "line") ;
Point = mkCN (mkN "point") ;
Circle = mkCN (mkN "circle") ;
Intersect = pred (mkV2 "intersect") ;
Parallel = pred (mkA2 (mkA "parallel") (mkPrep "to")) ;
Vertical = pred (mkA "vertical") ;
Centre = app (mkN2 (mkN "centre") (mkPrep "of")) ;
}

View File

@@ -0,0 +1,11 @@
concrete GeometryEng of Geometry = LogicEng **
open SyntaxEng, ParadigmsEng in {
lin
Line = mkN "line" ;
Point = mkN "point" ;
Circle = mkN "circle" ;
Intersect = pred (mkV2 "intersect") ;
Parallel = pred (mkA2 (mkA "parallel") (mkPrep "to")) ;
Vertical = pred (mkA "vertical") ;
Centre = app (mkN2 (mkN "centre") (mkPrep "of")) ;
}

View File

@@ -0,0 +1,7 @@
abstract Geometry = Logic ** {
fun
Line, Point, Circle : Dom ;
Intersect, Parallel : Ind -> Ind -> Prop ;
Vertical : Ind -> Prop ;
Centre : Ind -> Ind ;
}

View File

@@ -0,0 +1,21 @@
abstract Logic = {
flags startcat = Stm ;
cat
Stm ; -- top-level statement
Prop ; -- proposition
Atom ; -- atomic formula
Ind ; -- individual term
Dom ; -- domain expression
Var ; -- variable
[Prop] {2} ; -- list of propositions, 2 or more
[Var] {1} ; -- list of variables, 1 or more
fun
SProp : Prop -> Stm ;
And, Or : [Prop] -> Prop ;
If : Prop -> Prop -> Prop ;
Not : Prop -> Prop ;
PAtom : Atom -> Prop ;
All, Exist : [Var] -> Dom -> Prop -> Prop ;
IVar : Var -> Ind ;
VString : String -> Var ;
}

View File

@@ -0,0 +1,38 @@
concrete LogicEng of Logic = open
SyntaxEng, (P = ParadigmsEng), SymbolicEng, Prelude in {
lincat
Stm = Text ;
Prop = S ;
Atom = Cl ;
Ind = NP ;
Dom = CN ;
Var = NP ;
[Prop] = [S] ;
[Var] = NP ;
lin
SProp = mkText ;
And = mkS and_Conj ; -- A, B ... and C
Or = mkS or_Conj ; -- A, B ... or C
If A B = -- if A B
mkS (mkAdv if_Subj A) B ;
Not A = -- it is not the case that A
mkS negativePol (mkCl
(mkVP (mkNP the_Quant
(mkCN case_CN A)))) ;
All xs A B = -- for all A's xs, B
mkS (mkAdv for_Prep
(mkNP all_Predet (mkNP a_Quant
plNum (mkCN A xs)))) B ;
Exist xs A B = -- for some A's xs, B
mkS (mkAdv for_Prep
(mkNP somePl_Det (mkCN A xs))) B ;
PAtom = mkS ;
IVar x = x ;
VString s = symb s ;
BaseProp A B = mkListS A B ;
ConsProp A As = mkListS A As ;
BaseVar x = x ;
ConsVar x xs = mkNP and_Conj (mkListNP x xs) ;
oper
case_CN : CN = mkCN (P.mkN "case") ;
}

View File

@@ -0,0 +1,39 @@
concrete LogicEng of Logic = open
SyntaxEng, (P = ParadigmsEng), SymbolicEng, Prelude in {
lincat
Stm = Text ;
Prop = {pos,neg : S ; isAtom : Bool} ;
Atom = Cl ;
Ind = NP ;
Dom = CN ;
Var = NP ;
[Prop] = ListS ;
[Var] = NP ;
lin
SProp p = mkText p.pos ;
And ps = complexProp (mkS and_Conj ps) ;
Or ps = complexProp (mkS or_Conj ps) ;
If A B = complexProp (mkS if_then_Conj (mkListS A.pos B.pos)) ;
Not A = complexProp A.neg ;
All xs A B = complexProp (mkS (mkAdv for_Prep
(mkNP all_Predet (mkNP a_Quant plNum (mkCN A xs)))) B.pos) ;
Exist xs A B = complexProp (mkS (mkAdv for_Prep
(mkNP somePl_Det (mkCN A xs))) B.pos) ;
PAtom p =
{pos = mkS p ; neg = mkS negativePol p ; isAtom = True} ;
IVar x = x ;
VString s = symb s ;
BaseProp A B = mkListS A.pos B.pos ;
ConsProp A As = mkListS A.pos As ;
BaseVar x = x ;
ConsVar x xs = mkNP and_Conj (mkListNP x xs) ;
oper
complexProp : S -> {pos,neg : S ; isAtom : Bool} = \s -> {
pos = s ;
neg = negS s ;
isAtom = False
} ;
negS : S -> S = \s -> mkS negativePol (mkCl (mkNP it_Pron)
(mkNP the_Quant (mkCN (mkCN (P.mkN "case")) s))) ;
if_Then_Conj : Conj = P.mkConj "if" "then" ;
}

View File

@@ -0,0 +1,11 @@
abstract Logic = {
cat
Prop ; Ind ; Dom ; Var ; [Prop] {2} ; [Var] {1} ;
fun
And, Or : [Prop] -> Prop ;
If : Prop -> Prop -> Prop ;
Not : Prop -> Prop ;
All, Exist : [Var] -> Dom -> Prop -> Prop ;
IVar : Var -> Ind ;
VString : String -> Var ;
}

View File

@@ -0,0 +1,17 @@
abstract Anaphora = TestSemantics - [she_NP] ** {
cat
Proof Prop ;
fun
IfS : (A : S) -> (Proof (iS A) -> S) -> S ;
AnaNP : (A : CN) -> (a : Ind) -> Proof (iCN A a) -> NP ;
pe : (B : Ind -> Prop) -> Proof (Exist B) -> Ind ;
qe : (B : Ind -> Prop) -> (c : Proof (Exist B)) -> Proof (B (pe B c)) ;
pc : (A,B : Prop) -> Proof (And A B) -> Proof A ;
qc : (A,B : Prop) -> Proof (And A B) -> Proof B ;
}

View File

@@ -0,0 +1,17 @@
concrete AnaphoraIta of Anaphora = TestSemanticsIta - [she_NP] **
open ResIta, Prelude, Formal in {
lincat
Proof = {} ;
lin
IfS A B = {s = "se" ++ A.s ++ B.s} ;
AnaNP cn _ _ = case cn.g of {
Masc => pronNP "lui" "lo" "gli" Masc Sg Per3 ;
Fem => pronNP "lei" "la" "le" Fem Sg Per3
} ;
pe _ _ = constant [] ; ----
}

View File

@@ -0,0 +1,39 @@
abstract Grammar = {
flags startcat = S ;
cat
S ; Cl ; NP ; VP ; AP ; CN ;
Det ; N ; A ; V ; V2 ; AdA ;
Tense ; Pol ;
Conj ;
data
UseCl : Tense -> Pol -> Cl -> S ;
PredVP : NP -> VP -> Cl ;
ComplV2 : V2 -> NP -> VP ;
DetCN : Det -> CN -> NP ;
ModCN : AP -> CN -> CN ;
CompAP : AP -> VP ;
AdAP : AdA -> AP -> AP ;
ConjS : Conj -> S -> S -> S ;
ConjNP : Conj -> NP -> NP -> NP ;
UseV : V -> VP ;
UseN : N -> CN ;
UseA : A -> AP ;
a_Det, the_Det, every_Det : Det ;
this_Det, these_Det : Det ;
that_Det, those_Det : Det ;
i_NP, she_NP, we_NP : NP ;
very_AdA : AdA ;
Pos, Neg : Pol ;
Pres, Perf : Tense ;
and_Conj, or_Conj : Conj ;
}

View File

@@ -0,0 +1,141 @@
concrete GrammarIta of Grammar = open ResIta, Prelude in {
lincat
S = {s : Str} ;
Cl = {s : ResIta.Tense => Bool => Str} ;
NP = ResIta.NP ;
-- {s : Case => {clit,obj : Str ; isClit : Bool} ; a : Agr} ;
VP = ResIta.VP ;
-- {v : Verb ; clit : Str ; clitAgr : ClitAgr ; obj : Agr => Str} ;
AP = {s : Gender => Number => Str ; isPre : Bool} ;
CN = Noun ; -- {s : Number => Str ; g : Gender} ;
Det = {s : Gender => Case => Str ; n : Number} ;
N = Noun ; -- {s : Number => Str ; g : Gender} ;
A = Adj ; -- {s : Gender => Number => Str ; isPre : Bool} ;
V = Verb ; -- {s : VForm => Str ; aux : Aux} ;
V2 = Verb ** {c : Case} ;
AdA = {s : Str} ;
Pol = {s : Str ; b : Bool} ;
Tense = {s : Str ; t : ResIta.Tense} ;
Conj = {s : Str ; n : Number} ;
lin
UseCl t p cl = {s = t.s ++ p.s ++ cl.s ! t.t ! p.b} ;
PredVP np vp =
let
subj = (np.s ! Nom).obj ;
obj = vp.obj ! np.a ;
clit = vp.clit ;
verb = table {
Pres => agrV vp.v np.a ;
Perf => agrV (auxVerb vp.v.aux) np.a ++ agrPart vp.v np.a vp.clitAgr
}
in {
s = \\t,b => subj ++ neg b ++ clit ++ verb ! t ++ obj
} ;
ComplV2 v2 np =
let
nps = np.s ! v2.c
in {
v = v2 ;
clit = nps.clit ;
clitAgr = case <nps.isClit,v2.c> of {
<True,Acc> => CAgr np.a ;
_ => CAgrNo
} ;
obj = \\_ => nps.obj
} ;
UseV v = {
v = v ;
clit = [] ;
clitAgr = CAgrNo ;
obj = \\_ => []
} ;
DetCN det cn = {
s = \\c => {
obj = det.s ! cn.g ! c ++ cn.s ! det.n ;
clit = [] ;
isClit = False
} ;
a = Ag cn.g det.n Per3
} ;
ModCN ap cn = {
s = \\n => preOrPost ap.isPre (ap.s ! cn.g ! n) (cn.s ! n) ;
g = cn.g
} ;
CompAP ap = {
v = essere_V ;
clit = [] ;
clitAgr = CAgrNo ;
obj = \\ag => case ag of {
Ag g n _ => ap.s ! g ! n
}
} ;
AdAP ada ap = {
s = \\g,n => ada.s ++ ap.s ! g ! n ;
isPre = ap.isPre ;
} ;
ConjNP co nx ny = {
s = \\c => {
obj = (nx.s ! c).obj ++ co.s ++ (ny.s ! c).obj ;
clit = [] ;
isClit = False
} ;
a = conjAgr co.n nx.a ny.a
} ;
ConjS co x y = {s = x.s ++ co.s ++ y.s} ;
UseN n = n ;
UseA adj = adj ;
a_Det = adjDet (mkAdj "un" "una" [] [] True) Sg ;
every_Det = adjDet (regAdj "ogni") Sg ;
the_Det = {
s = table {
Masc => table {
Nom | Acc => elisForms "lo" "l'" "il" ;
Dat => elisForms "allo" "all'" "al"
} ;
Fem => table {
Nom | Acc => elisForms "la" "'l" "la" ;
Dat => elisForms "alla" "all'" "alla"
}
} ;
n = Sg
} ;
this_Det = adjDet (regAdj "questo") Sg ;
these_Det = adjDet (regAdj "questo") Pl ;
that_Det = adjDet quello_A Sg ;
those_Det = adjDet quello_A Pl ;
i_NP = pronNP "io" "mi" "mi" Masc Sg Per1 ;
she_NP = pronNP "lei" "la" "le" Fem Sg Per3 ;
we_NP = pronNP "noi" "ci" "ci" Masc Pl Per1 ;
very_AdA = ss "molto" ;
Pos = {s = [] ; b = True} ;
Neg = {s = [] ; b = False} ;
Pres = {s = [] ; t = ResIta.Pres} ;
Perf = {s = [] ; t = ResIta.Perf} ;
and_Conj = {s = "e" ; n = Pl} ;
or_Conj = {s = "o" ; n = Sg} ;
oper
quello_A : Adj = mkAdj
(elisForms "quello" "quell'" "quel") "quella"
(elisForms "quegli" "quegli" "quei") "quelle"
True ;
}

View File

@@ -0,0 +1,9 @@
abstract Logic = {
cat
Prop ; Ind ;
data
And, Or, If : Prop -> Prop -> Prop ;
Not : Prop -> Prop ;
All, Exist : (Ind -> Prop) -> Prop ;
Past : Prop -> Prop ;
}

View File

@@ -0,0 +1,54 @@
concrete LogicIta of Logic = GrammarIta ** open ResIta, Formal, Prelude in {
lincat
T, I = SS ;
lin
And x y = infixSS "&" x y ;
Or x y = infixSS "v" x y ;
If x y = infixSS "->" x y ;
Not x = prefixSS "~" x ;
All P = prefixSS (parenth ("A" ++ P.$0)) P ;
Exist P = prefixSS (parenth ("E" ++ P.$0)) P ;
Past P = prefixSS "Past" P ;
lin
iN f = star (f.s ! Sg) ;
iA f = star (f.s ! Masc ! Sg) ;
iV f = star (f.s ! VInf) ;
iV2 f x y = star (f.s ! VInf) (cc2 x y) ;
oper star : Str -> SS -> SS = \f,x -> prefixSS f (ss (parenth x.s)) ;
{-
lincat
T, I = TermPrec ;
lin
And = infixl 2 "&" ;
Or = infixl 2 "v" ;
If = infixr 1 "->" ;
-- Not = prefix 3 "~" ;
-- All : (I -> T) -> T ;
-- Exist : (I -> T) -> T ;
-- Past : T -> T ;
lin
iS : S -> T ;
iCl : Cl -> T ;
iNP : NP -> (I -> T) -> T ;
iVP : VP -> I -> T ;
iAP : AP -> I -> T ;
iCN : CN -> I -> T ;
iDet : Det -> (I -> T) -> (I -> T) -> T ;
iN : N -> I -> T ;
iA : A -> I -> T ;
iV : V -> I -> T ;
iV2 : V2 -> I -> I -> T ;
iAdA : AdA -> (I -> T) -> I -> T ;
iTense : Tense -> T -> T ;
iPol : Pol -> T -> T ;
iConj : Conj -> T -> T -> T ;
-}
}

View File

@@ -0,0 +1,13 @@
concrete LogicSymb of Logic = open Formal, Prelude in {
lincat
Prop, Ind = TermPrec ;
lin
And = infixl 2 "\\&" ;
Or = infixl 2 "\\vee" ;
If = infixr 1 "\\sup" ;
Not = prefix 3 "\\sim" ;
All P = prefix 3 (parenth ("\\forall" ++ P.$0)) P ;
Exist P = prefix 3 (parenth ("\\exists" ++ P.$0)) P ;
Past = prefix 3 "P" ;
}

View File

@@ -0,0 +1,47 @@
resource ParadigmsIta = GrammarIta [N,A,V] **
open ResIta, GrammarIta, Prelude in {
oper
masculine : Gender = Masc ;
feminine : Gender = Fem ;
accusative : Case = Acc ;
dative : Case = Dat ;
mkN = overload {
mkN : (vino : Str) -> N
= \n -> lin N (regNoun n) ;
mkN : (uomo, uomini : Str) -> Gender -> N
= \s,p,g -> lin N (mkNoun s p g) ;
} ;
mkA = overload {
mkA : (nero : Str) -> A
= \a -> lin A (regAdj a) ;
mkA : (buono,buona,buoni,buone : Str) -> Bool -> A
= \sm,sf,pm,pf,p -> lin A (mkAdj sm sf pm pf False) ;
} ;
preA : A -> A
= \a -> lin A {s = a.s ; isPre = True} ;
mkV = overload {
mkV : (finire : Str) -> V
= \v -> lin V (regVerb v) ;
mkV : (andare,vado,vadi,va,andiamo,andate,vanno,andato : Str) -> V
= \i,p1,p2,p3,p4,p5,p6,p -> lin V (mkVerb i p1 p2 p3 p4 p5 p6 p Avere) ;
} ;
essereV : V -> V
= \v -> lin V {s = v.s ; aux = Essere} ;
mkV2 = overload {
mkV2 : Str -> V2
= \s -> lin V2 (regVerb s ** {c = accusative}) ;
mkV2 : V -> V2
= \v -> lin V2 (v ** {c = accusative}) ;
mkV2 : V -> Case -> V2
= \v,c -> lin V2 (v ** {c = c}) ;
} ;
}

View File

@@ -0,0 +1,178 @@
resource ResIta = open Prelude in {
-- parameters
param
Number = Sg | Pl ;
Gender = Masc | Fem ;
Case = Nom | Acc | Dat ;
Agr = Ag Gender Number Person ;
Aux = Avere | Essere ;
Tense = Pres | Perf ;
Person = Per1 | Per2 | Per3 ;
VForm = VInf | VPres Number Person | VPart Gender Number ;
ClitAgr = CAgrNo | CAgr Agr ;
-- parts of speech
oper
VP = {
v : Verb ;
clit : Str ;
clitAgr : ClitAgr ;
obj : Agr => Str
} ;
NP = {
s : Case => {clit,obj : Str ; isClit : Bool} ;
a : Agr
} ;
-- the preposition word of an abstract case
prepCase : Case -> Str = \c -> case c of {
Dat => "a" ;
_ => []
} ;
-- for predication
agrV : Verb -> Agr -> Str = \v,a -> case a of {
Ag _ n p => v.s ! VPres n p
} ;
auxVerb : Aux -> Verb = \a -> case a of {
Avere =>
mkVerb "avere" "ho" "hai" "ha" "abbiamo" "avete" "hanno" "avuto" Avere ;
Essere =>
mkVerb "essere" "sono" "sei" "è" "siamo" "siete" "sono" "stato" Essere
} ;
agrPart : Verb -> Agr -> ClitAgr -> Str = \v,a,c -> case v.aux of {
Avere => case c of {
CAgr (Ag g n _) => v.s ! VPart g n ;
_ => v.s ! VPart Masc Sg
} ;
Essere => case a of {
Ag g n _ => v.s ! VPart g n
}
} ;
neg : Bool -> Str = \b -> case b of {True => [] ; False => "non"} ;
essere_V = auxVerb Essere ;
-- for coordination
conjAgr : Number -> Agr -> Agr -> Agr = \n,xa,ya ->
let
x = agrFeatures xa ; y = agrFeatures ya
in Ag
(conjGender x.g y.g)
(conjNumber (conjNumber x.n y.n) n)
(conjPerson x.p y.p) ;
agrFeatures : Agr -> {g : Gender ; n : Number ; p : Person} = \a ->
case a of {Ag g n p => {g = g ; n = n ; p = p}} ;
conjGender : Gender -> Gender -> Gender = \g,h ->
case g of {Masc => Masc ; _ => h} ;
conjNumber : Number -> Number -> Number = \m,n ->
case m of {Pl => Pl ; _ => n} ;
conjPerson : Person -> Person -> Person = \p,q ->
case <p,q> of {
<Per1,_> | <_,Per1> => Per1 ;
<Per2,_> | <_,Per2> => Per2 ;
_ => Per3
} ;
-- for morphology
Noun : Type = {s : Number => Str ; g : Gender} ;
Adj : Type = {s : Gender => Number => Str ; isPre : Bool} ;
Verb : Type = {s : VForm => Str ; aux : Aux} ;
mkNoun : Str -> Str -> Gender -> Noun = \vino,vini,g -> {
s = table {Sg => vino ; Pl => vini} ;
g = g
} ;
regNoun : Str -> Noun = \vino -> case vino of {
fuo + c@("c"|"g") + "o" => mkNoun vino (fuo + c + "hi") Masc ;
ol + "io" => mkNoun vino (ol + "i") Masc ;
vin + "o" => mkNoun vino (vin + "i") Masc ;
cas + "a" => mkNoun vino (cas + "e") Fem ;
pan + "e" => mkNoun vino (pan + "i") Masc ;
_ => mkNoun vino vino Masc
} ;
mkAdj : (_,_,_,_ : Str) -> Bool -> Adj = \buono,buona,buoni,buone,p -> {
s = table {
Masc => table {Sg => buono ; Pl => buoni} ;
Fem => table {Sg => buona ; Pl => buone}
} ;
isPre = p
} ;
regAdj : Str -> Adj = \nero -> case nero of {
ner + "o" => mkAdj nero (ner + "a") (ner + "i") (ner + "e") False ;
verd + "e" => mkAdj nero nero (verd + "i") (verd + "i") False ;
_ => mkAdj nero nero nero nero False
} ;
mkVerb : (_,_,_,_,_,_,_,_ : Str) -> Aux -> Verb =
\amare,amo,ami,ama,amiamo,amate,amano,amato,aux -> {
s = table {
VInf => amare ;
VPres Sg Per1 => amo ;
VPres Sg Per2 => ami ;
VPres Sg Per3 => ama ;
VPres Pl Per1 => amiamo ;
VPres Pl Per2 => amate ;
VPres Pl Per3 => amano ;
VPart g n => (regAdj amato).s ! g ! n
} ;
aux = aux
} ;
regVerb : Str -> Verb = \amare -> case amare of {
am + "are" => mkVerb amare (am+"o") (am+"i") (am+"a")
(am+"iamo") (am+"ate") (am+"ano") (am+"ato") Avere ;
tem + "ere" => mkVerb amare (tem+"o") (tem+"i") (tem+"e")
(tem+"iamo") (tem+"ete") (tem+"ono") (tem+"uto") Avere ;
fin + "ire" => mkVerb amare (fin+"isco") (fin+"isci") (fin+"isce")
(fin+"iamo") (fin+"ite") (fin+"iscono") (fin+"ito") Avere
} ;
-- for structural words
adjDet : Adj -> Number -> {s : Gender => Case => Str ; n : Number} =
\adj,n -> {
s = \\g,c => prepCase c ++ adj.s ! g ! n ;
n = n
} ;
pronNP : (s,a,d : Str) -> Gender -> Number -> Person -> NP =
\s,a,d,g,n,p -> {
s = table {
Nom => {clit = [] ; obj = s ; isClit = False} ;
Acc => {clit = a ; obj = [] ; isClit = True} ;
Dat => {clit = d ; obj = [] ; isClit = True}
} ;
a = Ag g n p
} ;
-- phonological auxiliaries
vowel : pattern Str = #("a" | "e" | "i" | "o" | "u" | "h") ;
s_impuro : pattern Str = #("z" | "s" + ("b"|"c"|"d"|"f"|"m"|"p"|"q"|"t")) ;
elisForms : (_,_,_ : Str) -> Str = \lo,l',il ->
pre {#s_impuro => lo ; #vowel => l' ; _ => il} ;
}

View File

@@ -0,0 +1,39 @@
abstract Semantics = Grammar, Logic ** {
fun
iS : S -> Prop ;
iCl : Cl -> Prop ;
iNP : NP -> (Ind -> Prop) -> Prop ;
iVP : VP -> Ind -> Prop ;
iAP : AP -> Ind -> Prop ;
iCN : CN -> Ind -> Prop ;
iDet : Det -> (Ind -> Prop) -> (Ind -> Prop) -> Prop ;
iN : N -> Ind -> Prop ;
iA : A -> Ind -> Prop ;
iV : V -> Ind -> Prop ;
iV2 : V2 -> Ind -> Ind -> Prop ;
iAdA : AdA -> (Ind -> Prop) -> Ind -> Prop ;
iTense : Tense -> Prop -> Prop ;
iPol : Pol -> Prop -> Prop ;
iConj : Conj -> Prop -> Prop -> Prop ;
def
iS (UseCl t p cl) = iTense t (iPol p (iCl cl)) ;
iCl (PredVP np vp) = iNP np (iVP vp) ;
iVP (ComplV2 v2 np) i = iNP np (iV2 v2 i) ;
iNP (DetCN det cn) f = iDet det (iCN cn) f ;
iCN (ModCN ap cn) i = And (iAP ap i) (iCN cn i) ;
iVP (CompAP ap) i = iAP ap i ;
iAP (AdAP ada ap) i = iAdA ada (iAP ap) i ;
iS (ConjS conj x y) = iConj conj (iS x) (iS y) ;
iNP (ConjNP conj x y) f = iConj conj (iNP x f) (iNP y f) ;
iVP (UseV v) i = iV v i ;
iAP (UseA a) i = iA a i ;
iCN (UseN n) i = iN n i ;
iDet a_Det d f = Exist (\x -> And (d x) (f x)) ;
iDet every_Det d f = All (\x -> If (d x) (f x)) ;
iPol Pos t = t ;
iPol Neg t = Not t ;
iTense Pres t = t ;
iTense Perf t = Past t ;
iConj and_Conj a b = And a b ;
iConj or_Conj a b = Or a b ;
}

View File

@@ -0,0 +1,42 @@
concrete SemanticsIta of Semantics = GrammarIta, LogicSymb ** open ResIta, Formal, Prelude in {
lin
iN f = star (f.s ! Sg) ;
iA f = star (f.s ! Masc ! Sg) ;
iV f = star (f.s ! VInf) ;
iV2 f x y = star (f.s ! VInf) (cc2 x y) ;
oper star : Str -> SS -> TermPrec = \f,x -> prefix 3 (f ++ "*") (constant (parenth x.s)) ;
{-
lincat
T, I = TermPrec ;
lin
And = infixl 2 "&" ;
Or = infixl 2 "v" ;
If = infixr 1 "->" ;
-- Not = prefix 3 "~" ;
-- All : (I -> T) -> T ;
-- Exist : (I -> T) -> T ;
-- Past : T -> T ;
lin
iS : S -> T ;
iCl : Cl -> T ;
iNP : NP -> (I -> T) -> T ;
iVP : VP -> I -> T ;
iAP : AP -> I -> T ;
iCN : CN -> I -> T ;
iDet : Det -> (I -> T) -> (I -> T) -> T ;
iN : N -> I -> T ;
iA : A -> I -> T ;
iV : V -> I -> T ;
iV2 : V2 -> I -> I -> T ;
iAdA : AdA -> (I -> T) -> I -> T ;
iTense : Tense -> T -> T ;
iPol : Pol -> T -> T ;
iConj : Conj -> T -> T -> T ;
-}
}

View File

@@ -0,0 +1,47 @@
interface Syntax = Grammar -
[UseCl,PredVP,ComplV2,UseV,DetCN,ModCN,CompAP,AdAP,
ConjS,ConjNP,UseN,UseA,Pres,Perf,Pos,Neg] **
open Grammar in {
oper
mkS = overload {
mkS : Cl -> S = UseCl Pres Pos ;
mkS : Tense -> Cl -> S = \t -> UseCl t Pos ;
mkS : Pol -> Cl -> S = UseCl Pres ;
mkS : Tense -> Pol -> Cl -> S = UseCl ;
mkS : Conj -> S -> S -> S = ConjS ;
} ;
mkCl = overload {
mkCl : NP -> V -> Cl = \np,v -> PredVP np (UseV v) ;
mkCl : NP -> V2 -> NP -> Cl = \np,v,o -> PredVP np (ComplV2 v o) ;
mkCl : NP -> A -> Cl = \np,a -> PredVP np (CompAP (UseA a)) ;
mkCl : NP -> AP -> Cl = \np,ap -> PredVP np (CompAP ap) ;
mkCl : NP -> VP -> Cl = PredVP ;
} ;
mkAP = overload {
mkAP : A -> AP = UseA ;
mkAP : AdA -> AP -> AP = AdAP ;
} ;
mkNP = overload {
mkNP : Det -> N -> NP = \d,n -> DetCN d (UseN n) ;
mkNP : Det -> CN -> NP = \d,n -> DetCN d n ;
mkNP : Conj -> NP -> NP -> NP = ConjNP ;
} ;
mkCN = overload {
mkCN : N -> CN = UseN ;
mkCN : A -> N -> CN = \a,n -> ModCN (UseA a) (UseN n) ;
mkCN : A -> CN -> CN = \a,n -> ModCN (UseA a) n ;
mkCN : AP -> N -> CN = \a,n -> ModCN a (UseN n) ;
mkCN : AP -> CN -> CN = \a,n -> ModCN a n ;
} ;
presTense : Tense = Pres ;
perfTense : Tense = Perf ;
posPol : Pol = Pos ;
negPol : Pol = Neg ;
}

View File

@@ -0,0 +1,3 @@
instance SyntaxIta of Syntax = GrammarIta -
[PredVP,ComplV2,UseV,DetCN,ModCN,CompAP,AdAP,UseN,UseA] **
open GrammarIta in {} ;

View File

@@ -0,0 +1,9 @@
abstract Test = Grammar ** {
fun
man_N, woman_N, house_N, tree_N : N ;
big_A, small_A, green_A : A ;
walk_V, arrive_V : V ;
love_V2, please_V2 : V2 ;
} ;

View File

@@ -0,0 +1,17 @@
concrete TestIta of Test = GrammarIta ** open ParadigmsIta in {
lin
man_N = mkN "uomo" "uomini" masculine ;
woman_N = mkN "donna" ;
house_N = mkN "casa" ;
tree_N = mkN "albero" ;
big_A = preA (mkA "grande") ;
small_A = preA (mkA "piccolo") ;
green_A = mkA "verde" ;
walk_V = mkV "camminare" ;
arrive_V = essereV (mkV "arrivare") ;
love_V2 = mkV2 "amare" ;
please_V2 = mkV2 (essereV (mkV "piacere" "piaccio" "piaci" "piace"
"piacciamo" "piacete" "piacciono" "piaciuto")) dative ;
} ;

View File

@@ -0,0 +1 @@
abstract TestSemantics = Test, Semantics ;

View File

@@ -0,0 +1 @@
concrete TestSemanticsIta of TestSemantics = TestIta, SemanticsIta ;