Doubt with the halting problem undecidable proof The Halting problem proof can be seen as the following programs:


Ends(P, I) is a program that detects (returns true or false) if the program P will halt or
not with the input I 
Diag( P ): is a program that 

2.1 Halts if P( P ) doesn't halt

2.2 Doesn't halt if P (P) halts


If we use (2) with input Diag it state:


Diag(Diag) halts if Diag(Diag) doesn't halt
Diag(Diag) doesn't halt if Diag(Diag) doesn't halt


Which by contradiction is proven that the program Ends can't exist.

Until here everything is fine. But What if instead of thinking on halt or never halt, we think in steps.

What if I do the following analogy:


Ends( P, I, S ) is a program that detects (returns true or false) if the program P with the input I, it will halt in less or equal S steps.
Diag( P, S) = Diag( P ): is a program that:

2.1 That halts in less or equal than S steps if Ends( P, P, S ) doesn't halts in less or equal than S steps.

2.2 That doesn't halts in less or equals than S steps if Ends( P, P, S ) halts in less or equal than S steps.


if we use (2):


Diag( Diag) halts in less or equal than S steps if Ends( Diag, Diag, S ) doesn't halt in less or equal than S steps.
Diag ( Diag ) doesn't halt in less or equals than S steps if Ends(  Diag, Diag, S ) halt in less or equal than S steps.


Which is the almost the same contradiction, and in this case Ends is possible to build. 

What I'm doing wrong?
The main problem with your analogy is the construction of Diag. The usual proof goes as follow:


Assume Ends exists.
Then we can construct Diag with a Turing machine calling Ends. As follows:


Diag(P) = If Ends(P,P) then Loop indefinitely Else Terminates.


This leads to a contradiction thus Ends does not exist.


What you are doing is the following:

1'. Construct Ends(P,I,S).

2'. Construct Diag(P,S).

3'. This leads to a contradiction.

The main problem is that you do not provide the actual construction of Diag in step 2' as we did it in step 2. How can you implement Diag with a TM machine calling Ends? I do not think so as you need more than S steps to run the program Ends.