Browse Source
Addition of F (future) and G (global) operators to property specification language.
Addition of F (future) and G (global) operators to property specification language.
git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@181 bbc10eb1-c90d-0410-af57-cb519fbb1720master
14 changed files with 2747 additions and 1763 deletions
-
1848prism/include/SimulatorEngine.h
-
8prism/include/simpctl.h
-
167prism/src/parser/PCTLProbBoundedFuture.java
-
167prism/src/parser/PCTLProbBoundedGlobal.java
-
57prism/src/parser/PCTLProbFuture.java
-
57prism/src/parser/PCTLProbGlobal.java
-
1758prism/src/parser/PrismParser.java
-
67prism/src/parser/PrismParser.jj
-
114prism/src/prism/NondetModelChecker.java
-
58prism/src/prism/ProbModelChecker.java
-
58prism/src/prism/StochModelChecker.java
-
111prism/src/simulator/SimulatorEngine.java
-
12prism/src/simulator/simpctl.cc
-
28prism/src/simulator/simpctlbuilder.cc
1848
prism/include/SimulatorEngine.h
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,167 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2002-2004, Dave Parker |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of the GNU General Public License as published by |
|||
// the Free Software Foundation; either version 2 of the License, or |
|||
// (at your option) any later version. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package parser; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
import prism.PrismException; |
|||
import simulator.*; |
|||
|
|||
public class PCTLProbBoundedFuture extends PCTLFormulaUnary |
|||
{ |
|||
Expression lBound = null; // none if null, i.e. zero |
|||
Expression uBound = null; // none if null, i.e. infinity |
|||
|
|||
// constructor |
|||
|
|||
public PCTLProbBoundedFuture(PCTLFormula f, Expression l, Expression u) |
|||
{ |
|||
super(f); |
|||
lBound = l; |
|||
uBound = u; |
|||
} |
|||
|
|||
public Expression getLowerBound() |
|||
{ |
|||
return lBound; |
|||
} |
|||
|
|||
public Expression getUpperBound() |
|||
{ |
|||
return uBound; |
|||
} |
|||
|
|||
// find all constants (i.e. locate idents which are constants) |
|||
|
|||
public PCTLFormula findAllConstants(ConstantList constantList) throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.findAllConstants(constantList); |
|||
// also do bound expressions |
|||
if (lBound != null) lBound = lBound.findAllConstants(constantList); |
|||
if (uBound != null) uBound = uBound.findAllConstants(constantList); |
|||
|
|||
return this; |
|||
} |
|||
|
|||
// find all variables (i.e. locate idents which are variables) |
|||
|
|||
public PCTLFormula findAllVars(Vector varIdents, Vector varTypes) throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.findAllVars(varIdents, varTypes); |
|||
// also do bound expressions |
|||
if (lBound != null) lBound = lBound.findAllVars(varIdents, varTypes); |
|||
if (uBound != null) uBound = uBound.findAllVars(varIdents, varTypes); |
|||
|
|||
return this; |
|||
} |
|||
|
|||
// type check |
|||
|
|||
public void typeCheck() throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.typeCheck(); |
|||
// check any time bounds are of type int/double |
|||
if (lBound != null) if (!(lBound.getType() == Expression.INT || lBound.getType() == Expression.DOUBLE)) { |
|||
throw new PrismException("Time bound \"" + lBound + "\" is the wrong type"); |
|||
} |
|||
if (uBound != null) if (!(uBound.getType() == Expression.INT || uBound.getType() == Expression.DOUBLE)) { |
|||
throw new PrismException("Time bound \"" + uBound + "\" is the wrong type"); |
|||
} |
|||
} |
|||
|
|||
// check everything is ok |
|||
|
|||
public void check() throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.check(); |
|||
// check any time bounds are ok and constant |
|||
if (lBound != null) { |
|||
lBound.check(); |
|||
if (!lBound.isConstant()) { |
|||
throw new PrismException("Time bound \"" + lBound + "\" is not constant"); |
|||
} |
|||
} |
|||
if (uBound != null) { |
|||
uBound.check(); |
|||
if (!uBound.isConstant()) { |
|||
throw new PrismException("Time bound \"" + uBound + "\" is not constant"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// check if formula is valid pctl |
|||
|
|||
public void checkValidPCTL() throws PrismException |
|||
{ |
|||
// must have upper bound only |
|||
if (lBound != null) throw new PrismException("PCTL bounded future formulas must have bounds of the form \"<=k\""); |
|||
// and it must be an integer |
|||
if (uBound.getType() != Expression.INT) throw new PrismException("Bounds in PCTL bounded future formulas must be of type integer"); |
|||
} |
|||
|
|||
// check if formula is valid csl |
|||
|
|||
public void checkValidCSL() throws PrismException |
|||
{ |
|||
// ok |
|||
} |
|||
|
|||
/** |
|||
* Convert and build simulator data structures |
|||
* Note: Although the simulator supports ProbBoundedFuture operators, they are |
|||
* only supported if they belong to a top-most Prob formulae, and so are not |
|||
* handled by a toSimulator method. Therefore, this method will only be called |
|||
* in error and hence throws an exception. |
|||
*/ |
|||
public int toSimulator(SimulatorEngine sim ) throws SimulatorException |
|||
{ |
|||
throw new SimulatorException("Unexpected Error when loading PCTL Formula into Simulator - BoundedFuture toSimulator should never be called"); |
|||
} |
|||
|
|||
// convert to string |
|||
|
|||
public String toString() |
|||
{ |
|||
String s = ""; |
|||
|
|||
s += "F"; |
|||
if (lBound == null) { |
|||
s += "<=" + uBound; |
|||
} |
|||
else if (uBound == null) { |
|||
s += ">=" + lBound; |
|||
} |
|||
else { |
|||
s += "[" + lBound + "," + uBound + "]"; |
|||
} |
|||
s += " " + operand; |
|||
|
|||
return s; |
|||
} |
|||
} |
|||
|
|||
//------------------------------------------------------------------------------ |
|||
@ -0,0 +1,167 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2002-2004, Dave Parker |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of the GNU General Public License as published by |
|||
// the Free Software Foundation; either version 2 of the License, or |
|||
// (at your option) any later version. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package parser; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
import prism.PrismException; |
|||
import simulator.*; |
|||
|
|||
public class PCTLProbBoundedGlobal extends PCTLFormulaUnary |
|||
{ |
|||
Expression lBound = null; // none if null, i.e. zero |
|||
Expression uBound = null; // none if null, i.e. infinity |
|||
|
|||
// constructor |
|||
|
|||
public PCTLProbBoundedGlobal(PCTLFormula f, Expression l, Expression u) |
|||
{ |
|||
super(f); |
|||
lBound = l; |
|||
uBound = u; |
|||
} |
|||
|
|||
public Expression getLowerBound() |
|||
{ |
|||
return lBound; |
|||
} |
|||
|
|||
public Expression getUpperBound() |
|||
{ |
|||
return uBound; |
|||
} |
|||
|
|||
// find all constants (i.e. locate idents which are constants) |
|||
|
|||
public PCTLFormula findAllConstants(ConstantList constantList) throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.findAllConstants(constantList); |
|||
// also do bound expressions |
|||
if (lBound != null) lBound = lBound.findAllConstants(constantList); |
|||
if (uBound != null) uBound = uBound.findAllConstants(constantList); |
|||
|
|||
return this; |
|||
} |
|||
|
|||
// find all variables (i.e. locate idents which are variables) |
|||
|
|||
public PCTLFormula findAllVars(Vector varIdents, Vector varTypes) throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.findAllVars(varIdents, varTypes); |
|||
// also do bound expressions |
|||
if (lBound != null) lBound = lBound.findAllVars(varIdents, varTypes); |
|||
if (uBound != null) uBound = uBound.findAllVars(varIdents, varTypes); |
|||
|
|||
return this; |
|||
} |
|||
|
|||
// type check |
|||
|
|||
public void typeCheck() throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.typeCheck(); |
|||
// check any time bounds are of type int/double |
|||
if (lBound != null) if (!(lBound.getType() == Expression.INT || lBound.getType() == Expression.DOUBLE)) { |
|||
throw new PrismException("Time bound \"" + lBound + "\" is the wrong type"); |
|||
} |
|||
if (uBound != null) if (!(uBound.getType() == Expression.INT || uBound.getType() == Expression.DOUBLE)) { |
|||
throw new PrismException("Time bound \"" + uBound + "\" is the wrong type"); |
|||
} |
|||
} |
|||
|
|||
// check everything is ok |
|||
|
|||
public void check() throws PrismException |
|||
{ |
|||
// call superclass (binary) |
|||
super.check(); |
|||
// check any time bounds are ok and constant |
|||
if (lBound != null) { |
|||
lBound.check(); |
|||
if (!lBound.isConstant()) { |
|||
throw new PrismException("Time bound \"" + lBound + "\" is not constant"); |
|||
} |
|||
} |
|||
if (uBound != null) { |
|||
uBound.check(); |
|||
if (!uBound.isConstant()) { |
|||
throw new PrismException("Time bound \"" + uBound + "\" is not constant"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// check if formula is valid pctl |
|||
|
|||
public void checkValidPCTL() throws PrismException |
|||
{ |
|||
// must have upper bound only |
|||
if (lBound != null) throw new PrismException("PCTL bounded global formulas must have bounds of the form \"<=k\""); |
|||
// and it must be an integer |
|||
if (uBound.getType() != Expression.INT) throw new PrismException("Bounds in PCTL bounded global formulas must be of type integer"); |
|||
} |
|||
|
|||
// check if formula is valid csl |
|||
|
|||
public void checkValidCSL() throws PrismException |
|||
{ |
|||
// ok |
|||
} |
|||
|
|||
/** |
|||
* Convert and build simulator data structures |
|||
* Note: Although the simulator supports ProbBoundedGlobal operators, they are |
|||
* only supported if they belong to a top-most Prob formulae, and so are not |
|||
* handled by a toSimulator method. Therefore, this method will only be called |
|||
* in error and hence throws an exception. |
|||
*/ |
|||
public int toSimulator(SimulatorEngine sim ) throws SimulatorException |
|||
{ |
|||
throw new SimulatorException("Unexpected Error when loading PCTL Formula into Simulator - BoundedGlobal toSimulator should never be called"); |
|||
} |
|||
|
|||
// convert to string |
|||
|
|||
public String toString() |
|||
{ |
|||
String s = ""; |
|||
|
|||
s += "G"; |
|||
if (lBound == null) { |
|||
s += "<=" + uBound; |
|||
} |
|||
else if (uBound == null) { |
|||
s += ">=" + lBound; |
|||
} |
|||
else { |
|||
s += "[" + lBound + "," + uBound + "]"; |
|||
} |
|||
s += " " + operand; |
|||
|
|||
return s; |
|||
} |
|||
} |
|||
|
|||
//------------------------------------------------------------------------------ |
|||
@ -0,0 +1,57 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2002-2004, Dave Parker |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of the GNU General Public License as published by |
|||
// the Free Software Foundation; either version 2 of the License, or |
|||
// (at your option) any later version. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package parser; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
import prism.PrismException; |
|||
import simulator.*; |
|||
|
|||
public class PCTLProbFuture extends PCTLFormulaUnary |
|||
{ |
|||
// constructor |
|||
|
|||
public PCTLProbFuture(PCTLFormula f) |
|||
{ |
|||
super(f); |
|||
} |
|||
|
|||
/** |
|||
* Convert and build simulator data structures |
|||
* Note: Although the simulator supports ProbFuture operators, they are |
|||
* only supported if they belong to a top-most Prob formulae, and so are not |
|||
* handled by a toSimulator method. Therefore, this method will only be called |
|||
* in error and hence throws an exception. |
|||
*/ |
|||
public int toSimulator(SimulatorEngine sim ) throws SimulatorException |
|||
{ |
|||
throw new SimulatorException("Unexpected error when loading PCTL formula into simulator - Future toSimulator should never be called"); |
|||
} |
|||
|
|||
// convert to string |
|||
|
|||
public String toString() |
|||
{ |
|||
return "F " + operand; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2002-2004, Dave Parker |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of the GNU General Public License as published by |
|||
// the Free Software Foundation; either version 2 of the License, or |
|||
// (at your option) any later version. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package parser; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
import prism.PrismException; |
|||
import simulator.*; |
|||
|
|||
public class PCTLProbGlobal extends PCTLFormulaUnary |
|||
{ |
|||
// constructor |
|||
|
|||
public PCTLProbGlobal(PCTLFormula f) |
|||
{ |
|||
super(f); |
|||
} |
|||
|
|||
/** |
|||
* Convert and build simulator data structures |
|||
* Note: Although the simulator supports ProbGlobal operators, they are |
|||
* only supported if they belong to a top-most Prob formulae, and so are not |
|||
* handled by a toSimulator method. Therefore, this method will only be called |
|||
* in error and hence throws an exception. |
|||
*/ |
|||
public int toSimulator(SimulatorEngine sim ) throws SimulatorException |
|||
{ |
|||
throw new SimulatorException("Unexpected error when loading PCTL formula into simulator - Global toSimulator should never be called"); |
|||
} |
|||
|
|||
// convert to string |
|||
|
|||
public String toString() |
|||
{ |
|||
return "G " + operand; |
|||
} |
|||
} |
|||
1758
prism/src/parser/PrismParser.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue