The loop invariants that you can detect may not be the loop invariants that they want. Consider:
for(int i = 0; i < n; i++) {..}
It looks like the invariant should be: 0 <= i < n
But if they mistyped the loop that would be wrong. You have to explicitly state your invariants. At best, you could detect them and ask for confirmation. And that's for an easy to detect case.