I’ve been trying to use AI to prove a simple theorem using the Cook Levin library - if a Turing machine outputs a certain bit at a certain location, then the Turing machine must read that bit. Chat GPT and Claude AI haven’t been able to do it. Anyone know how to do this?
Hi,
I'm interested in your question as well, and just to check whether I've understood it correctly: I can prove the following lemma by simp
, is it somewhat relevant to what you are proving?
lemma "|.| (act (w, Stay) tape) = w"
by simp
Yiran, the way I understand that statement, it means "If you write symbol w to a tape without moving the head, then reading from the tape returns w". When I asked my question, I meant if the Turing machine outputs w, then beforehand it must have read bit w. To give an idea of what I had in mind, I would like to use this to prove in Isabelle that if a Turing machine take the OR function of n bits and all n bits are zero, then the Turing machine must read all of the bits beforehand.
Thank you for explaning it again! So is it something like the following (I randomly chose some tm_copy_paste as an example)?
lemma aux:
assumes "t < 10"
shows "fst (execute tm_copy_paste start_cfg t) = 0 ∧
(execute tm_copy_paste start_cfg t) <#> 0 = t"
Here's more details including my definition for tm_copy_paste
and start_cfg
, where I managed to prove this lemma above in my awkward way.
Scratch.thy
edit: provide a name for the lemma
Lemma aux
is much stronger than (what I understood from) your statement, but I guess it provides a way to easily prove your goal. However if the ultimate goal is to prove that the turing machine terminates with some results, I think there might be better ways without having to prove such intermediate lemmas explicitly (but that's beyond my current experience with the Cook_Levin entry; I would be happy if I get the chance to learn about it in this discussion)
Yiran, It isn’t exactly what I was thinking, but it probably will be helpful. My question seems conceptually easy and obvious at first, but I couldn’t get ai to do it and it isn’t always true. What if Turing machine M prints out bit x? Then one might think M has to read bit x. But then what if it is mathematically provable that another bit y equals bit x. Then the Turing machine doesn’t have to read bit x. It could just read bit y and print it out. So there have to be extra assumptions.
Yiran, to give a better example of what I have in mind, suppose you want to determine whether there exists a nonzero x such that given square matrix A, Ax=0, where A and x are composed of zeroes and ones and we are using mod 2 arithmetic. You don’t have to check all possibilities for x to get the answer. You can do Gaussian elimination on A to see if it is non singular. In other words if you consider a bit y for each x as to whether Ax = 0 and take the or operators of these bits y you get the answer, but you don’t have to do it this way and in fact it is better that you don’t do it this way. This is why you need extra assumptions for what I’m trying to do in Isabelle to work, namely that there are no other ways of formulating the problem other than taking the or operator. Does this make sense?
Also, look up “adversary argument” as this is the type of argument that is necessary for this to work.
Another problem I just realized is that to output bit x, a Turing machine can read not x. So technically the Turing machine doesn’t have to read bit x.
But I think the assertion is correct in spirit.
A better way of phrasing it - before a Turing machine outputs bit x, it must “know” what bit x is. Similar to before a person speaks, he has to know what he is going to say.
Hi, unfortunately I still fail to understand the conversation. I try to list some points that I'm not sure with, as follows:
Craig Alan Feinstein said:
... suppose you want to determine whether there exists a nonzero x such that given square matrix A, Ax=0, where A and x are composed of zeroes and ones and we are using mod 2 arithmetic. ... if you consider a bit y for each x as to whether Ax = 0 and take the or operators of these bits y you get the answer ...
Are these words talking about the most brute-force method which tries all the possibilities of x (if the matrix A in this example is of shape )?
Craig Alan Feinstein said:
This is why you need extra assumptions for what I’m trying to do in Isabelle to work, namely that there are no other ways of formulating the problem other than taking the or operator. Does this make sense?
Here I am completely lost. I have no idea what "the problem" is referring to (maybe I also have doubts about what "formulating" means here).
Craig Alan Feinstein said:
... before a Turing machine outputs bit x, it must “know” what bit x is. ...
Does this mean "work with deterministic Turing Machines"?
Yiran said “Are these words talking about the most brute-force method which tries all the possibilities of x (if the matrix A in this example is of shape )?” Yes
Yiran said “Here I am completely lost. I have no idea what "the problem" is referring to (maybe I also have doubts about what "formulating" means here).” I was saying that the matrix problem can be formulated as an “or” problem but it is not necessary to take the or operator of all 2 to the n possible solutions to determine whether there is a solution. One can just do Gaussian elimination. This is an example of an “or” problem in which it is not necessary to take the “or” operator explicitly. Hence a proof in Isabelle has to specify context of the “or” problem in order to prove that a Turing machine has to read all of the bits.
Yiran said “Does this mean "work with deterministic Turing Machines"?” I was talking about deterministic Turing machines.
Craig Alan Feinstein said:
Yiran said “Does this mean "work with deterministic Turing Machines"?” I was talking about deterministic Turing machines.
I don't think I can imagine how a deterministic Turing machine "doesn't know" the bit to be output (for a given configuration). Maybe I had a different understanding of "knowing a bit"?
Yiran I would now define “knowing a bit” for a Turing machine as having the bit on the tape or the negation of the bit on the tape at a particular location. Then when the machine reads that particular location, it reads the bit or the not bit and then goes into another state in which the bit is encoded in it and then it outputs that bit.
The nuance here is to know a yes/no fact, it really doesn’t matter whether one means yes or zero means yes, as long the machine is consistent.
Craig Alan Feinstein said:
Yiran I would now define “knowing a bit” for a Turing machine as having the bit on the tape or the negation of the bit on the tape at a particular location. Then when the machine reads that particular location, it reads the bit or the not bit and then goes into another state in which the bit is encoded in it and then it outputs that bit.
That would mean the machine rewrites a bit at some "particular location" with itself or its negation, right?
Craig Alan Feinstein said:
A better way of phrasing it - before a Turing machine outputs bit x, it must “know” what bit x is. Similar to before a person speaks, he has to know what he is going to say.
I tried to replace the above informal definition of "knowing a bit" (along with a transition, sharing a fixed "particular location") into this statement, and I get the following:
"Before a machine outputs x
at some position head_pos
, the bit at head_pos
must have been x
or the negation of x
"
Is that what you meant, or did I misunderstood something?
Or, I guess it makes much more sense if there were actually some transitions that moves the tape head to different positions omitted; also consider working with multitape TMs, and add the constraint that contents on the first tape are never changed (which the Cook-Levin entry does), and we don't consider actions on the first tape (always rewriting with the original symbol) as an action of the machine "outputting" or "writing" something; thirdly, since we talked about bitwise or, I have always assumed that the tape alphabets only include something like 0 and 1 (and the blank symbol, or maybe also a start symbol).
In that case I would understand the goal as "when some bit x
is output, it shows that x
or its negation appears in the contents of the first tape (input)".
Then I must have missed something because based on this, I think it is basically to show that "if the machine ever writes a 0 or a 1 (on any tape other than the first one), the first tape must be non-empty (there is at least one 0 or 1 at any location)"?
Yiran your last comment illustrates how this problem is not as easy as it looks. You did not misunderstand me. Thinking about things more, I actually want to do the following in a proof - I want to show that in order for a Turing machine T to decide whether x = y, it is necessary for T to read both f(x) and f(y), for some one to one function f. (Assume x and y are integers.)
The proof is that if T did not read f(x) for some one to one function f, then T would behave the same way for some x’ not equal to x as it does for x. Therefore it could not decide whether x=y.
The one to one function f encodes x and y as bits that the Turing machine reads.
Last updated: Aug 23 2025 at 01:39 UTC