Browse Source

Code refactoring (checking for LTL with time bounds).

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@7731 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 12 years ago
parent
commit
d81ef64ff2
  1. 17
      prism/src/explicit/DTMCModelChecker.java
  2. 17
      prism/src/explicit/MDPModelChecker.java
  3. 22
      prism/src/parser/ast/Expression.java
  4. 49
      prism/src/prism/NondetModelChecker.java
  5. 17
      prism/src/prism/ProbModelChecker.java

17
prism/src/explicit/DTMCModelChecker.java

@ -215,21 +215,8 @@ public class DTMCModelChecker extends ProbModelChecker
long time;
// Can't do LTL with time-bounded variants of the temporal operators
try {
expr.accept(new ASTTraverse()
{
public void visitPre(ExpressionTemporal e) throws PrismLangException
{
if (e.getLowerBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
if (e.getUpperBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
}
});
} catch (PrismLangException e) {
String s = "Temporal operators (like " + e.getMessage() + ")";
s += " cannot have time bounds for LTL properties";
throw new PrismException(s);
if (Expression.containsTemporalTimeBounds(expr)) {
throw new PrismException("Time-bounded operators not supported in LTL: " + expr);
}
// For LTL model checking routines

17
prism/src/explicit/MDPModelChecker.java

@ -228,21 +228,8 @@ public class MDPModelChecker extends ProbModelChecker
long time;
// Can't do LTL with time-bounded variants of the temporal operators
try {
expr.accept(new ASTTraverse()
{
public void visitPre(ExpressionTemporal e) throws PrismLangException
{
if (e.getLowerBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
if (e.getUpperBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
}
});
} catch (PrismLangException e) {
String s = "Temporal operators (like " + e.getMessage() + ")";
s += " cannot have time bounds for LTL properties";
throw new PrismException(s);
if (Expression.containsTemporalTimeBounds(expr)) {
throw new PrismException("Time-bounded operators not supported in LTL: " + expr);
}
// For LTL model checking routines

22
prism/src/parser/ast/Expression.java

@ -666,6 +666,28 @@ public abstract class Expression extends ASTElement
return false;
}
/**
* Test if an expression contains time bounds on temporal operators
*/
public static boolean containsTemporalTimeBounds(Expression expr)
{
try {
expr.accept(new ASTTraverse()
{
public void visitPre(ExpressionTemporal e) throws PrismLangException
{
if (e.getLowerBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
if (e.getUpperBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
}
});
} catch (PrismLangException e) {
return true;
}
return false;
}
/**
* Test if an expression contains a multi(...) property within
*/

49
prism/src/prism/NondetModelChecker.java

@ -679,32 +679,6 @@ public class NondetModelChecker extends NonProbModelChecker
}
}
/**
* This function throws an exception if the parameter expr contains
* a subexpression which is a time-bounded operator.
* @param expr A multi objective
* @throws PrismException
*/
private void ensureNoTimeBounded(ExpressionFunc expr) throws PrismException
{
try {
expr.accept(new ASTTraverse()
{
public void visitPre(ExpressionTemporal e) throws PrismLangException
{
if (e.getLowerBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
if (e.getUpperBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
}
});
} catch (PrismLangException e) {
String s = "Temporal operators (like " + e.getMessage() + ")";
s += " cannot have time bounds for multi-objective properties";
throw new PrismException(s);
}
}
protected void addDummyFormula(NondetModel modelProduct, LTLModelChecker mcLtl, List<JDDNode> targetDDs, OpsAndBoundsList opsAndBounds)
throws PrismException
{
@ -845,10 +819,12 @@ public class NondetModelChecker extends NonProbModelChecker
List<JDDNode> rewards = new ArrayList<JDDNode>(numTargets);
List<JDDNode> rewardsIndex = new ArrayList<JDDNode>(numTargets);
// No time-bounded variants of the temporal operators allowed for multi-objective (or LTL)
// Can't do LTL with time-bounded variants of the temporal operators
// TODO removed since it is allowed for valiter.
// TODO make sure it is treated correctly for all params
//ensureNoTimeBounded(expr);
/*if (Expression.containsTemporalTimeBounds(expr)) {
throw new PrismException("Time-bounded operators not supported in LTL: " + expr);
}*/
ArrayList<String> targetName = new ArrayList<String>();
targetExprs = new ArrayList<Expression>(numTargets);
@ -1500,21 +1476,8 @@ public class NondetModelChecker extends NonProbModelChecker
long l;
// Can't do LTL with time-bounded variants of the temporal operators
try {
expr.accept(new ASTTraverse()
{
public void visitPre(ExpressionTemporal e) throws PrismLangException
{
if (e.getLowerBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
if (e.getUpperBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
}
});
} catch (PrismLangException e) {
String s = "Temporal operators (like " + e.getMessage() + ")";
s += " cannot have time bounds for LTL properties";
throw new PrismException(s);
if (Expression.containsTemporalTimeBounds(expr)) {
throw new PrismException("Time-bounded operators not supported in LTL: " + expr);
}
// Can't do "dfa" properties yet

17
prism/src/prism/ProbModelChecker.java

@ -555,21 +555,8 @@ public class ProbModelChecker extends NonProbModelChecker
long l;
// Can't do LTL with time-bounded variants of the temporal operators
try {
expr.accept(new ASTTraverse()
{
public void visitPre(ExpressionTemporal e) throws PrismLangException
{
if (e.getLowerBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
if (e.getUpperBound() != null)
throw new PrismLangException(e.getOperatorSymbol());
}
});
} catch (PrismLangException e) {
String s = "Temporal operators (like " + e.getMessage() + ")";
s += " cannot have time bounds for LTL properties";
throw new PrismException(s);
if (Expression.containsTemporalTimeBounds(expr)) {
throw new PrismException("Time-bounded operators not supported in LTL: " + expr);
}
// For LTL model checking routines

Loading…
Cancel
Save