|
| 1 | +module REMAINDER-PREDICATES |
| 2 | + imports INT |
| 3 | + imports BOOL |
| 4 | + |
| 5 | + syntax State ::= test1Init() |
| 6 | + | test1State1() |
| 7 | + | test1State2() |
| 8 | + | test1State3() |
| 9 | + |
| 10 | + | test2Init() |
| 11 | + | test2State1() |
| 12 | + | test2State2() |
| 13 | + | test2State3() |
| 14 | + |
| 15 | + | test3Init() |
| 16 | + | test3State1() |
| 17 | + | test3State2() |
| 18 | + | test3State3() |
| 19 | + |
| 20 | + | test4Init() |
| 21 | + | test4State1() |
| 22 | + | test4State2() |
| 23 | + | test4State3() |
| 24 | + | test4State4() |
| 25 | + |
| 26 | + | test5Init() |
| 27 | + | test5State1() |
| 28 | + | test5State2() |
| 29 | + | test5State3() |
| 30 | + | test5State4() |
| 31 | + | test5State5() |
| 32 | + |
| 33 | + | test6Init() |
| 34 | + | test6State1() |
| 35 | + | test6State2() |
| 36 | + | test6State3() |
| 37 | + | test6State4() |
| 38 | + | test6State5() |
| 39 | + |
| 40 | + configuration <k> $PGM:State ~> .K </k> |
| 41 | + <int> 0:Int </int> |
| 42 | + |
| 43 | + //////////////////////////////////////////////////////////////////////////////// |
| 44 | + /// two rules apply with UNSAT remainder predicate, no further rules apply. // |
| 45 | + /// Results in 2 branches. // |
| 46 | + //////////////////////////////////////////////////////////////////////////////// |
| 47 | + rule [test1-init]: <k> test1Init() => test1State1() ... </k> |
| 48 | + <int> _ => ?_X </int> |
| 49 | + |
| 50 | + rule [test1-1-2]: <k> test1State1() => test1State2() ... </k> |
| 51 | + <int> X </int> |
| 52 | + requires X >Int 0 |
| 53 | + |
| 54 | + rule [test1-1-3]: <k> test1State1() => test1State3() ... </k> |
| 55 | + <int> X </int> |
| 56 | + requires X <=Int 0 |
| 57 | + |
| 58 | + //////////////////////////////////////////////////////////////////////////////// |
| 59 | + /// two rules apply with SAT remainder predicate, // |
| 60 | + /// have to consider the remainder branch where X ==Int 0, // |
| 61 | + /// no further rules apply. // |
| 62 | + /// Results in 2 branches. // |
| 63 | + //////////////////////////////////////////////////////////////////////////////// |
| 64 | + rule [test2-init]: <k> test2Init() => test2State1() ... </k> |
| 65 | + <int> _ => ?_X </int> |
| 66 | + |
| 67 | + rule [test2-1-2]: <k> test2State1() => test2State2() ... </k> |
| 68 | + <int> X </int> |
| 69 | + requires X >Int 0 |
| 70 | + |
| 71 | + rule [test2-1-3]: <k> test2State1() => test2State3() ... </k> |
| 72 | + <int> X </int> |
| 73 | + requires X <Int 0 |
| 74 | + |
| 75 | + //////////////////////////////////////////////////////////////////////////////// |
| 76 | + /// two rules apply with SAT remainder predicate, // |
| 77 | + /// have to consider the remainder branch where X ==Int 0, // |
| 78 | + /// but the are no further rules to apply. // |
| 79 | + /// Results in 2 branches. // |
| 80 | + //////////////////////////////////////////////////////////////////////////////// |
| 81 | + rule [test3-init]: <k> test3Init() => test3State1() ... </k> |
| 82 | + <int> _ => ?_X </int> |
| 83 | + |
| 84 | + rule [test3-1-2]: <k> test3State1() => test3State2() ... </k> |
| 85 | + <int> X </int> |
| 86 | + requires X >Int 0 |
| 87 | + |
| 88 | + rule [test3-1-3]: <k> test3State1() => test3State3() ... </k> |
| 89 | + <int> X </int> |
| 90 | + requires X <Int 0 |
| 91 | + |
| 92 | + //////////////////////////////////////////////////////////////////////////////// |
| 93 | + /// two hight-priorty rules apply with SAT remainder predicate, // |
| 94 | + /// have to consider the remainder branch where X ==Int 0, // |
| 95 | + /// one further regular rule applies, // |
| 96 | + /// whose requires clause explicitly completes the space. // |
| 97 | + /// Results in 3 branches. // |
| 98 | + //////////////////////////////////////////////////////////////////////////////// |
| 99 | + rule [test4-init]: <k> test4Init() => test4State1() ... </k> |
| 100 | + <int> _ => ?_X </int> |
| 101 | + |
| 102 | + rule [test4-1-2]: <k> test4State1() => test4State2() ... </k> |
| 103 | + <int> X </int> |
| 104 | + requires X >Int 0 |
| 105 | + [priority(49)] |
| 106 | + |
| 107 | + rule [test4-1-3]: <k> test4State1() => test4State3() ... </k> |
| 108 | + <int> X </int> |
| 109 | + requires X <Int 0 |
| 110 | + [priority(49)] |
| 111 | + |
| 112 | + rule [test4-1-4]: <k> test4State1() => test4State4() ... </k> |
| 113 | + <int> X </int> |
| 114 | + requires X ==Int 0 |
| 115 | + |
| 116 | + |
| 117 | + //////////////////////////////////////////////////////////////////////////////// |
| 118 | + /// two hight-priorty rules apply with SAT remainder predicate, // |
| 119 | + /// have to consider the remainder branch where X ==Int 0, // |
| 120 | + /// one rule at a lower priority applies unconditionally, which means that // |
| 121 | + /// that the remainder is False. Rule test5-1-5 is unreachable. // |
| 122 | + /// Results in 3 branches. // |
| 123 | + //////////////////////////////////////////////////////////////////////////////// |
| 124 | + rule [test5-init]: <k> test5Init() => test5State1() ... </k> |
| 125 | + <int> _ => ?_X </int> |
| 126 | + |
| 127 | + rule [test5-1-2]: <k> test5State1() => test5State2() ... </k> |
| 128 | + <int> X </int> |
| 129 | + requires X >Int 0 [priority(48)] |
| 130 | + |
| 131 | + rule [test5-1-3]: <k> test5State1() => test5State3() ... </k> |
| 132 | + <int> X </int> |
| 133 | + requires X <Int 0 [priority(48)] |
| 134 | + |
| 135 | + rule [test5-1-4]: <k> test5State1() => test5State4() ... </k> |
| 136 | + [priority(49)] |
| 137 | + |
| 138 | + rule [test5-1-5]: <k> test5State1() => test5State5() ... </k> |
| 139 | + <int> X </int> |
| 140 | + requires X ==Int 0 |
| 141 | + |
| 142 | + //////////////////////////////////////////////////////////////////////////////// |
| 143 | + /// two hight-priorty rules apply with SAT remainder predicate, // |
| 144 | + /// have to consider the remainder branch where X ==Int 0, // |
| 145 | + /// two rule at a lower priority applies unconditionally. // |
| 146 | + /// Results in 4 branches. // |
| 147 | + //////////////////////////////////////////////////////////////////////////////// |
| 148 | + rule [test6-init]: <k> test6Init() => test6State1() ... </k> |
| 149 | + <int> _ => ?_X </int> |
| 150 | + |
| 151 | + rule [test6-1-2]: <k> test6State1() => test6State2() ... </k> |
| 152 | + <int> X </int> |
| 153 | + requires X >Int 0 [priority(48)] |
| 154 | + |
| 155 | + rule [test6-1-3]: <k> test6State1() => test6State3() ... </k> |
| 156 | + <int> X </int> |
| 157 | + requires X <Int 0 [priority(48)] |
| 158 | + |
| 159 | + rule [test6-1-4]: <k> test6State1() => test6State4() ... </k> |
| 160 | + [priority(49)] |
| 161 | + |
| 162 | + rule [test6-1-5]: <k> test6State1() => test6State5() ... </k> |
| 163 | + [priority(49)] |
| 164 | + |
| 165 | +// to produce input state: |
| 166 | +// krun --output kore --depth 1 -cPGM='test1Init()' | kore-parser test-kompiled/definition.kore --module TEST --pattern /dev/stdin --print-pattern-json > state-test1Init.json |
| 167 | +// then edit state-test1Init.json to substitute test1State1() for test1Init() |
| 168 | + |
| 169 | +endmodule |
0 commit comments