Fixed generation of partition invariant with refinement