In [5]:
import nltk
lp = nltk.sem.Expression.fromstring
Translate the following sentences into propositional logic and verify that they parse with LogicParser. Provide a key which shows how the propositional variables in your translation correspond to expressions of English.
In [7]:
p = 'Angus sings'
q = 'Bertie sulks'
lp('p->-q')
Out[7]:
In [8]:
p = 'Cyril runs'
q = 'Cyril barks'
lp('p & q')
Out[8]:
In [9]:
p = 'rain'
q = 'snow'
lp('-p -> q')
Out[9]:
In [10]:
p = 'Olive comes'
q = 'Tofu comes'
r = 'Irene will be happy'
lp('(p|q)-> -r')
Out[10]:
In [11]:
p = 'Pat cough'
q = 'Pat sneeze'
lp('-p|-q')
Out[11]:
In [12]:
p = 'I call'
q = 'you come'
r = 'You call'
s = 'I come'
lp('(p->-q)-> (r->-s)')
Out[12]:
Translate the following sentences into predicate-argument formula of first order logic.
In [13]:
lp('like(Angus,Cyril) & hate(Irene,Cyril)')
Out[13]:
In [14]:
lp('taller(Tofu,Bertie)')
Out[14]:
In [15]:
lp('loveshimself(Bruse) & loveshimself(Pat)')
Out[15]:
In [16]:
lp('saw(cyril,Bertie) & -saw(cyril,Angus)')
Out[16]:
In [17]:
lp('fourleggedfriend(Cyril)')
Out[17]:
In [18]:
lp('neareachother(Tofu,Olive)')
Out[18]:
Translate the following sentences into quantified formulas of first order logic.
In [19]:
lp('(exists x. likes(Angus,x) & exists y. likes(y,Julia))')
Out[19]:
In [20]:
lp('-exists x. smiles(x,Pat)')
Out[20]:
In [21]:
lp('-exists x. (cough(x) | sneeze(x))')
Out[21]:
In [25]:
lp('exists x. (asleep(x) & all y. (asleep(y) -> (y = x)))')
Out[25]:
Translate the following verb phrases using λ abstracts. quantified formulas of first order logic.
In [26]:
lp('\\x. all y. love(y,x)')
Out[26]:
In [27]:
lp('\\x. all y. (love(y,x) | detested(y,x))')
Out[27]:
In [28]:
lp('\\x. (all y. love(y,x) & -exists z. detested(z,x))')
Out[28]: