|
| 1 | +/* This file is part of KeY - https://key-project.org |
| 2 | + * KeY is licensed under the GNU General Public License Version 2 |
| 3 | + * SPDX-License-Identifier: GPL-2.0-only */ |
| 4 | + |
| 5 | +\schemaVariables { |
| 6 | + \term T a, b; |
| 7 | + \term Set<[T]> s, t, EQ; |
| 8 | +} |
| 9 | + |
| 10 | +\rules { |
| 11 | + |
| 12 | + // -------------------------------------------------------------------------- |
| 13 | + // axioms for sElementOf |
| 14 | + // -------------------------------------------------------------------------- |
| 15 | + |
| 16 | + sElementOfSEmpty { |
| 17 | + \find(sElementOf<[T]>(a, sEmpty<[T]>)) |
| 18 | + \replacewith(false) |
| 19 | + \heuristics(concrete) |
| 20 | + }; |
| 21 | + |
| 22 | + sElementOfSSingleton { |
| 23 | + \find(sElementOf<[T]>(a, sSingleton<[T]>(b))) |
| 24 | + \replacewith(a = b) |
| 25 | + \heuristics(simplify) |
| 26 | + }; |
| 27 | + |
| 28 | + sElementOfSUnion { |
| 29 | + \find(sElementOf<[T]>(a, sUnion<[T]>(s, t))) |
| 30 | + \replacewith(sElementOf<[T]>(a, s) | sElementOf<[T]>(a, t)) |
| 31 | + \heuristics(simplify_enlarging) |
| 32 | + }; |
| 33 | + |
| 34 | + sElementOfSIntersect { |
| 35 | + \find(sElementOf<[T]>(a, sIntersect<[T]>(s, t))) |
| 36 | + \replacewith(sElementOf<[T]>(a, s) & sElementOf<[T]>(a, t)) |
| 37 | + \heuristics(simplify_enlarging) |
| 38 | + }; |
| 39 | + |
| 40 | + sElementOfSSetMinus { |
| 41 | + \find(sElementOf<[T]>(a, sSetMinus<[T]>(s, t))) |
| 42 | + \replacewith(sElementOf<[T]>(a, s) & !sElementOf<[T]>(a, t)) |
| 43 | + \heuristics(simplify_enlarging) |
| 44 | + }; |
| 45 | + |
| 46 | + sElementOfSInfiniteUnion { |
| 47 | + // TODO: alpha or any (was like this already in locSetsRules)? |
| 48 | + \schemaVar \variables alpha av; |
| 49 | + \find(sElementOf<[T]>(a, sInfiniteUnion<[T]>{av;}(s))) |
| 50 | + \varcond(\notFreeIn(av, a)) |
| 51 | + \replacewith(\exists av; sElementOf<[T]>(a, s)) |
| 52 | + \heuristics(simplify) |
| 53 | + }; |
| 54 | + |
| 55 | + // -------------------------------------------------------------------------- |
| 56 | + // EQ versions of axioms (these are lemmata) |
| 57 | + // -------------------------------------------------------------------------- |
| 58 | + sElementOfSUnionEQ { |
| 59 | + \assumes(sUnion<[T]>(s, t) = EQ ==>) |
| 60 | + \find(sElementOf<[T]>(a, EQ)) |
| 61 | + \sameUpdateLevel |
| 62 | + \replacewith(sElementOf<[T]>(a, s) | sElementOf<[T]>(a, t)) |
| 63 | + \heuristics(simplify_enlarging) |
| 64 | + }; |
| 65 | + |
| 66 | + sElementOfSIntersectEQ { |
| 67 | + \assumes(sIntersect<[T]>(s, t) = EQ ==>) |
| 68 | + \find(sElementOf<[T]>(a, EQ)) |
| 69 | + \sameUpdateLevel |
| 70 | + \replacewith(sElementOf<[T]>(a, s) & sElementOf<[T]>(a, t)) |
| 71 | + \heuristics(simplify_enlarging) |
| 72 | + }; |
| 73 | + |
| 74 | + sElementOfSetMinusEQ { |
| 75 | + \assumes(sSetMinus<[T]>(s, t) = EQ ==>) |
| 76 | + \find(sElementOf<[T]>(a, EQ)) |
| 77 | + \sameUpdateLevel |
| 78 | + \replacewith(sElementOf<[T]>(a, s) & !sElementOf<[T]>(a, t)) |
| 79 | + \heuristics(simplify_enlarging) |
| 80 | + }; |
| 81 | + |
| 82 | + sElementOfSInfiniteUnionEQ { |
| 83 | + // TODO: alpha or any (was like this already in locSetsRules)? |
| 84 | + \schemaVar \variables alpha av; |
| 85 | + \assumes(sInfiniteUnion<[T]>{av;}(s) = EQ ==>) |
| 86 | + \find(sElementOf<[T]>(a, EQ)) |
| 87 | + \sameUpdateLevel |
| 88 | + \varcond(\notFreeIn(av, a)) |
| 89 | + \replacewith(\exists av; sElementOf<[T]>(a, s)) |
| 90 | + \heuristics(simplify) |
| 91 | + }; |
| 92 | + |
| 93 | + // -------------------------------------------------------------------------- |
| 94 | + // axioms for cardinality |
| 95 | + // -------------------------------------------------------------------------- |
| 96 | + sCardNonNegative { |
| 97 | + \find(sCard<[T]>(s)) |
| 98 | + \sameUpdateLevel |
| 99 | + \add(sCard<[T]>(s) >= 0 ==>) |
| 100 | + \heuristics(inReachableStateImplication) |
| 101 | + }; |
| 102 | + |
| 103 | + sCardSEmpty { |
| 104 | + \find(sCard<[T]>(sEmpty<[T]>)) |
| 105 | + \replacewith(0) |
| 106 | + \heuristics(concrete) |
| 107 | + }; |
| 108 | + |
| 109 | + sCardSSingleton { |
| 110 | + \find(sCard<[T]>(sSingleton<[T]>(b))) |
| 111 | + \replacewith(1) |
| 112 | + \heuristics(simplify) |
| 113 | + }; |
| 114 | + |
| 115 | + // -------------------------------------------------------------------------- |
| 116 | + // axioms for set predicates (reduce to sElementOf) |
| 117 | + // -------------------------------------------------------------------------- |
| 118 | + |
| 119 | + sEmptyEqualsSSingleton { |
| 120 | + \find(sEmpty<[T]> = sSingleton<[T]>(a)) |
| 121 | + \replacewith(false) |
| 122 | + \heuristics(concrete) |
| 123 | + }; |
| 124 | + |
| 125 | + sSingletonEqualsSEmpty { |
| 126 | + \find(sSingleton<[T]>(a) = sEmpty<[T]>) |
| 127 | + \replacewith(false) |
| 128 | + \heuristics(concrete) |
| 129 | + }; |
| 130 | + |
| 131 | + sUnionWithSSingletonEqualsSUnionWithSSingleton { |
| 132 | + \find(sUnion<[T]>(s, sSingleton<[T]>(a)) = sUnion<[T]>(t, sSingleton<[T]>(a))) |
| 133 | + |
| 134 | + \replacewith(sSetMinus<[T]>(s, sSingleton<[T]>(a)) = sSetMinus<[T]>(t, sSingleton<[T]>(a))) |
| 135 | + \heuristics(simplify) |
| 136 | + }; |
| 137 | + |
| 138 | + sUnionWithSSingletonEqualsSUnionWithSSingleton_2 { |
| 139 | + \find(sUnion<[T]>(sSingleton<[T]>(a), s) = sUnion<[T]>(sSingleton<[T]>(a), t)) |
| 140 | + \replacewith(sSetMinus<[T]>(s, sSingleton<[T]>(a)) = sSetMinus<[T]>(t, sSingleton<[T]>(a))) |
| 141 | + \heuristics(simplify) |
| 142 | + }; |
| 143 | + |
| 144 | + equalityToSElementOf { |
| 145 | + \schemaVar \variables T av; |
| 146 | + \find(s = t) |
| 147 | + \varcond(\notFreeIn(av, s, t)) |
| 148 | + \replacewith(\forall av; (sElementOf<[T]>(av, s) <-> sElementOf<[T]>(av, t))) |
| 149 | + //\heuristics(semantics_blasting) |
| 150 | + \heuristics(simplify_enlarging) |
| 151 | + }; |
| 152 | + |
| 153 | + sSubsetToSElementOf { |
| 154 | + \schemaVar \variables T av; |
| 155 | + \find(sSubset<[T]>(s, t)) |
| 156 | + \varcond(\notFreeIn(av, s, t)) |
| 157 | + \replacewith(\forall av; (sElementOf<[T]>(av, s) -> sElementOf<[T]>(av, t))) |
| 158 | + //\heuristics(semantics_blasting) |
| 159 | + \heuristics(simplify_enlarging) |
| 160 | + }; |
| 161 | + |
| 162 | + sDisjointToSElementOf { |
| 163 | + \schemaVar \variables T av; |
| 164 | + \find(sDisjoint<[T]>(s, t)) |
| 165 | + \varcond(\notFreeIn(av, s, t)) |
| 166 | + \replacewith(\forall av; (!sElementOf<[T]>(av, s) | !sElementOf<[T]>(av, t))) |
| 167 | +// \heuristics(semantics_blasting) |
| 168 | + \heuristics(simplify_enlarging) |
| 169 | + }; |
| 170 | +} |
0 commit comments