1
votes

Is it possible to make a transitive function like the following in DCG? Or to combine it with a DCG rule?

genx(A,B) :- gen(A,B).
genx(A,C) :- gen(A,B), genx(B,C).
gen(a,b).
gen(b,c).

I will explain what i'm trying to do exactly :

If i have this grammar:

noun_phrase(D,N) --> det(D), noun(N).
noun(n(cat)) --> [cat].

I want to make some restriction like if i want N in noun(N) to be an animal. So i can use something like this:

noun_phrase(np(D,N)) --> det(D), noun(N), genx(N, animal).

Where the information of a cat is an animal is inferenced from some facts like:

gen(cat,pet).
gen(pet,animal).

Thanks

1

1 Answers

0
votes

Not sure to undestand.

If I'm not wrong, from the formal point of view the rules

genx(A,B) :- gen(A,B).
genx(A,C) :- gen(A,B), genx(B,C).

can be written in DCG syntax as

genx --> gen.
genx --> gen, genx.

and, with facts,

gen(a, b).
gen(b, c).

genx(a, c) should return true.

However, the A, B, C in DCG are intended to be list.

I don't know if is reasonable to use DCG (that is intended for parsing) in this way to implement algebrical rules.