walther@59633
|
1 |
(* Title: CalcElements/calcelems.sml
|
walther@59633
|
2 |
Author: Walther Neuper 060113
|
walther@59633
|
3 |
(c) due to copyright terms
|
neuper@38061
|
4 |
*)
|
neuper@37906
|
5 |
|
neuper@38061
|
6 |
"--------------------------------------------------------";
|
neuper@38061
|
7 |
"--------------------------------------------------------";
|
neuper@38061
|
8 |
"table of contents --------------------------------------";
|
neuper@38061
|
9 |
"--------------------------------------------------------";
|
neuper@42456
|
10 |
"-------- Unsynchronized.ref doesn't work any more ------";
|
neuper@42179
|
11 |
"-------- fun thmID_of_derivation_name ------------------";
|
neuper@42179
|
12 |
"-------- fun term2str ----------------------------------";
|
neuper@42399
|
13 |
"-------- fun thmID_of_derivation_name 000---------------";
|
neuper@52146
|
14 |
"-------- fun merge_rlss -----------------------------------------------------";
|
neuper@55448
|
15 |
"-------- fun update_ptyps --------------------------------------------------";
|
walther@59633
|
16 |
"-------- fun subst2str' -----------------------------------------------------------------------";
|
neuper@38061
|
17 |
"--------------------------------------------------------";
|
neuper@38061
|
18 |
"--------------------------------------------------------";
|
neuper@38061
|
19 |
"--------------------------------------------------------";
|
neuper@38061
|
20 |
|
neuper@42456
|
21 |
"-------- Unsynchronized.ref doesn't work any more ------";
|
neuper@42456
|
22 |
"-------- Unsynchronized.ref doesn't work any more ------";
|
neuper@42456
|
23 |
"-------- Unsynchronized.ref doesn't work any more ------";
|
neuper@42456
|
24 |
(* this code resembles what would be needed to intermediately save original data ... *)
|
neuper@42456
|
25 |
|
neuper@42456
|
26 |
val ref_ = Unsynchronized.ref "original-data";
|
neuper@42456
|
27 |
(* save intermediately *) val val_ = ! ref_;
|
neuper@42456
|
28 |
ref_ := "test-data";
|
neuper@42456
|
29 |
(* restore original *) ref_ := val_;
|
neuper@42456
|
30 |
if ! ref_ = "original-data"
|
neuper@42456
|
31 |
then writeln "~~~~~ that's what we want"
|
neuper@42456
|
32 |
else writeln "===== why not original ?";
|
neuper@42456
|
33 |
|
neuper@42456
|
34 |
(* ... which works in this simple case. But the same did not work with
|
neuper@42456
|
35 |
--- fun insert_errpats ---, see changeset 90f3855dee3b *)
|
neuper@42456
|
36 |
|
neuper@42456
|
37 |
|
neuper@38061
|
38 |
"-------- fun thmID_of_derivation_name ----------------";
|
neuper@38061
|
39 |
"-------- fun thmID_of_derivation_name ----------------";
|
neuper@38061
|
40 |
"-------- fun thmID_of_derivation_name ----------------";
|
neuper@38061
|
41 |
val thm = @{thm radd_0};
|
neuper@38061
|
42 |
val dn = Thm.derivation_name thm;
|
neuper@38061
|
43 |
if dn = "Test.radd_0" then ()
|
neuper@38061
|
44 |
else error "calcelems.sml Thm.derivation_name changed 1";
|
neuper@38061
|
45 |
|
neuper@38061
|
46 |
val thmID = thmID_of_derivation_name dn;
|
neuper@38061
|
47 |
val thyID = thyID_of_derivation_name dn;
|
neuper@38061
|
48 |
if thmID = "radd_0" andalso thyID = "Test" then ()
|
neuper@38061
|
49 |
else error "calcelems.sml Thm.derivation_name changed 2";
|
neuper@38061
|
50 |
|
neuper@38061
|
51 |
"--- thm2 --";
|
neuper@38061
|
52 |
val thm = @{thm add_divide_distrib}
|
neuper@38061
|
53 |
val dn = Thm.derivation_name thm;
|
neuper@38061
|
54 |
val thmID = thmID_of_derivation_name dn;
|
neuper@38061
|
55 |
val thyID = thyID_of_derivation_name dn;
|
neuper@48787
|
56 |
if thmID = "add_divide_distrib" andalso thyID = "Fields" then ()
|
neuper@38061
|
57 |
else error "calcelems.sml Thm.derivation_name changed 3";
|
neuper@42179
|
58 |
|
neuper@42179
|
59 |
"-------- fun term2str ----------------------------------";
|
neuper@42179
|
60 |
"-------- fun term2str ----------------------------------";
|
neuper@42179
|
61 |
"-------- fun term2str ----------------------------------";
|
neuper@42179
|
62 |
(*Quick notes from Makarius.1003
|
neuper@42179
|
63 |
|
neuper@42179
|
64 |
@{term "2::int"}
|
neuper@42179
|
65 |
|
neuper@42179
|
66 |
term "(1.24444) :: real"
|
neuper@42179
|
67 |
|
neuper@42179
|
68 |
numbers_to_string @{term "%x. (-9993::int) + x + 1"}
|
neuper@42179
|
69 |
|
neuper@42179
|
70 |
Toplevel.debug := true;
|
neuper@42179
|
71 |
|
neuper@42179
|
72 |
literal types:
|
neuper@42179
|
73 |
PolyML.addPrettyPrinter
|
neuper@42179
|
74 |
(fn _ => fn _ => ml_pretty o Pretty.to_ML o raw_pp_typ);
|
neuper@42179
|
75 |
|
neuper@42179
|
76 |
pretty types:
|
neuper@42179
|
77 |
PolyML.addPrettyPrinter
|
neuper@42179
|
78 |
(fn _ => fn _ => ml_pretty o Pretty.to_ML o Proof_Display.pp_typ Pure.thy);
|
wneuper@59348
|
79 |
(*default_print_depth 3;*)
|
neuper@42179
|
80 |
*)
|
neuper@42179
|
81 |
"===== extend parse to string with markup===";
|
neuper@42179
|
82 |
(*
|
neuper@42179
|
83 |
fun parse thy str =
|
neuper@42179
|
84 |
(let val t = (typ_a2real o numbers_to_string)
|
neuper@42179
|
85 |
(Syntax.read_term_global thy str)
|
wneuper@59188
|
86 |
in SOME (Thm.global_cterm_of thy t) end) (*FIXXXXME 10.8.02: return term !!!*)
|
neuper@42179
|
87 |
handle _ => NONE;
|
neuper@42179
|
88 |
*)
|
neuper@42179
|
89 |
|
neuper@42399
|
90 |
"-------- fun thmID_of_derivation_name 000---------------";
|
neuper@42399
|
91 |
"-------- fun thmID_of_derivation_name 000---------------";
|
neuper@42399
|
92 |
"-------- fun thmID_of_derivation_name 000---------------";
|
neuper@42399
|
93 |
val long_id = Thm.get_name_hint @{thm mult_1_left};
|
neuper@42399
|
94 |
if long_id = "Groups.monoid_mult_class.mult_1_left" then ()
|
neuper@42399
|
95 |
else error "fun Thm.get_name_hint or @{thm mult_1_left} changed";
|
neuper@42179
|
96 |
|
neuper@42399
|
97 |
if thmID_of_derivation_name long_id = "mult_1_left" then ()
|
neuper@42399
|
98 |
else error "fun thmID_of_derivation_name broken";
|
neuper@42399
|
99 |
|
neuper@42399
|
100 |
if thyID_of_derivation_name long_id = "Groups" then ()
|
neuper@42399
|
101 |
else error "fun thyID_of_derivation_name broken";
|
neuper@42399
|
102 |
|
neuper@52146
|
103 |
"-------- fun merge_rlss -----------------------------------------------------";
|
neuper@52146
|
104 |
"-------- fun merge_rlss -----------------------------------------------------";
|
neuper@52146
|
105 |
"-------- fun merge_rlss -----------------------------------------------------";
|
neuper@52146
|
106 |
(*theory Thy_2 imports Thy_1*)
|
neuper@52146
|
107 |
val rlss2 = [("test_list_rls", (Context.theory_name @{theory},
|
neuper@52146
|
108 |
append_rls "test_list_rls" e_rls [Thm ("refl", @{thm refl}), Thm ("subst", @{thm subst})]))]
|
neuper@52146
|
109 |
(*theory Thy_2b imports Thy_1*)
|
neuper@52146
|
110 |
val rlss2b = [("test_list_rls", (Context.theory_name @{theory},
|
neuper@52146
|
111 |
append_rls "test_list_rls" e_rls [Thm ("False_def", @{thm False_def})]))]
|
neuper@52146
|
112 |
|
neuper@52146
|
113 |
val [(_, (_, Rls {rules, ...}))] = merge_rlss (rlss2, rlss2b)
|
neuper@52146
|
114 |
;
|
neuper@52146
|
115 |
case rules of
|
neuper@52146
|
116 |
[Thm ("subst", _), Thm ("refl", _), Thm ("False_def", _)] => ()
|
neuper@52146
|
117 |
| _ => error "merge_rlss changed"
|
neuper@52146
|
118 |
|
neuper@55448
|
119 |
"-------- fun update_ptyps --------------------------------------------------";
|
neuper@55448
|
120 |
"-------- fun update_ptyps --------------------------------------------------";
|
neuper@55448
|
121 |
"-------- fun update_ptyps --------------------------------------------------";
|
neuper@55448
|
122 |
val pty = [
|
neuper@55448
|
123 |
Ptyp ("aaa", [1], [
|
neuper@55448
|
124 |
Ptyp ("aaa-1", [11], [])]),
|
neuper@55448
|
125 |
Ptyp ("bbb", [2], [
|
neuper@55448
|
126 |
Ptyp ("bbb-1", [21], []),
|
neuper@55448
|
127 |
Ptyp ("bbb-2", [22], [
|
neuper@55448
|
128 |
Ptyp ("bbb-21", [221], []),
|
neuper@55448
|
129 |
Ptyp ("bbb-22", [222], [])])]),
|
neuper@55448
|
130 |
Ptyp ("ccc", [3], [])] : int ptyp list
|
neuper@55448
|
131 |
|
neuper@55448
|
132 |
val ID = ["ddd"];
|
neuper@55448
|
133 |
(*update_ptyps ID ID 99999 pty; ERROR update_ptyps: [aaa] does not exist*)
|
neuper@55448
|
134 |
|
neuper@55448
|
135 |
val ID = ["ccc"];
|
neuper@55448
|
136 |
if update_ptyps ID ID 99999 pty =
|
neuper@55448
|
137 |
[Ptyp ("aaa", [1], [Ptyp ("aaa-1", [11], [])]),
|
neuper@55448
|
138 |
Ptyp ("bbb", [2], [Ptyp ("bbb-1", [21], []),
|
neuper@55448
|
139 |
Ptyp ("bbb-2", [22], [Ptyp ("bbb-21", [221], []), Ptyp ("bbb-22", [222], [])])]),
|
neuper@55448
|
140 |
Ptyp ("ccc", [99999], [])]
|
neuper@55448
|
141 |
then () else error "update_ptyps has changed 1";
|
neuper@55448
|
142 |
|
neuper@55448
|
143 |
val ID = ["aaa"];
|
neuper@55448
|
144 |
(*update_ptyps ID ID 99999 pty; ERROR update_ptyps: [aaa] has descendants*)
|
neuper@55448
|
145 |
|
neuper@55448
|
146 |
val ID = ["bbb", "bbb-2", "bbb-21"];
|
neuper@55448
|
147 |
if update_ptyps ID ID 99999 pty =
|
neuper@55448
|
148 |
[Ptyp ("aaa", [1], [Ptyp ("aaa-1", [11], [])]),
|
neuper@55448
|
149 |
Ptyp ("bbb", [2], [Ptyp ("bbb-1", [21], []), Ptyp ("bbb-2", [22],
|
neuper@55448
|
150 |
[Ptyp ("bbb-21", [99999], []), Ptyp ("bbb-22", [222], [])])]),
|
neuper@55448
|
151 |
Ptyp ("ccc", [3], [])]
|
neuper@55448
|
152 |
then () else error "update_ptyps has changed 2";
|
neuper@55448
|
153 |
|
neuper@55448
|
154 |
val ID = ["bbb", "bbb-2", "bbb-22"];
|
neuper@55448
|
155 |
if update_ptyps ID ID 99999 pty =
|
neuper@55448
|
156 |
[Ptyp ("aaa", [1], [Ptyp ("aaa-1", [11], [])]),
|
neuper@55448
|
157 |
Ptyp ("bbb", [2], [Ptyp ("bbb-1", [21], []),
|
neuper@55448
|
158 |
Ptyp ("bbb-2", [22], [Ptyp ("bbb-21", [221], []), Ptyp ("bbb-22", [99999], [])])]),
|
neuper@55448
|
159 |
Ptyp ("ccc", [3], [])]
|
neuper@55448
|
160 |
then () else error "update_ptyps has changed 3";
|
wneuper@59414
|
161 |
|
wneuper@59414
|
162 |
"----------- fun subst2str' --------------------------------------------------------------------";
|
wneuper@59414
|
163 |
"----------- fun subst2str' --------------------------------------------------------------------";
|
wneuper@59414
|
164 |
"----------- fun subst2str' --------------------------------------------------------------------";
|
wneuper@59414
|
165 |
(*> subst2str' [(str2term "bdv", str2term "x"),
|
wneuper@59414
|
166 |
(str2term "bdv_2", str2term "y")];
|
wneuper@59414
|
167 |
val it = "[(bdv, x)]" : string
|
wneuper@59414
|
168 |
*)
|