This is mere assumption. AI is supposed to work like that, but that's a goal, and not the result of current implementations. Research shows that they do memorize solutions as well, and quite regularly so. (This is an unavoidable flaw in current LLMs; They must be capable of memorizing input verbatim in order to learn specific facts.)
> and there was a tiny perctange of a chance where you reproduced that exact varation of one you memorized
This is copyright infringement. Actionable copyright infringement. The big music publishers go after this kind of accidental partial reproduction.
> but then added an after the fact filter so you don't directly reproduce it...
"Legally distinct" is a gimmick that only works where the copyright is on specific identifiable parts of a work.
Changing a variable name does not make a code snippet "legally distinct", it's still copyright infringement.