test/Tools/isac/MathEngBasic/mstools.sml
author wneuper <Walther.Neuper@jku.at>
Sun, 09 Oct 2022 07:44:22 +0200
changeset 60565 f92963a33fe3
parent 60559 aba19e46dd84
child 60583 da7dd260f66e
permissions -rw-r--r--
eliminate term2str in test/*
neuper@38036
     1
(* Title: tests for Interpret/mstools.sml
e0726734@41957
     2
   Author: Walther Neuper 100930, Mathias Lehnfeld
neuper@38036
     3
   (c) copyright due to lincense terms.
neuper@38036
     4
*)
wneuper@59582
     5
"-----------------------------------------------------------------------------------------------";
wneuper@59582
     6
"table of contents -----------------------------------------------------------------------------";
wneuper@59582
     7
"-----------------------------------------------------------------------------------------------";
walther@59953
     8
"----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------";
wneuper@59309
     9
"----------- type penv -------------------------------------------------------------------------";
wneuper@59309
    10
"----------- fun untouched ---------------------------------------------------------------------";
wneuper@59309
    11
"----------- fun pbl_ids -----------------------------------------------------------------------";
wneuper@59309
    12
"----------- fun upd_penv ----------------------------------------------------------------------";
wneuper@59309
    13
"----------- fun upd ---------------------------------------------------------------------------";
wneuper@59309
    14
"----------- fun upds_envv ---------------------------------------------------------------------";
walther@59965
    15
"----------- fun sub_common for ThyC -----------------------------------------------------------";
walther@60021
    16
"-----------------------------------------------------------------------------------------------";
walther@60021
    17
"-----------------------------------------------------------------------------------------------";
walther@60021
    18
"-----------------------------------------------------------------------------------------------";
wneuper@59309
    19
walther@59953
    20
"----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------";
walther@59953
    21
"----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------";
walther@59953
    22
"----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------";
Walther@60565
    23
(*val t = TermC.parse_test @{context} "maximum A"; 
walther@59953
    24
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    25
val it = "maximum A" : cterm
Walther@60565
    26
> val t = TermC.parse_test @{context} "fixedValues [r=Arbfix]"; 
walther@59953
    27
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    28
"fixedValues [r = Arbfix]"
Walther@60565
    29
> val t = TermC.parse_test @{context} "valuesFor [a]"; 
walther@59953
    30
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    31
"valuesFor [a]"
Walther@60565
    32
> val t = TermC.parse_test @{context} "valuesFor [a,b]"; 
walther@59953
    33
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    34
"valuesFor [a, b]"
Walther@60565
    35
> val t = TermC.parse_test @{context} "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"; 
walther@59953
    36
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
walther@60242
    37
relations [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]"
Walther@60565
    38
> val t = TermC.parse_test @{context} "boundVariable a";
walther@59953
    39
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    40
"boundVariable a"
Walther@60565
    41
> val t = TermC.parse_test @{context} "interval {x::real. 0 <= x & x <= 2*r}"; 
walther@59953
    42
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    43
"interval {x. 0 <= x & x <= 2 * r}"
wneuper@59309
    44
Walther@60565
    45
> val t = TermC.parse_test @{context} "equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))"; 
walther@59953
    46
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    47
"equality (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))"
Walther@60565
    48
> val t = TermC.parse_test @{context} "solveFor x"; 
walther@59953
    49
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    50
"solveFor x"
Walther@60565
    51
> val t = TermC.parse_test @{context} "errorBound (eps=0)"; 
walther@59953
    52
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    53
"errorBound (eps = 0)"
Walther@60565
    54
> val t = TermC.parse_test @{context} "solutions L";
walther@59953
    55
> val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts);
wneuper@59309
    56
"solutions L"
wneuper@59309
    57
wneuper@59309
    58
before 6.5.03:
walther@60340
    59
> val t = (Thm.term_of o the o (TermC.parse thy)) "testdscforlist [#1]";
walther@59953
    60
> val (d,ts) = Input_Descript.split t;
walther@59953
    61
> Input_Descript.join thy (d,ts);
wneuper@59309
    62
val it = "testdscforlist [#1]" : cterm
wneuper@59309
    63
walther@60340
    64
> val t = (Thm.term_of o the o (TermC.parse thy)) "(A::real)";
walther@59953
    65
> val (d,ts) = Input_Descript.split t;
walther@59997
    66
val d = Const ("empty", "empty") : term
walther@59997
    67
val ts = [Free ("A", "RealDef.real")] : term list
walther@60340
    68
> val t = (Thm.term_of o the o (TermC.parse thy)) "[R=(R::real)]";
walther@59953
    69
> val (d,ts) = Input_Descript.split t;
walther@59997
    70
val d = Const ("empty", "empty") : term
wneuper@59309
    71
val ts = [Const # $ Free # $ Free (#,#)] : term list
walther@60340
    72
> val t = (Thm.term_of o the o (TermC.parse thy)) "[#1,#2]";
walther@59953
    73
> val (d,ts) = Input_Descript.split t;
walther@59997
    74
val ts = [Free ("#1", "'a"),Free ("#2", "'a")] : NOT WANTED
wneuper@59309
    75
*)
wneuper@59309
    76
"----------- type penv -------------------------------------------------------------------------";
wneuper@59309
    77
"----------- type penv -------------------------------------------------------------------------";
wneuper@59309
    78
"----------- type penv -------------------------------------------------------------------------";
wneuper@59309
    79
(*
walther@60340
    80
  val e_ = (Thm.term_of o the o (TermC.parse thy)) "e_::bool";
walther@60340
    81
  val ev = (Thm.term_of o the o (TermC.parse thy)) "#4 + #3 * x \<up> #2 = #0";
walther@60340
    82
  val v_ = (Thm.term_of o the o (TermC.parse thy)) "v_";
walther@60340
    83
  val vv = (Thm.term_of o the o (TermC.parse thy)) "x";
walther@60340
    84
  val r_ = (Thm.term_of o the o (TermC.parse thy)) "err_::bool";
walther@60340
    85
  val rv1 = (Thm.term_of o the o (TermC.parse thy)) "#0";
walther@60340
    86
  val rv2 = (Thm.term_of o the o (TermC.parse thy)) "eps";
wneuper@59309
    87
wneuper@59309
    88
  val penv = [(e_,[ev]),(v_,[vv]),(r_,[rv2,rv2])]:penv;
wneuper@59309
    89
  map getval penv;
walther@59997
    90
[(Free ("e_", "bool"),
walther@59997
    91
  Const (#,#) $ (# $ # $ (# $ #)) $ Free ("#0", "RealDef.real")),
walther@59997
    92
 (Free ("v_", "RealDef.real"),Free ("x", "RealDef.real")),
walther@59997
    93
 (Free ("err_", "bool"),Free ("#0", "RealDef.real"))] : (term * term) list      
wneuper@59309
    94
*)
wneuper@59309
    95
"----------- fun untouched ---------------------------------------------------------------------";
wneuper@59309
    96
"----------- fun untouched ---------------------------------------------------------------------";
wneuper@59309
    97
"----------- fun untouched ---------------------------------------------------------------------";
wneuper@59309
    98
(*> untouched [];
wneuper@59309
    99
val it = true : bool
walther@59940
   100
> untouched [I_Model.single_empty];
wneuper@59309
   101
val it = true : bool
walther@59940
   102
> untouched [I_Model.single_empty, (1,[],false,"I_Model.single_empty",Syn "I_Model.single_empty")];
wneuper@59309
   103
val it = false : bool*)
wneuper@59309
   104
"----------- fun pbl_ids -----------------------------------------------------------------------";
wneuper@59309
   105
"----------- fun pbl_ids -----------------------------------------------------------------------";
wneuper@59309
   106
"----------- fun pbl_ids -----------------------------------------------------------------------";
wneuper@59309
   107
(*
Walther@60565
   108
val t as t1 $ t2 = TermC.parse_test @{context} "antiDerivativeName M_b";
wneuper@59309
   109
pbl_ids ctxt t1 t2;
wneuper@59309
   110
walther@60340
   111
  val t = (Thm.term_of o the o (TermC.parse thy)) "fixedValues [r=Arbfix]";
wneuper@59309
   112
  val (d,argl) = strip_comb t;
walther@59953
   113
  Input_Descript.is_a d;                      (*see Input_Descript.split*)
wneuper@59309
   114
  dest_list (d,argl);
wneuper@59309
   115
  val (_ $ v) = t;
walther@60230
   116
  TermC.is_list v;
wneuper@59309
   117
  pbl_ids ctxt d v;
walther@60336
   118
[Const (\<^const_name>\<open>Cons\<close>, "[bool, bool List.list] => bool List.list") $
walther@60336
   119
       (Const # $ Free # $ Const (#,#)) $ Const (\<^const_name>\<open>Nil\<close>, "bool List..
wneuper@59309
   120
walther@60230
   121
  val (dsc,vl) = (Input_Descript.split o Thm.term_of o the o (TermC.parse thy)) "solveFor x";
walther@60336
   122
val dsc = Const (\<^const_name>\<open>Input_Descript.solveFor\<close>, "RealDef.real => Tools.una") : term
walther@59997
   123
val vl = Free ("x", "RealDef.real") : term 
wneuper@59309
   124
walther@60230
   125
  val (dsc,id) = (split_did o Thm.term_of o the o (TermC.parse thy)) "solveFor v_";
wneuper@59309
   126
  pbl_ids ctxt dsc vl;
walther@59997
   127
val it = [Free ("x", "RealDef.real")] : term list
wneuper@59309
   128
   
walther@60230
   129
  val (dsc,vl) = (Input_Descript.split o Thm.term_of o the o(TermC.parse thy))
wneuper@59309
   130
		       "errorBound (eps=#0)";
walther@60230
   131
  val (dsc,id) = (split_did o Thm.term_of o the o(TermC.parse thy)) "errorBound err_";
wneuper@59309
   132
  pbl_ids ctxt dsc vl;
walther@59997
   133
val it = [Free ("#0", "RealDef.real"),Free ("eps", "RealDef.real")] : term list     *)
wneuper@59309
   134
"----------- fun upd_penv ----------------------------------------------------------------------";
wneuper@59309
   135
"----------- fun upd_penv ----------------------------------------------------------------------";
wneuper@59309
   136
"----------- fun upd_penv ----------------------------------------------------------------------";
wneuper@59309
   137
(* 
wneuper@59309
   138
  val penv = [];
walther@60230
   139
  val (dsc,vl) = (split_did o Thm.term_of o the o (TermC.parse thy)) "solveFor x";
walther@60230
   140
  val (dsc,id) = (split_did o Thm.term_of o the o (TermC.parse thy)) "solveFor v_";
wneuper@59309
   141
  val penv = upd_penv thy penv dsc (id, vl);
walther@59997
   142
[(Free ("v_", "RealDef.real"),
walther@59997
   143
  [Const (#,#) $ Free (#,#) $ Free ("#0", "RealDef.real")])]
wneuper@59309
   144
: (term * term list) list                                                     
wneuper@59309
   145
walther@60230
   146
  val (dsc,vl) = (split_did o Thm.term_of o the o(TermC.parse thy))"errorBound (eps=#0)";
walther@60230
   147
  val (dsc,id) = (split_did o Thm.term_of o the o(TermC.parse thy))"errorBound err_";
wneuper@59309
   148
  upd_penv thy penv dsc (id, vl);
walther@59997
   149
[(Free ("v_", "RealDef.real"),
walther@59997
   150
  [Const (#,#) $ Free (#,#) $ Free ("#0", "RealDef.real")]),
walther@59997
   151
 (Free ("err_", "bool"),
walther@59997
   152
  [Free ("#0", "RealDef.real"),Free ("eps", "RealDef.real")])]
wneuper@59309
   153
: (term * term list) list    ^.........!!!!
wneuper@59309
   154
*)
wneuper@59309
   155
"----------- fun upd ---------------------------------------------------------------------------";
wneuper@59309
   156
"----------- fun upd ---------------------------------------------------------------------------";
wneuper@59309
   157
"----------- fun upd ---------------------------------------------------------------------------";
wneuper@59309
   158
(*
wneuper@59309
   159
  val i = 2;
wneuper@59309
   160
  val envv = [(1,[]:penv),(2,[]:penv),(3,[]:penv)]:envv;
walther@60230
   161
  val (dsc,vl) = (split_did o Thm.term_of o the o(TermC.parse thy))"boundVariable b";
walther@60230
   162
  val (dsc,id) = (split_did o Thm.term_of o the o(TermC.parse thy))"boundVariable v_";
wneuper@59309
   163
  upd thy envv dsc (id, vl) i;
walther@59997
   164
val it = (2,[(Free ("v_", "RealDef.real"),[Free ("b", "RealDef.real")])])
wneuper@59309
   165
  : int * (term * term list) list*)
wneuper@59309
   166
wneuper@59309
   167
"----------- fun upds_envv ---------------------------------------------------------------------";
wneuper@59309
   168
"----------- fun upds_envv ---------------------------------------------------------------------";
wneuper@59309
   169
"----------- fun upds_envv ---------------------------------------------------------------------";
wneuper@59309
   170
(* eval test-maximum.sml until Specify_Method ...
wneuper@59309
   171
  val PblObj{probl=(_,pbl),origin=(_,(_,_,mI),_),...} = get_obj I pt [];
Walther@60559
   172
  val met = (#ppc o MethodC.from_store ctxt) mI;
wneuper@59309
   173
wneuper@59309
   174
  val envv = [];
wneuper@59309
   175
  val eargs = flat eargs;
wneuper@59309
   176
  val (vs, dsc, id, vl) = hd eargs;
wneuper@59309
   177
  val envv = upds_envv thy envv [(vs, dsc, id, vl)];
wneuper@59309
   178
wneuper@59309
   179
  val (vs, dsc, id, vl) = hd (tl eargs);
wneuper@59309
   180
  val envv = upds_envv thy envv [(vs, dsc, id, vl)];
wneuper@59309
   181
wneuper@59309
   182
  val (vs, dsc, id, vl) = hd (tl (tl eargs));
wneuper@59309
   183
  val envv = upds_envv thy envv [(vs, dsc, id, vl)];
wneuper@59309
   184
wneuper@59309
   185
  val (vs, dsc, id, vl) = hd (tl (tl (tl eargs)));
wneuper@59309
   186
  val envv = upds_envv thy envv [(vs, dsc, id, vl)];
wneuper@59309
   187
[(1,
walther@59997
   188
  [(Free ("fix_", "bool List.list"),[Const (#,#),Free (#,#)]),
walther@59997
   189
   (Free ("m_", "bool"),[Free (#,#)]),
walther@59997
   190
   (Free ("vs_", "bool List.list"),[# $ # $ Const #]),
walther@59997
   191
   (Free ("rs_", "bool List.list"),[# $ # $ (# $ #)])]),
wneuper@59309
   192
 (2,
walther@59997
   193
  [(Free ("fix_", "bool List.list"),[Const (#,#),Free (#,#)]),
walther@59997
   194
   (Free ("m_", "bool"),[Free (#,#)]),
walther@59997
   195
   (Free ("vs_", "bool List.list"),[# $ # $ Const #]),
walther@59997
   196
   (Free ("rs_", "bool List.list"),[# $ # $ (# $ #)])]),
wneuper@59309
   197
 (3,
walther@59997
   198
  [(Free ("fix_", "bool List.list"),[Const (#,#),Free (#,#)]),
walther@59997
   199
   (Free ("m_", "bool"),[Free (#,#)]),
walther@59997
   200
   (Free ("vs_", "bool List.list"),[# $ # $ Const #])])] : envv *)
wneuper@59515
   201
walther@59965
   202
"----------- fun sub_common for ThyC -----------------------------------------------------------";
walther@59965
   203
"----------- fun sub_common for ThyC -----------------------------------------------------------";
walther@59965
   204
"----------- fun sub_common for ThyC -----------------------------------------------------------";
wneuper@59515
   205
val (thy1, thy2) = (@{theory Partial_Fractions}, @{theory Inverse_Z_Transform});
walther@59965
   206
if Context.theory_name (ThyC.sub_common (thy1, thy2)) = "Inverse_Z_Transform"
walther@59965
   207
then () else error "ThyC.sub_common 1";
wneuper@59515
   208
wneuper@59515
   209
val (thy1, thy2) = (@{theory Inverse_Z_Transform}, @{theory Partial_Fractions});(* Isac.Inverse_Z_Transform *)
walther@59965
   210
if Context.theory_name (ThyC.sub_common (thy1, thy2)) = "Inverse_Z_Transform"
walther@59965
   211
then () else error "ThyC.sub_common 2";
wneuper@59515
   212
wneuper@59515
   213
val (thy1, thy2) = (@{theory Partial_Fractions}, @{theory PolyEq});
walther@59965
   214
if Context.theory_name (ThyC.sub_common (thy1, thy2)) = "Isac_Knowledge" then () else error "ThyC.sub_common 3";
wneuper@59515
   215
wneuper@59592
   216
val (thy1, thy2) = (@{theory Partial_Fractions}, @{theory Isac_Knowledge});
walther@59965
   217
if Context.theory_name (ThyC.sub_common (thy1, thy2)) = "Isac_Knowledge" then () else error "ThyC.sub_common 4";
wneuper@59515
   218
wneuper@59515
   219
val (thy1, thy2) = (@{theory PolyEq}, @{theory Partial_Fractions});
walther@59965
   220
if Context.theory_name (ThyC.sub_common (thy1, thy2)) = "Isac_Knowledge" then () else error "ThyC.sub_common 5";
wneuper@59515
   221
wneuper@59592
   222
val (thy1, thy2) = (@{theory Isac_Knowledge}, @{theory Partial_Fractions});
walther@59965
   223
if Context.theory_name (ThyC.sub_common (thy1, thy2)) = "Isac_Knowledge" then () else error "ThyC.sub_common 6";