Exercises
○ Translate the following sentences into propositional logic and verify that they parse with
LogicParser
. Provide a key that shows how the propositional variables in your translation correspond to expressions of English.If Angus sings, it is not the case that Bertie sulks.
Cyril runs and barks.
It will snow if it doesn’t rain.
It’s not the case that Irene will be happy if Olive or Tofu comes.
Pat didn’t cough or sneeze.
If you don’t come if I call, I won’t come if you call.
○ Translate the following sentences into predicate-argument formulas of first-order logic.
Angus likes Cyril and Irene hates Cyril.
Tofu is taller than Bertie.
Bruce loves himself and Pat does too.
Cyril saw Bertie, but Angus didn’t.
Cyril is a four-legged friend.
Tofu and Olive are near each other.
○ Translate the following sentences into quantified formulas of first-order logic.
Angus likes someone and someone likes Julia.
Angus loves a dog who loves him.
Nobody smiles at Pat.
Somebody coughs and sneezes.
Nobody coughed or sneezed.
Bruce loves somebody other than Bruce.
Nobody other than Matthew loves Pat.
Cyril likes everyone except for Irene.
Exactly one person is asleep.
○ Translate the following verb phrases using λ-abstracts and quantified formulas of first-order logic.
feed Cyril and give a capuccino to Angus
be given ‘War and Peace’ by Pat
be loved by everyone
be loved or detested by everyone
be loved by everyone and detested by no-one
○ Consider the following statements:
>>> lp = nltk.LogicParser() >>> e2 = lp.parse('pat') ...
Get Natural Language Processing with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.