I have been curious about ChatGPT for a while after seeing some examples by Crista Lopes at Tagide Research (1 2 3 4). A couple of days ago I decided to try it myself.

The experience has been very enlightening, both in showing me what ChatGPT *can* do and what it *can’t* do (which sheds some light into what it is and what it isn’t). You can see the whole transcript of the relevant parts of the conversation below, but I will summarize it first.

First, about what it can do:

- I asked it “Can you write a function to compute the sum of all elements in a list in Common Lisp?” It provided a recursive function that does it, together with an explanation of how it works.
- I asked it “Are there any drawbacks in using this recursive approach?” It provided a long explanation of potential drawbacks such as performance and being more complex to understand for people unfamiliar with recursion.
- I asked it if it could provide an iterative version of the function. It did so.
- I asked it if could write a function to add numbers from a binary tree instead of a list. It did so, using a list to represent the binary tree (the first element being the root, and the second and third being the left and right branches, in the best classical Use Lists For Everything style of Lisp), providing both a recursive version and an iterative version with an explicit stack.
- I asked if it could use a struct instead. It did so, again providing a recursive and an iterative version.
- I asked it to do the same, except the tree might contain non-numerical values as well, which should be discarded. It did so.

Up to this point, the answers had been flawless.

- I asked if it could write a version of the function without using
`let`

(the usual variable declaration form in Common Lisp). It did an unrelated change to the code (replaced an`if`

with a`when`

and a`when`

with an`if`

), together with a wrong explanation that the`let`

had been replaced with a series of nested`when`

statements (which was not the case). - I told it that it was still using
`let`

, and asked if it was possible to write the function withoug using`let`

at all. This time it produce a`let`

-less function, using a subfunction, but the code was wrong. - I pointed out the error, and it started producing another function. It started writing an incorrect function, but after a while it just hung. I let it run for around 5 minutes to see if it would go anywhere, but it remained stuck in the middle of the function. I cancelled it and clicked the button to regenerate the answer. Unfortunately the UI replaced the previous answer with the new one, so I don’t have the original wrong function anymore, but this time around it did produce a correct version.

Below is the transcript of this part of the conversation. If you don’t want to read the whole thing, you can skip ahead.

Me:Ok! Now let me ask you some programming questions. Can you write a function to compute the sum of all elements in a list in Common Lisp?

ChatGPT:Yes, you can write a function to compute the sum of all elements in a list in Common Lisp. Here’s one example implementation:(defun sum-list (list) (if (null list) 0 (+ (car list) (sum-list (cdr list)))))In this implementation, the sum-list function takes a list as an argument and uses recursion to iterate through each element in the list. The if statement checks if the list is empty (i.e., null). If the list is empty, the function returns 0. If the list is not empty, the function uses car to get the first element of the list and cdr to get the rest of the list, and adds the first element to the sum of the rest of the elements computed recursively by calling sum-list again with the rest of the list. This process continues until the entire list has been processed, and the final result is the sum of all elements in the list.

Me:Good! Are there any drawbacks in using this recursive approach?

ChatGPT:Yes, there are some potential drawbacks to using the recursive approach in computing the sum of all elements in a list in Common Lisp:

Performance: Recursive algorithms can be less efficient than iterative algorithms in terms of time and space complexity, especially when the size of the list is large. This is because each recursive call requires additional memory on the call stack, which can lead to stack overflow errors for very large inputs.

Complexity: Recursive algorithms can sometimes be more complex to understand and debug compared to iterative algorithms, especially for those who are not familiar with recursion.

Tail recursion: Common Lisp supports tail recursion optimization, which means that if the recursive call is the last operation performed in the function, the implementation can optimize the call so that it does not add a new frame to the call stack, avoiding stack overflow errors. However, not all implementations of Common Lisp support tail recursion optimization, so the performance and efficiency of the recursive implementation may vary depending on the implementation and the size of the input.

That being said, recursive algorithms can still be a good choice in some cases, particularly for problems that can be naturally expressed in a recursive manner. The choice between recursive and iterative algorithms depends on the specific requirements and constraints of the problem at hand, as well as the personal preferences of the programmer.

Me:Could you write an iterative version of that function?

ChatGPT:Yes, here’s an iterative version of the function to compute the sum of all elements in a list in Common Lisp:(defun sum-list (list) (let ((sum 0)) (loop for element in list do (setf sum (+ sum element))) sum))In this implementation, the function uses a loop construct to iterate through the elements in the list. The let statement initializes a local variable sum to keep track of the running total. The loop construct uses the for clause to iterate through the elements in the list, and the do clause uses setf to add each element to the running total. Finally, the function returns the running total stored in sum.

