Browse Source

Modules2PTA: fix handling of probabilities in commands that refer to state variables [bug found by Linda Leuschner]

When translating the module state variables to locations, probabilities in
commands were not translated. If the probability expression contains a reference
to the state variables, e.g.,
  (s=0 ? 0.5 : 0.75)
then the variable reference persists, which leads to an exception when
updating variable information of the module later on, as the state variable
is no longer defined in the translated module.


git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11215 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 10 years ago
parent
commit
c3b802994e
  1. 10
      prism/src/pta/Modules2PTA.java

10
prism/src/pta/Modules2PTA.java

@ -606,7 +606,15 @@ public class Modules2PTA extends PrismComponent
updateNew.addElement(update.getVarIdent(k), update.getExpression(k)); updateNew.addElement(update.getVarIdent(k), update.getExpression(k));
} }
} }
updatesNew.addUpdate(updates.getProbability(j), updateNew);
// we translate the probability as well, as it may reference states
Expression probNew = updates.getProbability(j);
if (probNew != null) {
// if probability expression is null, it implicitly encodes probability 1,
// so we don't have to change anything
probNew = probNew.deepCopy();
probNew = (Expression) probNew.evaluatePartially(state, varMap).simplify();
}
updatesNew.addUpdate(probNew, updateNew);
} }
// Add new stuff to new module // Add new stuff to new module
commandNew.setUpdates(updatesNew); commandNew.setUpdates(updatesNew);

Loading…
Cancel
Save