This is equivalent to the last index being the first index plus
Thm* p q
Thm*
Thm* (a:.
Thm* (1of(HanoiSTD(n disks; from: p; to: q; indexing from: a)) = a+(2^n)-1)
The proof is by less-than induction over
n1:.
n1<n
(p,q:Peg.
(p q
(
((a:. 1of(HanoiSTD(n1 disks; from: p; to: q; indexing from: a)) = a+(2^n1)-1))
and assuming
1of(HanoiSTD(n disks; from: p; to: q; indexing from: a)) = a+(2^n)-1
Keeping in mind that
1of(HanoiSTD(n-1 disks; from: p; to: otherPeg(p; q); indexing from: a)/m,s1.
HanoiSTD(n-1 disks; from: otherPeg(p; q); to: q; indexing from: m+1)/z,s2.
<z,HanoiHelper(n; s1; i.p; s2; i.q)/r1,r2. r1 @(m) r2>)
=
a+2(2^(n-1))-1
By applying the inductive hypothesis we get
(A) =
(A) a+(2^(n-1))-1
then letting
and our goal simplifies to
1of(HanoiSTD(n-1 disks; from: otherPeg(p; q); to: q; indexing from: m+1)/z,s2.
<z,HanoiHelper(n; s1; i.p; s2; i.q)/r1,r2. r1 @(m) r2>)
=
a+2(2^(n-1))-1
And applying the inductive hypothesis again we get
(C) =
(C) m+1+(2^(n-1))-1
Then letting
(D) =
(D) 1of(HanoiSTD(n-1 disks; from: otherPeg(p; q); to: q; indexing from: m+1))
and our goal simplifies further to
z = a+2(2^(n-1))-1
which follows by arithmetic from (D), (C), (B), and (A).
QED
About: