# How would an AI learn the concept of the words "repeat twice"?

In a hypothetical conversation:

Person A - "Repeat the word 'cat' twice".
Person B - "cat cat".


I'm thinking about how a human or AI can learn the concept of "repeat twice". In reinforcment learning it would require that after the first sentence the AI would go through every random sentence until it got it right and hence got a reward.

Another way might be the AI or human overhearing the conversation. Then on hearing a repetition or a word it may trigger some neurons in the brain related to detecting repetition. Thus by pavlovian learning associate the word "repeat" or "twice" with these neurons. When given the stimulus of the word "repeat" these neurons may get triggered making the brain do some repetition algorithm. (This is my favorite theory).

I suppose a third way might be as follows:

Person A - "Hello! Hello!"
Person B - "Stop repeating yourself".


It might learn to associate repeating with the word "repeating" in this way.

I think either way the brain must have some neurons dedicated to detecting repetitions and possibly inacting them. (I don't think any standard RNN has this capability).

What do you think is the most likely way?