Flexible constrained sampling with guarantees for pattern mining