In such a case, a court would generally look at the result. If the later work is found to have "substantial similarity" to the earlier work, or to be a derivative work of the earlier work, and if fair use (in a US court) or another exception to copyright (elsewhere, including fair dealing in the UK) is not found, then the court might well find that there was an infringement of copyright.
Note, both "substantial similarity" and "derivative work " are intentionally somewhat vagusevague terms in copyright law, allowing case-by-case decision and flexibility.
The court will probably care little about whether or how an AI was used. It is the output, not the input, that will be the issue, I think. I do not know of a case with exactly this fact pattern, however.