src/Tools/isac/TODO.thy
author Walther Neuper <walther.neuper@jku.at>
Thu, 07 May 2020 11:04:02 +0200
changeset 59944 487954805988
parent 59943 4816df44437f
child 59946 c7546066881a
permissions -rw-r--r--
test for O_Model.init (was prep_ori)
     1 (* Title:  todo's for isac core
     2    Author: Walther Neuper 111013
     3    (c) copyright due to lincense terms.
     4 *)
     5 theory TODO
     6 imports "~~/src/Doc/Prog_Prove/LaTeXsugar"
     7 begin
     8 
     9 text \<open>
    10 Legend: here + code since 200120
    11   \<open>(*DOC\<close> identifies stuff dedicated for isac/Doc/Lucas_Interpreter
    12   \<open>(*?!?\<close> identifies a design question
    13 
    14 Distillation of "rounds of reforms":
    15   \<open>TODOs from current changesets\<close> \<rightarrow> \<open>Postponed from current changeset\<close> \<rightarrow>
    16   (*to be removed..*) \<rightarrow> \<open>Separated tasks\<close> (*.. to be removed*)
    17   \<rightarrow> subsection of \<open>Major reforms\<close>
    18 \<close>
    19 
    20 section \<open>TODOs from current changesets\<close>
    21 text\<open>
    22   Shift more complicated issues from  \<open>Current changeset\<close> to \<open>Postponed from current changeset\<close>
    23 \<close>
    24 subsection \<open>Current changeset\<close>
    25 text \<open>
    26 (*/------- to  from -------\*)
    27 (*\------- to  from -------/*)
    28   \begin{itemize}
    29   \item xxx
    30   \item fun specify_init_calc defined twice
    31   \item xxx
    32   \item push nes identifiers back from O/I_Model to Model_Def
    33   \item xxx
    34   \item rename Tactic.Calculate -> Tactic.Evaluate
    35   \item xxx
    36   \item xxx
    37   \item replace src/ Erls by Rule_Set.Empty
    38   \item xxx
    39   \item rename ptyps.sml -> specify-etc.sml
    40         rename Specify -> Specify_Etc
    41         rename SpecifyNEW -> Specify
    42   \item xxx
    43   \item specific_from_prog in..end: replace o by |> (Test_Isac or Test_Some!)
    44   \item xxx
    45   \item cleanup ThmC in MathEngBasic
    46   \item xxx
    47   \item xxx
    48   \item xxx
    49   \item xxx
    50   \item xxx
    51   \item xxx
    52   \item xxx
    53   \item xxx
    54   \end{itemize}
    55 \<close>
    56 subsection \<open>Postponed from current changeset\<close>
    57 text \<open>
    58   \begin{itemize}
    59   \item xxx
    60   \item ctxt is superfluous in specify-phase due to type constraints from Descript.thy
    61   \item xxx
    62   \item Derive.do_one: TODO find code in common with complete_solve
    63         Derive.embed: TODO rewrite according to CAO (+ no intermediate access to Ctree)
    64   \item xxx
    65   \item Solve_Check: postponed parsing input to _ option
    66   \item xxx
    67   \item ? "fetch-tactics.sml" from Mathengine -> BridgeLibisabelle ?
    68   \item xxx
    69   \item ? unify struct.Step and struct.Solve in MathEngine ?
    70   \item xxx
    71   \item use "Eval_Def" for renaming identifiers
    72   \item xxx
    73   \item why does Test_Build_Thydata.thy depend on ProgLang and not on CalcElements ?
    74   \item xxx
    75   \item xxx
    76   \begin{itemize}
    77   \item LI.do_next (*TODO RM..*) ???
    78   \item generate.sml: RM datatype edit TOGETHER WITH datatype inout
    79   \item TermC.list2isalist: typ -> term list -> term  .. should NOT requires typ
    80   \item get_ctxt_LI should replace get_ctxt
    81   \item ALL CODE: rename spec(ification) --> know(ledge), in Specification: Relation -> Knowledge
    82   \item rename   Base_Tool.thy  <---         Base_Tools
    83   \item adopt naming conventions in Knowledge: EqSystem --> Equation_System, etc
    84   \item rename field scr in meth
    85   \item DEL double code: nxt_specify_init_calc IN specify.sml + step-specify.sml
    86   \item xxx
    87   \item xxx
    88   \item xxx
    89   \item xxx
    90   \item xxx
    91   \item xxx
    92   \item xxx
    93   \item clarify Tactic.Subproblem (domID, pblID) as term in Pstate {act_arg, ...}
    94      there it is Free ("Subproblem", "char list \<times> ..
    95      instead of  Const (|???.Subproblem", "char list \<times> ..
    96      AND THE STRING REPRESENTATION IS STRANGE: 
    97        Subproblem (''Test'',
    98         ??.\ <^const> String.char.Char ''LINEAR'' ''univariate'' ''equation''
    99          ''test'')
   100      ML \<open>
   101      \<close> ML \<open>
   102      term2str; (*defined by..*)
   103      fun term_to_string''' thy t =
   104        let
   105          val ctxt' = Config.put show_markup false (Proof_Context.init_global thy)
   106        in Print_Mode.setmp [] (Syntax.string_of_term ctxt') t end;
   107      \<close> ML \<open>
   108      val t = @{term "aaa + bbb"}
   109      val t = @{term "Subproblem (''Test'', [''LINEAR'', ''univariate'', ''equation''])"};
   110      \<close> ML \<open>
   111      val sss = Print_Mode.setmp [] (Syntax.string_of_term @{context}) t
   112      \<close> ML \<open>
   113      writeln sss (*.. here perfect: Subproblem (''Test'', [''LINEAR'', ''univariate'', ''equation'']) *)
   114      \<close> ML \<open>
   115      \<close>
   116   \item xxx
   117   \item xxx
   118   \item cleanup fun me:
   119     fun me (*(_, Empty_Tac) p _ _ = raise ERROR ("me:  Empty_Tac at " ^ pos'2str p)
   120       | me*) (_, tac) p _(*NEW remove*) pt =
   121     + -------------------------^^^^^^
   122     # see test-code.sml fun me_trace
   123       use this also for me, not only for me_ist_ctxt; del. me
   124       this requires much updating in all test/*
   125   \item xxx
   126   \item shift tests into NEW model.sml (upd, upds_envv, ..)
   127   \item xxx
   128   \item clarify handling of contexts ctxt ContextC
   129     \begin{itemize}
   130     \item xxx
   131     \item Specify/ works with thy | Interpret/ works with ctxt | MathEngine.step works with ?!?ctxt
   132     \item xxx
   133     \item Check_Elementwise "Assumptions": prerequisite for ^^goal
   134       rm tactic Check_elementwise "Assumptions" in a way, which keeps it for Minisubpbl
   135       rm Assumptions  :: bool  (* TODO: remove with making ^^^ idle *)
   136     \item xxx
   137     \item xxx
   138     \end{itemize}
   139   \item xxx
   140   \item xxx
   141   \item complete mstools.sml (* survey on handling contexts:
   142   \item xxx
   143   \item xxx
   144   \item xxx
   145   \item xxx
   146   \item librarys.ml --> libraryC.sml + text from termC.sml
   147   \item xxx
   148   \item xxx
   149   \item xxx
   150   \item xxx
   151   \item xxx
   152   \item xxx
   153   \item concentrate "insert_assumptions" for locate_input_tactic in "associate", ?OR? Tactic.insert_assumptions
   154                                    DONE  for find_next_step by Tactic.insert_assumptions m' ctxt 
   155     \begin{itemize}
   156     \item rm from "generate1" ("Detail_Set_Inst'", Tactic.Detail_Set' ?)
   157     \item ?"insert_assumptions" necessary in "init_pstate" ?+++? in "applicable_in" ?+++? "associate"
   158     \item xxx
   159     \item xxx
   160     \item DO DELETIONS AFTER analogous concentrations in find_next_step
   161     \end{itemize}
   162   \item xxx
   163   \item ? what is the difference headline <--> cascmd in
   164     Subproblem' (spec, oris, headline, fmz_, context, cascmd)
   165   \item Substitute' what does "re-calculation mean in the datatype comment?
   166   \item xxx
   167   \item inform: TermC.parse (ThyC.get_theory "Isac_Knowledge") istr --> parseNEW context istr
   168   \item xxx
   169   \item unify/clarify stac2tac_ | 
   170     \begin{itemize}
   171     \item xxx
   172     \item extract common code from associate.. stac2tac_xxx
   173     \item rename LItool.tac_from_prog -> Tactic.from_prog_tac ? Solve_Tac.from_prog_tac,
   174     \item xxx
   175     \item xxx
   176     \end{itemize}
   177   \item xxx
   178   \item unify in signature LANGUAGE_TOOLS =\\
   179     val pblterm: ThyC.id -> Problem.id -> term     vvv        vvv\\
   180     val subpbl: string -> string list -> term          unify with ^^^
   181   \item xxx
   182   \item Telem.safe is questionable: has it been replaced by Safe_Step, Not_Derivable, Helpless, etc?
   183     Note: replacement of Istate.safe by Istate.appy_ didn't care much about Telem.safe.
   184     If Telem.safe is kept, consider merge with CTbasic.ostate
   185   \item xxx
   186   \item remove find_next_step from solve Apply_Method';
   187     this enforces Pos.at_first_tactic, which should be dropped, too.
   188   \item xxx
   189   \item xxx
   190   \item xxx
   191   \end{itemize}
   192 \<close>
   193 subsection \<open>Postponed --> Major reforms\<close>
   194 text \<open>
   195   \begin{itemize}
   196   \item xxx          
   197   \item revisit bootstrap Calcelements. rule->calcelems->termC
   198     would be nice, but is hard: UnparseC.terms -> TermC.s_to_string
   199   \item xxx
   200   \item replace all Ctree.update_* with Ctree.cupdate_problem
   201   \item xxx
   202   \item rename (ist as {eval, ...}) -> (ist as {eval_rls, ...})
   203   \item xxx
   204   \item exception PROG analogous to TERM
   205   \item xxx
   206   \item sig/struc ..elems --> ..elem
   207   \item xxx          
   208   \item distille CAS-command, CAScmd, etc into a struct
   209   \item xxx          
   210   \item check location of files:
   211         test/Tools/isac/Interpret/ptyps.thy
   212         test/Tools/isac/Specify.ptyps.sml
   213   \item xxx
   214   \item check occurences of Atools in src/ test/
   215   \item Const ("Atools.pow", _) ---> Const ("Base_Tool.pow", _) 
   216   \item xxx          
   217   \item rm Float
   218   \item xxx
   219   \item Diff.thy: differentiateX --> differentiate after removal of script-constant
   220   \item Test.thy: met_test_sqrt2: deleted?!
   221   \item xxx          
   222   \item Rewrite_Ord.rew_ord' := overwritel (! Rewrite_Ord.rew_ord', (*<<<---- use Know_Store.xxx, too*)
   223   \item xxx
   224     \item automatically extrac rls from program-code 
   225       ? take ["SignalProcessing", "Z_Transform", "Inverse_sub"] as an example ?
   226   \item xxx          
   227   \item finish output of LItool.trace with Check_Postcond (useful for SubProblem)
   228   \item xxx
   229   \item replace Rule_Set.empty by Rule_Set.Empty
   230     latter is more clear, but replacing ***breaks rewriting over all examples***,
   231     e.g. see ERROR: rewrite__set_ called with 'Erls' for 'precond_rootpbl x'
   232     in Minisubplb/200-start-method-NEXT_STEP.sml:
   233      (*+* )------- in f3cac3053e7b (Rule_Set.empty just renamed, NOT deleted) we had
   234      (*+*)  prls =
   235      (*+*)    Rls {calc = [], erls = Erls, errpatts = [], id = "empty", preconds = [], rew_ord =
   236      (*+*)      ("dummy_ord", fn), rules = [], scr = Empty_Prog, srls = Erls}:
   237      (*+*).. THIS IS Rule_Set.empty, BUT IT DID not CAUSE ANY ERROR !
   238      (*+*)------- WITH Rule_Set.empty REMOVED (based on f3cac3053e7b) we had
   239      (*+*)val Empty = prls (* <---ERROR: rewrite__set_ called with 'Erls' for 'precond_rootpbl x' *)
   240      ( *+*)val ["sqroot-test", "univariate", "equation", "test"] = cpI
   241     THAT INDICATES, that much rewriting/evaluating JUST WORKED BY CHANCE?!?
   242   \item xxx          
   243   \item xxx
   244   \item xxx          
   245   \item xxx
   246   \item xxx          
   247   \item xxx
   248   \item xxx          
   249   \end{itemize}
   250 \<close>
   251 
   252 section \<open>Major reforms\<close>
   253 text \<open>
   254 \<close>
   255 subsection \<open>Exception Size raised\<close>
   256 text \<open>
   257   During update Isabelle2018 --> Isabelle2019 we noticed, that
   258   "isabelle build" uses resources more efficiently than "isabelle jedit".
   259   The former works, but the latter causes 
   260   \begin{itemize}
   261   \item "Exception- Size raised"
   262     in Build_Thydata.thy
   263   \item "exception Size raised (line 169 of "./basis/LibrarySupport.sml")"
   264     in test/../biegelinie-*.xml.
   265   \end{itemize}
   266   This has been detected after changeset (30cd47104ad7) "lucin: reorganise theories in ProgLang".
   267 
   268   Find tools to investigate the Exception, and find ways around it eventually.
   269 \<close>
   270 subsection \<open>Cleanup & review signatures wrt. implementation.pdf canonical argument order\<close>
   271 text \<open>
   272   \begin{itemize}
   273   \item there are comments in several signatures
   274   \item ML_file "~~/src/Tools/isac/Interpret/specification-elems.sml" can be (almost) deleted
   275   \item src/../Frontend/: signatures missing
   276   \item xxx
   277   \end{itemize}
   278 \<close>
   279 subsection \<open>overall structure of code\<close>
   280 text \<open>
   281   \begin{itemize}
   282   \item try to separate Isac_Knowledge from MathEngine
   283     common base: Knowledge_Author / ..??
   284   \item xxx
   285   \item  ML_file "~~/src/Tools/isac/Interpret/ctree.sml" (*shift to base in common with Interpret*)
   286   \item xxx
   287   \item xxx
   288   \item xxx
   289   \end{itemize}
   290 \<close>
   291 subsection \<open>Separate MathEngineBasic/ Specify/ Interpret/ MathEngine/\<close>
   292 text \<open>
   293   \begin{itemize}
   294   \item xxx
   295   \item xxx
   296   \item re-organise code for Interpret
   297     \begin{itemize}
   298     \item Step*: Step_Specify | Step_Solve | Step DONE
   299     \item xxx
   300     \item Prog_Tac: fun get_first_argument takes both Prog_Tac + Program --- wait for separate Tactical
   301       then shift into common descendant
   302     \item xxx
   303     \end{itemize}
   304   \item xxx
   305   \item xxx
   306   \item ??????????? WHY CAN LI.by_tactic NOT BE REPLACED BY Step_Solve.by_tactic ???????????
   307   \item xxx
   308   \item xxx
   309   \end{itemize}
   310 \<close>
   311 subsection \<open>Review modelling- + specification-phase\<close>
   312 text \<open>
   313   \begin{itemize}
   314   \item xxx
   315   \item xxx
   316   \item xxx
   317   \item check match between args of partial_function and model-pattern of meth;
   318      provide error message.
   319   \item xxx
   320   \item "--- hack for funpack: generalise handling of meths which extend problem items ---"
   321     \begin{itemize}
   322     \item see several locations of hack in code
   323     \item these locations are NOT sufficient, see
   324       test/../biegelinie-3.sml --- IntegrierenUndKonstanteBestimmen2: Bsp.7.70. auto ---
   325     \item "fun associate" "match_ags ..dI" instead "..pI" breaks many tests, however,
   326       this would be according to survey Notes (3) in src/../calchead.sml.
   327     \end{itemize}
   328   \item see "failed trial to generalise handling of meths"98298342fb6d
   329   \item abstract specify + nxt_specif to common aux-funs;
   330     see e.g. "--- hack for funpack: generalise handling of meths which extend problem items ---"
   331   \item xxx
   332   \item type model = itm list ?
   333   \item review survey Notes in src/../calchead.sml: they are questionable
   334   \item review copy-named, probably two issues commingled 
   335     \begin{itemize}
   336     \item special handling of "#Find#, because it is not a formal argument of partial_function
   337     \item special naming for solutions of equation solving: x_1, x_2, ...
   338     \end{itemize}
   339   \item xxx
   340   \item xxx
   341   \item this has been written in one go:
   342     \begin{itemize}
   343     \item reconsidering I_Model.max_vt, use problem with meth ["DiffApp","max_by_calculus"]
   344     \item reconsider add_field': where is it used for what? Shift into mk_oris
   345     \item reconsider match_itms_oris: where is it used for what? max_vt ONLY???
   346     \item in Specify_Method search root-oris for items (e.g. "errorBound"), #1# in survey
   347     \item Specify_Problem, Specify_Method: check respective identifiers after re-Specify_
   348       (relevant for pre-condition)
   349     \item unify match_ags to mk_oris1..N with different args (fmz | pat list, pbl | meth
   350     \item 
   351     \end{itemize}
   352   \end{itemize}
   353 \<close>
   354 subsection \<open>taci list, type step\<close>
   355 text \<open>
   356 taci was, most likely, invented to make "fun me" more efficient by avoiding duplicate rewrite,
   357 and probably, because the Kernel interface separated setNextTactic and applyTactic.
   358 Both are no good reasons to make code more complicated.
   359 
   360 !!! taci list is used in do_next !!!
   361 
   362   \begin{itemize}
   363   \item xxx
   364   \item can lev_on_total replace lev_on ? ..Test_Isac_Short + rename lev_on_total -> lev_on
   365   \item xxx
   366   \item Step* functions should return Calc.T instead of Chead.calcstate'
   367   \item xxx
   368   \item states.sml: check, when "length tacis > 1"
   369   \item in Test_Isac.thy there is only 1 error in Interpret/inform.sml
   370   \item (*WN190713 REMOVE: "creating a new node" was never implemented for more than one node?!?
   371   \item xxx
   372   \item brute force setting all empty ([], [], ptp) works!?! but ptp causes errors -- investigate!
   373   \item xxx
   374   \end{itemize}
   375 \<close>
   376 subsection \<open>Ctree\<close>
   377 text \<open>
   378 analysis
   379 # mixture pos' .. pos in cappend_*, append_* is confusing
   380 # existpt p pt andalso Tactic.is_empty DIFFERENT IN append_*, cappend_* is confusing
   381   "exception PTREE "get_obj: pos =" ^^^^^: ^^^^ due to cut !!!
   382   NOTE: exn IN if..andalso.. IS NOT!!! DETECTED, THIS                       is confusing
   383   see test/../--- Minisubpbl/800-append-on-Frm.sml ---
   384 # ?!? "cut branches below cannot be decided here" in append_atomic
   385 # sign. of functions too different ?!?canonical arg.order ?!?
   386   \begin{itemize}
   387   \item xxx
   388   \item remove update_branch, update_*? -- make branch, etc args of append_*
   389   \item xxx
   390   \item close sig Ctree, contains cappend_* ?only? --- ?make parallel to ?Pide_Store?
   391   \item xxx
   392   \item unify args to Ctree.state (pt, p)
   393   \item  fun update_env       .. repl_env                   \<rightarrow>updatempty
   394   \item xxx
   395   \item xxx
   396   \item xxx
   397   \item xxx
   398   \end{itemize}
   399 \<close>
   400 subsection \<open>replace theory/thy by context/ctxt\<close>
   401 text \<open>
   402   \begin{itemize}
   403   \item xxx
   404   \item Specify/ works with thy | Interpret/ works with ctxt | MathEngine.step works with ?!?ctxt
   405     special case: Tactic.Refine_Problem
   406   \item xxx
   407   \item theory can be retrieved from ctxt by Proof_Context.theory_of
   408   \item xxx
   409   \item cleaup the many conversions string -- theory
   410   \item make dest_spec --> (theory, pblID, metID) ?+ common_subthy ?
   411   \item 1. Rewrite.eval_true_, then
   412     LItool.check_leaf, Rewrite.eval_prog_expr, Step.add, LItool.tac_from_prog.
   413   \item fun associate
   414     let val thy = ThyC.get_theory "Isac_Knowledge";(*TODO*)
   415   \item xxx
   416   \item xxx
   417   \item in locate_input_tactic .. ?scan_dn1?; Program.is_eval_expr   .use  Term.exists_Const
   418   \item push srls into pstate
   419   \item lucas-intrpreter.locate_input_tactic: scan_to_tactic1 srls tac cstate (progr, Rule_Set.Empty)
   420                                                                                       ^^^^^^^^^^^^^^^
   421   \item xxx
   422   \end{itemize}
   423 \<close>
   424 subsection \<open>Rfuns, Begin_/End_Detail', Rrls, Istate\<close>
   425 text \<open>
   426 remove refactor Rfuns, Rule.Prog, Rule.Empty_Prog, RrlsState: this is a concept never brought to work.
   427   Clarify relation to reverse rewriting!
   428   \begin{itemize}
   429   \item separate mut.recursion program with rule and rls by deleting fild scr in rls
   430     (possible since CS 43160c1e775a
   431   ` "replace Prog. in prep_rls by Auto_Prog.gen, which generates Prog. on the fly" )
   432   \item xxx
   433   \item probably only "normal_form" seems to be needed
   434   \item deleted Rfuns in NEW "locate_input_tactic": no active test for "locate_rule"
   435     but that seems desirable
   436   \item ?how is the relation to reverse-rewriting ???
   437   \item "Rfuns" markers in test/../rational
   438   \item xxx
   439   \item datatype istate (Istate.T): remove RrlsState, pstate: use Rrls only for creating results beyond
   440     rewriting and/or respective intermediate steps (e.g. cancellation of fractions).
   441     Thus we get a 1-step-action which does NOT require a state beyond istate/pstate.
   442     Thus we drastically reduce complexity, also get rid of "fun from_pblobj_or_detail_calc" , etc.
   443   \item debug ^^^ related: is there an occurence of Steps with more than 1 element?
   444   \item xxx
   445   \item and do_next (* WN1907: ?only for Begin_/End_Detail' DEL!!!*)
   446   \item xxx
   447   \item shouldn't go Rfuns from Rewrite --> Rewrite_Set; they behave similar to "fun interSteps" ?
   448   \item xxx
   449   \item ?finally Prog could go from Calcelems to ProgLang?
   450   \end{itemize}
   451 \<close>
   452 subsection \<open>Inverse_Z_Transform.thy\<close>
   453 text \<open>
   454   \begin{itemize}
   455   \item\label{new-var-rhs} rule1..6, ruleZY introduce new variables on the rhs of the rewrite-rule.
   456   ? replace rewriting with substitution ?!?
   457   The problem is related to the decision of typing for "d_d" and making bound variables free (while
   458   shifting specific handling in equation solving etc. to the meta-logic). 
   459   \item Find "stepResponse (x[n::real]::bool)" is superfluous, because immediately used by
   460     rewrite-rules; see \ref{new-var-rhs}.
   461   \item Reconsider whole problem:
   462     input only the polynomial as argument of partial_function, in ([1], Frm) compile lhs "X z" ?
   463   \end{itemize}
   464 \<close>
   465 subsection \<open>Adopt Isabelle's numerals for Isac\<close>
   466 text \<open>
   467   \begin{itemize}
   468   \item replace numerals of type "real" by "nat" in some specific functions from ListC.thy
   469     and have both representations in parallel for "nat".
   470   \item xxx
   471   \item xxx
   472   \end{itemize}
   473 \<close>
   474 subsection \<open>Redesign equation solver\<close>
   475 text \<open>
   476   Existing solver is structured along the WRONG assumption,
   477   that Poly.thy must be the LAST thy among all thys involved -- while the opposite is the case.
   478 
   479   Preliminary solution: all inappropriately located thms are collected in Base_Tools.thy
   480 \<close>
   481 subsection \<open>Finetunig required for xmldata in kbase\<close>
   482 text \<open>
   483   See xmldata https://intra.ist.tugraz.at/hg/isac/rev/5b222a649390
   484   and in kbase html-representation generated from these xmldata.
   485   Notes in ~~/xmldata/TODO.txt.
   486 \<close>
   487 
   488 section \<open>Hints for further development\<close>
   489 text \<open>
   490 \<close>
   491 subsection \<open>Coding standards & some explanations for math-authors\<close>
   492 text \<open>copy from doc/math-eng.tex WN.28.3.03
   493 WN071228 extended\<close>
   494 
   495 subsubsection \<open>Identifiers\<close>
   496 text \<open>Naming is particularily crucial, because Isabelles name space is global, and isac does
   497   not yet use the novel locale features introduces by Isar. For instance, {\tt probe} sounds
   498   reasonable as (1) a description in the model of a problem-pattern, (2) as an element of the
   499   problem hierarchies key, (3) as a socalled CAS-command, (4) as the name of a related script etc.
   500   However, all the cases (1)..(4) require different typing for one and the same
   501   identifier {\tt probe} which is impossible, and actually leads to strange errors
   502   (for instance (1) is used as string, except in a script addressing a Subproblem).
   503 
   504   These are the preliminary rules for naming identifiers>
   505   \begin{description}
   506   \item [elements of a key] into the hierarchy of problems or methods must not contain
   507     capital letters and may contain underscrores, e.g. {\tt probe, for_polynomials}.
   508   \item [descriptions in problem-patterns] must contain at least 1 capital letter and
   509     must not contain underscores, e.g. {\tt Probe, forPolynomials}.
   510   \item [CAS-commands] follow the same rules as descriptions in problem-patterns above, thus
   511     beware of conflicts~!
   512   \item [script identifiers] always end with {\tt Program}, e.g. {\tt ProbeScript}.
   513   \item [???] ???
   514   \item [???] ???
   515   \end{description}
   516 %WN071228 extended\<close>
   517 
   518 subsubsection \<open>Rule sets\<close>
   519 text \<open>The actual version of the coding standards for rulesets is in {\tt /IsacKnowledge/Atools.ML
   520   where it can be viewed using the knowledge browsers.
   521 
   522   There are rulesets visible to the student, and there are rulesets visible (in general) only for
   523   math authors. There are also rulesets which {\em must} exist for {\em each} theory;
   524   these contain the identifier of the respective theory (including all capital letters) 
   525   as indicated by {\it Thy} below.
   526 
   527   \begin{description}
   528   \item [norm\_{\it Thy}] exists for each theory, and {\em efficiently} calculates a
   529     normalform for all terms which can be expressed by the definitions of the respective theory
   530     (and the respective parents).
   531   \item [simplify\_{\it Thy}] exists for each theory, and calculates a normalform for all terms
   532     which can be expressed by the definitions of the respective theory (and the respective parents)
   533     such, that the rewrites can be presented to the student.
   534   \item [calculate\_{\it Thy}] exists for each theory, and evaluates terms with 
   535     numerical constants only (i.e. all terms which can be expressed by the definitions of
   536     the respective theory and the respective parent theories). In particular, this ruleset includes
   537     evaluating in/equalities with numerical constants only.
   538     WN.3.7.03: may be dropped due to more generality: numericals and non-numericals
   539     are logically equivalent, where the latter often add to the assumptions
   540     (e.g. in Check_elementwise).
   541   \end{description}
   542 
   543   The above rulesets are all visible to the user, and also may be input; 
   544   thus they must be contained in {\tt Theory_Data} (KEStore_Elems.add_rlss,
   545   KEStore_Elems.get_rlss). All these rulesets must undergo a preparation
   546   using the function {\tt prep_rls'}, which generates a script for stepwise rewriting etc.
   547   The following rulesets are used for internal purposes and usually invisible to the (naive) user:
   548 
   549   \begin{description}
   550   \item [*\_erls] TODO
   551   \item [*\_prls] 
   552   \item [*\_srls] 
   553   \end{description}
   554 {\tt Rule_Set.append_rules, Rule_Set.merge, remove_rls} TODO
   555 \<close>
   556 
   557 subsection \<open>get proof-state\<close>
   558 text \<open>
   559   Re: [isabelle] Programatically get "this"
   560   ----------------------------------------------------
   561   So here is my (Makarius') version of your initial example, following these principles:
   562   begin{verbatim}
   563     notepad
   564     begin
   565       assume a: A
   566       ML_val \<open>
   567         val ctxt = @{context};
   568     
   569         val this_name =
   570           Name_Space.full_name (Proof_Context.naming_of ctxt) (Binding.name Auto_Bind.thisN);
   571         val this = #thms (the (Proof_Context.lookup_fact ctxt this_name));
   572       \<close>
   573     end
   574   end{verbatim}
   575 \<close>
   576 subsection \<open>write Specification to jEdit\<close>
   577 text \<open>
   578   Re: [isabelle] Printing terms with type annotations
   579   ----------------------------------------------------
   580   On 06/02/2019 17:52, Moa Johansson wrote:
   581   >
   582   > I’m writing some code that should create a snippet of Isar script.
   583   
   584   This is how Sledgehammer approximates this:
   585   
   586   http://isabelle.in.tum.de/repos/isabelle/file/Isabelle2018/src/HOL/Tools/Sledgehammer/sledgehammer_isar_proof.ML#l299
   587   
   588   (The module name already shows that the proper terminology is "Isar
   589   proof" (or "Isar proof text").  Proof scripts are a thing from the past,
   590   before Isar. You can emulate old-style proof scripts via a sequence of
   591   'apply' commands, but this is improper Isar.)
   592   
   593   Note that there is no standard function in Isabelle/Pure, because the
   594   problem to print just the right amount of type information is very
   595   complex and not fully solved. One day, after 1 or 2 rounds of
   596   refinements over the above approach, it might become generally available.
   597 \<close>
   598 subsection \<open>follow Isabelle conventions (*Does not yet work in Isabelle2018\<close>
   599 text \<open>
   600   isabelle update -u path_cartouches
   601   isabelle update -u inner_syntax_cartouches
   602 \<close>
   603 section \<open>Questions to Isabelle experts\<close>
   604 text \<open>
   605 \begin{itemize}
   606 \item ad ERROR Undefined fact "all_left"        in Test_Isac: error-pattern.sml
   607                Undefined fact: "xfoldr_Nil"                   inssort.sml
   608     (* probably two different reasons:
   609     src/../LinEq.thy
   610       (*WN0509 compare PolyEq.all_left "[|Not(b=!=0)|] ==> (a = b) = (a - b = 0)"*)
   611       all_left:          "[|Not(b=!=0)|] ==> (a=b) = (a+(-1)*b=0)" and
   612     
   613     src/../PolyEq.thy
   614       (*WN0509 compare LinEq.all_left "[|Not(b=!=0)|] ==> (a=b) = (a+(-1)*b=0)"*)
   615       all_left:              "[|Not(b=!=0)|] ==> (a = b) = (a - b = 0)" and
   616     
   617     test/../partial_fractions.sml
   618     (*[7], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["PolyEq", "normalise_poly"])*)
   619     (*[7, 1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite ("all_left", "\<not> ?b =!= 0 \<Longrightarrow> (?a = ?b) = (?a - ?b = 0)"))*)
   620     
   621     test/../mathengine-stateless.sml
   622     (*if ThmC.string_of_thm @ {thm rnorm_equation_add} =  "\<not> ?b =!= 0 \<Longrightarrow> (?a = ?b) = (?a + - 1 * ?b = 0)"
   623     then () else error "string_of_thm changed";*)
   624     
   625     (*---------------------------------------------------------------------------------------------*)
   626     src/../LinEq.thy
   627     primrec xfoldr :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a xlist \<Rightarrow> 'b \<Rightarrow> 'b" where
   628     xfoldr_Nil:  "xfoldr f {|| ||} = id" |
   629     xfoldr_Cons: "xfoldr f (x @# xs) = f x \<circ> xfoldr f xs"
   630     
   631     src/../InsSort.thy
   632         srls = Rule_Set.empty, calc = [], rules = [
   633           Rule.Thm ("xfoldr_Nil",(*num_str*) @{thm xfoldr_Nil} (* foldr ?f [] = id *)),
   634     *)
   635 \item xxx
   636 \item xxx
   637 \item ?OK Test_Isac_Short with
   638     LI.by_tactic tac (get_istate_LI pt p, get_ctxt_LI pt p) ptp
   639   instead
   640     LI.by_tactic tac (Istate.empty, ContextC.empty) ptp
   641   in step-solve ?
   642 \item xxx
   643 \item test from last CS with outcommented re-def of code -> 
   644   -> \<open>further tests additional to src/.. files\<close>
   645       ADDTESTS/redefined-code.sml
   646 \item xxx
   647 \item efb749b79361 Test_Some_Short.thy has 2 errors, which disappear in thy ?!?:
   648   ML_file "Interpret/error-pattern.sml" Undefined fact: "all_left"
   649   ML_file "Knowledge/inssort.sml" Undefined fact: "xfoldr_Nil"
   650 \item xxx
   651 \item what is the actual replacement of "hg log --follow" ?
   652 \item xxx
   653 \item how HANDLE these exceptions, e.g.:
   654     Syntax.read_term ctxt "Randbedingungen y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]"
   655   GIVES
   656     "Inner syntax error
   657      Failed to parse term"
   658 \item xxx
   659 \item how cope with "exception Size raised (line 171 of "./basis/LibrarySupport.sml")"
   660   e.g. in test/Interpret/lucas-interpreter.sml
   661 \item xxx
   662 \item xxx
   663 \end{itemize}
   664 \<close>
   665 
   666 section \<open>For copy & paste\<close>
   667 text \<open>
   668 \begin{itemize}
   669 \item xxx
   670   \begin{itemize}
   671   \item xxx
   672     \begin{itemize}
   673     \item xxx
   674       \begin{itemize}
   675       \item xxx
   676         \begin{itemize}
   677         \item xxx
   678         \end{itemize}
   679       \end{itemize}
   680     \end{itemize}
   681   \end{itemize}
   682 \end{itemize}
   683 \<close>
   684 subsection \<open>xxx\<close>
   685 subsubsection \<open>xxx\<close>
   686 end