author | Walther Neuper <neuper@ist.tugraz.at> |
Mon, 02 Sep 2013 16:16:08 +0200 | |
changeset 52101 | c3f399ce32af |
parent 48787 | 0f62d7264b93 |
child 52146 | f47e195af9a3 |
permissions | -rw-r--r-- |
neuper@37906 | 1 |
(* tests for sml/calcelems.sml |
neuper@37906 | 2 |
author: Walther Neuper 060113 |
neuper@38061 | 3 |
*) |
neuper@37906 | 4 |
|
neuper@38061 | 5 |
"--------------------------------------------------------"; |
neuper@38061 | 6 |
"--------------------------------------------------------"; |
neuper@38061 | 7 |
"table of contents --------------------------------------"; |
neuper@38061 | 8 |
"--------------------------------------------------------"; |
neuper@42456 | 9 |
"-------- Unsynchronized.ref doesn't work any more ------"; |
neuper@42179 | 10 |
"-------- fun thmID_of_derivation_name ------------------"; |
neuper@42179 | 11 |
"-------- fun term2str ----------------------------------"; |
neuper@42399 | 12 |
"-------- fun thmID_of_derivation_name 000---------------"; |
neuper@38061 | 13 |
"--------------------------------------------------------"; |
neuper@38061 | 14 |
"--------------------------------------------------------"; |
neuper@38061 | 15 |
"--------------------------------------------------------"; |
neuper@38061 | 16 |
|
neuper@42456 | 17 |
"-------- Unsynchronized.ref doesn't work any more ------"; |
neuper@42456 | 18 |
"-------- Unsynchronized.ref doesn't work any more ------"; |
neuper@42456 | 19 |
"-------- Unsynchronized.ref doesn't work any more ------"; |
neuper@42456 | 20 |
(* this code resembles what would be needed to intermediately save original data ... *) |
neuper@42456 | 21 |
|
neuper@42456 | 22 |
val ref_ = Unsynchronized.ref "original-data"; |
neuper@42456 | 23 |
(* save intermediately *) val val_ = ! ref_; |
neuper@42456 | 24 |
ref_ := "test-data"; |
neuper@42456 | 25 |
(* restore original *) ref_ := val_; |
neuper@42456 | 26 |
if ! ref_ = "original-data" |
neuper@42456 | 27 |
then writeln "~~~~~ that's what we want" |
neuper@42456 | 28 |
else writeln "===== why not original ?"; |
neuper@42456 | 29 |
|
neuper@42456 | 30 |
(* ... which works in this simple case. But the same did not work with |
neuper@42456 | 31 |
--- fun insert_errpats ---, see changeset 90f3855dee3b *) |
neuper@42456 | 32 |
|
neuper@42456 | 33 |
|
neuper@38061 | 34 |
"-------- fun thmID_of_derivation_name ----------------"; |
neuper@38061 | 35 |
"-------- fun thmID_of_derivation_name ----------------"; |
neuper@38061 | 36 |
"-------- fun thmID_of_derivation_name ----------------"; |
neuper@38061 | 37 |
val thm = @{thm radd_0}; |
neuper@38061 | 38 |
val dn = Thm.derivation_name thm; |
neuper@38061 | 39 |
if dn = "Test.radd_0" then () |
neuper@38061 | 40 |
else error "calcelems.sml Thm.derivation_name changed 1"; |
neuper@38061 | 41 |
|
neuper@38061 | 42 |
val thmID = thmID_of_derivation_name dn; |
neuper@38061 | 43 |
val thyID = thyID_of_derivation_name dn; |
neuper@38061 | 44 |
if thmID = "radd_0" andalso thyID = "Test" then () |
neuper@38061 | 45 |
else error "calcelems.sml Thm.derivation_name changed 2"; |
neuper@38061 | 46 |
|
neuper@38061 | 47 |
"--- thm2 --"; |
neuper@38061 | 48 |
val thm = @{thm add_divide_distrib} |
neuper@38061 | 49 |
val dn = Thm.derivation_name thm; |
neuper@38061 | 50 |
val thmID = thmID_of_derivation_name dn; |
neuper@38061 | 51 |
val thyID = thyID_of_derivation_name dn; |
neuper@48787 | 52 |
if thmID = "add_divide_distrib" andalso thyID = "Fields" then () |
neuper@38061 | 53 |
else error "calcelems.sml Thm.derivation_name changed 3"; |
neuper@42179 | 54 |
|
neuper@42179 | 55 |
"-------- fun term2str ----------------------------------"; |
neuper@42179 | 56 |
"-------- fun term2str ----------------------------------"; |
neuper@42179 | 57 |
"-------- fun term2str ----------------------------------"; |
neuper@42179 | 58 |
(*Quick notes from Makarius.1003 |
neuper@42179 | 59 |
|
neuper@42179 | 60 |
@{term "2::int"} |
neuper@42179 | 61 |
|
neuper@42179 | 62 |
term "(1.24444) :: real" |
neuper@42179 | 63 |
|
neuper@42179 | 64 |
numbers_to_string @{term "%x. (-9993::int) + x + 1"} |
neuper@42179 | 65 |
|
neuper@42179 | 66 |
Toplevel.debug := true; |
neuper@42179 | 67 |
|
neuper@42179 | 68 |
literal types: |
neuper@42179 | 69 |
PolyML.addPrettyPrinter |
neuper@42179 | 70 |
(fn _ => fn _ => ml_pretty o Pretty.to_ML o raw_pp_typ); |
neuper@42179 | 71 |
|
neuper@42179 | 72 |
pretty types: |
neuper@42179 | 73 |
PolyML.addPrettyPrinter |
neuper@42179 | 74 |
(fn _ => fn _ => ml_pretty o Pretty.to_ML o Proof_Display.pp_typ Pure.thy); |
neuper@52101 | 75 |
print_depth 3; |
neuper@42179 | 76 |
*) |
neuper@42179 | 77 |
"===== extend parse to string with markup==="; |
neuper@42179 | 78 |
(* |
neuper@42179 | 79 |
fun parse thy str = |
neuper@42179 | 80 |
(let val t = (typ_a2real o numbers_to_string) |
neuper@42179 | 81 |
(Syntax.read_term_global thy str) |
neuper@42179 | 82 |
in SOME (cterm_of thy t) end) (*FIXXXXME 10.8.02: return term !!!*) |
neuper@42179 | 83 |
handle _ => NONE; |
neuper@42179 | 84 |
*) |
neuper@42179 | 85 |
|
neuper@42399 | 86 |
"-------- fun thmID_of_derivation_name 000---------------"; |
neuper@42399 | 87 |
"-------- fun thmID_of_derivation_name 000---------------"; |
neuper@42399 | 88 |
"-------- fun thmID_of_derivation_name 000---------------"; |
neuper@42399 | 89 |
val long_id = Thm.get_name_hint @{thm mult_1_left}; |
neuper@42399 | 90 |
if long_id = "Groups.monoid_mult_class.mult_1_left" then () |
neuper@42399 | 91 |
else error "fun Thm.get_name_hint or @{thm mult_1_left} changed"; |
neuper@42179 | 92 |
|
neuper@42399 | 93 |
if thmID_of_derivation_name long_id = "mult_1_left" then () |
neuper@42399 | 94 |
else error "fun thmID_of_derivation_name broken"; |
neuper@42399 | 95 |
|
neuper@42399 | 96 |
if thyID_of_derivation_name long_id = "Groups" then () |
neuper@42399 | 97 |
else error "fun thyID_of_derivation_name broken"; |
neuper@42399 | 98 |