equal
deleted
inserted
replaced
356 subsection {* Strings as dedicated type *} |
356 subsection {* Strings as dedicated type *} |
357 |
357 |
358 typedef literal = "UNIV :: string set" |
358 typedef literal = "UNIV :: string set" |
359 morphisms explode STR .. |
359 morphisms explode STR .. |
360 |
360 |
|
361 setup_lifting (no_code) type_definition_literal |
|
362 |
361 instantiation literal :: size |
363 instantiation literal :: size |
362 begin |
364 begin |
363 |
365 |
364 definition size_literal :: "literal \<Rightarrow> nat" |
366 definition size_literal :: "literal \<Rightarrow> nat" |
365 where |
367 where |
370 end |
372 end |
371 |
373 |
372 instantiation literal :: equal |
374 instantiation literal :: equal |
373 begin |
375 begin |
374 |
376 |
375 definition equal_literal :: "literal \<Rightarrow> literal \<Rightarrow> bool" |
377 lift_definition equal_literal :: "literal \<Rightarrow> literal \<Rightarrow> bool" is "op =" . |
376 where |
378 |
377 "equal_literal s1 s2 \<longleftrightarrow> explode s1 = explode s2" |
379 instance by intro_classes (transfer, simp) |
378 |
380 |
379 instance |
381 end |
380 proof |
382 |
381 qed (auto simp add: equal_literal_def explode_inject) |
383 declare equal_literal.rep_eq[code] |
382 |
|
383 end |
|
384 |
384 |
385 lemma [code nbe]: |
385 lemma [code nbe]: |
386 fixes s :: "String.literal" |
386 fixes s :: "String.literal" |
387 shows "HOL.equal s s \<longleftrightarrow> True" |
387 shows "HOL.equal s s \<longleftrightarrow> True" |
388 by (simp add: equal) |
388 by (simp add: equal) |
389 |
389 |
390 lemma STR_inject' [simp]: |
390 lemma STR_inject' [simp]: |
391 "STR xs = STR ys \<longleftrightarrow> xs = ys" |
391 "STR xs = STR ys \<longleftrightarrow> xs = ys" |
392 by (simp add: STR_inject) |
392 by (simp add: STR_inject) |
393 |
|
394 |
393 |
395 subsection {* Code generator *} |
394 subsection {* Code generator *} |
396 |
395 |
397 ML_file "Tools/string_code.ML" |
396 ML_file "Tools/string_code.ML" |
398 |
397 |