The only four-letter sequence [????] that works is:
This evaluates as
I found this through directed guessing:
I evaluated the 3 letter sequences [AAB], [BBA] and [BBB], and these gave me a good feel for what might work and what definitely wouldn't. Then I jumped to four letter sequences and took a couple wrong guesses before finding this solution.
I've now written some code to find generable outputs (and was able to confirm that the above solution is unique for four letter inputs). I believe that the rule is:
Treating "A" as 0 and "B" as 1, and evaluating the outputs that can be produced by this ruleset as binary, the possible outputs are all the multiples of 3. (Or, at minimum, they are all multiples of 3, even if not all such multiples can be generated.)
Here's what I've been able to find are the generable outputs:
length of 1: A B
length of 2: AA AB BA BB
length of 3: AAA AAB ABA ABB BAA BAB BBA BBB
length of 4: AAAA AAAB AABA AABB ABAA ABAB ABBA ABBB
BAAA BAAB BABA BABB BBAA BBAB BBBA BBBB
where BOLD are generable outputs and ITALIC are outputs that cannot be generated.
The only generable outputs of length 5 are:
AAAAA AAABB AABBA ABAAB ABBAA ABBBB
BAABA BABAB BBAAA BBABB BBBBA
and for length 6 are:
AAAAAA AAAABB AAABBA AABAAB AABBAA AABBBB
ABAABA ABABAB ABBAAA ABBABB ABBBBA BAAAAB
BAABAA BAABBB BABABA BABBAB BBAAAA BBAABB
BBABBA BBBAAB BBBBAA BBBBBB
I finally noticed that ...
the generable outputs occur at intervals of 3.