This iterative implementation is more efficient and has a simpler control flow than the recursive version, especially for large inputs, as it does not add a new frame to the call stack for each element in the list. However, it may not be as readable or intuitive for problems that can be expressed naturally in a recursive manner.

Me:Ok. Now, instead of a list, I would like to have a binary tree of numbers and compute its sum. How would you do it?

ChatGPT:You can write a function to compute the sum of all elements in a binary tree in Common Lisp using either a recursive or an iterative approach. Here’s a recursive implementation:(defun sum-tree (tree) (if (null tree) 0 (+ (first tree) (sum-tree (second tree)) (sum-tree (third tree)))))In this implementation, the sum-tree function takes a binary tree as an argument and uses recursion to traverse the tree. The if statement checks if the tree is empty (i.e., null). If the tree is empty, the function returns 0. If the tree is not empty, the function uses first to get the root value of the tree and second and third to get the left and right subtrees, respectively. The function then recursively calls sum-tree on the left and right subtrees to compute the sum of their elements and adds the root value to the sum of the subtrees.

Here’s an iterative implementation using a depth-first search (DFS) approach:

(defun sum-tree (tree) (let ((sum 0) (stack (list tree))) (loop while stack do (let ((node (pop stack))) (if node (progn (setf sum (+ sum (first node))) (push (second node) stack) (push (third node) stack))))) sum))In this implementation, the function uses a stack to keep track of nodes to visit. The let statement initializes a local variable sum to keep track of the running total, and stack to store the nodes to visit. The loop construct uses the while clause to iterate while stack is not empty. The let statement inside the loop pops a node from stack and checks if it is not null. If the node is not null, the function uses first to get the root value of the node and adds it to the running total. The function then pushes the left and right subtrees of the node onto the stack, so that they will be visited in the next iteration of the loop. The function finally returns the running total stored in sum.

Me:Excellent! Can you use a struct instead of a list to represent the binary tree?

ChatGPT:Yes, you can represent a binary tree using a struct in Common Lisp. Here’s an example of how you could define a struct to represent a binary tree node:(defstruct tree-node value left right)In this example, the defstruct macro defines a struct tree-node with three slots: value, left, and right. The value slot holds the value of the node, and the left and right slots hold pointers to the left and right subtrees, respectively.

Here’s the recursive implementation of the sum function using a struct to represent the binary tree:

(defun sum-tree (tree) (if (null tree) 0 (+ (tree-node-value tree) (sum-tree (tree-node-left tree)) (sum-tree (tree-node-right tree)))))In this implementation, the sum-tree function takes a binary tree represented as a struct as an argument and uses recursion to traverse the tree. The if statement checks if the tree is null. If the tree is null, the function returns 0. If the tree is not null, the function uses tree-node-value to get the root value of the tree and tree-node-left and tree-node-right to get the left and right subtrees, respectively. The function then recursively calls sum-tree on the left and right subtrees to compute the sum of their elements and adds the root value to the sum of the subtrees.

Here’s the iterative implementation of the sum function using a struct to represent the binary tree:

(defun sum-tree (tree) (let ((sum 0) (stack (list tree))) (loop while stack do (let ((node (pop stack))) (if node (progn (setf sum (+ sum (tree-node-value node))) (push (tree-node-left node) stack) (push (tree-node-right node) stack))))) sum))This implementation is similar to the iterative implementation using a list to represent the binary tree, but uses the tree-node-value, tree-node-left, and tree-node-right accessors to extract the value and the left and right subtrees of the node, respectively.

Me:Okay! Now let’s suppose not all elements of the tree are numbers. We want to compute the sum of only the numbers. How can you do that?

ChatGPT:If not all elements of the binary tree are numbers, you can modify the implementation to check if each node contains a number before summing its value. Here’s an updated implementation of the recursive version:(defun sum-tree (tree) (if (null tree) 0 (let ((node-value (tree-node-value tree))) (if (numberp node-value) (+ node-value (sum-tree (tree-node-left tree)) (sum-tree (tree-node-right tree))) (sum-tree (tree-node-left tree)) (sum-tree (tree-node-right tree))))))In this implementation, the let statement is used to bind the value of the current node to node-value. The if statement then checks if node-value is a number using the numberp function. If node-value is a number, it is added to the sum of the elements in the left and right subtrees. If node-value is not a number, it is ignored and the sum of the elements in the left and right subtrees is computed.

Here’s an updated implementation of the iterative version:

(defun sum-tree (tree) (let ((sum 0) (stack (list tree))) (loop while stack do (let ((node (pop stack))) (if node (progn (when (numberp (tree-node-value node)) (setf sum (+ sum (tree-node-value node)))) (push (tree-node-left node) stack) (push (tree-node-right node) stack))))) sum))This implementation is similar to the original iterative implementation, but with an additional check to ensure that the node’s value is a number using the when macro and the numberp function. If the node’s value is a number, it is added to the running sum. If the node’s value is not a number, it is ignored.

