Commit 4611f353 authored by POGODALLA Sylvain's avatar POGODALLA Sylvain

Example files provided

parent de74d6bc
......@@ -38,5 +38,6 @@ then on the prompt type
Example files are given in the ./examples directory
Example files are given in the ./examples directory. Read the
./examples/README file
We suppose that the executables are acgc and acg (they could have been
acgc.opt or acg.opt)
This directory provide the following files:
+ strings.acg : a file containing a very simple signature (with
definitions). You can use it as follows:
acgc strings.acg
It will say that it correctly parse the file. You can also run:
acgc -i strings.acg
then, on the prompt, enter the following term:
every + dog ! chases + a + cat : string
it does not complain, or the term:
lambda x. every + x : string -> string
But with the term:
lambda x.every x : string -> string
you will have a typing error
+ tag.acg : a file containing various signatures and lexicons to model
TAG in ACG. You can run acgc on it
+ tag-script : this file provide (commented) commands that you can run
in acg. You can also run it with the following command:
acg tag-script
(press return after each command)
signature strings =
s:type ;
string = s->s : type;
infix + = lambda g f x.g(f x) : string -> string -> string;
(* string: type;
infix + : string -> string -> string; *)
E = lambda x.x:string;
infix ! : string -> string -> string;
prefix " : string -> string;
every,dog,chases,a,cat,sleeps,slowly,new,big,black,seems,John,Mary,Bill,Paul,Kim,Dana,Chris,
Sandy,everyone,someone,everybody,somebody,
claims,loves,to,love,who,said,liked,does,think,thinks,thought,likes,wondered,whether,what,barked:string;
end
# First print the help messasge that describes the commands
help;
# Require a user interaction (press return) to continue
# between commands
wait;
# First load an acg
load d tag.acg;
# List the available data
list;
# Then composte two of the present lexicon to
# build a third one
compose tag_strings tag_syntax as tag_yields;
# Now look at the available data
list;
# Ok. We are ready to try to analyse some terms
# We require to analyse in teh context of 3 lexicons (tag_syntax
# tag_yields and tag_semantics) a term
# build on the *SHARED* abstract vocabulary of the 3 lexicons
tag_syntax tag_yields tag_semantics analyse C_sleeps I_s I_vp (C_dog C_a (C_black (C_big (C_new I_n)))) : S;
# Ok, now we're ready to do the same for another term
tag_syntax tag_yields tag_semantics analyse C_chases I_s I_vp (C_dog C_every I_n) (C_cat C_a I_n) : S;
# And now let's see if we can get long distance dependancies
tag_syntax tag_yields tag_semantics analyse C_loves (C_claims I_s I_vp C_paul) I_vp C_john C_mary : S;
tag_syntax tag_yields tag_semantics analyse C_to_love (C_claims I_s I_vp C_paul) (C_seems I_vp) C_john C_mary : S;
tag_syntax tag_yields tag_semantics analyse C_liked ( C_said (C_does_think I_s I_vp C_paul) I_vp C_john) I_vp C_who C_bill : S;
(* We first provide a signature for the derivation trees *)
signature derivation_trees =
(* types with as Xa with an "a" index indicate they are meant
for adjunction. See https://hal.inria.fr/inria-00141913 for further
explanation of the TAG into ACG encoding *)
Sa,Na, Na_d, N, VPa, S,WH : type;
C_dog,C_cat:Na_d -> Na-> N;
C_sleeps:Sa -> VPa -> N -> S;
C_chases, C_loves, C_to_love:Sa -> VPa -> N -> N -> S;
C_every,C_a:Na_d;
C_slowly,C_seems : VPa -> VPa ;
C_new,C_big,C_black : Na -> Na;
C_claims,C_said : Sa -> VPa -> N -> Sa ;
C_john,C_paul,C_mary,C_bill : N ;
C_who : WH;
C_liked : Sa -> VPa -> WH -> N -> S ;
C_does_think : Sa -> VPa -> N -> Sa ;
(* Dummy element to specify the end of adjunctions *)
I_vp : VPa;
I_n : Na;
I_s : Sa;
end
(* Now we specify the signature for derived trees *)
signature derived_trees =
(* It uses ony one type : tye type of tree *)
tree:type;
(* Here are the non terminal symbol we find in the trees, with
an index indicating their arity *)
WH1,N1,VP1 : tree -> tree;
N2,S2,VP2:tree -> tree -> tree;
(* Here are the terminal symbols *)
every,dog,chases,a,cat,sleeps,slowly,new,big,black,seems,john,mary,bill,paul,
claims,loves,to_love,who,said,liked,does,think:tree;
(* We define feww constants that will make the lexicon definitions easier. *)
n = lambda n . lambda d a.d (a(N1 n)) : tree -> (tree -> tree) -> (tree -> tree) -> tree;
iv = lambda v . lambda s a np0 .s (S2 np0 (a (VP1 v))) : tree -> (tree -> tree) -> (tree -> tree) -> tree -> tree ;
tv = lambda v . lambda s a np0 np1 .s (S2 np0 (a (VP2 v np1))) : tree -> (tree -> tree) -> (tree -> tree) -> tree -> tree -> tree ;
ph_arg_v = lambda v . lambda s_root a np0 s_foot .s_root (S2 np0 (a (VP2 v s_foot))) : tree -> (tree -> tree) -> (tree -> tree) -> tree -> tree -> tree ;
det = lambda d . lambda n . N2 d n : tree -> (tree -> tree) ;
adv = lambda adv . lambda a v . a (VP2 v adv) : tree -> (tree -> tree) -> (tree -> tree) ;
l_adj = lambda adj. lambda a n . a (N2 adj n) : tree -> (tree -> tree) -> (tree -> tree) ;
r_adj = lambda adj. lambda a n . a (N2 n adj) : tree -> (tree -> tree) -> (tree -> tree) ;
ctrl_v = lambda v. lambda v_root v_foot .v_root (VP2 v v_foot) : tree -> (tree -> tree) -> (tree -> tree) ;
np = lambda proper_name . N1 proper_name : tree -> tree;
inf_tv = lambda v . lambda s a np0 np1 .S2 np1 (s (S2 np0 (a (VP1 v)))) : tree -> (tree -> tree) -> (tree -> tree) -> tree -> tree -> tree ;
wh_extract_tv = lambda v . lambda s adv wh subj . S2 wh (s (S2 subj (adv (VP1 v)))) : tree -> (tree -> tree) -> (tree -> tree) -> tree -> tree -> tree;
end
(* Then a signature for the strings *)
signature strings =
string: type;
infix + : string -> string -> string;
every,dog,chases,a,cat,sleeps,slowly,new,big,black,seems,john,mary,bill,paul,
claims,loves,to,love,who,said,liked,does,think:string;
end
(* Ok. Now is our first lexicon. It translates derived trees into strings *)
lexicon tag_strings(derived_trees) : strings =
(* So every tree result in a string *)
tree := string;
every := every;
dog := dog;
chases := chases;
a := a;
cat := cat;
sleeps := sleeps;
slowly := slowly;
new := new;
big := big;
black := black;
seems := seems;
john := john;
mary := mary;
bill := bill;
paul := paul;
claims := claims;
loves := loves;
to_love := to + love;
who := who;
said := said;
liked := liked;
does := does;
think:=think;
WH1,N1,VP1 := lambda f.f;
N2,S2,VP2:=lambda f g . f + g;
end
(* We also provide a signature for the semantics *)
signature semantics =
(* We define the usual types *)
e,t:type;
(* Then few non logical-constants *)
dog,cat,sleep : e->t;
love,chase,like:e -> e -> t;
j,m,b,p:e;
slowly : t -> t;
seem : (e -> t) -> e -> t;
new,big,black:e ->t;
claim,say,think : e -> t -> t;
WHO : (e -> t) -> t;
(* And finally, here are the logical constants *)
infix & : t -> t -> t;
infix > : t -> t -> t;
binder All : (e=>t) -> t;
binder Ex : (e=>t) -> t;
end
(* We now define the semantics associated to each derivation tree *)
lexicon tag_semantics(derivation_trees) : semantics =
S := t;
N := (e -> t) -> t;
Sa := t -> t;
Na := (e =>t) -> (e =>t);
VPa := (e -> t) -> (e -> t);
Na_d := (e => t) -> (e -> t) -> t;
WH := (e ->t) -> t;
C_every := lambda n.lambda P.All x. (n x) > (P x) ;
C_a := lambda n.lambda P.Ex x. (n x) & (P x);
C_dog := lambda d a . d (a (Lambda x.dog x)) ;
C_cat := lambda d a . d (a (Lambda x.cat x)) ;
C_sleeps := lambda s a S.s(S(a(lambda x.(sleep x))));
C_chases := lambda s a S O.s(S(a(lambda x.O(lambda y.(chase x y)))));
C_loves := lambda s a S O.s(S(a(lambda x.O(lambda y.(love x y)))));
C_to_love := lambda s a O S.s(S(a(lambda x.O(lambda y.(love x y)))));
C_slowly := lambda vp r. vp (lambda x. slowly (r x));
C_seems := lambda vp r. vp (lambda x. seem r x);
C_new := lambda a n . a (Lambda x.(new x)&(n x));
C_big := lambda a n . a (Lambda x.(big x)&(n x));
C_black := lambda a n . a (Lambda x.(black x)&(n x));
C_claims := lambda sa a S comp. sa (S(a(lambda x.claim x comp)));
C_said := lambda sa a S comp. sa (S(a(lambda x.say x comp)));
C_john := lambda P.P j;
C_mary := lambda P.P m;
C_paul := lambda P.P p;
C_bill := lambda P.P b;
C_who := lambda P.WHO P;
C_liked := lambda sa a w S.w(lambda y.sa(S(a(lambda x.(like x y)))));
C_does_think := lambda sa a S comp. sa(S(a(lambda x.(think x comp))));
I_vp := lambda x.x;
I_n := lambda x.x;
I_s := lambda x.x;
end
(* And a lexicon from derivation trees to derived trees *)
lexicon tag_syntax (derivation_trees) : derived_trees =
N, S, WH := tree;
Sa,Na,VPa,Na_d := tree -> tree ;
C_john := np john;
C_mary := np mary;
C_bill := np bill;
C_paul := np paul;
C_dog := n dog;
C_cat := n cat;
C_chases := tv chases;
C_loves := tv loves ;
C_to_love := inf_tv to_love ;
C_sleeps := iv sleeps;
C_seems := ctrl_v seems;
C_claims := ph_arg_v claims;
C_every := det every;
C_a := det a;
C_slowly := adv slowly;
C_new := l_adj new;
C_big := l_adj big;
C_black := l_adj black;
C_who := WH1 who ;
C_liked := wh_extract_tv liked;
C_said := ph_arg_v said;
C_does_think := lambda s_root a subj s_foot . s_root (S2 does (S2 subj (a (VP2 think s_foot))));
I_n,I_vp,I_s := lambda x.x;
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment