@@ -246,6 +246,39 @@ exprt string_constraint_generatort::add_axioms_for_to_lower_case(
246
246
return add_axioms_for_to_lower_case (res, str);
247
247
}
248
248
249
+ // / Expression which is true for uppercase characters of the Basic Latin and
250
+ // / Latin-1 supplement of unicode.
251
+ static exprt is_upper_case (const exprt &character)
252
+ {
253
+ const exprt char_A = from_integer (' A' , character.type ());
254
+ const exprt char_Z = from_integer (' Z' , character.type ());
255
+ exprt::operandst upper_case;
256
+ // Characters between 'A' and 'Z' are upper-case
257
+ upper_case.push_back (
258
+ and_exprt (
259
+ binary_relation_exprt (char_A, ID_le, character),
260
+ binary_relation_exprt (character, ID_le, char_Z)));
261
+
262
+ // Characters between 0xc0 (latin capital A with grave)
263
+ // and 0xd6 (latin capital O with diaeresis) are upper-case
264
+ upper_case.push_back (
265
+ and_exprt (
266
+ binary_relation_exprt (
267
+ from_integer (0xc0 , character.type ()), ID_le, character),
268
+ binary_relation_exprt (
269
+ character, ID_le, from_integer (0xd6 , character.type ()))));
270
+
271
+ // Characters between 0xd8 (latin capital O with stroke)
272
+ // and 0xde (latin capital thorn) are upper-case
273
+ upper_case.push_back (
274
+ and_exprt (
275
+ binary_relation_exprt (
276
+ from_integer (0xd8 , character.type ()), ID_le, character),
277
+ binary_relation_exprt (
278
+ character, ID_le, from_integer (0xde , character.type ()))));
279
+ return disjunction (upper_case);
280
+ }
281
+
249
282
// / Add axioms ensuring `res` corresponds to `str` in which uppercase characters
250
283
// / have been converted to lowercase.
251
284
// / These axioms are:
@@ -274,33 +307,6 @@ exprt string_constraint_generatort::add_axioms_for_to_lower_case(
274
307
275
308
constraints.push_back ([&] {
276
309
const symbol_exprt idx = fresh_univ_index (" QA_lower_case" , index_type);
277
-
278
- const exprt is_upper_case = disjunction ([&] {
279
- exprt::operandst upper_case;
280
- // Characters between 'A' and 'Z' are upper-case
281
- upper_case.push_back (
282
- and_exprt (
283
- binary_relation_exprt (char_A, ID_le, str[idx]),
284
- binary_relation_exprt (str[idx], ID_le, char_Z)));
285
-
286
- // Characters between 0xc0 (latin capital A with grave)
287
- // and 0xd6 (latin capital O with diaeresis) are upper-case
288
- upper_case.push_back (
289
- and_exprt (
290
- binary_relation_exprt (from_integer (0xc0 , char_type), ID_le, str[idx]),
291
- binary_relation_exprt (
292
- str[idx], ID_le, from_integer (0xd6 , char_type))));
293
-
294
- // Characters between 0xd8 (latin capital O with stroke)
295
- // and 0xde (latin capital thorn) are upper-case
296
- upper_case.push_back (
297
- and_exprt (
298
- binary_relation_exprt (from_integer (0xd8 , char_type), ID_le, str[idx]),
299
- binary_relation_exprt (
300
- str[idx], ID_le, from_integer (0xde , char_type))));
301
- return upper_case;
302
- }());
303
-
304
310
const exprt conditional_convert = [&] {
305
311
// The difference between upper-case and lower-case for the basic latin and
306
312
// latin-1 supplement is 0x20.
@@ -309,7 +315,7 @@ exprt string_constraint_generatort::add_axioms_for_to_lower_case(
309
315
const exprt non_converted = and_exprt (
310
316
equal_exprt (res[idx], str[idx]),
311
317
binary_relation_exprt (str[idx], ID_lt, from_integer (0x100 , char_type)));
312
- return if_exprt (is_upper_case, converted, non_converted);
318
+ return if_exprt (is_upper_case (str[idx]) , converted, non_converted);
313
319
}();
314
320
315
321
return string_constraintt (
0 commit comments