# Automatically Converting Natural Language to First-Order Logic

I'm trying to find a way to automatically convert arbitrary natural language sentences into first-order logic predicates. Although complex, this seems to be feasible to me, through inverse lambda calculus; one of the biggest downsides of this technique is that it heavily relies on a combinatory categorial grammar (CCG), which must be trained to yield the appropriate results.

Are there other known approaches to such conversion at all, or it is a bad idea?

... it heavily relies on a combinatory categorial grammar (CCG), which must be trained...

There are two broad-coverage CCG parsers for English, which you could use:

1. Curran & Clark Parser by itself only generates CCG derivations with categories, not with semantics. Boxer works on the parses to generate semantics.

2. OpenCCG when used with the broad-coverage grammar, MOLOKO can show semantics. But I haven't used this one yet, and can't read their output.

Are there other approaches...

CCG is not the only logic-based grammar. There are others that closer to mathematics, in that, their derivation trees for sentences that look exactly like natural deduction proofs. I think the ACG guys have a working parser. I am not sure about the others like TLG, CVG, etc.

• Unfortunately, the link to the Boxer parser is broken now. Commented Nov 27, 2018 at 9:13
• @AndersonGreen Thanks for notifying me. I have updated the links.
– prash
Commented Nov 29, 2018 at 14:53
• @prash. It looks like C&C and Boxer are missing final piece from DRS to FOL. Commented Mar 25, 2019 at 21:33

It is also possible to convert natural language into first-order logic using a discourse representation theory. For example, the ACE reasoner is an automated theorem prover that can convert English text into first-order logical predicates.

• But if I understand correctly, we need to convert English to ACE language first and only then we can get first order logic representation. Commented Mar 21, 2019 at 15:12

Fine-tuned Large Language Models (LLMs) perform well at translating natural language to first order logic.

GPT-4 likely has the best performance. For a cheaper open-source approach, consider LogicLLaMa, a version of LLaMa fine-tuned for exactly this task.

Their model is open-source and you can run it on your own sentences using their code: https://github.com/gblackout/LogicLLaMA