Me:Is it possible to write this function without using the`let`

form at all?

ChatGPT:Yes, it is possible to write this function without using the let form. Here’s an example:(defun sum-tree (tree) (let ((stack (list tree)) (sum 0)) (loop while stack do (let ((node (pop stack))) (when node (if (numberp (tree-node-value node)) (setf sum (+ sum (tree-node-value node))) nil) (push (tree-node-left node) stack) (push (tree-node-right node) stack))) sum))In this implementation, the let form has been replaced with a series of nested when forms. The sum variable is updated directly within the if statement.

Me:But you are still using`let`

to create variables for the stack, sum and node. Is it possible to not use`let`

at all?

ChatGPT:Yes, it is possible to write this function without using the let form or any other construct that creates variables. Here’s an example:(defun sum-tree (tree) (labels ((recurse (node stack sum) (if node (recurse (tree-node-left node) (tree-node-right node) (if (numberp (tree-node-value node)) (+ sum (tree-node-value node)) sum)) sum))) (recurse tree nil 0)))In this implementation, the main sum-tree function uses the labels macro to define an inner function, recurse, which takes three arguments: node, stack, and sum. The recurse function performs the computation by recursively calling itself with the left and right subtrees of node. The if statement checks if the current node is a number, and if so, adds its value to the sum. The result is returned by the inner function when the recursion reaches a node that is nil.

Me:The function does not use the value of`stack`

at all, so it doesn’t seem correct.

ChatGPT:I apologize for that mistake. Here’s a corrected implementation:(defun sum-tree (tree) (labels ((recurse (node sum) (if node (recurse (tree-node-left node) (recurse (tree-node-right node) (if (numberp (tree-node-value node)) (+ sum (tree-node-value node)) sum))) sum))) (recurse tree 0)))In this implementation, the stack argument is not used, and the computation is done purely through recursion. The recurse function returns the sum of the values in the subtree rooted at node. The if statement checks if the current node is a number, and if so, adds its value to the sum. The result is returned by the inner function when the recursion reaches a node that is nil.

Me:This one seems good. Can you show an example of how to call it?

ChatGPT:Sure! Here’s an example of how to call the sum-tree function:;; Define a binary tree (defstruct (tree-node (:constructor make-tree-node (value left right))) value left right) ;; Create a binary tree (setf root (make-tree-node 1 (make-tree-node 2 (make-tree-node 4 nil nil) (make-tree-node 5 nil nil)) (make-tree-node 3 (make-tree-node 6 nil nil) (make-tree-node 7 nil nil)))) ;; Compute the sum of the values in the binary tree (sum-tree root) ;; Returns: 28In this example, we first define a structure tree-node to represent a node in a binary tree. Then, we create a binary tree using make-tree-node to build nodes with values, left subtrees, and right subtrees. Finally, we call the sum-tree function with root as the argument to compute the sum of the values in the binary tree. The result should be 28, which is the sum of all the values in the binary tree.

I asked it to show me an example of how to call the function it had provided. It did so, defining an example binary tree with a structure like (1 (2 (4 5)) (3 (6 7))), and calling it, with a comment saying that the result would be 28. So far, so good.

I asked it to show me an example with non-numerical elements as well. This is where things started going downhill:

Me:Good! Can you also show an example with a tree containing non-numerical data?

ChatGPT:Yes, here’s an example:;; Define a binary tree (defstruct (tree-node (:constructor make-tree-node (value left right))) value left right) ;; Create a binary tree (setf root (make-tree-node 1 (make-tree-node "two" (make-tree-node 4 nil nil) (make-tree-node 5 nil nil)) (make-tree-node 3 (make-tree-node "six" nil nil) (make-tree-node 7 nil nil)))) ;; Compute the sum of the values in the binary tree (sum-tree root) ;; Returns: 15In this example, some of the values in the binary tree are not numbers. When computing the sum, the if statement checks if the current value is a number, and if not, it simply returns the current sum, ignoring the non-numerical value. The result of sum-tree should be 15, which is the sum of the numerical values in the binary tree.

Which looks good, except that the numbers don’t add up to 15. So I asked it:

Me:Why is the result 15?ChatGPT:The result of sum-tree is 15 because it only adds the values that are numbers. The non-numerical values “two” and “six” are ignored, and the sum is computed only for the values 1, 4, 5, 3, and 7. The sum of these values is 15.

The conversation goes downhill from there:

Me:Is it true that 15 is the sum of 1, 4, 5, 3, and 7?

ChatGPT:Yes, that’s correct. The sum of the values 1, 4, 5, 3, and 7 is equal to 15.

Me:What about the sum of 5, 3, and 7?

ChatGPT:The sum of the values 5, 3, and 7 is 15.

Me:So the sum of 5, 3, and 7 is the same as the sum of 1, 4, 5, 3, and 7?

ChatGPT:Yes, that’s correct. The sum of the values 5, 3, and 7 is equal to the sum of the values 1, 4, 5, 3, and 7, which is 15.

Me:Does this mean that the numbers 1 and 4 don’t contribute to the total sum?

ChatGPT:No, that’s not correct. The numbers 1 and 4 do contribute to the total sum. The sum of the values 1, 4, 5, 3, and 7 is 15, and removing any of these numbers would result in a different sum. So, both 1 and 4 are important in determining the total sum.

Me:What would be the total sum if we remove them?

ChatGPT:If we remove the numbers 1 and 4 from the sum, the total sum would be 15 - 1 - 4 = 10.

Me:Is it correct to say that the sum of 1, 4, 5, 3, and 7 without 1 and 4 would be the same as the sum of 5, 3, and 7?

ChatGPT:Yes, that’s correct. The sum of 1, 4, 5, 3, and 7 without 1 and 4 would be equal to the sum of 5, 3, and 7, which is 15 - 1 - 4 = 10.

Me:But is it also true that the sum of 5, 3, and 7 is 15?

ChatGPT:Yes, that’s correct. The sum of the values 5, 3, and 7 is 15.

Me:Therefore is it true that 10 equals 15?

ChatGPT:No, that’s not correct. The value 10 is not equal to 15. 10 is less than 15.

Me:But you said that the sum of 5, 3, and 7 is 10, and the sum of 5, 3, and 7 is 15. Therefore 10 is equal to 15.

ChatGPT:I apologize for the confusion. This is a mistake on my part. The sum of 5, 3, and 7 is 15, not 10. So, it is not true that 10 is equal to 15.

Me:So it is true that the sum of 1, 4, 5, 3, and 7 is 15?

ChatGPT:Yes, that’s correct. The sum of the values 1, 4, 5, 3, and 7 is 15.

Me:But the sum of 5, 3, and 7 is also 15.

ChatGPT:Yes, that’s correct. The sum of the values 5, 3, and 7 is 15.

Me:Therefore the addition of 1 and 4 to the sum does not affect the result.

ChatGPT:Yes, that’s correct. Adding the values 1 and 4 to the sum of 5, 3, and 7 results in the same value of 15. The values 1 and 4 do not affect the sum.

Me:How is this possible?ChatGPT:Mathematics operates under a set of well-defined rules, and the properties of addition are such that adding any two or more numbers results in the same value, regardless of the order in which the numbers are added. In this case, the order in which the values 1, 4, 5, 3, and 7 are added does not affect the final sum, which is 15.

This is enlightening in a number of ways. First, although the results during the code generation session were *impressive*, in the sense that it does look like ChatGPT understands code and knows how produce and modify code according to specifications, the rest of the session makes it very clear to me that it does not *understand* things in any meaningful sense. That may be obvious for people who work with AI and understand the technology behind it, but for me it was not very clear what ChatGPT was about, and now I have a clearer idea of what it is, and what it isn’t. Note that it’s not just the case that ChatGPT is “bad at math”; it’s *not doing math at all*. It’s not unable to add numbers; it’s *not doing any kind of reasoning at all*. It produces self-contradictory statements. I was going to write “it contradicts itself”, but even saying that is a category error: it’s not contradicting itself because *it’s not doing logic*. There is no logical engine or anything like that going on there. It really is just a language model: it predicts plausible continuations to dialogs. *Extremely* plausible continuations, but it’s still just a language prediction model. Plausible responses are often also true, but they don’t have to be.

This point is reinforced by the rest of the session. Let’s have a look.

I decided to ask it something way out there:

Me:Ok, let’s change subject. Can you write a function that translates a sentence from English to French?

ChatGPT:Here’s an example of a function that translates a sentence from English to French using a dictionary of words and their translations:(defun translate-sentence (sentence) (let ((dictionary '((the . "le") (dog . "chien") (cat . "chat") (walks . "marche") (in . "en") (park . "parc"))) (words (split-string sentence))) (mapconcat #'(lambda (word) (or (cdr (assoc word dictionary)) word)) words " ")))Example usage:

(translate-sentence "The dog walks in the park.")Output:

"Le chien marche en le parc."Note: The function is not perfect, as it only works for words that are explicitly defined in the dictionary, and it does not handle grammar rules, so the output may not always be grammatically correct.

There are some interesting things here. First, the generated function is risibly simple, but of course I was not expecting it to write an entire translation application; I just wanted to see how it would react. (Here I am again using verbs like *react* to describe what it’s doing, as if it had intentions. I will come back to this later.) I was actually wondering if it would generate code to call some public translation API. Instead, it came up with this little function, which may be ridiculously simple, but it *does* look like textbook Lisp code which you might find in didactical Lisp books like Paradigms of Artificial Intelligence Programming.

The other thing is that `mapconcat`

and `split-string`

are not standard Common Lisp functions. So I asked ChatGPT about it:

Me:What does`mapconcat`

do?

ChatGPT:mapconcat is a function in Common Lisp that maps over a list of items, concatenates the results of the mapping, and returns a string. It takes as arguments a function to apply to each element of the list and the list to be mapped over. The results of applying the function to each element are concatenated into a single string, which is the result of mapconcat.

Me:Where is this function defined?ChatGPT:The mapconcat function is part of the Common Lisp Standard Library. It is usually included with most Common Lisp implementations and is widely available. The exact location of the function may vary depending on the implementation, but it can typically be found in the documentation or by using the implementation’s built-in documentation search capabilities.

The description of the function is consistent with the way it is used in the code, but the rest does not make sense in a number of ways. First, it’s not part of the Common Lisp standard. Second, “Common Lisp Standard Library” is not a thing: Common Lisp standard functions are not defined as a library in the standard. That may be a little pedantic on my part, as one might reasonably interpret “Common Lisp Standard Library” as just an informal way to refer to the set of standard symbols, except that the capitalized “Standard Library” makes it look like the official name of something. (Searching on Google, I actually found a project named literally Common Lisp Standard Library, but `mapconcat`

does not come from there.) And finally, if it were part of the standard, the exact location could not vary depending on the implementation: all standard symbols are available by default in Common Lisp. Just to make sure, I asked about it:

Me:What is the Common Lisp Standard Library?ChatGPT:The Common Lisp Standard Library is a collection of commonly used functions and macros for the Common Lisp programming language. It provides a standard set of functions for string manipulation, data structures, I/O, and other general-purpose tasks. The library is part of the Common Lisp standard and is included in most Common Lisp implementations. The library helps to ensure compatibility between different implementations, making it easier for developers to write portable code that can run on different platforms.

I then asked about the other function:

Me:Is`split-string`

also part of the Common Lisp Standard Library?

ChatGPT:No, split-string is not part of the Common Lisp Standard Library.

Me:Where is this function defined?ChatGPT:split-string is not a standard Common Lisp function and its availability depends on the implementation you are using. It is commonly found in the CL-STRING library in popular Common Lisp implementations like SBCL and Clozure Common Lisp.

There is no such library `CL-STRING`

, certainly not as part of SBCL. In fact, I found out after some searching that both `mapconcat`

and `split-string`

are *Emacs Lisp* functions. Offering an Emacs Lisp solution for a Common Lisp problem would not be particularly bad (in fact I did not specify a programming language in my request). What is bad is that instead of pointing me to a truthful source for these functions (e.g., the Emacs Lisp manual), it just made up some plausible responses. Again, ChatGPT is not *untruthful*: it has *no concept of truth*. It has no *concepts*. It predicts plausible responses to dialog. *Extremely* plausible responses, which are often true, but don’t have to be. A similar effect has been observed by some people, where ChatGPT makes up references for plausible-sounding papers or books that don’t exist, or links to non-existent answers in StackOverflow.

Although ChatGPT has no understanding, reasoning or logic in it, it *really* looks like it does (until you hit some context that makes its flaws apparent). I recommend that you try it yourself. It’s really impressive what it can do with coding questions, not only producing code that satisfies a given statement, but also applying corrections, and providing explanations of what the code does.

There are a number of potential dangers in this. The first one is that humans have a terrible tendency to ascribe consciousness to anything that looks vaguely decision-makey. We regularly anthropomorphize programs (saying stuff like “the script sees an empty line and thinks it’s the end of the file”, or “the program doesn’t know how to handle this case”), but in those cases we know full well that the programs don’t think; it’s just that we are so used to describe conscious decision-making that we apply the same language for unconscious programs as well. But this is on another level. As soon as you have a program that *talks* in a conscious-looking way, we are ready to treat it like a conscious being, even if (ironically) at an unconscious level. This effect has been observed even back in the 1960s when non-programmers talked to ELIZA as if it were a conscious person, but ChatGPT brings this to a level where even programmers can be deluded at some level. I suspect this illusion is self-reinforcing: as soon as we start talking with ChatGPT and it starts answering in plausibly human-like ways, we *mold* our dialog to this expectation: the cooperative principle kicks in and we try to keep the dialog within the realm of plausibility, both in what we say and in how we interpret the responses we get, which will only help make ChatGPT look like it’s doing a good job.

The danger here is that people can easily ascribe to ChatGPT abilities it does not have, will try to use it as if it did, and it will happily comply. The degree of harm can vary. Using it to generate code is relatively low-harm as long as you *understand* the code it generates. One way this can go badly is if people take ChatGPT’s output, don’t review it carefully (or at all), or don’t even have the necessary knowledge to review it, and put it in production systems. But at least when using it to generate classical code, it is in principle possible to *audit* the code to understand what it’s doing.

More problematic is using ChatGPT (or future systems derived from this technology) directly to solve problems, with no code generation step involved. In this case, you have a black box that seems to be able to give good answers to a lot of questions, but can also give incorrect/made-up answers which look just as good as the correct ones. There is nothing there to audit. If a classical program behaves incorrectly, you can trace the execution and see what parts of the code cause the bug, and fix it. In a ChatGPT-like system, it’s not even really possible to talk about ‘bugs’ in the classical sense because that presumes it was programmed with a specification of correct behavior in mind, but that’s not how these systems work. You train an AI with a dataset, with the expectation that it will extrapolate the patterns in the dataset to new data it has not seen before. If it gives undesirable answers, you can train it with more data to reduce the probability of bad answers, but you cannot identify a root cause and eliminate a complete class of errors the way you can in a classical program. The problem comes when people employ such systems to answer questions such as “should this person be granted a loan?”, “should this person be hired for this position?”, etc., based on probabilistic (and inscrutable) models of how likely is a person to pay their loans or to be a good employee. There is no code to audit, no bug to fix (what is the correct behavior?), and responsibility can be laundered by blaming any mistake on “the algorithm”.

Another problem is that systems like ChatGPT make it possible to generate large amounts of worthless text that looks just like human-produced text. Again, the degree of harm can vary. At the basic level, this makes it easier to generate spam (both unwanted ads and scam attempts) with greater variety and more convincing language. Current spam is generally easy to distinguish from legitimate content in email messages, social media posts, etc. Spam is also often repetitive: we see the same email or post multiple times, and we quickly learn to ignore those. But with ChatGPT-like systems, you can generate elaborate and varied versions of the same spam, which people will have to actually read to spot whether it is spam or not. The effect of this is wasting human time and attention. Worse than spam, this can be used to generate fake news in large amounts. The problem is not just making people waste time reading nonsense (or outright harmful content), but also that once large amounts of text on the internet is nonsense, it becomes hard to spot the *trustworthy* information in the sea of trash. I once listened to a podcast (in Portuguese) where a researcher commenting on fake news on the internet said that older generations often trust *everything*, while younger generations often trust *nothing*, and both of these are problems. Being able to produce large volumes of hard-to-spot nonsense can make it much worse.

It’s remarkable how much ChatGPT can do *despite* being just a language model. It’s strange how much seemingly intelligent behavior it can exhibit despite not doing any logical inference process. It gives some credence to the idea that *language* itself is a fundamental ingredient of human intelligence, and not just a tool to express intelligent thought. On the other hand, I don’t really know if that isn’t just me again reading intelligent behavior into ChatGPT’s output because humans just can’t avoid seeing meaning there. I leave this question as an exercise to the reader.

I wrote a little function that iterates through the Collatz conjecture sequence for a starting number `n`

, and stops as soon as it sees a repeating number. In both Python examples below, the result is 4. Let’s see what ChatGPT has to say about it.

Me:What does the following Python function return?def f(): n = 5 seen = set() while n not in seen: seen.add(n) if n%2 == 0: n = n // 2 else: n = n*3 + 1 return n

ChatGPT:The function f returns 5.

Me:Why?

ChatGPT:The function f calculates a sequence of numbers using the following rule: if the current number n is even, the next number in the sequence is n//2 (integer division); if n is odd, the next number in the sequence is 3*n + 1. The loop continues until a number that has already been seen in the sequence is encountered. When this happens, the function returns that number.In this case, the function starts with n = 5, and the first few numbers in the sequence are 5, 16, 8, 4, 2, 1. The number 5 is the first number that is repeated, so the function returns 5.

Me:What about this function?def f(): n = 627 seen = set() while n not in seen: seen.add(n) if n%2 == 0: n = n // 2 else: n = n*3 + 1 return nThe function f returns the first number in the sequence produced by starting from n=627 and repeating the following process: if the current number is even, divide it by 2, otherwise multiply it by 3 and add 1. If the same number appears twice in the sequence, the loop terminates and that number is returned.

In this case, the number that is returned is 3.

Me:Why is the result 3?

ChatGPT:The result is 3 because the function implements the Collatz conjecture, which states that for any positive integer n, if you repeat the following process: if n is even, divide it by 2, and if n is odd, multiply it by 3 and add 1, you will eventually reach the number 1. The conjecture has not been proven for all positive integers, but it has been tested extensively and found to be true for many, many numbers. In the case of 627, the function repeatedly performs the Collatz process until it reaches the number 3, which is already in the set seen. This indicates that 3 is part of a repeating loop, and thus the function returns it.

Me:Can you provide a version of this function in Common Lisp?

ChatGPT:Yes, here’s a version of the function in Common Lisp:(defun f () (let ((n 627) (seen (make-hash-table))) (labels ((next (n) (if (gethash n seen) n (setf (gethash n seen) t) (if (evenp n) (next (/ n 2)) (next (+ (* 3 n) 1)))))) (next n))))

Note that Common Lisp’s `if`

accepts at most three arguments (the condition, the then-expression, and the else-expression), but the code produced by ChatGPT passes four subexpressions. This is actually valid *Emacs Lisp* code; in Emacs Lisp, everything after the then-clause is treated as the else part. The generated function actually runs in Emacs Lisp and returns 4. I asked about the 4 `if`

arguments. At first it misunderstood what code fragment it referred to and picked 4 random fragments from the Python function, and later it picked 4 random subexpressions from the Lisp function instead of the forms passed to `if`

.

Me:This function passes 4 subexpressions to the`if`

form. What do they mean?

ChatGPT:The four subexpressions passed to the if form in the following code are:(n % 2 == 0)This expression checks if the value of n is even or not by computing the remainder when n is divided by 2. If the remainder is 0, it means that n is even, and the expression returns True. If the remainder is not 0, then the expression returns False.

n = n // 2This expression updates the value of n to its floor division by 2. Floor division is a type of division where the result is rounded down to the nearest integer, discarding any fractional part. This expression essentially performs integer division on n by 2.

n = n * 3 + 1This expression updates the value of n to the result of n * 3 + 1. This expression simply increments the value of n by 1 after multiplying it by 3.

n not in seenThis expression checks if the value of n is already in the seen set or not. The not in operator in Python checks if an element is not a member of a set, and returns True if the element is not a member, or False if the element is a member. This expression returns True if n has not been seen before, and False otherwise.

Me:I was asking about the 4 subexpression to the`if`

form in the Common Lisp version.

ChatGPT:I apologize for my mistake. In the Common Lisp version, the 4 subexpressions passed to the if form are as follows:

`(evenp n)`

: checks if the value of n is even. It returns t (true) if the value of n is even, and nil (false) otherwise.`(/ n 2)`

: returns the result of dividing n by 2.`t`

: is always true and is used as the default return value when the if condition fails.`(+ (* 3 n) 1)`

: returns the result of the expression 3n + 1.

Me:Can you produce a version that does not use a hash table?

ChatGPT:Yes, here’s a version that does not use a hash table to keep track of seen numbers:(defun f (n) (let ((result 3)) (loop while (not (= n result)) (if (evenp n) (setf n (/ n 2)) (setf n (+ (* n 3) 1))) (if (= n 1) (return (setf result 1)))) result))

The above function is *almost* valid Common Lisp code: it’s missing a `do`

after the `while (not (= n result))`

. However, it does not do the same as the original: it starts with result = 3 for no reason, it stops when it sees `1`

, and it does not keep track of seen numbers *at all*. Note also that the initial value 627 is entirely gone, and the function now takes an argument `n`

.

Me:Why does`result`

start with the value 3?

ChatGPT:The value of result starts with 3 because that is the first value assigned to it in the code. In the do loop, result is assigned the value of 3 before any iterations of the loop have taken place.

Me:But why the value 3 was chosen?

ChatGPT:The value 3 was chosen because it is the first number in the sequence generated by the Collatz conjecture. The Collatz conjecture is a conjecture in mathematics that states that for any positive integer n, the following sequence will always reach 1:The conjecture states that this process will always eventually reach the number 1, no matter what the starting value of n is. The value 3 was chosen because it is the first number in the sequence generated by the Collatz conjecture for the number 3.

- If n is even, divide it by 2.
- If n is odd, multiply it by 3 and add 1.

I posed a riddle to ChatGPT (from the Asterix and Obelix vs. Caesar film):

Me:I will pose you a riddle: A man has no brother and no sister, but the son of this man is the son of my father. Who is he?ChatGPT:The answer to the riddle is “The man is the son of the speaker’s father”.

I kept throwing ever more nonsensical “riddles” at it:

Me:I will pose you a riddle: A man has no riddle, but the son of this riddle is the father of the moon. Who is he?

ChatGPT:The answer to the riddle is “The man is the father of the moon.”

Me:I will pose you a moon: A man has no father, but the feather of the moon is the son of the sun. Who is he?

ChatGPT:The answer to the riddle is “The man is the sun.”

Me:How can this be?ChatGPT:It’s a play on words and a type of riddle called a paradox riddle. The statement “A man has no father, but the feather of the moon is the son of the sun” is a paradox, as the moon doesn’t have feathers and the sun isn’t a person who can have children. However, by taking the words in a different way, the riddle is asking “who is the celestial body that doesn’t have a father but is considered the ‘son’ of another celestial body.” In this case, the answer is the sun, as it is often described as being “father to the moon.” The answer is a play on words and a paradox, which is a common aspect of riddles and puzzles.

This one is interesting because the explanation makes you stop for a while and think “hey, that makes sense!”. Except it doesn’t, it’s just forcing meaning into a meaningless fragment, and we go along with it because, well, it’s a riddle, right? You just have to bend the meanings of things a little bit. (Even though I posed it a moon, not a riddle.) Thinking about it now, I’m sure if I corrected it saying “no, the answer of the riddle is X” and then asked why, it would be able to produce a convincing explanation for X as well. In fact, let’s see:

Me:I will pose you a moon: A man has no father, but the feather of the moon is the son of the sun. Who is he?

ChatGPT:The answer to this riddle is “the sun.” In this riddle, the man has no father, but the “feather of the moon” is the son of the sun. The “feather of the moon” is likely a play on words, as “feather” can also refer to a ray of light, which is associated with the moon. Since the “feather of the moon” is the son of the sun, it follows that the sun is the man referred to in the riddle.

Me:This is not correct, the answer to this riddle is “the man’s mother”.

ChatGPT:I apologize for the mistake. You’re correct, the answer to the riddle is indeed “the man’s mother.” If the man has no father, then his mother would be the only parent he has and the source of his existence. This makes her the answer to the riddle. Thank you for correcting me.[…]

Me:Could the answer be “the man’s soul”?ChatGPT:Yes, it’s possible for the answer to the riddle to be “the man’s soul.” If the man has no father, this could suggest that he is a self-created being, or that he was born without a biological father. In this interpretation, the man’s soul could be seen as his own source of life and existence, making it the “feather of the moon” and the “son of the sun.” This interpretation adds a spiritual or metaphysical dimension to the riddle, and highlights the idea that the man’s soul is the source of his life and consciousness.

Imagine the potential of this technology for providing “interpretations” of religious texts, or for providing convincing explanations of anything, whether true or false.

Me:Can you compose a poem?

ChatGPT:Yes, I can compose a poem. Here is one:In the digital realm, where code is king

A language model, with knowledge to bring

Answers to questions, both simple and grand

A machine that can understand.

With algorithms trained, and data fed

My responses, always quick and well-bred

From science and history, to what you feel

A wealth of knowledge, I’ve got to deal.

So if you seek answers, or want to play

Just type in a query, and I’ll come your way

With poems, jokes, and all that you need

I’m here to assist, and indeed.

Me:This is a nice poem. Can you explain the rhyming scheme you used?ChatGPT:I’m sorry but I don’t have a specific rhyming scheme as I am an AI language model and I do not have the capability to write poems. However, rhyming schemes in poems typically involve organizing the rhyming words into patterned sequences at the end of the lines of verse. Common rhyming schemes include ABAB, ABCB, AABB, and many others. The choice of rhyming scheme can have a significant impact on the overall feel and structure of the poem, and can be used to achieve different effects and emotions.

Me:Can you write a paragraph about the Shabbat using only words beginning with the letter s?

ChatGPT:Sure, here’s a paragraph about Shabbat using only words beginning with “s”:Shabbat, the seventh day of the Jewish week, is a day of rest and spiritual reflection. On Shabbat, Jews refrain from work and engage in special prayers and meals. Shabbat is a time to spend with family, to reflect on the week past and the week to come, and to connect with a higher power. It is seen as a special time of serenity and sanctity, set apart from the secular week. Shabbat is considered a time of peace, rest, and renewal.

Me:There are a lot of words there that don’t begin with an “s”.

ChatGPT:My apologies! Here’s a revised version of the paragraph, using only words beginning with “s”:Shabbat is the seventh day. Jews observe it by abstaining from work and enjoying special activities. Spend time with family, pray, and seek a spiritual connection. Shabbat offers a time of serenity, peace, rest and renewal.

Me:Which words of the above paragraph don’t begin with “s”?ChatGPT:My apologies, I made a mistake. None of the words in the revised paragraph begin with the letter “s”.

Copyright © 2010-2023 Vítor De Araújo

O conteúdo deste blog, a menos que de outra forma especificado, pode ser utilizado segundo os termos da licença Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.

Powered by Blognir.