src/Tools/isac/TODO.thy
author Walther Neuper <walther.neuper@jku.at>
Wed, 18 Dec 2019 14:48:43 +0100
changeset 59746 00da1a5352f3
parent 59744 5cf58a93d077
child 59748 f446e732cb00
permissions -rw-r--r--
cleanup, unify code for Check_Postcond'
     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 section \<open>TODOs from current changesets\<close>
    10 text\<open>
    11   Shift more complicated issues from the next subsection to the next but one!
    12 \<close>
    13 subsection \<open>Current changeset\<close>
    14 text \<open>
    15   \begin{itemize}
    16   \item xxx
    17   \item xxx
    18   \item xxx
    19   \item xxx
    20   \item xxx
    21   \item rm test/..--- check Scripts ---
    22   \item xxx
    23   \item reformat + rename "fun eval_leaf"+"fun get_stac"
    24         (*1*)(*2*)
    25         ?consistency with subst term?
    26   \item Tactic.Rewrite*': drop "bool"
    27   \item xxx
    28   \item exception PROG analogous to TERM
    29   \item xxx
    30   \item xxx
    31   \item xxx
    32   \item Prog_Tac: fun get_stac takes both Prog_Tac + Program --- wait for separate Taciical
    33     then shift into common descendant
    34     rename get_stac --> ?ptac?
    35   \item xxx
    36   \item xxx
    37   \item xxx
    38   \item separate code required in both, ProgLang & Interpret
    39   \item xxx
    40   \item /-------------------------------------------------------------------
    41   \item check occurences of KEStore_Elems.add_rlss [("list_rls",
    42   \item rename list_rls accordingly
    43   \item ------------------------------------------------------------------/
    44   \item xxx
    45     \item lucas-interpreter.sml         ----- vvvvvvvvv etc.
    46       val (p'',_,_,pt'') = Generate.generate1 @ {theory} tac' (Istate.Pstate is, ctxt) (po', p_) pt
    47   \item xxx
    48   \item rm Float
    49   \item xxx
    50     \item signature LIBRARY_C
    51     \item Program.thy  (*=========== record these ^^^ in 'tacs' in program.ML =========*)
    52     \item sig/struc ..elems --> elem
    53     \item xxx
    54     \item xxx
    55     \end{itemize}
    56   \item xxx
    57   \item xxx
    58   \item distribute test/../scrtools.sml
    59   \item xxx
    60   \item xxx
    61   \item simplify calls of scan_dn1, scan_dn2 etc
    62   \item open Istate in LucinNEW
    63   \end{itemize}
    64 \<close>
    65 subsection \<open>Differences between code and paper\<close>
    66 text \<open>
    67   \begin{itemize}
    68   \item xxx
    69   \item xxx
    70   \item xxx
    71   \item xxx
    72   \item xxx
    73   \end{itemize}
    74 \<close>
    75 subsection \<open>Postponed from current changeset\<close>
    76 text \<open>
    77   \begin{itemize}
    78   \item xxx
    79   \item re-organise code for Interpret
    80     \begin{itemize}
    81     \item Step*:
    82           datatype step_result =  Step of Ctree.state | Step_Failed of msg (*TODO: exn hierarchy*)
    83           not other returns, because Step_Solve.add immediately after lucin, so all in Ctree.state.
    84       \begin{itemize}
    85       \item Step_Specify in Specify/step-specify.sml in analogy to Interpret/... TODO
    86         \begin{itemize}
    87         \item Step_Specify.check <-- Applicable.applicable_in
    88           inserts all data into Tactic.T available -- not all are at time of call!
    89         \item Step_Specify.add   <-- Generate.generate1
    90         \item Step_Specify.by_tactic : Tactic.input -> Ctree.state -> step_result
    91         \item Step_Specify.by_formula: ?term?       -> Ctree.state -> step_result
    92         \item Step_Specify.find_next :                 Ctree.state -> step_result
    93         \end{itemize}
    94       \item Step_Solve in Interpret/step-solve.sml
    95         \begin{itemize}
    96         \item Step_Solve.check   <-- Applicable.applicable_in
    97           inserts all data into Tactic.T available -- not all are at time of call!
    98         \item Step_Solve.add     <-- Generate.generate1
    99         \item Step_Solve.by_tactic   : Tactic.input -> Ctree.state -> step_result
   100           ^^^^LucinNEW,begin_end_prog
   101         \item Step_Solve.by_formula  : term         -> Ctree.state -> step_result
   102         \item Step_Solve.find_next   :                 Ctree.state -> step_result
   103           ^^^^LucinNEW,do_solve_step;  Apply_Method ever used???
   104         \end{itemize}
   105       \item Step in MathEngine/step.sml
   106         \begin{itemize}
   107         \item Step.check     : Step_Specify.check      | Step_Solve.check      depending on pos'
   108           inserts all data into Tactic.T available -- not all are at time of call!
   109         \item Step.add       : Step_Specify.add        | Step_Solve.add        depending on pos'
   110         \item Step.by_tactic : Step_Specify.by_tactic  | Step_Solve.by_tactic  depending on pos'
   111         \item Step.by_formula: Step_Specify.by_formula | Step_Solve.by_formula depending on pos'
   112         \item Step.find_next : Step_Specify.find_next  | Step_Solve.find_next  depending on pos'
   113         \end{itemize}
   114       \end{itemize}
   115     \item xxx
   116     \item MathEngBasic/calculation.sml
   117       \begin{itemize}
   118       \item rename Calc --> Calc_
   119       \item ? type Calc.T = CTree.state ?
   120       \item Calc.add_step <-- Step_Specify.add + Step_Solve.add <-- Generate.generate*
   121       \item xxx
   122       \end{itemize}
   123     \item xxx
   124     \end{itemize}
   125   \item xxx
   126   \item xxx
   127   \item decompose do_solve_step, begin_end_prog: mutual recursion only avoids multiple generate1
   128     ! ^^^ in find_next_tactic --- ? ? ? in locate_input_tactic ?
   129   \item xxx
   130   \item Generate.generate1 thy is redundant: is the same during pbl, thus lookup spec
   131   \item xxx
   132   \item NEW structure Step.applicable     Step.add
   133                           ^applicable_in      ^generate1
   134   \item xxx
   135   \item revise Pstate {or, ...}; strange occurrence in program without Tactical.Or documented here
   136   \item xxx
   137   \item shift tests into NEW model.sml (upd, upds_envv, ..)
   138   \item xxx
   139   \item NEW structures
   140     \begin{itemize}
   141     \item Step
   142       \begin{itemize}
   143       \item Applicable.applicable_in --> Step.applicable
   144       \item Generate.generate1       --> Step.add        ?-->? Calculation.add_step 
   145       \item xxx
   146       \end{itemize}
   147     \item Calculation ("Calc" is occupied ?!?)           ?^^^? Calculation
   148       \begin{itemize}
   149       \item Ctree.state ?-->? Calculation.T
   150       \item Chead.calcstate   --> Calculation.prestate
   151       \item Chead.calcstate'  --> Calculation.poststate
   152       \item e_calcstate, e_calcstate' -"-
   153       \item xxx
   154       \end{itemize}
   155     \end{itemize}
   156   \item xxx
   157   \item clarify handling of contexts
   158     \begin{itemize}
   159     \item Check_Elementwise "Assumptions": prerequisite for ^^goal
   160       rm tactic Check_elementwise "Assumptions" in a way, which keeps it for Minisubpbl
   161       rm Assumptions  :: bool  (* TODO: remove with making ^^^ idle *)
   162     \item xxx
   163     \item cleanup fun me:
   164       fun me (*(_, Empty_Tac) p _ _ = raise ERROR ("me:  Empty_Tac at " ^ pos'2str p)
   165         | me*) (_, tac) p _(*NEW remove*) pt =
   166       + -------------------------^^^^^^
   167     \item xxx
   168     \item Tactic.Apply_Method' (mI, _, _, _(*ctxt ?!?*))) .. remove ctxt
   169     \item rm ctxt from Subproblem' (is separated in associate!))
   170     \item check Tactic.Subproblem': are 2 terms required?
   171     \item xxx
   172     \item Test_Some.--- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts --
   173       --: wait for deleting Check_Elementwise Assumptions
   174     \item xxx
   175     \item lucas-intrpreter.scan_dn1: Generate.generate1 (Celem.assoc_thy "Isac_Knowledge") 
   176     \end{itemize}
   177   \item xxx
   178   \item reconsider "fun eval_leaf"
   179      CAUTION: (1) currying with @@ requires 2 patterns for each tactic
   180               (2) the non-curried version must return NONE for a 
   181      	      (3) non-matching patterns become an Program.Expr by fall-through.
   182        (a, (*in these cases we hope, that a = SOME _*) --> exn ?PROGRAM?
   183      rename ?ptac?, prog_tac
   184   \item xxx
   185   \item complete mstools.sml (* survey on handling contexts:
   186   \item xxx
   187   \item dest_spec (Const ("Product_Type.Pair", _) $ d $ (Const ("Product_Type.Pair", _) FORALL occur.
   188   \item introduce simple type names to LUCAS_INTERPRETER <-?-> readable paper
   189   \item xxx
   190   \item check in states: length ?? > 1 with tracing these cases
   191   \item xxx
   192   \item xxx
   193   \item Lucin.Ass_Weak etc \<longrightarrow> NEW structutre ? LItool ?
   194   \item xxx
   195   \item istate
   196     \begin{itemize}
   197     \item datatype L,R,D --> Istate
   198     \item xxx
   199     \item xxx
   200     \item xxx
   201     \item in locate_input_tactic .. ?scan_dn1?; Program.is_eval_expr   .use  Term.exists_Const
   202     \item xxx
   203     \item change Lucin.interpret_leaf "locate" "Isac_Knowledge" sr E a v t
   204         to     Lucin.interpret_leaf "locate"  ctxt ( pstate )        !!srls in pstate!!^^
   205         and redesign interpret_leaf .. eval_leaf .. associate
   206         to Tactic.from_code : 
   207         + keep ! trace_script
   208         + scrstate2str --> pstate2str
   209     \item xxx
   210     \item after review of Rrls, detail ?-->? istate
   211     \item locate_input_tactic: get_simplifier cstate (*TODO: shift to init_istate*)
   212     \item xxx
   213     \item push srls into pstate
   214     \item lucas-intrpreter.locate_input_tactic: scan_to_tactic1 srls tac cstate (progr, Rule.e_rls)
   215                                                                                         ^^^^^^^^^^
   216     \item xxx
   217     \item xxx
   218     \end{itemize}
   219   \item xxx
   220   \item ctxt context
   221     \begin{itemize}
   222     \item xxx
   223     \item xxx
   224     \item xxx
   225     \end{itemize}
   226   \item trace_script: replace ' by " in writeln
   227   \item xxx
   228   \item librarys.ml --> libraryC.sml + text from termC.sml
   229   \item xxx
   230   \item xxx
   231   \item xxx
   232   \item xxx
   233   \item xxx
   234   \item xxx
   235   \item pull update of Ctree.state out of 2 Lucin funs (locate_input_formula is different))
   236     \begin{itemize}
   237     \item 1. check if Ctree.state can be updated OUTSIDE determine_next_step
   238     \item 2. fun locate_input_tactic: pull generate1 out (because it stores ctxt also in cstate)
   239     \item 
   240     \item xxx
   241     \end{itemize}
   242   \item concentrate "insert_assumptions" for locate_input_tactic in "associate", ?OR? Tactic.insert_assumptions
   243                                    DONE  for find_next_tactic by Tactic.insert_assumptions m' ctxt 
   244     \begin{itemize}
   245     \item rm from "generate1" ("Detail_Set_Inst'", Tactic.Detail_Set' ?)
   246     \item shift from "applicable_in..Apply_Method" to ? ? ? (is ONLY use-case in appl.sml))
   247     \item ?"insert_assumptions" necessary in "init_pstate" ?+++? in "applicable_in" ?+++? "associate"
   248     \item xxx
   249     \item xxx
   250     \item DO DELETIONS AFTER analogous concentrations in find_next_tactic
   251     \end{itemize}
   252   \item xxx
   253   \item ? what is the difference headline <--> cascmd in
   254     Subproblem' (spec, oris, headline, fmz_, context, cascmd)
   255   \item xxx
   256   \item inform: TermC.parse (Celem.assoc_thy "Isac_Knowledge") istr --> parseNEW context istr
   257   \item extract common code from associate.. stac2tac_
   258   \end{itemize}
   259 \<close>
   260 
   261 section \<open>Separated tasks\<close>
   262 text \<open>
   263 \<close>
   264 subsection \<open>Simple\<close>
   265 text \<open>
   266   \item xxx
   267   \item xxx
   268   \item check location of files:
   269         test/Tools/isac/Interpret/ptyps.thy
   270         test/Tools/isac/Specify.ptyps.sml
   271   \item xxx
   272   \item check occurences of Atools in src/ test/
   273   \item xxx
   274   \item drop  drop_questionmarks_
   275   \item xxx
   276   \item Const ("Atools.pow", _) ---> Const ("Base_Tool.pow", _) 
   277   \item rename   Base_Tool.thy  <---         Base_Tool
   278   \item xxx
   279   \item test/..  tools.sml, atools.sml, scrtools.sml ...
   280   \item xxx
   281   \item Diff.thy: differentiateX --> differentiate after removal of script-constant
   282   \item Test.thy: met_test_sqrt2: deleted?!
   283   \item xxx
   284   \item Applicable.applicable_in --> Applicable.tactic_at
   285   \item xxx
   286   \item adopt naming conventions in Knowledge: EqSystem --> Equation_System, etc
   287   \item xxx
   288   \item TermC.vars_of replace by vars (recognises numerals)
   289   \item xxx
   290   \item xxx
   291   \end{itemize}
   292 \<close>
   293 subsection \<open>Simple but laborous\<close>
   294 text \<open>
   295   \begin{itemize}
   296   \item prep_met
   297     \begin{itemize}
   298     \item rename field scr in meth
   299     \item xxx
   300     \item Rule.rew_ord' := overwritel (! Rule.rew_ord', (*<<<---- use KEStore.xxx, too*)
   301     \item xxx
   302     \item check match between args of partial_function and model-pattern of meth;
   303        provide error message.
   304     \item xxx
   305     \item automatically extrac rls from program-code 
   306       ? take ["SignalProcessing", "Z_Transform", "Inverse_sub"] as an example ?
   307     \item xxx
   308     \item xxx
   309     \item xxx
   310     \end{itemize}
   311   \item xxx
   312   \item drop "init_form" and use "Take" in programs (start with latter!)
   313   \item xxx
   314   \item deprive Check_elementwise, but keep it for Minisubpl
   315     (which checks for Check_Postcond separated by another tactic)
   316     This seems a prerequisite for appropriate handling of contexts at Check_Postcond.
   317   \item xxx
   318   \end{itemize}
   319 \<close>
   320 subsection \<open>Questionable\<close>
   321 text \<open>
   322   \begin{itemize}
   323   \item finish output of trace_script with Check_Postcond (useful for SubProblem)
   324   \item unify in signature LANGUAGE_TOOLS =\\
   325     val pblterm: Rule.domID -> Celem.pblID -> term     vvv        vvv\\
   326     val subpbl: string -> string list -> term          unify with ^^^
   327   \item xxx
   328   \item Telem.safe is questionable: has it been replaced by Safe_Step, Not_Derivable, Helpless, etc?
   329     Note: replacement of Istate.safe by Istate.appy_ didn't care much about Telem.safe.
   330     If Telem.safe is kept, consider merge with CTbasic.ostate
   331   \item xxx
   332   \item remove find_next_tactic from solve Apply_Method';
   333     this enforces Pos.at_first_tactic, which should be dropped, too.
   334   \item xxx
   335   \item xxx
   336   \end{itemize}
   337 \<close>
   338 section \<open>Complex, related to --> other tasks\<close>
   339 text \<open>
   340 \<close>
   341 subsection \<open>Exception Size raised\<close>
   342 text \<open>
   343   During update Isabelle2018 --> Isabelle2019 we noticed, that
   344   "isabelle build" uses resources more efficiently than "isabelle jedit".
   345   The former works, but the latter causes 
   346   \begin{itemize}
   347   \item "Exception- Size raised"
   348     in Build_Thydata.thy
   349   \item "exception Size raised (line 169 of "./basis/LibrarySupport.sml")"
   350     in test/../biegelinie-*.xml.
   351   \end{itemize}
   352   This has been detected after changeset (30cd47104ad7) "lucin: reorganise theories in ProgLang".
   353 
   354   Find tools to investigate the Exception, and find ways around it eventually.
   355 \<close>
   356 subsection \<open>Cleanup & review signatures wrt. implementation.pdf canonical argument order\<close>
   357 text \<open>
   358   \begin{itemize}
   359   \item there are comments in several signatures
   360   \item ML_file "~~/src/Tools/isac/Interpret/specification-elems.sml" can be (almost) deleted
   361   \item src/../Frontend/: signatures missing
   362   \item xxx
   363   \end{itemize}
   364 \<close>
   365 subsection \<open>overall structure of code\<close>
   366 text \<open>
   367   \begin{itemize}
   368   \item try to separate Isac_Knowledge from MathEngine
   369     common base: Knowledge_Author / ..??
   370   \item xxx
   371   \item  ML_file "~~/src/Tools/isac/Interpret/ctree.sml" (*shift to base in common with Interpret*)
   372   \item xxx
   373   \item xxx
   374   \item xxx
   375   \end{itemize}
   376 \<close>
   377 subsection \<open>solve, loc_solve_, begin_end_prog, do_solve_step, ...\<close>
   378 text \<open>
   379   unify to calcstate, calcstate', ?Ctree.state?
   380   \begin{itemize}
   381   \item begin_end_prog Check_Postcond' needs NO 2.find_next_tactic
   382                  solve Check_Postcond' needs, because NO prog_result in Tactic.input
   383      and applicable_in cannot get it.
   384   \item xxx
   385   \item adopt the same for specification phase
   386   \item xxx
   387   \end{itemize}
   388 \<close>
   389 subsection \<open>Review modelling- + specification-phase\<close>
   390 text \<open>
   391   \begin{itemize}
   392   \item "--- hack for funpack: generalise handling of meths which extend problem items ---"
   393     \begin{itemize}
   394     \item see several locations of hack in code
   395     \item these locations are NOT sufficient, see
   396       test/../biegelinie-3.sml --- IntegrierenUndKonstanteBestimmen2: Bsp.7.70. auto ---
   397     \item "fun associate" "match_ags ..dI" instead "..pI" breaks many tests, however,
   398       this would be according to survey Notes (3) in src/../calchead.sml.
   399     \end{itemize}
   400   \item see "failed trial to generalise handling of meths"98298342fb6d
   401   \item abstract specify + nxt_specif to common aux-funs;
   402     see e.g. "--- hack for funpack: generalise handling of meths which extend problem items ---"
   403   \item xxx
   404   \item type model = itm list ?
   405   \item review survey Notes in src/../calchead.sml: they are questionable
   406   \item review copy-named, probably two issues commingled 
   407     \begin{itemize}
   408     \item special handling of "#Find#, because it is not a formal argument of partial_function
   409     \item special naming for solutions of equation solving: x_1, x_2, ...
   410     \end{itemize}
   411   \item xxx
   412   \item structure Tactic Specify -?-> Proglang (would require Model., Selem.)
   413   \item xxx
   414   \item this has been written in one go:
   415     \begin{itemize}
   416     \item reconsidering Model.max_vt, use problem with meth ["DiffApp","max_by_calculus"]
   417     \item reconsider add_field': where is it used for what? Shift into mk_oris
   418     \item reconsider match_itms_oris: where is it used for what? max_vt ONLY???
   419     \item in Specify_Method search root-oris for items (e.g. "errorBound"), #1# in survey
   420     \item Specify_Problem, Specify_Method: check respective identifiers after re-Specify_
   421       (relevant for pre-condition)
   422     \item unify match_ags to mk_oris1..N with different args (fmz | pat list, pbl | meth
   423     \item 
   424     \end{itemize}
   425   \end{itemize}
   426 \<close>
   427 subsection \<open>taci list, type step\<close>
   428 text \<open>
   429   \begin{itemize}
   430   \item states.sml: check, when "length tacis > 1"
   431   \item in Test_Isac.thy there is only 1 error in Interpret/inform.sml
   432   \item (*WN190713 REMOVE: "creating a new node" was never implemented for more than one node?!?
   433   \item xxx
   434   \end{itemize}
   435 \<close>
   436 subsection \<open>Ctree\<close>
   437 text \<open>
   438   \begin{itemize}
   439   \item review get_ctxt, update_ctxt, get_istate, upd_istate, upd_ctxt,
   440     <---> update_loc', repl_loc (remove the latter)
   441   \item delete field ctxt in PblObj in favour of loc
   442   \item xxx
   443   \item xxx
   444   \end{itemize}
   445 \<close>
   446 subsection \<open>replace theory/thy by context/ctxt\<close>
   447 text \<open>
   448   \begin{itemize}
   449   \item xxx
   450   \item ??? can theory be retrieved from ctxt --- YES --- see Proof_Context.theory_of below
   451   \item xxx
   452   \item cleaup the many conversions string -- theory
   453   \item make dest_spec --> (theory, pblID, metID) ?+ common_subthy ?
   454   \item 1. Rewrite.eval_true_, then
   455     Lucin.interpret_leaf, Rewrite.eval_prog_expr, Generate.generate1, Lucin.stac2tac.
   456   \item fun associate
   457     let val thy = Celem.assoc_thy "Isac_Knowledge";(*TODO*)
   458   \item xxx
   459   \item xxx
   460   \item xxx
   461   \item !!! Tactic.Refine_Problem uses Pattern.match, which takes a theory, NOT a ctxt
   462     but there is Proof_Context.theory_of !!!
   463   \end{itemize}
   464 \<close>
   465 subsection \<open>Rfuns, Begin_/End_Detail', Rrls, Istate\<close>
   466 text \<open>
   467   \begin{itemize}
   468   \item removing from_pblobj_or_detail' causes many strange errors
   469   \item ^^^+ see from_pblobj_or_detail_thm, from_pblobj_or_detail_calc, ...
   470   \item xxx
   471   \item probably only "normal_form" seems to be needed
   472   \item deleted Rfuns in NEW "locate_input_tactic": no active test for "locate_rule"
   473     but that seems desirable
   474   \item ?how is the relation to reverse-rewriting ???
   475   \item "Rfuns" markers in test/../rational
   476   \item xxx
   477   \item datatype istate (Istate.T): remove RrlsState, pstate: use Rrls only for creating results beyond
   478     rewriting and/or respective intermediate steps (e.g. cancellation of fractions).
   479     Thus we get a 1-step-action which does NOT require a state beyond istate/pstate.
   480     Thus we drastically reduce complexity, also get rid of "fun from_pblobj_or_detail_calc" , etc.
   481   \item debug ^^^ related: is there an occurence of Steps with more than 1 element?
   482   \item xxx
   483   \item and do_solve_step (* WN1907: ?only for Begin_/End_Detail' DEL!!!*)
   484   \item xxx
   485   \item shouldn't go Rfuns from Rewrite --> Rewrite_Set; they behave similar to "fun interSteps" ?
   486   \end{itemize}
   487 \<close>
   488 subsection \<open>Inverse_Z_Transform.thy\<close>
   489 text \<open>
   490   \begin{itemize}
   491   \item\label{new-var-rhs} rule1..6, ruleZY introduce new variables on the rhs of the rewrite-rule.
   492   ? replace rewriting with substitution ?!?
   493   The problem is related to the decision of typing for "d_d" and making bound variables free (while
   494   shifting specific handling in equation solving etc. to the meta-logic). 
   495   \item Find "stepResponse (x[n::real]::bool)" is superfluous, because immediately used by
   496     rewrite-rules; see \ref{new-var-rhs}.
   497   \item Reconsider whole problem:
   498     input only the polynomial as argument of partial_function, in ([1], Frm) compile lhs "X z" ?
   499   \end{itemize}
   500 \<close>
   501 subsection \<open>Adopt Isabelle's numerals for Isac\<close>
   502 text \<open>
   503   \begin{itemize}
   504   \item replace numerals of type "real" by "nat" in some specific functions from ListC.thy
   505     and have both representations in parallel for "nat".
   506   \item xxx
   507   \item xxx
   508   \end{itemize}
   509 \<close>
   510 subsection \<open>Auto_Prog\<close>
   511 text \<open>
   512 two issues:
   513 (1) fun prep_rls creates a Program with too general and wrong types.
   514 (2) generated Programs (huge since strings are coded in ASCII) stored in rls drives
   515     Build_Thydata towards limits of resources.
   516   \begin{itemize}
   517   \item rename Auto_Prog.prep_rls --> Auto_Prog.generate
   518   \item Auto_Prog.generate : term -> rls -> (*Program*)term
   519      Ctree.current_formula---^^^^
   520   \item xxx
   521   \item xxx
   522   \item generate Program on demand in from_pblobj_or_detail'
   523   \item xxx
   524   \item xxx
   525   \end{itemize}
   526 \<close>
   527 subsection \<open>Redesign specify-phase\<close>
   528 text \<open>
   529   \begin{itemize}
   530   \item xxx
   531   \item Separate Specify/ Interpret/ MathEngine/
   532     MathEngine.solve, ...,
   533     ? or identify "layers" like in Isabelle?
   534   \item xxx
   535   \item xxx
   536   \end{itemize}
   537 \<close>
   538 subsection \<open>Redesign thms for equation solver\<close>
   539 text \<open>
   540   Existing solver is structured along the WRONG assumption,
   541   that Poly.thy must be the LAST thy among all thys involved.
   542 
   543   Preliminary solution: all inappropriately located thms are collected in Base_Tools.thy
   544 \<close>
   545 subsection \<open>Finetunig required for xmldata\<close>
   546 text \<open>
   547   See xmldata https://intra.ist.tugraz.at/hg/isac/rev/5b222a649390
   548   and in kbase html-representation generated from these xmldata.
   549   Notes in ~~/xmldata/TODO.txt.
   550 \<close>
   551 
   552 section \<open>Hints for further development\<close>
   553 text \<open>
   554 \<close>
   555 subsection \<open>Coding standards & some explanations for math-authors\<close>
   556 text \<open>copy from doc/math-eng.tex WN.28.3.03
   557 WN071228 extended\<close>
   558 
   559 subsubsection \<open>Identifiers\<close>
   560 text \<open>Naming is particularily crucial, because Isabelles name space is global, and isac does
   561   not yet use the novel locale features introduces by Isar. For instance, {\tt probe} sounds
   562   reasonable as (1) a description in the model of a problem-pattern, (2) as an element of the
   563   problem hierarchies key, (3) as a socalled CAS-command, (4) as the name of a related script etc.
   564   However, all the cases (1)..(4) require different typing for one and the same
   565   identifier {\tt probe} which is impossible, and actually leads to strange errors
   566   (for instance (1) is used as string, except in a script addressing a Subproblem).
   567 
   568   These are the preliminary rules for naming identifiers>
   569   \begin{description}
   570   \item [elements of a key] into the hierarchy of problems or methods must not contain
   571     capital letters and may contain underscrores, e.g. {\tt probe, for_polynomials}.
   572   \item [descriptions in problem-patterns] must contain at least 1 capital letter and
   573     must not contain underscores, e.g. {\tt Probe, forPolynomials}.
   574   \item [CAS-commands] follow the same rules as descriptions in problem-patterns above, thus
   575     beware of conflicts~!
   576   \item [script identifiers] always end with {\tt Program}, e.g. {\tt ProbeScript}.
   577   \item [???] ???
   578   \item [???] ???
   579   \end{description}
   580 %WN071228 extended\<close>
   581 
   582 subsubsection \<open>Rule sets\<close>
   583 text \<open>The actual version of the coding standards for rulesets is in {\tt /IsacKnowledge/Atools.ML
   584   where it can be viewed using the knowledge browsers.
   585 
   586   There are rulesets visible to the student, and there are rulesets visible (in general) only for
   587   math authors. There are also rulesets which {\em must} exist for {\em each} theory;
   588   these contain the identifier of the respective theory (including all capital letters) 
   589   as indicated by {\it Thy} below.
   590 
   591   \begin{description}
   592   \item [norm\_{\it Thy}] exists for each theory, and {\em efficiently} calculates a
   593     normalform for all terms which can be expressed by the definitions of the respective theory
   594     (and the respective parents).
   595   \item [simplify\_{\it Thy}] exists for each theory, and calculates a normalform for all terms
   596     which can be expressed by the definitions of the respective theory (and the respective parents)
   597     such, that the rewrites can be presented to the student.
   598   \item [calculate\_{\it Thy}] exists for each theory, and evaluates terms with 
   599     numerical constants only (i.e. all terms which can be expressed by the definitions of
   600     the respective theory and the respective parent theories). In particular, this ruleset includes
   601     evaluating in/equalities with numerical constants only.
   602     WN.3.7.03: may be dropped due to more generality: numericals and non-numericals
   603     are logically equivalent, where the latter often add to the assumptions
   604     (e.g. in Check_elementwise).
   605   \end{description}
   606 
   607   The above rulesets are all visible to the user, and also may be input; 
   608   thus they must be contained in {\tt Theory_Data} (KEStore_Elems.add_rlss,
   609   KEStore_Elems.get_rlss). All these rulesets must undergo a preparation
   610   using the function {\tt prep_rls'}, which generates a script for stepwise rewriting etc.
   611   The following rulesets are used for internal purposes and usually invisible to the (naive) user:
   612 
   613   \begin{description}
   614   \item [*\_erls] TODO
   615   \item [*\_prls] 
   616   \item [*\_srls] 
   617   \end{description}
   618 {\tt Rule.append_rls, Rule.merge_rls, remove_rls} TODO
   619 \<close>
   620 
   621 subsection \<open>get proof-state\<close>
   622 text \<open>
   623   Re: [isabelle] Programatically get "this"
   624   ----------------------------------------------------
   625   So here is my (Makarius') version of your initial example, following these principles:
   626   begin{verbatim}
   627     notepad
   628     begin
   629       assume a: A
   630       ML_val \<open>
   631         val ctxt = @{context};
   632     
   633         val this_name =
   634           Name_Space.full_name (Proof_Context.naming_of ctxt) (Binding.name
   635     Auto_Bind.thisN);
   636         val this = #thms (the (Proof_Context.lookup_fact ctxt this_name));
   637       \<close>
   638     end
   639   end{verbatim}
   640 \<close>
   641 subsection \<open>write Specification to jEdit\<close>
   642 text \<open>
   643   Re: [isabelle] Printing terms with type annotations
   644   ----------------------------------------------------
   645   On 06/02/2019 17:52, Moa Johansson wrote:
   646   >
   647   > I’m writing some code that should create a snippet of Isar script.
   648   
   649   This is how Sledgehammer approximates this:
   650   
   651   http://isabelle.in.tum.de/repos/isabelle/file/Isabelle2018/src/HOL/Tools/Sledgehammer/sledgehammer_isar_proof.ML#l299
   652   
   653   (The module name already shows that the proper terminology is "Isar
   654   proof" (or "Isar proof text").  Proof scripts are a thing from the past,
   655   before Isar. You can emulate old-style proof scripts via a sequence of
   656   'apply' commands, but this is improper Isar.)
   657   
   658   Note that there is no standard function in Isabelle/Pure, because the
   659   problem to print just the right amount of type information is very
   660   complex and not fully solved. One day, after 1 or 2 rounds of
   661   refinements over the above approach, it might become generally available.
   662 \<close>
   663 subsection \<open>follow Isabelle conventions (*Does not yet work in Isabelle2018\<close>
   664 text \<open>
   665   isabelle update -u path_cartouches
   666   isabelle update -u inner_syntax_cartouches
   667 \<close>
   668 section \<open>Questions to Isabelle experts\<close>
   669 text \<open>
   670 \begin{itemize}
   671 \item what is the actual replacement of "hg log --follow" ?
   672 \item xxx
   673 \item how HANDLE these exceptions, e.g.:
   674     Syntax.read_term ctxt "Randbedingungen y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]"
   675   GIVES
   676     "Inner syntax error
   677      Failed to parse term"
   678 \item xxx
   679 \item how cope with "exception Size raised (line 171 of "./basis/LibrarySupport.sml")"
   680   e.g. in test/Interpret/lucas-interpreter.sml
   681 \item xxx
   682 \item xxx
   683 \end{itemize}
   684 \<close>
   685 
   686 section \<open>For copy & paste\<close>
   687 text \<open>
   688 \begin{itemize}
   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