If you can compare the code and it matches you probably have a good case if the AI user can't demonstrate it's not coming from you.
It's not necessarily that simple.
Copyright protects creative expression, not underlying ideas or concepts or functionality.
The famous examples are that a phone book or map get limited copyright protection, because the text or image on the page corresponds to a ground truth that can't be copyrighted. Recipe books also have to deal with that legal reality.
In software, functionality, including documented APIs, are not copyrightable in themselves. There was a phenomenon where AT&T asserted copyright over their Unix executable /bin/true, despite that script doing nothing except exit successfully, but there's really nothing stopping anyone else from doing the same thing with a file with identical non-comment contents. So copyright doesn't protect bare functionality.
And the easiest way to prove that you didn't copy any nonfunctional expression is to have someone take the documentation and reimplement that functionality without ever looking at the original code, aka a "clean room implementation." Plenty of examples of that happening in the past, surviving challenges in court: Compaq reverse engineering IBM's BIOS and kicking off the IBM clone PC revolution, Google reimplementing the Java APIs from documentation to free themselves from Oracle's oppressive contracts in Android, etc.
And because copyLEFT licenses rely on the force of copyright law to work, these types of areas where code doesn't get copyright protection are also the areas where FOSS code wouldn't get copyleft protections, either.