This is a question from the first chapter of Herbert Endertons Computability book
I've been stuck on it since yesterday and its been driving me crazy. The basic commands from this language are as follows:
1) x <- 0 - to assign the value 0 to x
2) x <- x + 1 - the successor command
3) x <- y - the copy command (leaves the value of y unchanged)
4) loop x, P, endloop x - loops the instructions P by the number k times, where k is the initial value of x
5) while x \neq 0, P, endwhile x \neq 0 - the program keeps executing P so long as x is not equal to zero, and therefore running P can affect the value of x and the number of times it is run
I don't know why but I just can't seem to get a program for computing x-1 out this. It seems easy enough using primitive recursive functions... any help would be greatly appreciated!
I think you are probably looking for how to make the function $\mathrm{subtract1}:\mathbb{N} \rightarrow \mathbb{N}$ which is basically $subtract1(x)=x-1$ with the exception that $subtract1(0)=0$.
How about this? I suppose you are looking for something similar to this.