public BooleanPermutationBranchingProgram applyPerm(Permutation perm) {
    BooleanPermutationBranchingProgram result = new BooleanPermutationBranchingProgram();

    Permutation permInverse = perm.getInverse();

    for (int i = 0; i < getLength(); i++) {
      result.addInstruction(
          vars.get(i),
          new DefaultPermutation(perm, leftPerms.get(i), permInverse),
          new DefaultPermutation(perm, rightPerms.get(i), permInverse));
    }

    return result;
  }
 public void addProgram(BooleanPermutationBranchingProgram pbp) {
   for (int i = 0; i < pbp.getLength(); i++) {
     addInstruction(pbp.vars.get(i), pbp.leftPerms.get(i), pbp.rightPerms.get(i));
   }
 }