// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
private PathFormula withCorrectionTermsAndPC(
      Block pBlock,
      FormulaManagerView pFmgr,
      BooleanFormulaManagerView pBfmgr,
      BitvectorFormulaManagerView pBvfmgr,
      PathFormulaManager pPfmgr,
      CFA pCFA) {
    BooleanFormula extendedBlockFormula = pBlock.getFormula();
    PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
    PathFormula primedBlockContext = pBlock.getPrimedContext();
    SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
    SSAMap primedSSAMap = primedBlockContext.getSsa();
    for (String varName : programVariableNames) {
      // Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
      if (!primedSSAMap.containsVariable(varName)) {
        BooleanFormula correctionterm =
            pBvfmgr.equal(
                makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
                makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
        extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
      } else {
        // Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
        if (unprimedSSAMap.containsVariable(varName)
            && unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
          BooleanFormula correctionterm =
              pBvfmgr.equal(
                  makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
                  makeVar(
                      pPfmgr,
                      pFmgr,
                      unprimedBlockContext,
                      varName,
                      unprimedSSAMap.getIndex(varName)));
          extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
        }
        // Add high correction v_? = v_max if primed context for v has lower index (? < max)
        if (primedSSAMap.getIndex(varName) < highestSSA) {
          BooleanFormula correctionterm =
              pBvfmgr.equal(
                  makeVar(
                      pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
                  makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
          extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
        }
      }
    }
    // Add program counter
    int predID = getID(pBlock.getPredecessorLocation());
    int succID = getID(pBlock.getSuccessorLocation());
    BooleanFormula pcBefore =
        pFmgr.instantiate(
            makeProgramcounterFormula(predID, pBvfmgr, pCFA),
            SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
    BooleanFormula pcAfter =
        pFmgr.instantiate(
            makeProgramcounterFormula(succID, pBvfmgr, pCFA),
            SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
    extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
    @SuppressWarnings("deprecation")
    // TODO: seems buggy because it implicitly combines extendedBlockFormula and
    // primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
    PathFormula pathFormula =
        pPfmgr.makeNewPathFormula(
            primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
    return pathFormula;
  }
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));