Invariant generation