generating pack and unpack for a predicate