test/Tools/isac/Specify/m-match.sml
author wneuper <Walther.Neuper@jku.at>
Sun, 09 Oct 2022 07:44:22 +0200
changeset 60565 f92963a33fe3
parent 60559 aba19e46dd84
child 60586 007ef64dbb08
permissions -rw-r--r--
eliminate term2str in test/*
walther@60324
     1
(* Title:  "Specify/m-match.sml"
walther@59968
     2
   Author: Walther Neuper
walther@59968
     3
   (c) due to copyright terms
walther@59968
     4
*)
walther@59968
     5
walther@59968
     6
"-----------------------------------------------------------------------------------------------";
walther@59968
     7
"table of contents -----------------------------------------------------------------------------";
walther@59968
     8
"-----------------------------------------------------------------------------------------------";
walther@59996
     9
"----------- fun match_pbl ---------------------------------------------------------------------";
walther@59996
    10
"----------- fun match_oris --------------------------------------------------------------------";
Walther@60469
    11
"----------- M_Match.arguments, is_cp, O_Model.copy_name +with EqSystem (!) --------------------";
walther@59968
    12
"-----------------------------------------------------------------------------------------------";
walther@59968
    13
"-----------------------------------------------------------------------------------------------";
walther@59968
    14
"-----------------------------------------------------------------------------------------------";
walther@59968
    15
walther@59984
    16
open M_Match;
walther@59996
    17
"----------- fun match_pbl ---------------------------------------------------------------------";
walther@59996
    18
"----------- fun match_pbl ---------------------------------------------------------------------";
walther@59996
    19
"----------- fun match_pbl ---------------------------------------------------------------------";
walther@59996
    20
val fmz = ["equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))",
walther@59997
    21
	      "solveFor x", "errorBound (eps=0)", "solutions L"];
walther@59996
    22
val pbt as {thy = thy, where_ = pre, ppc = ppc,...} =
Walther@60559
    23
    Problem.from_store @{context} ["univariate", "equation"];
walther@59996
    24
val xxx = M_Match.match_pbl fmz pbt;
walther@59996
    25
walther@59996
    26
case xxx of
walther@59996
    27
  Matches'
walther@59996
    28
    {Find = [Correct "solutions L"],
walther@59996
    29
    Given = [
walther@59996
    30
      Correct "equality (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))",
walther@59996
    31
      Correct "solveFor x",
walther@60324
    32
      Superfl "errorBound (eps = (0::'a))"],
walther@59996
    33
    Relate = [],
wenzelm@60237
    34
    Where = [Correct "matches (?a = ?b) (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))"],
walther@59996
    35
    With = []} => ()
walther@59996
    36
  | _ => error "M_Match.match_pbl CHANGED";
walther@59996
    37
walther@59996
    38
walther@59996
    39
"----------- fun match_oris --------------------------------------------------------------------";
walther@59996
    40
"----------- fun match_oris --------------------------------------------------------------------";
walther@59996
    41
"----------- fun match_oris --------------------------------------------------------------------";
walther@59996
    42
val fmz = ["equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))",
walther@59997
    43
	      "solveFor x", "errorBound (eps=0)", "solutions L"];
walther@59996
    44
val pbt as {ppc = ppc,...} =
Walther@60559
    45
    Problem.from_store @{context} ["univariate", "equation"];
Walther@60470
    46
val o_model = O_Model.init @{theory} fmz ppc
Walther@60559
    47
val py = Problem.from_store @{context} ["equation"];
Walther@60559
    48
val py = Problem.from_store @{context} ["univariate", "equation"];
Walther@60559
    49
val py = Problem.from_store @{context} ["sq", "rootX", "univariate", "equation"];
walther@59996
    50
walther@59996
    51
if match_oris @{theory} (#prls py) o_model (#ppc py, #where_ py)
walther@59996
    52
then () else error "fun match_oris CHANGED";
walther@59996
    53
walther@59996
    54
Walther@60475
    55
"----------- M_Match.arguments, is_cp, O_Model.copy_name +with EqSystem (!) ------------=-------";
Walther@60475
    56
"----------- M_Match.arguments, is_cp, O_Model.copy_name +with EqSystem (!) ------------=-------";
Walther@60475
    57
"----------- M_Match.arguments, is_cp, O_Model.copy_name +with EqSystem (!) --------------------";
walther@60336
    58
val Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
    59
	  (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
    60
		 Free (dI',_) $ 
wenzelm@60309
    61
		 (Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
    62
    (*...copied from LItool.tac_from_prog*)
Walther@60565
    63
    TermC.parse_test @{context} (
walther@59996
    64
	"SubProblem (EqSystemX, [LINEAR, system], [no_met])         " ^
walther@60242
    65
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]," ^
walther@59996
    66
        "      REAL_LIST [c, c_2]]");
walther@59996
    67
val ags = isalist2list ags';
walther@59997
    68
val pI = ["LINEAR", "system"];
Walther@60559
    69
val pats = (#ppc o Problem.from_store @{context}) pI;
walther@59996
    70
"-a1-----------------------------------------------------";
walther@59996
    71
(*M_Match.arguments = fn : theory -> pat list -> term list -> O_Model.T*)
walther@59996
    72
val xxx = M_Match.arguments @{theory "EqSystem"} pats ags;
walther@59996
    73
"-a2-----------------------------------------------------";
walther@59996
    74
case M_Match.arguments @{theory  "Isac_Knowledge"} pats ags of 
walther@60336
    75
    [(1, [1], "#Given", Const (\<^const_name>\<open>Input_Descript.equalities\<close>, _), _),
walther@60336
    76
     (2, [1], "#Given", Const (\<^const_name>\<open>EqSystem.solveForVars\<close>, _),
walther@59996
    77
      [ _ $ Free ("c", _) $ _, _ $ Free ("c_2", _) $ _]),
walther@60336
    78
     (3, [1], "#Find", Const (\<^const_name>\<open>EqSystem.solution\<close>, _), [Free ("ss'''", _)])] 
walther@59996
    79
    =>()
walther@59996
    80
  | _ => error "calchead.sml M_Match.arguments 2 args Nok ----------------";
walther@59996
    81
walther@59996
    82
"-b------------------------------------------------------";
walther@60336
    83
val Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
    84
	  (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
    85
		 Free (dI',_) $ 
wenzelm@60309
    86
		 (Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
    87
    (*...copied from LItool.tac_from_prog*)
Walther@60565
    88
    TermC.parse_test @{context} (
walther@59996
    89
	"SubProblem (EqSystemX, [LINEAR, system], [no_met])         " ^
walther@60242
    90
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]," ^
walther@59996
    91
        "      REAL_LIST [c, c_2], BOOL_LIST ss''']");
walther@59996
    92
val ags = isalist2list ags';
walther@59997
    93
val pI = ["LINEAR", "system"];
Walther@60559
    94
val pats = (#ppc o Problem.from_store @{context}) pI;
walther@59996
    95
"-b1-----------------------------------------------------";
walther@59996
    96
val xxx = M_Match.arguments @{theory  "Isac_Knowledge"} pats ags;
walther@59996
    97
"-b2-----------------------------------------------------";
walther@59996
    98
case M_Match.arguments @{theory "EqSystem"} pats ags of 
walther@60336
    99
    [(1, [1], "#Given", Const (\<^const_name>\<open>Input_Descript.equalities\<close>, _), _),
walther@60336
   100
     (2, [1], "#Given", Const (\<^const_name>\<open>EqSystem.solveForVars\<close>, _),
walther@59996
   101
         [_ $ Free ("c", _) $ _,
walther@59996
   102
          _ $ Free ("c_2", _) $ _]),
walther@60336
   103
     (3, [1], "#Find", Const (\<^const_name>\<open>EqSystem.solution\<close>, _), [Free ("ss'''", _)])]
walther@59996
   104
    (*         type of Find:            [Free ("ss'''", "bool List.list")]*)
walther@59996
   105
    =>()
walther@59996
   106
  | _ => error "calchead.sml M_Match.arguments copy-named dropped --------";
walther@59996
   107
walther@59996
   108
"-c---ERROR case: stac is missing #Given equalities e_s--";
walther@60336
   109
val stac as Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
   110
	 (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
   111
		Free (dI',_) $ 
wenzelm@60309
   112
		(Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
   113
    (*...copied from LItool.tac_from_prog*)
Walther@60565
   114
    TermC.parse_test @{context} (
walther@59996
   115
	"SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^
walther@59996
   116
        "     [REAL_LIST [c, c_2]]");
walther@59996
   117
val ags = isalist2list ags'; 
walther@59997
   118
val pI = ["LINEAR", "system"];
Walther@60559
   119
val pats = (#ppc o Problem.from_store @{context}) pI;
walther@59996
   120
(*============ inhibit exn AK110726 ==============================================
walther@59996
   121
val xxx - M_Match.arguments (theory "EqSystem") pats ags;
walther@59996
   122
============ inhibit exn AK110726 ==============================================*)
walther@59996
   123
"-c1-----------------------------------------------------";
walther@59996
   124
"--------------------------step through code M_Match.arguments---";
walther@59996
   125
val (thy, pbt: Model_Pattern.T, ags) = (@{theory "EqSystem"}, pats, ags);
walther@59996
   126
fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
walther@59996
   127
	val pbt' = filter_out O_Model.is_copy_named pbt; (*=equalities, solveForVars*)
walther@59996
   128
	val cy = filter O_Model.is_copy_named pbt;       (*=solution*)
walther@59996
   129
(*============ inhibit exn AK110726 ==============================================
walther@59996
   130
	val oris' - O_Model.matc thy pbt' ags [];
walther@59996
   131
============ inhibit exn AK110726 ==============================================*)
walther@59996
   132
"-------------------------------step through code O_Model.matc---";
walther@59996
   133
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
Walther@60475
   134
(O_Model.is_copy_named' o free2str) t;
walther@59996
   135
"---if False:...";
walther@59996
   136
(*============ inhibit exn AK110726 ==============================================
walther@59996
   137
val opt - mtc thy p a;
walther@59996
   138
============ inhibit exn AK110726 ==============================================*)
walther@59996
   139
"--------------------------------step through code mtc---";
walther@59996
   140
val (thy, (str, (dsc, _)): Model_Pattern.single, ty $ var) = (thy, p, a);
walther@59996
   141
Thm.global_cterm_of;
walther@59996
   142
val ttt = (dsc $ var);
walther@59996
   143
(*============ inhibit exn AK110726 ==============================================
walther@59996
   144
Thm.global_cterm_of thy (dsc $ var);
walther@59996
   145
============ inhibit exn AK110726 ==============================================*)
walther@59996
   146
walther@59996
   147
"-------------------------------------step through end---";
Walther@60473
   148
"--------- M_Match.arguments, is_cp, O_Model.copy_name +with EqSystem (!)--";
walther@60336
   149
val Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
   150
	  (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
   151
		 Free (dI',_) $ 
wenzelm@60309
   152
		 (Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
   153
    (*...copied from LItool.tac_from_prog*)
Walther@60565
   154
    TermC.parse_test @{context} (
walther@59996
   155
	"SubProblem (EqSystemX, [LINEAR, system], [no_met])         " ^
walther@60242
   156
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]," ^
walther@59996
   157
        "      REAL_LIST [c, c_2]]");
walther@59996
   158
val ags = isalist2list ags';
walther@59997
   159
val pI = ["LINEAR", "system"];
Walther@60559
   160
val pats = (#ppc o Problem.from_store @{context}) pI;
walther@59996
   161
"-a1-----------------------------------------------------";
walther@59996
   162
(*M_Match.arguments = fn : theory -> pat list -> term list -> O_Model.T*)
walther@59996
   163
val xxx = M_Match.arguments @{theory "EqSystem"} pats ags;
walther@59996
   164
"-a2-----------------------------------------------------";
walther@59996
   165
case M_Match.arguments @{theory  "Isac_Knowledge"} pats ags of 
walther@60336
   166
    [(1, [1], "#Given", Const (\<^const_name>\<open>Input_Descript.equalities\<close>, _), _),
walther@60336
   167
     (2, [1], "#Given", Const (\<^const_name>\<open>EqSystem.solveForVars\<close>, _),
walther@59996
   168
      [ _ $ Free ("c", _) $ _, _ $ Free ("c_2", _) $ _]),
walther@60336
   169
     (3, [1], "#Find", Const (\<^const_name>\<open>EqSystem.solution\<close>, _), [Free ("ss'''", _)])] 
walther@59996
   170
    =>()
walther@59996
   171
  | _ => error "calchead.sml M_Match.arguments 2 args Nok ----------------";
walther@59996
   172
walther@59996
   173
"-b------------------------------------------------------";
walther@60336
   174
val Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
   175
	  (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
   176
		 Free (dI',_) $ 
wenzelm@60309
   177
		 (Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
   178
    (*...copied from LItool.tac_from_prog*)
Walther@60565
   179
    TermC.parse_test @{context} (
walther@59996
   180
	"SubProblem (EqSystemX, [LINEAR, system], [no_met])         " ^
walther@60242
   181
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]," ^
walther@59996
   182
        "      REAL_LIST [c, c_2], BOOL_LIST ss''']");
walther@59996
   183
val ags = isalist2list ags';
walther@59997
   184
val pI = ["LINEAR", "system"];
Walther@60559
   185
val pats = (#ppc o Problem.from_store @{context}) pI;
walther@59996
   186
"-b1-----------------------------------------------------";
walther@59996
   187
val xxx = M_Match.arguments @{theory  "Isac_Knowledge"} pats ags;
walther@59996
   188
"-b2-----------------------------------------------------";
walther@59996
   189
case M_Match.arguments @{theory "EqSystem"} pats ags of 
walther@60336
   190
    [(1, [1], "#Given", Const (\<^const_name>\<open>Input_Descript.equalities\<close>, _), _),
walther@60336
   191
     (2, [1], "#Given", Const (\<^const_name>\<open>EqSystem.solveForVars\<close>, _),
walther@59996
   192
         [_ $ Free ("c", _) $ _,
walther@59996
   193
          _ $ Free ("c_2", _) $ _]),
walther@60336
   194
     (3, [1], "#Find", Const (\<^const_name>\<open>EqSystem.solution\<close>, _), [Free ("ss'''", _)])]
walther@59996
   195
    (*         type of Find:            [Free ("ss'''", "bool List.list")]*)
walther@59996
   196
    =>()
walther@59996
   197
  | _ => error "calchead.sml M_Match.arguments copy-named dropped --------";
walther@59996
   198
walther@59996
   199
"-c---ERROR case: stac is missing #Given equalities e_s--";
walther@60336
   200
val stac as Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
   201
	 (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
   202
		Free (dI',_) $ 
wenzelm@60309
   203
		(Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
   204
    (*...copied from LItool.tac_from_prog*)
Walther@60565
   205
    TermC.parse_test @{context} (
walther@59996
   206
	"SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^
walther@59996
   207
        "     [REAL_LIST [c, c_2]]");
walther@59996
   208
val ags = isalist2list ags'; 
walther@59997
   209
val pI = ["LINEAR", "system"];
Walther@60559
   210
val pats = (#ppc o Problem.from_store @{context}) pI;
walther@59996
   211
(*============ inhibit exn AK110726 ==============================================
walther@59996
   212
val xxx - M_Match.arguments (theory "EqSystem") pats ags;
walther@59996
   213
-------------------------------------------------------------------*)
walther@59996
   214
"-c1-----------------------------------------------------";
walther@59996
   215
"--------------------------step through code M_Match.arguments---";
walther@59996
   216
val (thy, pbt: Model_Pattern.T, ags) = (@{theory "EqSystem"}, pats, ags);
walther@59996
   217
fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
walther@59996
   218
	val pbt' = filter_out O_Model.is_copy_named pbt; (*=equalities, solveForVars*)
walther@59996
   219
	val cy = filter O_Model.is_copy_named pbt;       (*=solution*)
walther@59996
   220
(*============ inhibit exn AK110726 ==============================================
walther@59996
   221
	val oris' - O_Model.matc thy pbt' ags [];
walther@59996
   222
-------------------------------------------------------------------*)
walther@59996
   223
"-------------------------------step through code O_Model.matc---";
walther@59996
   224
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
Walther@60475
   225
(O_Model.is_copy_named' o free2str) t;
walther@59996
   226
"---if False:...";
walther@59996
   227
(*============ inhibit exn AK110726 ==============================================
walther@59996
   228
val opt - mtc thy p a;
walther@59996
   229
-------------------------------------------------------------------*)
walther@59996
   230
"--------------------------------step through code mtc---";
walther@59996
   231
val (thy, (str, (dsc, _)): Model_Pattern.single, ty $ var) = (thy, p, a);
walther@59996
   232
Thm.global_cterm_of;
walther@59996
   233
val ttt = (dsc $ var);
walther@59996
   234
(*============ inhibit exn AK110726 ==============================================
walther@59996
   235
Thm.global_cterm_of thy (dsc $ var);
walther@59996
   236
-------------------------------------------------------------------*)
walther@59996
   237
"-------------------------------------step through end---";
walther@59996
   238
walther@59996
   239
case ((M_Match.arguments @{theory "EqSystem"} pats ags)
walther@59996
   240
      handle ERROR _ => []) of (*why not TYPE ?WN100920*)
Walther@60559
   241
    [] => M_Match.arguments_msg @{context} pI stac ags
walther@59996
   242
  | _ => error "calchead.sml M_Match.arguments 1st arg missing --------";
walther@59996
   243
walther@59996
   244
"-d------------------------------------------------------";
walther@60336
   245
val stac as Const (\<^const_name>\<open>SubProblem\<close>,_) $
wenzelm@60309
   246
	 (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
   247
		Free (dI',_) $ 
wenzelm@60309
   248
		(Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
   249
    (*...copied from LItool.tac_from_prog*)
Walther@60565
   250
   TermC.parse_test @{context} (
walther@59996
   251
	"SubProblem (TestX,[univariate,equation,test]," ^
walther@59996
   252
        "             [no_met]) [BOOL (x+1=2), REAL x]");
walther@59996
   253
val AGS = isalist2list ags';
walther@59997
   254
val pI = ["univariate", "equation", "test"];
walther@59996
   255
walther@59996
   256
walther@59996
   257
case ((M_Match.arguments @{theory "EqSystem"} pats ags)
walther@59996
   258
      handle ERROR _ => []) of (*why not TYPE ?WN100920*)
Walther@60559
   259
    [] => M_Match.arguments_msg @{context} pI stac ags
walther@59996
   260
  | _ => error "calchead.sml M_Match.arguments 1st arg missing --------";
walther@59996
   261
walther@59996
   262
"-d------------------------------------------------------";
walther@60336
   263
val stac as Const (\<^const_name>\<open>SubProblem\<close>, _) $
wenzelm@60309
   264
	 (Const (\<^const_name>\<open>Pair\<close>,_) $
walther@59996
   265
		Free (dI',_) $ 
wenzelm@60309
   266
		(Const (\<^const_name>\<open>Pair\<close>,_) $ pI' $ mI')) $ ags' =
walther@59996
   267
    (*...copied from LItool.tac_from_prog*)
Walther@60565
   268
    TermC.parse_test @{context} (
walther@59996
   269
	"SubProblem (TestX,[univariate,equation,test]," ^
walther@59996
   270
        "             [no_met]) [BOOL (x+1=2), REAL x]");
walther@59996
   271
val AGS = isalist2list ags';
walther@59997
   272
val pI = ["univariate", "equation", "test"];
Walther@60559
   273
val PATS = (#ppc o Problem.from_store @{context}) pI;
walther@59996
   274
"-d1-----------------------------------------------------";
walther@59996
   275
"--------------------------step through code M_Match.arguments---";
walther@59996
   276
val (thy, pbt: Model_Pattern.T, ags) = (@{theory "Test"}, PATS, AGS);
walther@59996
   277
fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
walther@59996
   278
	val pbt' = filter_out O_Model.is_copy_named pbt; 
walther@59996
   279
	val cy = filter O_Model.is_copy_named pbt;       
walther@59996
   280
	val oris' = M_Match.matc thy pbt' ags [];
walther@59996
   281
"-------------------------------step through code O_Model.matc---";
walther@59996
   282
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
Walther@60475
   283
(O_Model.is_copy_named' o free2str) t;
walther@59996
   284
"---if False:...";
walther@59996
   285
val opt = mtc thy p a;
walther@59996
   286
"--------------------------------step through code mtc---";
walther@59996
   287
val (thy, (str, (dsc, _)): Model_Pattern.single, ty $ var) = (thy, p, a);
walther@59996
   288
val ttt = (dsc $ var);
walther@59996
   289
Thm.global_cterm_of thy (dsc $ var);
walther@59996
   290
val ori = ((([1], str, dsc, (*[var]*) Input_Descript.split' (dsc, var))): O_Model.preori);
walther@59996
   291
walther@59996
   292
"-d2-----------------------------------------------------";
walther@59996
   293
pbt = [];  (*false*)
walther@59996
   294
"-------------------------------step through code O_Model.matc---";
walther@59996
   295
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt, ags, oris @ [ori]);
Walther@60475
   296
(O_Model.is_copy_named' o free2str) t;
walther@59996
   297
"---if False:...";
walther@59996
   298
val opt = mtc thy p a;
walther@59996
   299
"--------------------------------step through code mtc---";
walther@59996
   300
val (thy, (str, (dsc, _)):Model_Pattern.single, ty $ var) = (thy, p, a);
walther@59996
   301
val ttt = (dsc $ var);
walther@59996
   302
Thm.global_cterm_of thy (dsc $ var);
walther@59996
   303
val ori = ((([1], str, dsc, (*[var]*) Input_Descript.split' (dsc, var))): O_Model.preori);
walther@59996
   304
"-d3-----------------------------------------------------";
walther@59996
   305
pbt = [];  (*true, base case*)
walther@59996
   306
"-----------------continue step through code M_Match.arguments---";
Walther@60473
   307
	val oris' = oris @ [ori]; (*result 2 oris, O_Model.copy_name added later*)
Walther@60473
   308
"--------------------------------step through O_Model.copy_name----";
walther@59996
   309
val (pbt, oris, p as (field, (dsc, t)):Model_Pattern.single) = (pbt', oris', hd cy);
walther@59996
   310
(*t = "v_v'i'" : term             OLD: t = "v_i_"*)
walther@59996
   311
"--------------------------------------------------------";
walther@59996
   312
fun is_copy_named_generating_idstr str =
Walther@60475
   313
    if O_Model.is_copy_named' str
walther@59996
   314
    then case (rev o Symbol.explode) str of
walther@59996
   315
      (*"_"::"_"::"_"::_ => false*)
walther@59996
   316
	"'"::"'"::"'"::_ => false
walther@59996
   317
      | _ => true
walther@59996
   318
    else false;
walther@59996
   319
fun is_copy_named_generating (_, (_, t)) = 
walther@59996
   320
    (is_copy_named_generating_idstr o free2str) t;
walther@59996
   321
"--------------------------------------------------------";
walther@59996
   322
is_copy_named_generating p (*true*);
walther@59996
   323
           fun sel (_,_,d,ts) = Input_Descript.join'''' (d, ts);
walther@59996
   324
	   val cy' = (implode o (drop_last_n 3) o Symbol.explode o free2str) t;
walther@59996
   325
               (*"v_v"             OLD: "v_"*)
walther@59996
   326
	   val ext = (last_elem o drop_last o Symbol.explode o free2str) t;
walther@59996
   327
               (*"i"               OLD: "i"*)
walther@59996
   328
	   val vars' = map (free2str o snd o snd) pbt(*cpy-nam filtered_out*);
walther@59996
   329
               (*["e_e", "v_v"]    OLD: ["e_", "v_"]*)
walther@59996
   330
	   val vals = map sel oris;
walther@59996
   331
               (*[x+1=2, x]        OLD: [x+1=2, x] : term list*)
walther@59996
   332
vars' ~~ vals;
walther@59996
   333
(*[("e_e", [x+1=2), ("v_v", x)]    OLD: [("e_", [x+1=2), ("v_", x)]*)
walther@59996
   334
(LibraryC.assoc (vars'~~vals, cy'));
walther@59996
   335
(*SOME (Free ("x", "Real.real")) : term option*)
walther@59996
   336
	   val cy_ext = (free2str o the) (LibraryC.assoc (vars'~~vals, cy'))^"_"^ext;
walther@59996
   337
               (*x_i*)
walther@59996
   338
"-----------------continue step through code M_Match.arguments---";
Walther@60473
   339
	val cy' = map (O_Model.copy_name pbt' oris') cy;
walther@59996
   340
               (*[([1], "#Find", "solutions, [x_i"] (*as terms*) )]*)
walther@59996
   341
"-------------------------------------step through end---";
walther@59996
   342
walther@59996
   343
case M_Match.arguments thy PATS AGS of
walther@60336
   344
[(1, [1], "#Given", Const (\<^const_name>\<open>Input_Descript.equality\<close>, _),
walther@60336
   345
  [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Const (\<^const_name>\<open>plus_class.plus\<close>, _) $
walther@60324
   346
		Free ("x", _) $ _(*1*)) $ _(*1*)]),
walther@60336
   347
 (2, [1], "#Given", Const (\<^const_name>\<open>Input_Descript.solveFor\<close>, _), [Free ("x", _)]),
walther@60336
   348
 (3, [1], "#Find", Const (\<^const_name>\<open>Input_Descript.solutions\<close>, _), [Free ("x_i", _)])]
walther@59996
   349
    => ()
walther@59996
   350
  | _ => error "calchead.sml M_Match.arguments [univariate,equation,test]--";