LLMs and logic: Does ChatGPT understand logic?

This is the question I asked BingChat/Copilot. The chat we had was informative.

Parick Reany

30 January 2024

Patrick:
Does ChatGPT understand logic? If not, why not?

BingChat/Copilot:
ChatGPT is a natural language processing tool that uses artificial intelligence and machine
learning technology to generate responses to user text inputs [1]. It is essentially a super-sized
computer program that can understand and produce natural language [1]. ChatGPT works by
attempting to understand a text input (called a prompt) and generating dynamic text to respond.
It can do this because it's a large language model (LLM) [1].

While ChatGPT is not perfect, it has shown impressive results in understanding and imitating
logical reasoning [2,3]. However, it is not specifically designed to understand logic, and its
ability to reason logically is limited [4]. ChatGPT works on the balance of probabilities, to
determine which word token is the most likely to come next. It has no clue about logic [4].

In summary, ChatGPT can understand and imitate logical reasoning to some extent, but it is not
specifically designed to understand logic. Its ability to reason logically is limited, and it
works on the balance of probabilities to generate responses [1,4].

[1] https://www.semrush.com/blog/how-does-chatgpt-work/
[2] https://medium.com/@evlabs/chatgpt-imitates-logical-reasoning-surprisingly-well-f88b1ac8d6f7
[3] https://arxiv.org/abs/2304.03439
[4] https://ai.stackexchange.com/questions/40313/how-can-chatgpt-get-simple-two-statement-logic-wrong

Patrick:
Let's do some simple logic. Let '&' be logical AND and '^' be logical OR.
Let '->' be logical implication. Then, if I write ((P->Q)&P)->Q, what is the
truth value of this claim: True, False, or it depends?

BingChat/Copilot:
Sure, let's do some simple logic! The claim you wrote is a conditional statement
that can be expressed in English as "If P implies Q and P is true, then Q is true."
This is a well-known logical statement called modus ponens [1].

To determine the truth value of this claim, we can use a truth table. Here is
the truth table for the claim:

Table

   P        Q     P -> Q   (P -> Q) & P   ((P -> Q) & P) -> Q
True   True     True           True                    True
True   False    False           False                 True
False   True    True           False                  True
False   False   True           False                  True

As we can see from the truth table, the claim is always true regardless of the
truth values of P and Q. Therefore, the answer to your question is that the
truth value of the claim is True [1,2].

[1] https://calculator-online.net/truth-table-calculator/
[2] https://byjus.com/question-answer/if-p-p-q-is-false-then-the-truth-values-of-p-and-q-are-respectively/

Patrick:
When I queried if ChatGPT understands logic, I didn't mean at the level of Russell
and Whitehead's Principia Mathematica. I meant more like at the level of common reasoning
by modus ponens and contradiction. Do you suppose that ChatGPT could reply to my original
question in the affirmative, or should I be more specific in my query to it?

BingChat/Copilot:
I understand your question better now. ChatGPT is capable of understanding and
reasoning with common logical statements such as modus ponens and contradiction. However,
it is important to note that ChatGPT is not a human and does not have the same level of
understanding as humans do. It is a machine learning model that has been trained on a large
corpus of text data and can generate responses based on patterns it has learned from that data.

In general, ChatGPT can understand and reason with common logical statements, but it
may not always be able to provide the most accurate or complete answers to complex logical
questions. Therefore, it is always a good idea to be as specific as possible when asking
ChatGPT questions about logic or any other topic. I hope this helps!

Patrick:
I am constantly amazed at how well ChatGPT and BingChat/Copilot are able to reason in
complicated ways. And I wonder if anybody yet understands how LLMs are able to do this.
One thing I know: It has to involve more than calculating the probability of the right next
word. Can you comment?

BingChat/Copilot:
It's true that large language models (LLMs) like ChatGPT and BingChat/Copilot are capable
of reasoning in complicated ways, and it's a fascinating area of research. While the exact
mechanisms behind how LLMs reason are not yet fully understood, there are some theories.

One theory is that LLMs are able to reason by using attention mechanisms to identify
important connections in data, which helps them understand relationships [1]. Another theory
is that LLMs are able to reason by training on a mix of reasoning tasks, which helps refine
their skills in drawing conclusions and spotting patterns [1].

However, it's important to note that LLMs are not capable of principled reasoning, which
often involves computationally hard inference/search [2]. They are also not capable of
understanding concepts like causality or counterfactuals [2].

In general, LLMs are able to reason to some extent, but their reasoning abilities are limited
and they are not capable of reasoning in the same way that humans do [2,1]. I hope this helps!

[1] https://medium.com/@hamza_autoblocks/llms-as-reasoning-engines-1085efdea64b
[2] https://cacm.acm.org/blogs/blog-cacm/276268-can-llms-really-reason-and-plan/fulltext