I am trying to define a Lambda-Calculus representation of the word 'are', which is an equality predicate for this ccg:
ccg = '''
# CCG grammar
# complete the lexical entries with their categories and semantics
:- S, NP, N
logicians => NP { \\x. LOGICIANS(x) }
logicians => N { \\x. LOGICIANS(x) }
linguists => NP { \\x. LINGUISTS(x) }
linguists => N { \\x. LINGUISTS(x) }
engineers => NP { \\x. ENGINEERS(x) }
engineers => N { \\x. ENGINEERS(x) }
non => NP/N { \\N x. ~N(x) }
are => (S\\NP)/NP {\\x y.are(x,y)}
all => NP/N { \\P Q. all x. (P(x) -> Q(x)) }
no => NP/N { \\P Q. all x. (P(x) -> ~Q(x)) }
some => NP/N { \\N V. exists x. (N(x) & V(x)) }
'''
With this ccg, I want to parse sentences like 'all logicians are linguists'. However, I find it hard to find the correct representation of the word 'are'. For example, I tried to define 'are' as:
are => (S\\NP)/NP {\\X x.X(\y.are(x,y))}
Unfortunately, this resulted in a faulty semantic interpretation:
S {are(\x.LINGUISTS(x),\Q.all x.(LOGICIANS(x) -> Q(x)))}
Next, I tried to define it as:
are => (S\\NP)/NP { \\X Y. all y. (X(y) <-> Y(y)) }
But then I ended up with the following error because y gets interpreted as a variable
LogicalExpressionException Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/nltk/sem/logic.py in parse(self, data, signature)
153 try:
--> 154 result = self.process_next_expression(None)
155 if self.inRange(0):
24 frames
LogicalExpressionException: 'y' is an illegal predicate name. Individual variables may not be used as predicates.
The above exception was the direct cause of the following exception:
LogicalExpressionException Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/nltk/sem/logic.py in parse(self, data, signature)
157 except LogicalExpressionException as e:
158 msg = "{}\n{}\n{}^".format(e, data, " " * mapping[e.index - 1])
--> 159 raise LogicalExpressionException(None, msg) from e
160
161 if self.type_check:
LogicalExpressionException: 'y' is an illegal predicate name. Individual variables may not be used as predicates.
all y.(LINGUISTS(y) <-> all x.(LOGICIANS(x) -> y(x)))
I can't change the grammar itself (the S,NP,N rules) so I feel like I'm stuck. Is there any way to define the equality relation in Lambda-Calculus for ccg's?