%I #38 Mar 07 2020 04:07:26
%S 0,1,1,2,3,3,4,5,5,6,6,7,8,8,9,10,10,11,11,12,13,13,14,14,15,16,16,17,
%T 18,18,19,19,20,21,21,22,23,23,24,24,25,26,26,27,27,28,29,29,30,31,31,
%U 32,32,33,34,34,35,35,36,37,37,38,39,39,40,40,41,42,42,43,44
%N Hofstadter Flip-G-sequence.
%C This sequence is an answer to the question posed on page 137 of Goedel, Escher, Bach: find a sequence that generates a tree which is like that of the G-sequence (see A005206), but flipped and renumbered, so that when the nodes of the tree are read from bottom-to-top, left-to-right, the natural numbers: 1, 2, 3, 4, 5, 6, ... are obtained.
%C 14.15.16.17.18.19.20.21
%C .\..\./...\./..\...\./
%C ..9..10....11...12.13
%C ...\./......\...\./
%C ....6........7...8
%C .....\........\./
%C ......4........5
%C ........\..../
%C ..........3
%C ............\
%C .............2
%C ..............\ /
%C ...............1
%C To construct the tree: node n is connected to the node flip-G(n) = a(n) below it:
%C n
%C .\
%C .a(n)
%C For example:
%C 7
%C .\
%C ..5
%C since a(7) = 5. The tree has a recursive structure, since the following construct
%C \
%C .x
%C ..\ /
%C ...x
%C can be repeatedly added on top of its own ends, to construct the tree from its root: e.g.
%C \
%C .x
%C ..\./...\
%C ...x.....x
%C ....\.....\ /
%C .....x.....x
%C ......\.../
%C ........x
%D D. Hofstadter, "Goedel, Escher, Bach", p. 137.
%H David Fifield, <a href="/A123070/b123070.txt">Table of n, a(n) for n = 0..10000</a>
%H Pierre Letouzey, <a href="http://hal.inria.fr/hal-01195587">Hofstadter's problem for curious readers</a>, technical report, 2015.
%H Physics Forum Discussion, <a href="https://www.physicsforums.com/threads/recursive-trees-from-ged.127822">Recursive Trees (from GED)</a>.
%H <a href="/index/Go#GEB">Index entries for sequences from "Goedel, Escher, Bach"</a>
%H <a href="/index/Ho#Hofstadter">Index entries for Hofstadter-type sequences</a>
%F Conjecture: a(0) = 0, a(1) = 1, a(2) = 1, a(3) = 2; a(n) = (n+1) - a(a(n-1)+1) for n>=4. [Conjecture has been proved; see Letouzey link. - _Pierre Letouzey_, Sep 09 2015]
%F Conjecture: a(0) = 0, a(1) = 1, a(2) = 1, a(3) = 2; for n>=4, let T = n-a(n-1). If T = (n-1) - a((n-1)-1) then a(n) = max{a-inv(T)} otherwise a(n) = min{a-inv(T)}, where a-inv(n) is the inverse of a(n).
%F From _Pierre Letouzey_, Sep 09 2015: (Start)
%F Alternative definition via differences:
%F a(0) = 0; a(n+1) = a(n) + d(n) where:
%F d(0) = 1, d(1) = 0, d(2) = 1, d(3) = 1; d(n)=1-d(n-1)*d(a(n)) for n>=4.
%F Also satisfies: a(n-1)+a(a(n)) = n for n>=4.
%F a(n) = A005206(n) + e(n), where e(n) is 0 or 1 depending of the shape of the decomposition of n as sums of Fibonacci numbers via Zeckendorf's theorem. (End)
%t a[n_] := a[n] = Switch[n, 0, 0, 1, 1, 2, 1, 3, 2, _, (n+1) - a[a[n-1]+1]];
%t a /@ Range[0, 100] (* _Jean-François Alcover_, Nov 16 2019 *)
%o (Python) # Emulate a breadth-first traversal of the tree defining the "flip-tree" of the Hofstadter G-sequence.
%o def gflip_iter():
%o yield 0
%o yield 1
%o # Start on a left-branch node, parent node is 1.
%o queue = [(1, 1)]
%o n = 2
%o while True:
%o parent, state = queue.pop(0)
%o yield parent
%o if state == 0:
%o # Root node. Add the two children.
%o queue.append((n, 1))
%o queue.append((n, 0))
%o elif state == 1:
%o # Left-branch node. Add a new root.
%o queue.append((n, 0))
%o n += 1
%o i = gflip_iter()
%o for n in range(0, 10001):
%o print("%d %d" % (n, next(i)))
%o # David Fifield (david(AT)bamsoftware.com), Jan 17 2009
%Y Cf. A005206.
%K nonn
%O 0,4
%A Albert Neumueller (albert.neu(AT)gmail.com), Sep 28 2006
|