OFFSET
0,3
COMMENTS
In "minimal subset/superset bitmask transform", applicable to any N -> N injection f, we start from a(0) = 0, after which for n > 0, if there are one or more k_i that are not already present in the sequence among terms a(0) .. a(n-1), and for which bitor(k_i,a(n-1)) = a(n-1), then a(n) = that k_i for which f(k_i) is minimized; otherwise, a(n) = that h_i for which f(h_i) is minimized among the infinite set of numbers h_i for which bitand(h_i,a(n-1)) = a(n-1) and that are not yet present in the sequence. In this case f(n) = A193231(n).
Shares with permutations like A003188, A006068, A163252, A300838, A302846, A303763, A303765, A303767, A303773 and A304083 the property that when moving from any a(n) to a(n+1) either a subset of 0-bits are toggled on (changed to 1's), or a subset of 1-bits are toggled off (changed to 0's), but no both kind of changes may occur at the same step. Note that A303767 is obtained when the same transform is applied to A001477, and A304083 when it is applied to A054429.
LINKS
EXAMPLE
After a(3) = 2, "10" in binary, there are no submasks that wouldn't have been used, so one selects from supermasks h_i = "110" (6), "111" (7), "1010" (10), "1011" (11), "1110" (14), "1111" (15), "10010" (18), "10011" (19), etc. that one for which A193231(h_i) is minimized, which happens to be at 6 (as A193231(6) = 6, but A193231(7) = 7, and for n >= 8, A193231(n) >= 8), thus a(4) = 6.
After a(4) = 6, "110" in binary, the submask "10" (2) is already present in sequence, while submask "100" (4) is only one which is not present, thus 4 is selected to be the value of a(5).
PROG
(PARI)
up_to = (2^18)+2;
A193231(n) = { my(x='x); subst(lift(Mod(1, 2)*subst(Pol(binary(n), x), x, 1+x)), x, 2) }; \\ From A193231
v303775 = vector(up_to);
m303776 = Map();
find_minimal_submask_for_A193231(n, m_inverses) = { my(minval=0, minmask=0); for(m=1, n, if((bitor(m, n)==n) && !mapisdefined(m_inverses, m) && (!minval || (A193231(m) < minval)), minval = A193231(m); minmask = m)); (minmask); };
find_minimal_supermask_for_A193231(n, m_inverses) = { my(minval=0, minmask=0); for(m=1, (1<<(1+#binary(n)))-1, if((bitand(m, n)==n) && !mapisdefined(m_inverses, m) && (!minval || (A193231(m) < minval)), minval = A193231(m); minmask = m)); (minmask); };
w=1; for(n=1, up_to, s = Set([]); if((submask = find_minimal_submask_for_A193231(w, m303776)), w = submask, w = find_minimal_supermask_for_A193231(w, m303776)); v303775[n] = w; mapput(m303776, w, n));
A303775(n) = if(!n, n, v303775[n]);
A303776(n) = if(!n, n, mapget(m303776, n));
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, May 05 2018
STATUS
approved