test/Tools/isac/ProgLang/calculate.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Thu, 27 Oct 2016 10:48:10 +0200
changeset 59255 383722bfcff5
parent 59253 f0bb15a046ae
child 59267 aab874fdd910
permissions -rw-r--r--
rename get_calculation* to adhoc_thm*
neuper@38022
     1
(* Title:  test calculation of values for function constants
neuper@38022
     2
   Author: Walther Neuper 2000
neuper@38022
     3
   (c) copyright due to lincense terms.
neuper@37906
     4
neuper@38022
     5
12345678901234567890123456789012345678901234567890123456789012345678901234567890
neuper@38022
     6
        10        20        30        40        50        60        70        80
neuper@37906
     7
*)
neuper@37906
     8
neuper@38022
     9
"--------------------------------------------------------";
neuper@38022
    10
"table of contents --------------------------------------";
neuper@38022
    11
"--------------------------------------------------------";
neuper@55366
    12
"-calculate.thy: provides 'setup' -----------------------";
neuper@41924
    13
"----------- fun norm -----------------------------------";
wneuper@59255
    14
"----------- check return value of adhoc_thm  ----";
neuper@38032
    15
"----------- fun calculate_ -----------------------------";
neuper@38032
    16
"----------- fun calculate_ -----------------------------";
neuper@55366
    17
"----------- calculate from script --requires 'setup'----";
neuper@38032
    18
"----------- calculate check test-root-equ --------------";
wneuper@59253
    19
"----------- check calcul,ate bottom up -----------------";
neuper@42223
    20
"----------- Atools.pow Power.power_class.power ---------";
neuper@41934
    21
" ================= calculate.sml: calculate_ 2002 ======";
neuper@38032
    22
"----------- get_pair with 3 args -----------------------";
neuper@38032
    23
"----------- calculate (2 * x is_const) -----------------";
neuper@38022
    24
"--------------------------------------------------------";
neuper@38022
    25
"--------------------------------------------------------";
neuper@38022
    26
"--------------------------------------------------------";
neuper@37906
    27
wneuper@59255
    28
"----------- check return value of adhoc_thm  ----";
wneuper@59255
    29
"----------- check return value of adhoc_thm  ----";
wneuper@59255
    30
"----------- check return value of adhoc_thm  ----";
neuper@41924
    31
val thy = @{theory "Poly"};
s1210629013@52153
    32
