I have an algorithm which contains only the instructions of type:
- $X_i=X_j$
- $X_i=X_i+1$
$\text{while }(X_i\le N)\text{ do }\{C\}$ where $C$ is another instruction
$N$ is a global constant and Initially all variables are equal to $0$
I want to prove that if this algorithm terminates then the number of executed affectations is polynomial on $N$. I think that this is already done by someone else so I need some references for this problem (or likewise) if someone can provide a proof or the idea behind it, it will be greatly appreciated.
Note that all numbers greater than $N$ are indistinguishable to the program from each other. With no change to running time, we can replace all instructions $X_i = X_i+1$ with $X_i=\min(X_i+1,N+1)$. This way all variables are confined to $\{0,1,2,..,N,N+1\}$.
Create a graph of all possible states of an executing program. The vertices are tuples $(X_1, X_2, \dots, X_k, L)$ where each $X_i$ is in $\{0,1,2,..,N,N+1\}$ and $L$ is a location in the program.
A walk in such a graph is either a cycle (the program does not terminate) or a path of length $O(N^k)$.