src/Tools/isac/Interpret/ctree.sml
changeset 59280 ee5efb0697f6
parent 59279 255c853ea2f0
child 59281 bcfca6e8b79e
equal deleted inserted replaced
59279:255c853ea2f0 59280:ee5efb0697f6
   282   val get_trace : ctree -> int list -> int list -> int list list
   282   val get_trace : ctree -> int list -> int list -> int list list
   283   val subte2subst : term list -> (term * term) list
   283   val subte2subst : term list -> (term * term) list
   284   val branch2str : branch -> string
   284   val branch2str : branch -> string
   285 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
   285 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
   286 end
   286 end
   287 (*
       
   288 structure Ctree :
       
   289 sig
       
   290   val Ets : ets exception PTREE of string
       
   291   val append_atomic :
       
   292      pos -> istate * Proof.context -> term -> tac -> term * term list -> ostate -> ctree -> ctree
       
   293   val append_form : int list -> istate * Proof.context -> term -> ctree -> ctree
       
   294   val append_parent : pos -> istate * Proof.context -> term -> tac -> branch -> ctree -> ctree
       
   295   val append_problem : int list -> istate * Proof.context -> fmz -> ori list * spec * term -> ctree -> ctree
       
   296   val append_result : ctree -> pos -> istate * Proof.context -> term * term list -> ostate -> ctree * 'a list
       
   297   val appl_branch : (ppobj -> bool) * (posel -> ctree list -> ctree list) -> ctree -> int list -> ctree * bool
       
   298   val appl_obj : (ppobj -> ppobj) -> ctree -> pos -> ctree
       
   299   val appl_to_node : (ppobj -> ppobj) -> ctree -> ctree
       
   300   datatype branch = AndB | CollectB | IntersectB | MapB | NoBranch | OrB | SequenceB | TransitiveB
       
   301   val branch2str : branch -> string
       
   302   val cappend_atomic :
       
   303      ctree -> pos -> istate * Proof.context -> term -> tac -> term * term list -> ostate -> ctree * pos' list
       
   304   val cappend_form : ctree -> pos -> istate * Proof.context -> term -> ctree * pos' list
       
   305   val cappend_parent : ctree -> pos -> istate * Proof.context -> term -> tac -> branch -> ctree * pos' list
       
   306   val cappend_problem :
       
   307      ctree -> int list -> istate * Proof.context -> fmz -> ori list * spec * term -> ctree * pos' list
       
   308   eqtype cellID
       
   309   val children : ctree -> ctree list
       
   310   type cid = cellID list
       
   311   datatype con = land | lor
       
   312   val cut_bottom : pos * posel -> ctree -> (ctree * pos' list) * bool
       
   313   val cut_level : pos' list -> pos -> ctree -> int list * pos_ -> ctree * pos' list
       
   314   val cut_level_'_ : pos' list -> pos -> ctree -> int list * pos_ -> ctree * pos' list
       
   315   val cut_levup : pos' list -> bool -> ctree -> ctree -> posel list * posel -> ctree -> ctree * pos' list
       
   316   val cut_tree : ctree -> pos * 'a -> ctree * pos' list
       
   317   val cutlevup : ppobj -> bool
       
   318   val del_res : ppobj -> ppobj
       
   319   val delete_result : ctree -> pos -> ctree
       
   320   val e_ctxt : Proof.context
       
   321   val e_fmz : 'a list * spec
       
   322   val e_ocalhd : bool * pos_ * term * itm list * (bool * term) list * spec
       
   323   val e_origin : ori list * spec * term
       
   324   val e_ptform : ptform
       
   325   val e_ptform' : ptform
       
   326   val e_ctree : ctree
       
   327   val e_scrstate : scrstate
       
   328   val e_sube : cterm' list
       
   329   val e_subs : string list
       
   330   val e_subte : term list
       
   331   val empty_envp : envp type env = (term * term) list
       
   332   type envp = (int * term list) list * (int * rls) list * (int * ets) list * (string * pos) list
       
   333   val eq_tac : tac * tac -> bool type ets = (loc_ * (tac_ * env * env * term * term * safe)) list
       
   334   val ets2s : loc_ * (tac_ * subst * subst * term * term * safe) -> string
       
   335   val ets2str : ets -> string
       
   336   val exist_lev_on' : ctree -> pos' -> bool
       
   337   val existpt : pos -> ctree -> bool
       
   338   val existpt' : pos' -> ctree -> bool
       
   339   type fmz = fmz_ * spec
       
   340   type fmz_ = cterm' list
       
   341   val g_branch : ppobj -> branch
       
   342   val g_cell : ppobj -> lrd option
       
   343   val g_ctxt : ppobj -> Proof.context
       
   344   val g_domID : ppobj -> domID
       
   345   val g_env : ppobj -> (istate * Proof.context) option
       
   346   val g_fmz : ppobj -> fmz
       
   347   val g_form : ppobj -> term
       
   348   val g_form' : ctree -> term
       
   349   val g_loc : ppobj -> (istate * Proof.context) option * (istate * Proof.context) option
       
   350   val g_met : ppobj -> itm list
       
   351   val g_metID : ppobj -> metID
       
   352   val g_origin : ppobj -> ori list * spec * term
       
   353   val g_ostate : ppobj -> ostate
       
   354   val g_ostate' : ctree -> ostate
       
   355   val g_pbl : ppobj -> itm list
       
   356   val g_res : ppobj -> term
       
   357   val g_res' : ctree -> term
       
   358   val g_result : ppobj -> term * term list
       
   359   val g_spec : ppobj -> spec
       
   360   val g_tac : ppobj -> tac
       
   361   val get_all : (ppobj -> 'a) -> ctree -> 'a list
       
   362   val get_allp : pos' list -> pos * (int list * pos_) -> ctree -> pos' list
       
   363   val get_allpos' : pos * posel -> ctree -> pos' list
       
   364   val get_allpos's : pos * posel -> ctree list -> (pos * pos_) list
       
   365   val get_allps : (pos * pos_) list -> posel list -> ctree list -> pos' list
       
   366   val get_alls : (ppobj -> 'a) -> ctree list -> 'a list
       
   367   val get_assumptions_ : ctree -> pos * pos_ -> term list
       
   368   val get_ctxt : ctree -> pos * pos_ -> Proof.context
       
   369   val get_curr_formula : ctree * (pos * pos_) -> term
       
   370   val get_istate : ctree -> pos * pos_ -> istate
       
   371   val get_loc : ctree -> pos * pos_ -> istate * Proof.context
       
   372   val get_nd : ctree -> pos -> ctree
       
   373   val get_obj : (ppobj -> 'a) -> ctree -> pos -> 'a
       
   374   val get_somespec : spec -> spec -> spec
       
   375   val get_somespec' : spec -> spec -> spec
       
   376   val get_trace : ctree -> int list -> int list -> int list list
       
   377   val gpt_cell : ctree -> lrd option
       
   378   type iist = istate option * istate option
       
   379   val ind : pos' -> int
       
   380   val ins_chn : ctree list -> ctree -> int list -> ctree
       
   381   val ins_nth : int -> 'a -> 'a list -> 'a list
       
   382   val insert_pt : ppobj -> ctree -> int list -> ctree
       
   383   val is_curr_endof_calc : ctree -> pos' -> bool
       
   384   val is_e_ctxt : Proof.context -> bool
       
   385   val is_empty_tac : tac -> bool
       
   386   val is_interpos : pos' -> bool
       
   387   val is_pblnd : ctree -> bool
       
   388   val is_pblobj : ppobj -> bool
       
   389   val is_pblobj' : ctree -> pos -> bool
       
   390   val is_prfobj : ppobj -> bool
       
   391   val is_rewset : tac -> bool
       
   392   val is_rewtac : tac -> bool
       
   393   val isasub2subst : term -> (term * term) list
       
   394   datatype istate = RrlsState of rrlsstate | ScrState of scrstate | Uistate
       
   395   val istate2str : istate -> string
       
   396   val istates2str : istate option * istate option -> string
       
   397   val just_created : ctree * pos' -> bool
       
   398   val just_created_ : ppobj -> bool
       
   399   val last_onlev : ctree -> pos -> bool
       
   400   val lev_back' : pos' -> pos'
       
   401   val lev_dn : posel list -> posel list
       
   402   val lev_dnRes : pos' -> pos'
       
   403   val lev_dn_ : pos' -> pos'
       
   404   val lev_of : pos' -> int
       
   405   val lev_on : pos -> posel list
       
   406   val lev_on' : ctree -> pos' -> pos'
       
   407   val lev_onFrm : pos' -> pos'
       
   408   val lev_pred : pos -> pos
       
   409   val lev_pred' : ctree -> pos' -> pos'
       
   410   val lev_up : pos -> pos
       
   411   val lev_up_ : pos' -> pos'
       
   412   val move_dn : pos -> ctree -> int list * pos_ -> int list * pos_
       
   413   val move_up : int list -> ctree -> int list * pos_ -> int list * pos_
       
   414   val movecalchd_up : ctree -> pos' -> pos'
       
   415   val movelevel_dn : int list -> ctree -> int list * pos_ -> int list * pos_
       
   416   val movelevel_up : int list -> ctree -> int list * pos_ -> int list * pos_
       
   417   val new_val : term -> istate -> istate
       
   418   val nth : int -> 'a list -> 'a
       
   419   type ocalhd = bool * pos_ * term * itm list * (bool * term) list * spec
       
   420   val ocalhd2str : ocalhd -> string
       
   421   datatype ostate = Complete | Incomplete | Inconsistent
       
   422   val ostate2str : ostate -> string
       
   423   val par_children : ctree -> pos -> ctree list * pos
       
   424   val par_pbl_det : ctree -> pos -> bool * pos * rls
       
   425   val par_pblobj : ctree -> pos -> pos
       
   426   type pos = posel list
       
   427   type pos' = pos * pos_
       
   428   val pos's2str : (int list * pos_) list -> string
       
   429   val pos2str : int list -> string
       
   430   datatype pos_ = Frm | Met | Pbl | Res | Und
       
   431   val pos_2str : pos_ -> string
       
   432   val pos_plus : int -> pos * pos_ -> pos'
       
   433   eqtype posel
       
   434   val posless : int list -> int list -> bool
       
   435   datatype ppobj
       
   436   = PblObj of
       
   437     {branch: branch,
       
   438      cell: lrd option,
       
   439      ctxt: Proof.context,
       
   440      env: (istate * Proof.context) option,
       
   441      fmz: fmz,
       
   442      loc: (istate * Proof.context) option * (istate * Proof.context) option,
       
   443      meth: itm list,
       
   444      origin: ori list * spec * term, ostate: ostate, probl: itm list, result: term * term list, spec: spec}
       
   445      | PrfObj of
       
   446      {branch: branch,
       
   447       cell: lrd option,
       
   448       form: term,
       
   449       loc: (istate * Proof.context) option * (istate * Proof.context) option,
       
   450       ostate: ostate, result: term * term list, tac: tac}
       
   451   val pr_pos : int list -> string
       
   452   val pr_ctree : (pos -> ppobj -> string) -> ctree -> string
       
   453   val pr_short : pos -> ppobj -> string
       
   454   val pre_pos : pos -> pos
       
   455   val preconds2str : (bool * term) list -> string
       
   456   datatype ptform = Form of term | ModSpec of ocalhd
       
   457   datatype ctree = EmptyPtree | Nd of ppobj * ctree list
       
   458   val rep_pblobj :
       
   459      ppobj ->
       
   460      {branch: branch,
       
   461       cell: lrd option,
       
   462       ctxt: Proof.context,
       
   463       env: (istate * Proof.context) option,
       
   464       fmz: fmz,
       
   465       loc: (istate * Proof.context) option * (istate * Proof.context) option,
       
   466       meth: itm list,
       
   467       origin: ori list * spec * term, ostate: ostate, probl: itm list, result: term * term list, spec: spec}
       
   468   val rep_prfobj :
       
   469      ppobj ->
       
   470      {branch: branch,
       
   471       cell: lrd option,
       
   472       form: term,
       
   473       loc: (istate * Proof.context) option * (istate * Proof.context) option,
       
   474       ostate: ostate, result: term * term list, tac: tac}
       
   475   val repl : 'a list -> int -> 'a -> 'a list
       
   476   val repl_app : 'a list -> int -> 'a -> 'a list
       
   477   val repl_branch : branch -> ppobj -> ppobj
       
   478   val repl_ctxt : Proof.context -> ppobj -> ppobj
       
   479   val repl_domID : domID -> ppobj -> ppobj
       
   480   val repl_env : (istate * Proof.context) option -> ppobj -> ppobj
       
   481   val repl_form : term -> ppobj -> ppobj
       
   482   val repl_loc : (istate * Proof.context) option * (istate * Proof.context) option -> ppobj -> ppobj
       
   483   val repl_met : itm list -> ppobj -> ppobj
       
   484   val repl_metID : metID -> ppobj -> ppobj
       
   485   val repl_oris : ori list -> ppobj -> ppobj
       
   486   val repl_orispec : spec -> ppobj -> ppobj
       
   487   val repl_pbl : itm list -> ppobj -> ppobj
       
   488   val repl_pblID : pblID -> ppobj -> ppobj
       
   489   val repl_result :
       
   490      (istate * Proof.context) option * (istate * Proof.context) option ->
       
   491      term * term list -> ostate -> ppobj -> ppobj
       
   492   val repl_spec : spec -> ppobj -> ppobj
       
   493   val repl_tac : tac -> ppobj -> ppobj
       
   494   val res2str : term * term list -> string
       
   495   val rls_of : tac -> rls'
       
   496   val rls_of_rewset : tac -> rls' * subst option
       
   497   val rootthy : ctree -> theory
       
   498   val rta2str : rule * (term * term list) -> string
       
   499   val rule2tac : theory -> (term * term) list -> rule -> tac
       
   500   val safe2str : safe -> string
       
   501   type scrstate = env * loc_ * term option * term * safe * bool
       
   502   val scrstate2str : subst * loc_ * term option * term * safe * bool -> string
       
   503   val str2pos_ : string -> pos_
       
   504   type sube = cterm' list
       
   505   val sube2str : string list -> string
       
   506   val sube2subst : theory -> string list -> (term * term) list
       
   507   val sube2subte : string list -> term list
       
   508   type subs = cterm' list
       
   509   val subs2subst : theory -> string list -> (term * term) list
       
   510   val subst2sube : (term * term) list -> string list
       
   511   val subst2subs : (term * term) list -> string list
       
   512   val subst2subs' : (term * term) list -> (string * string) list
       
   513   type subte = term list
       
   514   val subte2str : term list -> string
       
   515   val subte2sube : term list -> string list
       
   516   val subte2subst : term list -> (term * term) list
       
   517   datatype tac
       
   518   = Add_Find of cterm' | Add_Given of cterm' | Add_Relation of cterm' | Apply_Assumption of cterm' list
       
   519      | Apply_Method of metID | Begin_Sequ | Begin_Trans | CAScmd of cterm' | Calculate of string
       
   520      | Check_Postcond of pblID | Check_elementwise of cterm' | Collect_Trues | Conclude_And | Conclude_Or
       
   521      | Del_Find of cterm' | Del_Given of cterm' | Del_Relation of cterm' | Derive of rls' | Detail_Set of rls'
       
   522      | Detail_Set_Inst of subs * rls' | Empty_Tac | End_Detail | End_Intersect | End_Proof' | End_Ruleset
       
   523      | End_Sequ | End_Subproblem | End_Trans | Free_Solve | Group of con * int list
       
   524      | Init_Proof of cterm' list * spec | Model_Problem | Or_to_List | Refine_Problem of pblID
       
   525      | Refine_Tacitly of pblID | Rewrite of thm'' | Rewrite_Asm of thm'' | Rewrite_Inst of subs * thm''
       
   526      | Rewrite_Set of rls' | Rewrite_Set_Inst of subs * rls' | Specify_Method of metID
       
   527      | Specify_Problem of pblID | Specify_Theory of domID | Split_And | Split_Intersect | Split_Or
       
   528      | Subproblem of domID * pblID | Substitute of sube | Tac of string | Take of cterm' | Take_Inst of cterm'
       
   529   val tac2IDstr : tac -> string
       
   530   datatype tac_
       
   531   = Add_Find' of cterm' * itm list | Add_Given' of cterm' * itm list | Add_Relation' of cterm' * itm list
       
   532      | Apply_Assumption' of term list * term | Apply_Method' of metID * term option * istate * Proof.context
       
   533      | Begin_Sequ' | Begin_Trans' of term | CAScmd' of term
       
   534      | Calculate' of theory' * string * term * (term * thm') | Check_Postcond' of pblID * (term * term list)
       
   535      | Check_elementwise' of term * string * (term * term list) | Collect_Trues' of term
       
   536      | Conclude_And' of term | Conclude_Or' of term | Del_Find' of cterm' | Del_Given' of cterm'
       
   537      | Del_Relation' of cterm' | Derive' of rls
       
   538      | Detail_Set' of theory' * bool * rls * term * (term * term list)
       
   539      | Detail_Set_Inst' of theory' * bool * subst * rls * term * (term * term list) | Empty_Tac_
       
   540      | End_Detail' of term * term list | End_Intersect' of term | End_Proof'' | End_Ruleset' of term
       
   541      | End_Sequ' | End_Subproblem' of term | End_Trans' of term * term list | Free_Solve'
       
   542      | Group' of con * int list * term | Init_Proof' of cterm' list * spec
       
   543      | Model_Problem' of pblID * itm list * itm list | Or_to_List' of term * term
       
   544      | Refine_Problem' of pblID * (itm list * (bool * term) list)
       
   545      | Refine_Tacitly' of pblID * pblID * domID * metID * itm list
       
   546      | Rewrite' of theory' * rew_ord' * rls * bool * thm'' * term * (term * term list)
       
   547      | Rewrite_Asm' of theory' * rew_ord' * rls * bool * thm'' * term * (term * term list)
       
   548      | Rewrite_Inst' of theory' * rew_ord' * rls * bool * subst * thm'' * term * (term * term list)
       
   549      | Rewrite_Set' of theory' * bool * rls * term * (term * term list)
       
   550      | Rewrite_Set_Inst' of theory' * bool * subst * rls * term * (term * term list)
       
   551      | Specify_Method' of metID * ori list * itm list
       
   552      | Specify_Problem' of pblID * (bool * (itm list * (bool * term) list)) | Specify_Theory' of domID
       
   553      | Split_And' of term | Split_Intersect' of term | Split_Or' of term
       
   554      | Subproblem' of spec * ori list * term * fmz_ * Proof.context * term
       
   555      | Substitute' of rew_ord_ * rls * subte * term * term | Tac_ of theory * string * string * string
       
   556      | Take' of term | Take_Inst' of term
       
   557   val tac_2str : tac_ -> string
       
   558   val test_trans : ppobj -> bool
       
   559   val thm_of_rew : tac -> thmID * subst option
       
   560   val topt2str : term option -> string
       
   561   val update_branch : ctree -> pos -> branch -> ctree
       
   562   val update_ctxt : ctree -> pos -> Proof.context -> ctree
       
   563   val update_domID : ctree -> pos -> domID -> ctree
       
   564   val update_env : ctree -> pos -> (istate * Proof.context) option -> ctree
       
   565   val update_loc' : ctree -> pos -> (istate * Proof.context) option * (istate * Proof.context) option -> ctree
       
   566   val update_met : ctree -> pos -> itm list -> ctree
       
   567   val update_metID : ctree -> pos -> metID -> ctree
       
   568   val update_metppc : ctree -> pos -> itm list -> ctree
       
   569   val update_oris : ctree -> pos -> ori list -> ctree
       
   570   val update_orispec : ctree -> pos -> spec -> ctree
       
   571   val update_pbl : ctree -> pos -> itm list -> ctree
       
   572   val update_pblID : ctree -> pos -> pblID -> ctree
       
   573   val update_pblppc : ctree -> pos -> itm list -> ctree
       
   574   val update_spec : ctree -> pos -> spec -> ctree
       
   575   val update_tac : ctree -> pos -> tac -> ctree end
       
   576 *)
       
   577 
   287 
   578 (**)
   288 (**)
   579 structure Ctree(**): CALC_TREEE(**) =
   289 structure Ctree(**): CALC_TREEE(**) =
   580 struct
   290 struct
   581 (**)
   291 (**)
  1203 	    branch: branch,           (* like PrfObj *)
   913 	    branch: branch,           (* like PrfObj *)
  1204 	    result: result, (* like PrfObj *)
   914 	    result: result, (* like PrfObj *)
  1205 	    ostate: ostate};          (* like PrfObj *)
   915 	    ostate: ostate};          (* like PrfObj *)
  1206 
   916 
  1207 (*.this tree contains isac's calculations; TODO.WN03 rename to ctree;
   917 (*.this tree contains isac's calculations; TODO.WN03 rename to ctree;
  1208    the structure has been copied from an early version of Theorema(c);
   918    the tree's structure has been copied from an early version of Theorema(c);
  1209    it has the disadvantage, that there is no space 
   919    it has the disadvantage, that there is no space 
  1210    for the first tactic in a script generating the first formula at (p,Frm);
   920    for the first tactic in a script generating the first formula at (p,Frm);
  1211    this trouble has been covered by 'init_form' and 'Take' so far,
   921    this trouble has been covered by 'init_form' and 'Take' so far,
  1212    but it is crucial if the first tactic in a script is eg. 'Subproblem';
   922    but it is crucial if the first tactic in a script is eg. 'Subproblem';
  1213    see 'type tac ', Apply_Method.
   923    see 'type tac ', Apply_Method.