test/Tools/isac/Specify/i-model.sml
author wneuper <Walther.Neuper@jku.at>
Thu, 20 Oct 2022 10:23:38 +0200
changeset 60571 19a172de0bb5
parent 60559 aba19e46dd84
child 60586 007ef64dbb08
permissions -rw-r--r--
followup 6a: tests run from @{context} without sessions
walther@59957
     1
(* Title:  "Specify/i-model.sml"
walther@59957
     2
   Author: Walther Neuper
walther@59957
     3
   (c) due to copyright terms
walther@59957
     4
*)
walther@59957
     5
walther@59957
     6
"-----------------------------------------------------------------------------------------------";
walther@59957
     7
"table of contents -----------------------------------------------------------------------------";
walther@59957
     8
"-----------------------------------------------------------------------------------------------";
walther@59957
     9
"----------- investigate fun add_single in I_Model ---------------------------------------------";
walther@59957
    10
"-----------------------------------------------------------------------------------------------";
walther@59957
    11
"-----------------------------------------------------------------------------------------------";
walther@59957
    12
"-----------------------------------------------------------------------------------------------";
walther@59957
    13
walther@59957
    14
open I_Model;
walther@59957
    15
"----------- investigate fun add_single in I_Model -------------------------------------------";
walther@59957
    16
"----------- investigate fun add_single in I_Model -------------------------------------------";
walther@59957
    17
"----------- investigate fun add_single in I_Model -------------------------------------------";
walther@59997
    18
val f_model = ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
walther@59957
    19
	"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
walther@59957
    20
	"FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
walther@59957
    21
  "AbleitungBiegelinie dy"];
walther@59957
    22
val f_spec = ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]);
Walther@60571
    23
(*[], Pbl*)val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(f_model, f_spec)]; (*\<rightarrow>Model_Problem*)
walther@59957
    24
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Given "Traegerlaenge L"*)
walther@59957
    25
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "Streckenlast q_0"*)
walther@59957
    26
