test/Tools/isac/BaseDefinitions/calcelems.sml
author wneuper <Walther.Neuper@jku.at>
Sun, 09 Oct 2022 07:44:22 +0200
changeset 60565 f92963a33fe3
parent 60270 844610c5c943
child 60660 c4b24621077e
permissions -rw-r--r--
eliminate term2str in test/*
walther@59866
     1
(* Title:  BaseDefinitions/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 ------";
walther@59876
    11
"-------- fun ThmC.cut_id ------------------";
walther@59868
    12
"-------- fun UnparseC.term ----------------------------------";
walther@59876
    13
"-------- fun ThmC.cut_id 000---------------";
walther@59852
    14
"-------- fun Rule_Set.merge -----------------------------------------------------";
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
walther@59876
    38
"-------- fun ThmC.cut_id ----------------";
walther@59876
    39
"-------- fun ThmC.cut_id ----------------";
walther@59876
    40
"-------- fun ThmC.cut_id ----------------";
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
walther@59876
    46
val thmID = ThmC.cut_id dn;
walther@59879
    47
val thyID = ThyC.cut_id 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;
walther@59876
    54
val thmID = ThmC.cut_id dn;
walther@59879
    55
val thyID = ThyC.cut_id 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
walther@59868
    59
"-------- fun UnparseC.term ----------------------------------";
walther@59868
    60
"-------- fun UnparseC.term ----------------------------------";
walther@59868
    61
"-------- fun UnparseC.term ----------------------------------";
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
walther@59875
    68
 ThmC_Def.num_to_Free @{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
walther@59876
    82
"-------- fun ThmC.cut_id 000---------------";
walther@59876
    83
"-------- fun ThmC.cut_id 000---------------";
walther@59876
    84
"-------- fun ThmC.cut_id 000---------------";
neuper@42399
    85
val long_id = Thm.get_name_hint @{thm mult_1_left};
neuper@42399
    86
if long_id = "Groups.monoid_mult_class.mult_1_left" then ()
neuper@42399
    87
else error "fun Thm.get_name_hint or @{thm mult_1_left} changed";
neuper@42179
    88
walther@59876
    89
if ThmC.cut_id long_id = "mult_1_left" then ()
walther@59876
    90
else error "fun ThmC.cut_id broken";
neuper@42399
    91
walther@59879
    92
if ThyC.cut_id long_id = "Groups" then ()
walther@59879
    93
else error "fun ThyC.cut_id broken";
neuper@42399
    94
walther@59852
    95
"-------- fun Rule_Set.merge -----------------------------------------------------";
walther@59852
    96
"-------- fun Rule_Set.merge -----------------------------------------------------";
walther@59852
    97
"-------- fun Rule_Set.merge -----------------------------------------------------";
neuper@52146
    98
(*theory Thy_2 imports Thy_1*)
neuper@52146
    99
val rlss2 = [("test_list_rls", (Context.theory_name @{theory},
walther@59852
   100
  Rule_Set.append_rules "test_list_rls" Rule_Set.empty [Thm ("refl", @{thm refl}), Thm ("subst", @{thm subst})]))]
neuper@52146
   101
(*theory Thy_2b imports Thy_1*)
neuper@52146
   102
val rlss2b = [("test_list_rls", (Context.theory_name @{theory},
walther@59852
   103
  Rule_Set.append_rules "test_list_rls" Rule_Set.empty [Thm ("False_def", @{thm False_def})]))]
neuper@52146
   104
walther@59852
   105
val [(_, (_, Rule_Set.Repeat {rules, ...}))] = Rule_Set.to_kestore (rlss2, rlss2b)
neuper@52146
   106
;
neuper@52146
   107
case rules of
neuper@52146
   108
  [Thm ("subst", _), Thm ("refl", _), Thm ("False_def", _)] => ()
walther@59852
   109
| _ => error "Rule_Set.merge changed"
neuper@52146
   110
neuper@55448
   111
"-------- fun update_ptyps --------------------------------------------------";
neuper@55448
   112
"-------- fun update_ptyps --------------------------------------------------";
neuper@55448
   113
"-------- fun update_ptyps --------------------------------------------------";
neuper@55448
   114
val pty = [
walther@59897
   115
  Store.Node ("aaa", [1], [
walther@59897
   116
    Store.Node ("aaa-1", [11], [])]),
walther@59897
   117
  Store.Node ("bbb", [2], [
walther@59897
   118
    Store.Node ("bbb-1", [21], []),
walther@59897
   119
    Store.Node ("bbb-2", [22], [
walther@59897
   120
      Store.Node ("bbb-21", [221], []),
walther@59897
   121
      Store.Node ("bbb-22", [222], [])])]),
walther@59897
   122
  Store.Node ("ccc", [3], [])] : int Store.T
neuper@55448
   123
neuper@55448
   124
val ID = ["ddd"];
neuper@55448
   125
(*update_ptyps ID ID 99999 pty; ERROR update_ptyps: [aaa] does not exist*)
neuper@55448
   126
neuper@55448
   127
val ID = ["ccc"];
walther@59898
   128
if Store.update ID ID 99999 pty = 
walther@59897
   129
  [Store.Node ("aaa", [1], [Store.Node ("aaa-1", [11], [])]), 
walther@59897
   130
  Store.Node ("bbb", [2], [Store.Node ("bbb-1", [21], []), 
walther@59897
   131
    Store.Node ("bbb-2", [22], [Store.Node ("bbb-21", [221], []), Store.Node ("bbb-22", [222], [])])]),
walther@59897
   132
  Store.Node ("ccc", [99999], [])] 
neuper@55448
   133
  then () else error "update_ptyps has changed 1";
neuper@55448
   134
                                      
neuper@55448
   135
val ID = ["aaa"];
neuper@55448
   136
(*update_ptyps ID ID 99999 pty; ERROR update_ptyps: [aaa] has descendants*)
neuper@55448
   137
neuper@55448
   138
val ID = ["bbb", "bbb-2", "bbb-21"];
walther@59898
   139
if Store.update ID ID 99999 pty = 
walther@59897
   140
  [Store.Node ("aaa", [1], [Store.Node ("aaa-1", [11], [])]), 
walther@59897
   141
  Store.Node ("bbb", [2], [Store.Node ("bbb-1", [21], []), Store.Node ("bbb-2", [22], 
walther@59897
   142
    [Store.Node ("bbb-21", [99999], []), Store.Node ("bbb-22", [222], [])])]), 
walther@59897
   143
  Store.Node ("ccc", [3], [])] 
neuper@55448
   144
then () else error "update_ptyps has changed 2";
neuper@55448
   145
neuper@55448
   146
val ID = ["bbb", "bbb-2", "bbb-22"];
walther@59898
   147
if Store.update ID ID 99999 pty = 
walther@59897
   148
  [Store.Node ("aaa", [1], [Store.Node ("aaa-1", [11], [])]), 
walther@59897
   149
  Store.Node ("bbb", [2], [Store.Node ("bbb-1", [21], []), 
walther@59897
   150
      Store.Node ("bbb-2", [22], [Store.Node ("bbb-21", [221], []), Store.Node ("bbb-22", [99999], [])])]), 
walther@59897
   151
  Store.Node ("ccc", [3], [])] 
neuper@55448
   152
then () else error "update_ptyps has changed 3";
wneuper@59414
   153
wneuper@59414
   154
"----------- fun subst2str' --------------------------------------------------------------------";
wneuper@59414
   155
"----------- fun subst2str' --------------------------------------------------------------------";
wneuper@59414
   156
"----------- fun subst2str' --------------------------------------------------------------------";
Walther@60565
   157
(*> subst2str' [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x"),
Walther@60565
   158
		(TermC.parse_test @{context} "bdv_2", TermC.parse_test @{context} "y")];
wneuper@59414
   159
val it = "[(bdv, x)]" : string
wneuper@59414
   160
*)