> if AI generates something that is equal to existing code, then the license of that code applies.
No, it doesn't, if the generation is independent of the existing code. If a person using AI uses existing code and makes a literal copy of it, then, yes, the copyright (and any license offer applicable in the circumstances) of the existing code may apply (it may also not, the same as with copies of portions of code made by other means), and it's less than clear if (especially for small portions of code) that legally such a copy has been made when a work is in the training set.
Copyright protects against copying. It doesn't protect against someone creating the same content by means other than copying.
btw, this is the reason why people who at some point of time may have had access to windows source code are not allowed to work on wine. because if wine accidentally reproduces windows code, the only defense is that none of the contributors have ever seen that code before.
if AI has seen that code in training, then this defense is no longer possible.
No, almost cerainly it would be practically impossible if you reproduced the entire work, on top of evidence that you had perused it, because it would be very hard to convince a trier of fact that the duplication really was coincidence rather than copying, but it might be a very different story if you had read Harry Potter and then wrote another work that includes the text “Up!” she screeched. (which appears verbatim in the first volume of the series.)
No, it doesn't, if the generation is independent of the existing code. If a person using AI uses existing code and makes a literal copy of it, then, yes, the copyright (and any license offer applicable in the circumstances) of the existing code may apply (it may also not, the same as with copies of portions of code made by other means), and it's less than clear if (especially for small portions of code) that legally such a copy has been made when a work is in the training set.
Copyright protects against copying. It doesn't protect against someone creating the same content by means other than copying.