|
| 1 | +// Author: Diffblue Ltd. |
| 2 | + |
| 3 | +#include <solvers/smt2_incremental/smt_core_theory.h> |
| 4 | + |
| 5 | +const char *smt_core_theoryt::nott::identifier() |
| 6 | +{ |
| 7 | + return "not"; |
| 8 | +} |
| 9 | + |
| 10 | +smt_sortt smt_core_theoryt::nott::return_sort(const smt_termt &operand) |
| 11 | +{ |
| 12 | + return smt_bool_sortt{}; |
| 13 | +} |
| 14 | + |
| 15 | +void smt_core_theoryt::nott::validate(const smt_termt &operand) |
| 16 | +{ |
| 17 | + INVARIANT( |
| 18 | + operand.get_sort() == smt_bool_sortt{}, |
| 19 | + "\"not\" may only be applied to terms which have bool sort."); |
| 20 | +} |
| 21 | + |
| 22 | +const smt_function_application_termt::factoryt<smt_core_theoryt::nott> |
| 23 | + smt_core_theoryt::make_not{}; |
| 24 | + |
| 25 | +const char *smt_core_theoryt::impliest::identifier() |
| 26 | +{ |
| 27 | + return "=>"; |
| 28 | +} |
| 29 | + |
| 30 | +smt_sortt |
| 31 | +smt_core_theoryt::impliest::return_sort(const smt_termt &, const smt_termt &) |
| 32 | +{ |
| 33 | + return smt_bool_sortt{}; |
| 34 | +} |
| 35 | + |
| 36 | +void smt_core_theoryt::impliest::validate( |
| 37 | + const smt_termt &lhs, |
| 38 | + const smt_termt &rhs) |
| 39 | +{ |
| 40 | + INVARIANT( |
| 41 | + lhs.get_sort() == smt_bool_sortt{}, |
| 42 | + "Left hand side of \"=>\" must have bool sort."); |
| 43 | + INVARIANT( |
| 44 | + rhs.get_sort() == smt_bool_sortt{}, |
| 45 | + "Right hand side of \"=>\" must have bool sort."); |
| 46 | +} |
| 47 | + |
| 48 | +const smt_function_application_termt::factoryt<smt_core_theoryt::impliest> |
| 49 | + smt_core_theoryt::implies{}; |
| 50 | + |
| 51 | +const char *smt_core_theoryt::andt::identifier() |
| 52 | +{ |
| 53 | + return "and"; |
| 54 | +} |
| 55 | + |
| 56 | +smt_sortt |
| 57 | +smt_core_theoryt::andt::return_sort(const smt_termt &, const smt_termt &) |
| 58 | +{ |
| 59 | + return smt_bool_sortt{}; |
| 60 | +} |
| 61 | + |
| 62 | +void smt_core_theoryt::andt::validate( |
| 63 | + const smt_termt &lhs, |
| 64 | + const smt_termt &rhs) |
| 65 | +{ |
| 66 | + INVARIANT( |
| 67 | + lhs.get_sort() == smt_bool_sortt{}, |
| 68 | + "Left hand side of \"and\" must have bool sort."); |
| 69 | + INVARIANT( |
| 70 | + rhs.get_sort() == smt_bool_sortt{}, |
| 71 | + "Right hand side of \"and\" must have bool sort."); |
| 72 | +} |
| 73 | + |
| 74 | +const smt_function_application_termt::factoryt<smt_core_theoryt::andt> |
| 75 | + smt_core_theoryt::make_and{}; |
| 76 | + |
| 77 | +const char *smt_core_theoryt::ort::identifier() |
| 78 | +{ |
| 79 | + return "or"; |
| 80 | +} |
| 81 | + |
| 82 | +smt_sortt |
| 83 | +smt_core_theoryt::ort::return_sort(const smt_termt &, const smt_termt &) |
| 84 | +{ |
| 85 | + return smt_bool_sortt{}; |
| 86 | +} |
| 87 | + |
| 88 | +void smt_core_theoryt::ort::validate(const smt_termt &lhs, const smt_termt &rhs) |
| 89 | +{ |
| 90 | + INVARIANT( |
| 91 | + lhs.get_sort() == smt_bool_sortt{}, |
| 92 | + "Left hand side of \"or\" must have bool sort."); |
| 93 | + INVARIANT( |
| 94 | + rhs.get_sort() == smt_bool_sortt{}, |
| 95 | + "Right hand side of \"or\" must have bool sort."); |
| 96 | +} |
| 97 | + |
| 98 | +const smt_function_application_termt::factoryt<smt_core_theoryt::ort> |
| 99 | + smt_core_theoryt::make_or{}; |
| 100 | + |
| 101 | +const char *smt_core_theoryt::xort::identifier() |
| 102 | +{ |
| 103 | + return "xor"; |
| 104 | +} |
| 105 | + |
| 106 | +smt_sortt |
| 107 | +smt_core_theoryt::xort::return_sort(const smt_termt &, const smt_termt &) |
| 108 | +{ |
| 109 | + return smt_bool_sortt{}; |
| 110 | +} |
| 111 | + |
| 112 | +void smt_core_theoryt::xort::validate( |
| 113 | + const smt_termt &lhs, |
| 114 | + const smt_termt &rhs) |
| 115 | +{ |
| 116 | + INVARIANT( |
| 117 | + lhs.get_sort() == smt_bool_sortt{}, |
| 118 | + "Left hand side of \"xor\" must have bool sort."); |
| 119 | + INVARIANT( |
| 120 | + rhs.get_sort() == smt_bool_sortt{}, |
| 121 | + "Right hand side of \"xor\" must have bool sort."); |
| 122 | +} |
| 123 | + |
| 124 | +const smt_function_application_termt::factoryt<smt_core_theoryt::xort> |
| 125 | + smt_core_theoryt::make_xor{}; |
| 126 | + |
| 127 | +const char *smt_core_theoryt::equalt::identifier() |
| 128 | +{ |
| 129 | + return "="; |
| 130 | +} |
| 131 | + |
| 132 | +smt_sortt |
| 133 | +smt_core_theoryt::equalt::return_sort(const smt_termt &, const smt_termt &) |
| 134 | +{ |
| 135 | + return smt_bool_sortt{}; |
| 136 | +} |
| 137 | + |
| 138 | +void smt_core_theoryt::equalt::validate( |
| 139 | + const smt_termt &lhs, |
| 140 | + const smt_termt &rhs) |
| 141 | +{ |
| 142 | + INVARIANT( |
| 143 | + lhs.get_sort() == rhs.get_sort(), |
| 144 | + "\"=\" may only be applied to terms which have the same sort."); |
| 145 | +} |
| 146 | + |
| 147 | +const smt_function_application_termt::factoryt<smt_core_theoryt::equalt> |
| 148 | + smt_core_theoryt::equal{}; |
| 149 | + |
| 150 | +const char *smt_core_theoryt::distinctt::identifier() |
| 151 | +{ |
| 152 | + return "distinct"; |
| 153 | +} |
| 154 | + |
| 155 | +smt_sortt |
| 156 | +smt_core_theoryt::distinctt::return_sort(const smt_termt &, const smt_termt &) |
| 157 | +{ |
| 158 | + return smt_bool_sortt{}; |
| 159 | +} |
| 160 | + |
| 161 | +void smt_core_theoryt::distinctt::validate( |
| 162 | + const smt_termt &lhs, |
| 163 | + const smt_termt &rhs) |
| 164 | +{ |
| 165 | + INVARIANT( |
| 166 | + lhs.get_sort() == rhs.get_sort(), |
| 167 | + "\"distinct\" may only be applied to terms which have the same sort."); |
| 168 | +} |
| 169 | + |
| 170 | +const smt_function_application_termt::factoryt<smt_core_theoryt::distinctt> |
| 171 | + smt_core_theoryt::distinct{}; |
| 172 | + |
| 173 | +const char *smt_core_theoryt::if_then_elset::identifier() |
| 174 | +{ |
| 175 | + return "ite"; |
| 176 | +} |
| 177 | + |
| 178 | +smt_sortt smt_core_theoryt::if_then_elset::return_sort( |
| 179 | + const smt_termt &, |
| 180 | + const smt_termt &then_term, |
| 181 | + const smt_termt &) |
| 182 | +{ |
| 183 | + return then_term.get_sort(); |
| 184 | +} |
| 185 | + |
| 186 | +void smt_core_theoryt::if_then_elset::validate( |
| 187 | + const smt_termt &condition, |
| 188 | + const smt_termt &then_term, |
| 189 | + const smt_termt &else_term) |
| 190 | +{ |
| 191 | + INVARIANT( |
| 192 | + condition.get_sort() == smt_bool_sortt{}, |
| 193 | + "Condition term must have bool sort."); |
| 194 | + INVARIANT( |
| 195 | + then_term.get_sort() == else_term.get_sort(), |
| 196 | + "\"ite\" must have \"then\" and \"else\" terms of the same sort."); |
| 197 | +} |
| 198 | + |
| 199 | +const smt_function_application_termt::factoryt<smt_core_theoryt::if_then_elset> |
| 200 | + smt_core_theoryt::if_then_else; |
0 commit comments