I am doing self study from MIT OCW exercises and I could not understand this question.
The following rules define the binary-GCD state machine working on states in $\mathbb{N}^3$ with start state $(a,b,1)$ for $a>b>0$. If multiple rules apply, smaller numbers have precedence.
Provided $\min(x,y) >0$, then $(x,y,e) \to $
- $(1,0,ex)$ if $x=y$
- $(1,0,e)$ if $y=1$
- $(x/2,y/2,2e)$ if $2|x \land 2|y$
- $(y,x,e)$ if $y>x$
- $(x,y/2,e)$ if $2|y$
- $(x/2,y,e)$ if $2|x$
- $(x-y,y,e)$ otherwise
The binary-GCD state machine computes the GCD of $a$ and $b$ using only division by $2$ and subtraction, which makes it run very efficiently on hardware that uses binary representation of numbers. In practice, it runs more quickly than the Euclidean algorithm state machine.
Each execution of a command (one of rules 1-7 according to algorithm) is a transition and the current state $(x,y,e)$ is stored in registers $A,B,E$. At first the values in the registers $a,b,1$
Here is the question I am having trouble with:
Prove that the machine reaches a final state in at most $3+2\log(\max(a,b))$ transitions.
Hint: Strong induction on $\max(a,b)$
First, why does this state machine assume it halves the $\max(a,b)$ at every two transitions beacuse we can apply rule 4 and 7 and one extra rule to halve the $\max(a,b)$, which is more than two transitions/steps. I know it is not a common case but a case is a case unless proved.
Next I don't see where an extra 3 comes from in $3+2\log(\max(a,b))$.