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