val cal = snd (assoc_calc' thy "is_polyexp");
neuper@38022
    33
val t = @{term "(x / x) is_polyexp"};
wneuper@59255
    34
val SOME (thmID, thm) = adhoc_thm thy cal t;
wneuper@59188
    35
(HOLogic.dest_Trueprop (Thm.prop_of thm); writeln "all thms wrapped by Trueprop")
neuper@38022
    36
handle TERM _ => 
wneuper@59255
    37
       error "calculate.sml: adhoc_thm must return Trueprop";
neuper@38022
    38
neuper@38033
    39
"----------- fun calculate_ -----------------------------";
neuper@38033
    40
"----------- fun calculate_ -----------------------------";
neuper@38033
    41
"----------- fun calculate_ -----------------------------";
neuper@41924
    42
val thy = @{theory "Test"};
neuper@38033
    43
"===== test 1";
wneuper@59188
    44
val t = (Thm.term_of o the o (parse thy)) "1+2";
wneuper@59255
    45
val SOME (thmID,thm) = adhoc_thm thy (the(assoc(calclist,"PLUS"))) t;
wneuper@59195
    46
term2str (Thm.prop_of thm) = "1 + 2 = 3";
neuper@38033
    47
neuper@38033
    48
"===== test 2";
wneuper@59188
    49
val t = (Thm.term_of o the o (parse thy)) "((1+2)*4/3)^^^2";
wneuper@59255
    50
val SOME (thmID,thm) = adhoc_thm thy (the(assoc(calclist,"PLUS"))) t;
neuper@38033
    51
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@41931
    52
if term2str t = "(3 * 4 / 3) ^^^ 2" then ()
neuper@41931
    53
else error "calculate.sml: ((1+2)*4/3)^^^2 --> (3 * 4 / 3) ^^^ 2";
neuper@38033
    54
neuper@38033
    55
"===== test 3b -- 2 contiued";
wneuper@59255
    56
val SOME (thmID,thm) = adhoc_thm thy (the(assoc(calclist,"TIMES"))) t;
neuper@38033
    57
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@38033
    58
term2str t;
neuper@38033
    59
(*val it = "(#12 // #3) ^^^ #2" : string*)
neuper@37906
    60
neuper@38033
    61
"===== test 4";
wneuper@59255
    62
val SOME (thmID,thm) = adhoc_thm thy(the(assoc(calclist,"DIVIDE")))t;
neuper@38032
    63
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@38033
    64
term2str t;
neuper@38033
    65
(*it = "#4 ^^^ #2" : string*)
neuper@38033
    66
neuper@38033
    67
"===== test 5";
wneuper@59255
    68
val SOME (thmID,thm) = adhoc_thm thy(the(assoc(calclist,"POWER")))t;
neuper@38032
    69
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@41931
    70
(*show_types := false;*)
neuper@38037
    71
if term2str t <> "16" then error "calculate.sml: new behaviour in calculate_"
neuper@37906
    72
else ();
neuper@37906
    73
neuper@37906
    74
neuper@37906
    75
val fmz = ["realTestGiven (((1+2)*4/3)^^^2)","realTestFind s"];
neuper@37906
    76
val (dI',pI',mI') =
neuper@38035
    77
  ("Test",["calculate","test"],["Test","test_calculate"]);
neuper@38035
    78
neuper@37906
    79
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@37906
    80
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@37906
    81
(*nxt =("Add_Given",Add_Given "realTestGiven (((#1 + #2) * #4 // #3) ^^^#2)")*)
neuper@37906
    82
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@37906
    83
(*nxt = ("Add_Find",Add_Find "realTestFind s") : string * tac*)
neuper@37906
    84
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38035
    85
(*nxt = ("Specify_Theory",Specify_Theory "Test") : string * tac*)
neuper@37906
    86
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@37906
    87
(*nxt = ("Specify_Problem",Specify_Problem ["calculate","test"])*)
neuper@37906
    88
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38035
    89
(*nxt = ("Specify_Method",Specify_Method ("Test","test_calculate"))*)
neuper@37906
    90
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38035
    91
(*nxt = ("Apply_Method",Apply_Method ("Test","test_calculate"))*)
neuper@37906
    92
neuper@37906
    93
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38033
    94
(*nxt = ("Calculate",Calculate "PLUS")*)
neuper@37906
    95
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38033
    96
(*nxt = ("Calculate",Calculate "TIMES")*)
neuper@37906
    97
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38033
    98
(*nxt = ("Calculate",Calculate "DIVIDE")*)
neuper@37906
    99
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@38033
   100
(*nxt = ("Calculate",Calculate "POWER")*)
neuper@37906
   101
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@37906
   102
(*nxt = ("Check_Postcond",Check_Postcond ["calculate","test"])*)
neuper@37906
   103
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@37906
   104
(*nxt = ("End_Proof'",End_Proof')*)
wneuper@59253
   105
case f of Form' (FormKF (~1,EdUndef,0,Nundef,"16")) => () | _ =>
wneuper@59253
   106
error "calculate.sml: script test_calculate changed behaviour";
neuper@37906
   107
neuper@37906
   108
neuper@38032
   109
"----------- calculate check test-root-equ --------------";
neuper@38032
   110
"----------- calculate check test-root-equ --------------";
neuper@38032
   111
"----------- calculate check test-root-equ --------------";
neuper@37906
   112
(*(1): 2nd Test_simplify didn't work:
neuper@37906
   113
val ct =
neuper@37906
   114
  "sqrt (x ^^^ 2 + -3 * x) = (-3 + 2 * x + -1 * (9 + 4 * x)) / (-1 * 2)"
neuper@37906
   115
> val rls = ("Test_simplify");
neuper@37906
   116
> val (ct,_) = the (rewrite_set thy' ("tval_rls") false rls ct);
neuper@37906
   117
val ct = "sqrt (x ^^^ 2 + -3 * x) =
neuper@37906
   118
(-9) / (-2) + (-3 / (-2) + (x * ((-4) / (-2)) + x * (2 / (-2))))";
neuper@37906
   119
ie. cancel does not work properly
neuper@37906
   120
*)
neuper@38035
   121
 val thy = "Test";
neuper@38033
   122
 val op_ = "DIVIDE";
neuper@37906
   123
 val ct = "sqrt (x ^^^ 2 + -3 * x) =\
neuper@37906
   124
 \(-9) / (-2) + (-3 / (-2) + (x * ((-4) / (-2)) + x * (2 / (-2))))";
neuper@38032
   125
 val SOME (ct,_) = calculate thy (the(assoc(calclist,op_))) ct;
neuper@37906
   126
 writeln ct;
neuper@37906
   127
(*
neuper@37906
   128
           sqrt (x ^^^ 2 + -3 * x) =\
neuper@37906
   129
 \(-9) / (-2) + (-3 / (-2) + (x * ((-4) / (-2)) + x * (2 / (-2))))
neuper@37906
   130
............... does not work *)
neuper@37906
   131
neuper@37906
   132
(*--------------(2): does divide work in Test_simplify ?: ------*)
akargl@42188
   133
 val thy = @{theory Test};
wneuper@59188
   134
 val t = (Thm.term_of o the o (parse thy)) "6 / 2";
neuper@37906
   135
 val rls = Test_simplify;
neuper@37906
   136
 val (t,_) = the (rewrite_set_ thy false rls t);
neuper@55279
   137
(*val t = Free ("3","Real.real") : term*)
neuper@37906
   138
neuper@38035
   139
 val thy = "Test";
neuper@37906
   140
 val t = "6 / 2";
neuper@37906
   141
 val rls = "Test_simplify";
neuper@37906
   142
 val (t,_) = the (rewrite_set thy false rls t);
neuper@37906
   143
(*val t = "3" : string
neuper@37906
   144
      ....... works, thus: which rule in SqRoot_simplify works differently ?*)
neuper@37906
   145
neuper@37906
   146
neuper@37906
   147
(*--------------(3): is_const works ?: -------------------------------------*)
wneuper@59188
   148
 val t = (Thm.term_of o the o (parse @{theory Test})) "2 is_const";
neuper@37906
   149
 atomty t;
akargl@42188
   150
 rewrite_set_ @{theory Test} false tval_rls t;
neuper@41928
   151
(*val it = SOME (Const ("HOL.True","bool"),[]) ... works*)
neuper@37906
   152
neuper@37906
   153
 val t = str2term "2 * x is_const";
akargl@42188
   154
 val SOME (str,t') = eval_const "" "" t (@{theory "Isac"});
neuper@37906
   155
 term2str t';
neuper@37906
   156
 
neuper@37906
   157
neuper@38032
   158
"----------- check calculate bottom up ------------------";
neuper@38032
   159
"----------- check calculate bottom up ------------------";
neuper@38032
   160
"----------- check calculate bottom up ------------------";
neuper@37906
   161
(*-------------- eval_cancel works: *)
neuper@52070
   162
 trace_rewrite:=false;
akargl@42188
   163
 val thy = @{theory Test};
wneuper@59188
   164
 val t = (Thm.term_of o the o (parse thy)) "(-4) / 2";
akargl@42188
   165
neuper@48789
   166
val SOME (_, t) = eval_cancel "xxx" "Fields.inverse_class.divide" t thy;
akargl@42188
   167
neuper@37906
   168
 term2str t;
neuper@37906
   169
"-4 / 2 = (-2)";
neuper@37906
   170
(*-------------- but ... *)
neuper@37906
   171
 val ct = "x + (-4) / 2";
akargl@42188
   172
akargl@42218
   173
val thy' = "Test"; (* added AK110727 *)
neuper@37906
   174
 val (ct,_) = the (rewrite_set thy' false rls ct);
akargl@42188
   175
neuper@37906
   176
"(-2) + x";
neuper@37906
   177
(*-------------- while ... *)
neuper@37906
   178
 val ct = "(-4) / 2";
akargl@42202
   179
neuper@37906
   180
 val (ct,_) = the (rewrite_set thy'  false rls ct);
akargl@42202
   181
neuper@37906
   182
"-2";
neuper@37906
   183
neuper@37906
   184
(*--------------(5): reproduce (1) with simpler term: ------------*)
neuper@38035
   185
 val thy = "Test";
neuper@37906
   186
 val t = "(3+5)/2";
neuper@37906
   187
 val (t,_) = the (rewrite_set thy false rls t);
neuper@37906
   188
(*val t = "4" ... works*)
neuper@37906
   189
neuper@37906
   190
 val t = "(3+1+2*x)/2";
neuper@37906
   191
 val (t,_) = the (rewrite_set thy false rls t);
neuper@37906
   192
(*val t = "2 + x" ... works*)
neuper@37906
   193
neuper@52070
   194
 trace_rewrite:=false; (*=true3.6.03*)
akargl@42218
   195
neuper@38035
   196
 val thy = "Test";
neuper@37906
   197
 val rls = "Test_simplify";
neuper@37906
   198
 val t = "(3+(1+2*x))/2";
neuper@37906
   199
 val (t,_) = the (rewrite_set thy false rls t);
neuper@37906
   200
(*val t = "2 + x" ... works: give up----------------------------------------*)
neuper@37906
   201
 trace_rewrite:=false; 
neuper@37906
   202
neuper@52070
   203
 trace_rewrite:=false; (*=true3.6.03*)
akargl@42188
   204
 val thy = @{theory Test};
neuper@37906
   205
 val rls = Test_simplify;
neuper@37906
   206
 val t = str2term "(3+(1+2*x))/2";
neuper@38032
   207
 val SOME (t',asm) = rewrite_set_ thy false rls t;
neuper@37906
   208
 term2str t';
neuper@37906
   209
(*val t = "2 + x" ... works: give up----------------------------------------*)
neuper@37906
   210
 trace_rewrite:=false; 
neuper@37906
   211
neuper@37906
   212
neuper@37906
   213
neuper@37906
   214
neuper@37906
   215
(*--- trace_rewrite before correction of ... --------------------
neuper@37906
   216
 val ct = "(-3 + 2 * x + -1) / 2";
neuper@37906
   217
 val (ct,_) = the (rewrite_set thy'  false rls ct);
neuper@37906
   218
:
neuper@37906
   219
### trying thm 'root_ge0_2'
neuper@37906
   220
### rewrite_set_: x + (-1 + -3) / 2
neuper@37906
   221
### trying thm 'radd_real_const_eq'
neuper@37906
   222
### trying thm 'radd_real_const'
neuper@37906
   223
### rewrite_set_: x + (-4) / 2
neuper@37906
   224
### trying thm 'rcollect_right'
neuper@37906
   225
:
neuper@37906
   226
"x + (-4) / 2"
neuper@37906
   227
-------------------------------------while before Isabelle20002:
neuper@37906
   228
 val ct = "(#-3 + #2 * x + #-1) // #2";
neuper@37906
   229
 val (ct,_) = the (rewrite_set thy'  false rls ct);
neuper@37906
   230
:
neuper@37906
   231
### trying thm 'root_ge0_2'
neuper@37906
   232
### rewrite_set_: x + (#-1 + #-3) // #2
neuper@37906
   233
### trying thm 'radd_real_const_eq'
neuper@37906
   234
### trying thm 'radd_real_const'
neuper@37906
   235
### rewrite_set_: x + #-4 // #2
neuper@37906
   236
### rewrite_set_: x + #-2
neuper@37906
   237
### trying thm 'rcollect_right'
neuper@37906
   238
:
neuper@37906
   239
"#-2 + x"
neuper@37906
   240
-----------------------------------------------------------------*)
neuper@37906
   241
neuper@37906
   242
neuper@37906
   243
(*===================*)
neuper@52070
   244
 trace_rewrite:=false; (*WN130722: =true stopped Test_Isac.thy*)
neuper@38035
   245
 val thy' = "Test";
neuper@37906
   246
 val rls = "Test_simplify";		
neuper@37906
   247
 val ct = "x + (-1 + -3) / 2";
neuper@37906
   248
 val (ct,_) = the (rewrite_set thy'  false rls ct);	
neuper@37906
   249
"x + (-4) / 2";						
neuper@37906
   250
(*
neuper@37906
   251
### trying calc. 'cancel'
neuper@37906
   252
@@@ get_pair: binop, t = x + (-4) / 2
neuper@37906
   253
@@@ get_pair: t else
neuper@38032
   254
@@@ get_pair: t else -> NONE
neuper@37906
   255
@@@ get_pair: binop, t = (-4) / 2
neuper@37906
   256
@@@ get_pair: then 1
neuper@38032
   257
@@@ get_pair: t -> NONE
neuper@38032
   258
@@@ get_pair: t1 -> NONE
wneuper@59255
   259
@@@ adhoc_thm': NONE
neuper@37906
   260
### trying calc. 'pow'
neuper@37906
   261
*)
neuper@37906
   262
neuper@52070
   263
 trace_rewrite:=false; (*WN130722: =true stopped Test_Isac.thy*)
neuper@38035
   264
 val thy' = "Test";
neuper@37906
   265
 val rls = "Test_simplify";		
neuper@37906
   266
 val ct = "x + (-4) / 2";
neuper@37906
   267
 val (ct,_) = the (rewrite_set thy'  false rls ct);	
neuper@37906
   268
"(-2) + x";
neuper@37906
   269
(*
neuper@37906
   270
### trying calc. 'cancel'
neuper@37906
   271
@@@ get_pair: binop, t = x + -4 / 2
neuper@37906
   272
@@@ get_pair: t else
neuper@38032
   273
@@@ get_pair: t else -> NONE
neuper@37906
   274
@@@ get_pair: binop, t = -4 / 2
neuper@37906
   275
@@@ get_pair: then 1
wneuper@59255
   276
@@@ adhoc_thm': SOME #cancel_-4_2
neuper@37906
   277
### calc. to: x + (-2)
neuper@37906
   278
### trying calc. 'cancel'
neuper@37906
   279
*)
neuper@37906
   280
 trace_rewrite:=false;
neuper@37906
   281
neuper@42223
   282
"----------- Atools.pow Power.power_class.power ---------";
neuper@42223
   283
"----------- Atools.pow Power.power_class.power ---------";
neuper@42223
   284
"----------- Atools.pow Power.power_class.power ---------";
wneuper@59188
   285
val t = (Thm.term_of o the o (parseold thy)) "1 ^ aaa";
neuper@42223
   286
atomty t;
neuper@37906
   287
(*** -------------
neuper@37906
   288
*** Const ( Nat.power, ['a, nat] => 'a)
neuper@37906
   289
*** . Free ( 1, 'a)
neuper@37906
   290
*** . Free ( aaa, nat) *)
akargl@42218
   291
neuper@42223
   292
val t = str2term "1 ^^^ aaa";
neuper@42223
   293
atomty t;
neuper@42223
   294
(**** 
neuper@42223
   295
*** Const (Atools.pow, real => real => real)
neuper@42223
   296
*** . Free (1, real)
neuper@42223
   297
*** . Free (aaa, real)
neuper@42223
   298
*** *);
neuper@37906
   299
neuper@37906
   300
" ================= calculate.sml: calculate_ 2002 =================== ";
neuper@37906
   301
" ================= calculate.sml: calculate_ 2002 =================== ";
neuper@37906
   302
" ================= calculate.sml: calculate_ 2002 =================== ";
neuper@37906
   303
akargl@42188
   304
val thy = @{theory Test};
wneuper@59188
   305
val t = (Thm.term_of o the o (parse thy)) "12 / 3";
wneuper@59255
   306
val SOME (thmID,thm) = adhoc_thm thy(the(assoc(calclist,"DIVIDE")))t;
neuper@38032
   307
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@37906
   308
"12 / 3 = 4";
akargl@42188
   309
val thy = @{theory Test};
wneuper@59188
   310
val t = (Thm.term_of o the o (parse thy)) "4 ^^^ 2";
wneuper@59255
   311
val SOME (thmID,thm) = adhoc_thm thy(the(assoc(calclist,"POWER"))) t;
neuper@38032
   312
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@37906
   313
"4 ^ 2 = 16";
neuper@37906
   314
wneuper@59188
   315
 val t = (Thm.term_of o the o (parse thy)) "((1 + 2) * 4 / 3) ^^^ 2";
wneuper@59255
   316
 val SOME (thmID,thm) = adhoc_thm thy (the(assoc(calclist,"PLUS"))) t;
neuper@37906
   317
"1 + 2 = 3";
neuper@38032
   318
 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@38033
   319
 term2str t;
neuper@37906
   320
"(3 * 4 / 3) ^^^ 2";
wneuper@59255
   321
 val SOME (thmID,thm) = adhoc_thm thy (the(assoc(calclist,"TIMES")))t;
neuper@37906
   322
"3 * 4 = 12";
neuper@38032
   323
 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@38033
   324
 term2str t;
neuper@37906
   325
"(12 / 3) ^^^ 2";
wneuper@59255
   326
 val SOME (thmID,thm) =adhoc_thm thy(the(assoc(calclist,"DIVIDE")))t;
neuper@37906
   327
"12 / 3 = 4";
neuper@38032
   328
 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@38033
   329
 term2str t;
neuper@37906
   330
"4 ^^^ 2";
wneuper@59255
   331
 val SOME (thmID,thm) = adhoc_thm thy(the(assoc(calclist,"POWER")))t;
neuper@37906
   332
"4 ^^^ 2 = 16";
neuper@38032
   333
 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t;
neuper@38033
   334
 term2str t;
neuper@37906
   335
"16";
neuper@38031
   336
 if it <> "16" then error "calculate.sml: new behaviour in calculate_"
neuper@37906
   337
 else ();
neuper@37906
   338
neuper@37906
   339
(*13.9.02 *** calc: operator = pow not defined*)
wneuper@59188
   340
  val t = (Thm.term_of o the o (parse thy)) "3^^^2";
neuper@38032
   341
  val SOME (thmID,thm) = 
wneuper@59255
   342
      adhoc_thm thy (the(assoc(calclist,"POWER"))) t;
neuper@37906
   343
(*** calc: operator = pow not defined*)
neuper@37906
   344
neuper@38033
   345
  val (op_, eval_fn) = the (assoc(calclist,"POWER"));
neuper@37906
   346
  (*
neuper@37906
   347
val op_ = "Atools.pow" : string
neuper@37906
   348
val eval_fn = fn : string -> term -> theory -> (string * term) option*)
neuper@37906
   349
neuper@38032
   350
  val SOME (thmid,t') = get_pair thy op_ eval_fn t;
neuper@37906
   351
(*** calc: operator = pow not defined*)
neuper@37906
   352
neuper@38032
   353
  val SOME (id,t') = eval_fn op_ t thy;
neuper@37906
   354
(*** calc: operator = pow not defined*)
neuper@37906
   355
neuper@37906
   356
  val (thmid, (Const (op0,t0) $ Free (n1,t1) $ Free(n2,t2))) = (op_, t);
neuper@38032
   357
  val SOME (id,t') = eval_binop thmid op_ t thy;
neuper@37906
   358
(*** calc: operator = pow not defined*)
neuper@37906
   359
akargl@42188
   360
neuper@37906
   361
"----------- get_pair with 3 args --------------------------------";
neuper@37906
   362
"----------- get_pair with 3 args --------------------------------";
neuper@37906
   363
"----------- get_pair with 3 args --------------------------------";
neuper@37906
   364
val (thy, op_, ef, arg) =
neuper@37906
   365
    (thy, "EqSystem.occur'_exactly'_in", 
s1210629013@52158
   366
     assoc_calc' (Thy_Info.get_theory "EqSystem") "occur_exactly_in" |> snd |> snd,
neuper@37906
   367
     str2term
akargl@42188
   368
      "[] from [c, c_2, c_3, c_4] occur_exactly_in -1 * (q_0 * L ^^^ 2) / 2"
neuper@37906
   369
      );
neuper@38032
   370
val SOME (str, simpl) = get_pair thy op_ ef arg;
neuper@37906
   371
if str = 
akargl@42188
   372
"[] from [c, c_2, c_3, c_4] occur_exactly_in -1 * (q_0 * L ^^^ 2) / 2 = True"
neuper@38031
   373
then () else error "calculate.sml get_pair with 3 args:occur_exactly_in";
neuper@37906
   374
neuper@37906
   375
neuper@38032
   376
"----------- calculate (2 * x is_const) -----------------";
neuper@38032
   377
"----------- calculate (2 * x is_const) -----------------";
neuper@38032
   378
"----------- calculate (2 * x is_const) -----------------";
neuper@37906
   379
val t = str2term "2 * x is_const";
akargl@42188
   380
val SOME (str, t') = eval_const "" "" t @{theory Test};
neuper@37906
   381
term2str t';
neuper@37906
   382
"(2 * x is_const) = False";
neuper@37906
   383
akargl@42188
   384
val SOME (t',_) = rewrite_set_ @{theory Test} false tval_rls t;
neuper@37906
   385
term2str t';
neuper@41928
   386
"HOL.False";