1#include "storm-config.h"
8TEST(PrismParser, StandardModelTest) {
21TEST(PrismParser, SimpleTest) {
22 std::string testInput =
26 [a] true -> 1: (b'=true != false = b => false);
53TEST(PrismParser, expressionTest) {
54 std::string testInput = R
"(dtmc
58 [] c = ceil(log(1,2)) -> (c'=1);
68 auto const& guard = result.
getModule(
"test").
getCommands().front().getGuardExpression().getBaseExpression();
69 ASSERT_TRUE(guard.isBinaryRelationExpression());
70 EXPECT_EQ(0ll, guard.asBinaryRelationExpression().getSecondOperand()->evaluateAsInt());
73TEST(PrismParser, FormulaOrderTest) {
76 std::string testInput =
79 formula leader_set = ((A_mark & A_leader = current_min_leader_calc | A_mark = false)?true:false) & ((B_mark & B_leader = current_min_leader_calc | B_mark = false)?true:false);
81 formula current_min_leader_calc = min((A_mark?A_leader:8), (B_mark?B_leader:8));
84 A_mark : bool init true;
85 B_mark : bool init true;
87 test1 : bool init false;
89 A_leader : [0..10] init 1;
90 B_leader : [0..10] init 1;
92 [] A_mark = true & leader_set & test1 = false -> (test1'=true);
97 ASSERT_TRUE(result.
hasModule(
"whatever"));
101TEST(PrismParser, NonReservedPlayerKeywordTest) {
103 std::string testInput =
107 player : [0..5] init 0;
108 [] player < 5 -> (player'=player+1);
118TEST(PrismParser, NonReservedInvariantKeywordTest) {
120 std::string testInput =
124 invariant : [0..5] init 0;
125 [] invariant < 5 -> (invariant'=invariant+1);
135TEST(PrismParser, ComplexTest) {
136 std::string testInput =
142 const bool d = true | false;
146 formula test = a >= 10 & (max(a,b) > floor(e));
148 formula test3 = (a + b > 10 ? floor(e) : h) + a;
150 global g : bool init false;
158 [a] test&false -> (i'=true)&(k'=1+1) + 1 : (k'=floor(e) + max(k, b) - 1 + k);
163 [] (k > 3) & false & (min(a, 0) < max(h, k)) -> 1-e: (g'=(1-a) * 2 + floor(f) > 2);
166 module mod3 = mod1 [ i = i1, j = j1, k = k1 ] endmodule
168 label "mal" = max(a, 10) > 0;
170 rewards "testrewards"
172 max(f, a) <= 8 : 2*b;
175 rewards "testrewards2"
177 max(f, a) <= 8 : 2*b;
189TEST(PrismParser, UnboundedTest) {
190 std::string testInput =
194 [a] true -> 1: (b'=b+1);
204TEST(PrismParser, POMDPInputTest) {
205 std::string testInput =
215 [] s=0 -> 0.5: (s'=1) & (i'=false) + 0.5: (s'=2) & (i'=false);
216 [] s=1 | s=2 -> 1: (s'=3) & (i'=true);
217 [r] s=1 -> 1: (s'=4) & (i'=true);
218 [r] s=2 -> 1: (s'=3) & (i'=true);
226 std::string testInput2 =
229 observable intermediate = s=1 | s=2;
233 [] s=0 -> 0.5: (s'=1) + 0.5: (s'=2);
234 [l] s=1 -> 1: (s'=3);
235 [l] s=2 -> 1: (s'=4);
236 [r] s=1 -> 1: (s'=4);
237 [r] s=2 -> 1: (s'=3);
244 std::string testInput3 =
256 [] s=0 -> 0.5: (s'=1) & (i'=false) + 0.5: (s'=2) & (i'=false);
257 [] s=1 | s=2 -> 1: (s'=3) & (i'=true);
258 [r] s=1 -> 1: (s'=4) & (i'=true);
259 [r] s=2 -> 1: (s'=3) & (i'=true);
268 std::string testInput4 =
284 [] s=0 -> 0.5: (s'=1) & (i'=false) + 0.5: (s'=2) & (i'=false);
285 [] s=1 | s=2 -> 1: (s'=3) & (i'=true);
286 [r] s=1 -> 1: (s'=4) & (i'=true);
287 [r] s=2 -> 1: (s'=3) & (i'=true);
295TEST(PrismParser, NAryPredicates) {
296 std::string testInput =
302 [] s=0 -> 0.5: (s'=1) & (i'=false) + 0.5: (s'=2) & (i'=false);
303 [] s=1 | s=2 -> 1: (s'=3) & (i'=true);
304 [r] s=1 -> 1: (s'=4) & (i'=true);
305 [r] s=2 -> 1: (s'=3) & (i'=true);
308 label "test" = atMostOneOf(s=0, s=3, s=4);
309 label "test2" = exactlyOneOf(s=0, i, !i & s=3);
316TEST(PrismParser, Intervals) {
317 std::string testInput =
323 [] s=0 -> [0.5,0.9]: (s'=1) & (i'=false) + [0.4,0.6] : (s'=2) & (i'=false);
324 [] s=1 -> 1: (s'=3) & (i'=true);
325 [] s>0 -> [i?0.3:1/s,1]: (s'=4) & (i'=true) + 0.5 : (s'=3);
326 [r] s=2 -> 1: (s'=3) & (i'=true);
328 module example2 = example [ s = t, i = j ] endmodule
336TEST(PrismParser, IllegalInputTest) {
337 std::string testInput =
345 [] c < 3 -> 2: (c' = c+1);
359 [] a < 3 -> 1: (a' = a+1);
372 [] c < 3 -> 1: (c' = c+1);
388 [] c < 3 -> 1: (c' = c+1);
404 [] c < 3 -> 1: (c' = c+1);
408 [] c < 3 -> 1: (c' = c+1);
418 [] c < 3 -> 1: (c' = c+1)&(c'=c-1);
428 [] c < 3 -> 1: (c' = true || false);
438 [] c + 3 -> 1: (c' = 1);
448 [] c + 3 -> 1: (c' = 1);
451 label "test" = c + 1;
463 [] ma < 5 -> (ma'=ma+1);
473 player : [0..5] init 0;
474 [] player < 5 -> (player'=player+1);
484 invariant : [0..5] init 0;
490TEST(PrismParser, IllegalSynchronizedWriteTest) {
492 storm::exceptions::WrongFormatException);
TEST(PrismParser, StandardModelTest)
static storm::prism::Program parseFromString(std::string const &input, std::string const &filename, bool prismCompatability=false)
Parses the given input stream into the PRISM storage classes assuming it complies with the PRISM synt...
static storm::prism::Program parse(std::string const &filename, bool prismCompatability=false)
Parses the given file into the PRISM storage classes assuming it complies with the PRISM syntax.
std::vector< storm::prism::Command > const & getCommands() const
Retrieves the commands of the module.
std::vector< storm::prism::IntegerVariable > const & getIntegerVariables() const
Retrieves the integer variables of the module.
std::vector< storm::prism::BooleanVariable > const & getBooleanVariables() const
Retrieves the boolean variables of the module.
std::size_t getNumberOfIntegerVariables() const
Retrieves the number of integer variables in the module.
std::size_t getNumberOfCommands() const
Retrieves the number of commands of this module.
ModelType getModelType() const
Retrieves the model type of the model.
std::size_t getNumberOfLabels() const
Retrieves the number of labels in the program.
Module const & getModule(uint_fast64_t index) const
Retrieves the module with the given index.
std::size_t getNumberOfRewardModels() const
Retrieves the number of reward models in the program.
bool hasModule(std::string const &moduleName) const
Retrieves whether the program has a module with the given name.
bool hasUnboundedVariables() const
std::size_t getNumberOfModules() const
Retrieves the number of modules in the program.
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)