(*[], Pbl*)val (p''''',_,f,nxt''''',_,pt''''') = me nxt p [] pt; (*\<rightarrow>Add_Find "Biegelinie y"*)
walther@59957
    27
walther@59957
    28
(*/------------------- begin step into -----------------------------------------------------\*)
walther@59957
    29
(*+*)val Add_Given "Streckenlast q_0" = nxt;
walther@59957
    30
walther@59957
    31
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, [], pt);
walther@59957
    32
walther@60021
    33
  val ("ok", ([(Add_Given "Streckenlast q_0", _, _)], [], _)) = (*case*)
walther@59957
    34
      Step.by_tactic tac (pt, p) (*of*);
walther@59957
    35
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
walther@59957
    36
  val Applicable.Yes tac' = (*case*)
walther@59957
    37
      Step.check tac (pt, p) (*of*);
walther@59957
    38
	    (*if*) Tactic.for_specify' tac' (*then*);
walther@59957
    39
walther@60021
    40
  val ("ok", ([(Add_Given "Streckenlast q_0", _, _)], [], _)) = (*case*)
walther@59957
    41
Step_Specify.by_tactic tac' ptp;
walther@59957
    42
"~~~~~ fun by_tactic , args:"; val ((Tactic.Add_Given' (ct, _)), (pt, p)) = (tac', ptp);
walther@59957
    43
walther@60021
    44
  val ("ok", ([(Add_Given "Streckenlast q_0", _, _)], [], _)) = (*case*)
walther@60016
    45
   Specify.by_Add_ "#Given" ct (pt, p);
walther@60016
    46
"~~~~~ fun by_Add_ , args:"; val (sel, ct, (pt, pos as (p,_(*Frm, Pbl*)))) =
walther@59957
    47
  ("#Given", ct, (pt, p));
walther@60097
    48
        val (met, oris, (dI', pI', mI'), pbl, (dI, pI, mI), ctxt) = SpecificationC.get_data (pt, pos)
walther@59957
    49
        val thy = if dI = ThyC.id_empty then ThyC.get_theory dI' else ThyC.get_theory dI
walther@59957
    50
        val cpI = if pI = Problem.id_empty then pI' else pI
walther@60154
    51
        val cmI = if mI = MethodC.id_empty then mI' else mI
Walther@60559
    52
        val {ppc, where_, prls, ...} = Problem.from_store ctxt cpI;
walther@59957
    53
walther@59957
    54
(*+*)if Model_Pattern.to_string ppc = "[\"" ^
walther@59997
    55
  "(#Given, (Traegerlaenge, l_l))\", \"" ^
walther@59997
    56
  "(#Given, (Streckenlast, q_q))\", \"" ^
walther@59997
    57
  "(#Find, (Biegelinie, b_b))\", \"" ^
walther@59957
    58
  "(#Relate, (Randbedingungen, r_b))\"]"
walther@59957
    59
(*+*)then () else error "INITIAL Model_Pattern CHANGED";
walther@59957
    60
(*+*)if O_Model.to_string oris = "[\n" ^
walther@59997
    61
  "(1, [\"1\"], #Given, Traegerlaenge, [\"L\"]), \n" ^
walther@59997
    62
  "(2, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@59997
    63
  "(3, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@59997
    64
  "(4, [\"1\"], #Relate, Randbedingungen, [\"[y 0 = 0]\", \"[y L = 0]\", \"[M_b 0 = 0]\", \"[M_b L = 0]\"]), \n" ^
walther@59997
    65
  "(5, [\"1\"], #undef, FunktionsVariable, [\"x\"]), \n" ^
walther@59997
    66
  "(6, [\"1\"], #undef, GleichungsVariablen, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"]), \n" ^
walther@59997
    67
  "(7, [\"1\"], #undef, AbleitungBiegelinie, [\"dy\"])]"
walther@59957
    68
(*+*)then () else error "INITIAL O_Model CHANGED";
walther@59957
    69
(*+*)if I_Model.to_string ctxt pbl = "[\n" ^
walther@59997
    70
  "(0 ,[] ,false ,#Given ,Inc Streckenlast ,(??.empty, [])), \n" ^
walther@59997
    71
  "(0 ,[] ,false ,#Find ,Inc Biegelinie ,(??.empty, [])), \n" ^
walther@59997
    72
  "(0 ,[] ,false ,#Relate ,Inc Randbedingungen [] ,(??.empty, [])), \n" ^
walther@59957
    73
  "(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L ,(l_l, [L]))]"
walther@59957
    74
(*+*)then () else error "INITIAL I_Model CHANGED";
walther@59957
    75
walther@60336
    76
val Add (2, [1], true, "#Given", Cor ((Const (\<^const_name>\<open>Streckenlast\<close>, _), [Free ("q_0", _)]),
walther@59957
    77
      (Free ("q_q", _), [Free ("q_0", _)]))) = (*case*)
walther@59958
    78
   I_Model.check_single ctxt sel oris pbl ppc ct (*of*);
walther@60015
    79
"~~~~~ fun check_single , args:"; val (ctxt, m_field, o_model, i_model, m_patt, str) = (ctxt, sel, oris, pbl, ppc, ct);
walther@59957
    80
      val SOME t =(*case*) TermC.parseNEW ctxt str (*of*);
walther@60336
    81
(** )val ("", (2, [1], "#Given", Const (\<^const_name>\<open>Streckenlast\<close>, _), [Free ("q_0", _)]), [Free ("q_0", _)]) =( **)
walther@59957
    82
(**)val ("", ori', all) =(**)
Walther@60469
    83
          (*case*) O_Model.contains ctxt m_field o_model t (*of*);
walther@59957
    84
walther@59957
    85
(*+*)O_Model.single_to_string ori';
walther@59957
    86
(*+*)val [Free ("q_0", _)] = all;
walther@59957
    87
walther@60336
    88
(** )val ("", (2, [1], true, "#Given", Cor ((Const (\<^const_name>\<open>Streckenlast\<close>, _), [Free ("q_0", _)]), (Free ("q_q", _), [Free ("q_0", _)])))) =( **)
walther@59957
    89
(**)val ("", itm) =(**)
walther@59957
    90
 (*case*) is_notyet_input ctxt i_model all ori' m_patt (*of*);
walther@59957
    91
walther@59957
    92
             Add itm  (*return from add_single*);
walther@60016
    93
"~~~~~ from fun check_single \<longrightarrow>fun by_Add_ , return:"; val (I_Model.Add itm) = (Add itm);
walther@59958
    94
	            val pbl' = I_Model.add_single thy itm pbl;
walther@59957
    95
walther@59957
    96
(*+*)if I_Model.to_string ctxt pbl' = "[\n" ^
walther@59997
    97
  "(0 ,[] ,false ,#Find ,Inc Biegelinie ,(??.empty, [])), \n" ^
walther@59997
    98
  "(0 ,[] ,false ,#Relate ,Inc Randbedingungen [] ,(??.empty, [])), \n" ^
walther@59997
    99
  "(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L ,(l_l, [L])), \n" ^
walther@59957
   100
  "(2 ,[1] ,true ,#Given ,Cor Streckenlast q_0 ,(q_q, [q_0]))]"
walther@59957
   101
(*+*)then () else error "FINAL I_Model CHANGED";
walther@59957
   102
walther@60015
   103
(* this is under cleanup ...*)
Walther@60477
   104
              val tac' = I_Model.make_tactic sel (ct, pbl')
walther@59957
   105
	            val (p, pt') =
walther@60015
   106
	              case Specify_Step.add tac' (Istate_Def.Uistate, ctxt) (pt, (p, Pos.Pbl)) of
walther@60015
   107
  	              ((p, Pos.Pbl), _, _, pt') => (p, pt')
walther@60016
   108
  	            | _ => raise ERROR "by_Add_: uncovered case of Specify_Step.add"
walther@60015
   109
  	            (* only for getting final p_ ..*)
walther@60018
   110
	            val (pb, pre) = Pre_Conds.check prls where_ pbl' 0;
walther@59957
   111
walther@59965
   112
(*+*)if pre = [] then () else error "FINAL Pre_Conds.check' CHANGED 1";
walther@59965
   113
(*+*)if pb = true then () else error "FINAL Pre_Conds.check' CHANGED 1";
walther@59957
   114
(*-------------------- stop step into -------------------------------------------------------*)
walther@59957
   115
(*\------------------- end step into -------------------------------------------------------/*)
walther@59957
   116
walther@59957
   117
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' [] pt'''''; (*\<rightarrow>Add_Relation "Randbedingungen [y 0 = 0]"*)
walther@59957
   118
walther@59957
   119
(* final test ...*)
walther@59957
   120
if p = ([], Pbl) then
walther@59957
   121
  case nxt of Add_Relation "Randbedingungen [y 0 = 0]" => () | _ => error "investigate fun add_single CHANGED 1"
walther@59957
   122
else error "investigate fun add_single CHANGED 2"