1.1 --- a/src/Tools/isac/calcelems.sml Sun Mar 25 11:57:33 2018 +0200
1.2 +++ b/src/Tools/isac/calcelems.sml Sun Mar 25 13:59:57 2018 +0200
1.3 @@ -13,7 +13,7 @@
1.4 type rew_ord
1.5 eqtype errpatID
1.6 type calc
1.7 - datatype rule = Cal1 of string * eval_fn | Calc of string * eval_fn | Erule | Rls_ of rls
1.8 + datatype rule = Cal1 of string * eval_fn | Calc of string * eval_fn | Erule | Rls_ of rls
1.9 | Thm of string * thm
1.10 and scr
1.11 = EmptyScr
1.12 @@ -34,7 +34,6 @@
1.13 id: string, prepat: (term list * term) list, rew_ord: rew_ord, scr: scr}
1.14
1.15 eqtype rls'
1.16 - eqtype theory'
1.17 eqtype prog_calcID
1.18 eqtype calID
1.19 type cas_elem
1.20 @@ -54,12 +53,11 @@
1.21 val subst2str: subst -> string
1.22 val subst2str': subst -> string
1.23
1.24 - eqtype thyID
1.25 type fillpat
1.26 datatype thydata
1.27 = Hcal of {calc: calc, coursedesign: authors, guh: guh, mathauthors: authors}
1.28 | Hord of {coursedesign: authors, guh: guh, mathauthors: authors, ord: subst -> term * term -> bool}
1.29 - | Hrls of {coursedesign: authors, guh: guh, mathauthors: authors, thy_rls: thyID * rls}
1.30 + | Hrls of {coursedesign: authors, guh: guh, mathauthors: authors, thy_rls: Rule.thyID * rls}
1.31 | Hthm of {coursedesign: authors, fillpats: fillpat list, guh: guh, mathauthors: authors, thm: thm}
1.32 | Html of {coursedesign: authors, guh: guh, html: string, mathauthors: authors}
1.33 type theID
1.34 @@ -81,20 +79,13 @@
1.35 val get_py: 'a ptyp list -> pblID -> string list -> 'a
1.36 val update_hthm: thydata -> fillpat list -> thydata
1.37 val update_ptyps: string list -> string list -> 'a -> 'a ptyp list -> 'a ptyp list
1.38 - val e_rls: rls
1.39 - val e_rrls: rls
1.40 val part2guh: theID -> guh
1.41 val spec2str: string * string list * string list -> string
1.42 - val term_to_string''': theory -> term -> string
1.43 val linefeed: string -> string
1.44 val pbts2str: pbt list -> string
1.45 val thes2str: thydata list -> string
1.46 val theID2str: string list -> string
1.47 val the2str: thydata -> string
1.48 - val Thy_Info_get_theory: string -> theory
1.49 - val string_of_typ: typ -> string
1.50 - val string_of_typ_thy: thyID -> typ -> string
1.51 - val term2str: term -> string
1.52 val thy2ctxt: theory -> Proof.context
1.53 val trace_calc: bool Unsynchronized.ref
1.54 eqtype thmID
1.55 @@ -103,35 +94,23 @@
1.56 val trace_rewrite: bool Unsynchronized.ref
1.57 val depth: int Unsynchronized.ref
1.58 val t2str: theory -> term -> string
1.59 - val ts2str: theory -> term list -> string
1.60 - val terms2str: term list -> string
1.61 val id_rls: rls -> string
1.62 val rls2str: rls -> string
1.63 type errpat
1.64 val rep_rls: rls -> {calc: calc list, erls: rls, errpats: errpatID list, id: string,
1.65 preconds: term list, rew_ord: rew_ord, rules: rule list, scr: scr, srls: rls}
1.66 - val string_of_thmI: thm -> string
1.67 - val rule2str: rule -> string
1.68 val e_term: term
1.69 val dummy_ord: subst -> term * term -> bool
1.70 - val theory2domID: theory -> theory'
1.71 - val assoc_thy: theory' -> theory
1.72 - val append_rls: string -> rls -> rule list -> rls
1.73 - eqtype domID
1.74 - val get_rules: rls -> rule list
1.75 + val assoc_thy: Rule.theory' -> theory
1.76 val id_rule: rule -> string
1.77 eqtype cterm'
1.78 - val term_to_string': Proof.context -> term -> string
1.79 - val thy2ctxt': string -> Proof.context
1.80 type rrlsstate = term * term * rule list list * (rule * (term * term list)) list
1.81 type loc_
1.82 val loc_2str: loc_ -> string
1.83 - val termopt2str: term option -> string
1.84 eqtype rew_ord'
1.85 type thm''
1.86 type rew_ord_
1.87 val metID2str: string list -> string
1.88 - val e_domID: domID
1.89 val e_pblID: pblID
1.90 val e_metID: metID
1.91 val empty_spec: spec
1.92 @@ -144,65 +123,50 @@
1.93 val coll_metguhs: met ptyp list -> guh list
1.94 type pat
1.95 val e_type: typ
1.96 - val theory2str: theory -> theory'
1.97 val pats2str: pat list -> string
1.98 - val string_of_thy: theory -> theory'
1.99 - val theory2theory': theory -> theory'
1.100 val maxthy: theory -> theory -> theory
1.101 val e_evalfn: 'a -> term -> theory -> (string * term) option
1.102 val assoc_rew_ord: string -> subst -> term * term -> bool
1.103 eqtype filename
1.104 - val rule2str': rule -> string
1.105 val lim_deriv: int Unsynchronized.ref
1.106 val id_of_thm: rule -> string
1.107 val isabthys: unit -> theory list
1.108 val thyID_of_derivation_name: string -> string
1.109 - val partID': theory' -> string
1.110 - val Isac: 'a -> theory
1.111 - val theory'2thyID: theory' -> theory'
1.112 - val thm2guh: string * thyID -> thmID -> guh
1.113 + val partID': Rule.theory' -> string
1.114 + val thm2guh: string * Rule.thyID -> thmID -> guh
1.115 val thmID_of_derivation_name: string -> string
1.116 - val rls2guh: string * thyID -> rls' -> guh
1.117 + val rls2guh: string * Rule.thyID -> rls' -> guh
1.118 val eq_rule: rule * rule -> bool
1.119 val e_rew_ordX: rew_ord
1.120 val theID2guh: theID -> guh
1.121 - val thyID2theory': thyID -> thyID
1.122 val e_rule: rule
1.123 - val scr2str: scr -> string
1.124 val type2str: typ -> string
1.125 eqtype fillpatID
1.126 type pbt_ = string * (term * term)
1.127 val e_rew_ord: subst -> term * term -> bool
1.128 eqtype xml
1.129 - val cal2guh: string * thyID -> string -> guh
1.130 + val cal2guh: string * Rule.thyID -> string -> guh
1.131 val ketype2str': ketype -> string
1.132 val str2ketype': string -> ketype
1.133 val thmID_of_derivation_name': thm -> string
1.134 eqtype path
1.135 - val theID2thyID: theID -> thyID
1.136 + val theID2thyID: theID -> Rule.thyID
1.137 val thy2guh: theID -> guh
1.138 - val theory2thyID: theory -> thyID
1.139 val thypart2guh: theID -> guh
1.140 - val ord2guh: string * thyID -> rew_ord' -> guh
1.141 + val ord2guh: string * Rule.thyID -> rew_ord' -> guh
1.142 val update_hrls: thydata -> errpatID list -> thydata
1.143 eqtype iterID
1.144 eqtype calcID
1.145 val thm''_of_thm: thm -> thm''
1.146 val rew_ord': (rew_ord' * (subst -> term * term -> bool)) list Unsynchronized.ref
1.147 - val merge_rls: string -> rls -> rls -> rls
1.148 val e_rrlsstate: rrlsstate
1.149 val thm_of_thm: rule -> thm
1.150 - val remove_rls: string -> rls -> rule list -> rls
1.151 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
1.152 val thm2str: thm -> string
1.153 - val term_to_string'': thyID -> term -> string
1.154 - val terms2str': term list -> string
1.155 val insert_fillpats: thydata ptyp list -> (pblID * fillpat list) list -> thydata ptyp list ->
1.156 thydata ptyp list
1.157 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
1.158 val terms2strs: term list -> string list
1.159 - val string_of_thm': theory -> thm -> string
1.160 - val string_of_thm: thm -> string
1.161 val knowthys: unit -> theory list
1.162 val e_pbt: pbt
1.163 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
1.164 @@ -213,14 +177,13 @@
1.165
1.166
1.167 (**)
1.168 -structure Celem(**): CALC_ELEMENT(**) =
1.169 +structure Celem(*: CALC_ELEMENT*) =
1.170 struct
1.171 (**)
1.172
1.173 val linefeed = (curry op^) "\n"; (* ?\<longrightarrow> libraryC ?*)
1.174 type authors = string list;
1.175
1.176 -type cterm' = string;
1.177 type iterID = int;
1.178 type calcID = int;
1.179
1.180 @@ -240,7 +203,7 @@
1.181 WN120524: dont use Thm.derivation_name, this is destroyed by num_str;
1.182 Thm.get_name_hint survives num_str and seems perfectly reliable *)
1.183
1.184 -type thm' = thmID * cterm';(*WN060610 deprecated in favour of thm''; WN180324: used in TODO review:
1.185 +type thm' = thmID * Rule.cterm';(*WN060610 deprecated in favour of thm''; WN180324: used in TODO review:
1.186 val thm'2xml : int -> Celem.thm' -> Celem.xml
1.187 val assoc_thm': theory -> Celem.thm' -> thm
1.188 | Calculate' of Celem.theory' * string * term * (term * Celem.thm')
1.189 @@ -268,51 +231,6 @@
1.190
1.191 type xml = string; (* rm together with old code replaced by XML.tree *)
1.192
1.193 -(* eval function calling sml code during rewriting.
1.194 -Unifying "type cal" and "type calc" would make Lucas-Interpretation more efficient,
1.195 - see "fun rule2stac": instead of
1.196 - Calc: calID * eval_fn -> rule
1.197 - would be better
1.198 - Calc: prog_calcID * (calID * eval_fn)) -> rule*)
1.199 -type eval_fn = (string -> term -> theory -> (string * term) option);
1.200 -fun e_evalfn (_ : 'a) (_ : term) (_ : theory) = NONE : (string * term) option;
1.201 -(* op in isa-term "Const(op,_)" *)
1.202 -type calID = string;
1.203 -type cal = calID * eval_fn;
1.204 -type prog_calcID = string;
1.205 -type calc = (prog_calcID * cal);
1.206 -type calc_elem = (* fun calculate_ fetches the evaluation-function via this list *)
1.207 - prog_calcID * (* a simple identifier used in programs *)
1.208 - (calID * (* a long identifier used in Const *)
1.209 - eval_fn) (* an ML function *)
1.210 -fun calc_eq ((pi1, (ci1, _)), (pi2, (ci2, _))) =
1.211 - if pi1 = pi2
1.212 - then if ci1 = ci2 then true else error ("calc_eq: " ^ ci1 ^ " <> " ^ ci2)
1.213 - else false
1.214 -
1.215 -(*WN180324 TODO clean types subst, *)
1.216 -type subs' = (cterm' * cterm') list; (*16.11.00 for FE-KE*)
1.217 -type subst = (term * term) list; (*here for ets2str*)
1.218 -
1.219 -(*TODO.WN060610 make use of "type rew_ord" total*)
1.220 -type rew_ord' = string;
1.221 -val e_rew_ord' = "e_rew_ord" : rew_ord';
1.222 -type rew_ord_ = subst -> Term.term * Term.term -> bool;
1.223 -fun dummy_ord (_:subst) (_:term,_:term) = true;
1.224 -val e_rew_ord_ = dummy_ord;
1.225 -type rew_ord = rew_ord' * rew_ord_;
1.226 -val e_rew_ord = dummy_ord; (* TODO.WN071231 clarify identifiers..e_rew_ordX*)
1.227 -val e_rew_ordX = (e_rew_ord', e_rew_ord_) : rew_ord;
1.228 -
1.229 -(* error patterns and fill patterns *)
1.230 -type errpatID = string
1.231 -type errpat =
1.232 - errpatID (* one identifier for a list of patterns
1.233 - DESIGN ?TODO: errpatID list for hierarchy of errpats ? *)
1.234 - * term list (* error patterns *)
1.235 - * thm list (* thms related to error patterns; note that respective lhs
1.236 - do not match (which reflects student's error).
1.237 - fillpatterns are stored with these thms. *)
1.238
1.239 (* for (at least) 2 kinds of access:
1.240 (1) given an errpatID, find the respective fillpats (e.g. in fun find_fill_pats)
1.241 @@ -321,153 +239,10 @@
1.242 type fillpat =
1.243 fillpatID (* DESIGN ?TODO: give an order w.r.t difficulty ? *)
1.244 * term (* the pattern with fill-in gaps *)
1.245 - * errpatID; (* which the fillpat would be a help for
1.246 + * Rule.errpatID; (* which the fillpat would be a help for
1.247 DESIGN ?TODO: list for several patterns ? *)
1.248
1.249 -datatype rule =
1.250 - Erule (*.the empty rule .*)
1.251 -| Thm of (string * Basic_Thm.thm) (* see TODO CLEANUP Thm *)
1.252 -| Calc of string * (*.sml-code manipulating a (sub)term .*)
1.253 - eval_fn
1.254 -| Cal1 of string * (*.sml-code applied only to whole term
1.255 - or left/right-hand-side of eqality .*)
1.256 - eval_fn
1.257 -| Rls_ of rls (*.ie. rule sets may be nested.*)
1.258 -and scr =
1.259 - EmptyScr
1.260 - | Prog of term (* a leaf is either a tactic or an 'exp' in 'let v = expr'
1.261 - where 'exp' does not contain a tactic. *)
1.262 - | Rfuns of (* for Rrls, usage see rational.sml ----- reverse rewrite ----- *)
1.263 - {init_state : (* initialise for reverse rewriting by the Interpreter *)
1.264 - term -> (* for this the rrlsstate is initialised: *)
1.265 - term * (* the current formula: goes locate_gen -> next_tac via istate *)
1.266 - term * (* the final formula *)
1.267 - rule list (* of reverse rewrite set (#1#) *)
1.268 - list * (* may be serveral, eg. in norm_rational *)
1.269 - ( rule * (* Thm (+ Thm generated from Calc) resulting in ... *)
1.270 - (term * (* ... rewrite with ... *)
1.271 - term list)) (* ... assumptions *)
1.272 - list, (* derivation from given term to normalform
1.273 - in reverse order with sym_thm;
1.274 - (#1#) could be extracted from here #1 *)
1.275 - normal_form: (* the function which drives the Rrls ##############################*)
1.276 - term -> (term * term list) option,
1.277 - locate_rule: (* checks a rule R for being a cancel-rule, and if it is,
1.278 - then return the list of rules (+ the terms they are rewriting to)
1.279 - which need to be applied before R should be applied.
1.280 - precondition: the rule is applicable to the argument-term. *)
1.281 - rule list list -> (* the reverse rule list *)
1.282 - term -> (* ... to which the rule shall be applied *)
1.283 - rule -> (* ... to be applied to term *)
1.284 - ( rule * (* value: a rule rewriting to ... *)
1.285 - (term * (* ... the resulting term ... *)
1.286 - term list)) (* ... with the assumptions ( //#0) *)
1.287 - list, (* there may be several such rules; the list is empty,
1.288 - if the rule has nothing to do with e.g. cancelation *)
1.289 - next_rule: (* for a given term return the next rules to be done for cancelling *)
1.290 - rule list list->(* the reverse rule list *)
1.291 - term -> (* the term for which ... *)
1.292 - rule option, (* ... this rule is appropriate for cancellation;
1.293 - there may be no such rule (if the term is eg.canceled already*)
1.294 - attach_form: (* checks an input term TI, if it may belong to e.g. a current
1.295 - cancellation, by trying to derive it from the given term TG.
1.296 - NOT IMPLEMENTED *)
1.297 - rule list list->(**)
1.298 - term -> (* TG, the last one agreed upon by user + math-eng *)
1.299 - term -> (* TI, the next one input by the user *)
1.300 - ( rule * (* the rule to be applied in order to reach TI *)
1.301 - (term * (* ... obtained by applying the rule ... *)
1.302 - term list)) (* ... and the respective assumptions *)
1.303 - list} (* there may be several such rules; the list is empty, if the
1.304 - users term does not belong to e.g. a cancellation of the term
1.305 - last agreed upon. *)
1.306 -and rls =
1.307 - Erls (*for init e_rls*)
1.308
1.309 - | Rls of (*a confluent and terminating ruleset, in general *)
1.310 - {id : string, (*for trace_rewrite:=true *)
1.311 - preconds : term list, (*unused WN020820 *)
1.312 - (*WN060616 for efficiency...
1.313 - bdvs : false, (*set in prep_rls' for get_bdvs *)*)
1.314 - rew_ord : rew_ord, (*for rules*)
1.315 - erls : rls, (*for the conditions in rules *)
1.316 - srls : rls, (*for evaluation of list_fns in script *)
1.317 - calc : calc list, (*for Calculate in scr, set by prep_rls' *)
1.318 - rules : rule list,
1.319 - errpatts : errpatID list,(*dialog-authoring in Build_Thydata.thy*)
1.320 - scr : scr} (*Prog term: generating intermed.steps *)
1.321 - | Seq of (*a sequence of rules to be tried only once *)
1.322 - {id : string, (*for trace_rewrite:=true *)
1.323 - preconds : term list, (*unused 20.8.02 *)
1.324 - (*WN060616 for efficiency...
1.325 - bdvs : false, (*set in prep_rls' for get_bdvs *)*)
1.326 - rew_ord : rew_ord, (*for rules *)
1.327 - erls : rls, (*for the conditions in rules *)
1.328 - srls : rls, (*for evaluation of list_fns in script *)
1.329 - calc : calc list, (*for Calculate in scr, set by prep_rls' *)
1.330 - rules : rule list,
1.331 - errpatts : errpatID list,(*dialog-authoring in Build_Thydata.thy*)
1.332 - scr : scr} (*Prog term (how to restrict type ???)*)
1.333 -
1.334 - (*Rrls call SML-code and simulate an rls
1.335 - difference: there is always _ONE_ redex rewritten in 1 call,
1.336 - thus wrap Rrls by: Rls (Rls_ ...)*)
1.337 - | Rrls of (* SML-functions within rewriting; step-wise execution provided;
1.338 - Rrls simulate an rls
1.339 - difference: there is always _ONE_ redex rewritten in 1 call,
1.340 - thus wrap Rrls by: Rls (Rls_ ...) *)
1.341 - {id : string, (* for trace_rewrite := true *)
1.342 - prepat : (term list *(* preconds, eval with subst from pattern;
1.343 - if [@{term True}], match decides alone *)
1.344 - term ) (* pattern matched with current (sub)term *)
1.345 - list, (* meta-conjunction is or *)
1.346 - rew_ord : rew_ord, (* for rules *)
1.347 - erls : rls, (* for the conditions in rules and preconds *)
1.348 - calc : calc list, (* for Calculate in scr, set automatic.in prep_rls' *)
1.349 - errpatts : errpatID list,(*dialog-authoring in Build_Thydata.thy*)
1.350 - scr : scr}; (* Rfuns {...} (how to restrict type ???) *)
1.351 -fun id_rls Erls = "e_rls" (*WN060714 quick and dirty: recursive defs! TODO "Erls" *)
1.352 - | id_rls (Rls {id, ...}) = id
1.353 - | id_rls (Seq {id, ...}) = id
1.354 - | id_rls (Rrls {id, ...}) = id;
1.355 -val rls2str = id_rls;
1.356 -fun id_rule (Thm (id, _)) = id
1.357 - | id_rule (Calc (id, _)) = id
1.358 - | id_rule (Cal1 (id, _)) = id
1.359 - | id_rule (Rls_ rls) = id_rls rls
1.360 - | id_rule Erule = "Erule";
1.361 -fun eq_rule (Thm (thm1, _), Thm (thm2, _)) = thm1 = thm2
1.362 - | eq_rule (Calc (id1, _), Calc (id2, _)) = id1 = id2
1.363 - | eq_rule (Rls_ rls1, Rls_ rls2) = id_rls rls1 = id_rls rls2
1.364 - | eq_rule _ = false;
1.365 -
1.366 -(*ad thm':
1.367 - there are two kinds of theorems ...
1.368 - (1) known by isabelle
1.369 - (2) not known, eg. calc_thm, instantiated rls
1.370 - the latter have a thmid "#..."
1.371 - and thus outside isa we ALWAYS transport both (thmID, string_of_thmI)
1.372 - and have a special assoc_thm / assoc_rls in this interface *)
1.373 -type theory' = string; (* = domID ^".thy" WN.101011 ABOLISH !*)
1.374 -type domID = string; (* domID ^".thy" = theory' WN.101011 replace by thyID*)
1.375 -type thyID = string; (* WN.3.11.03 TODO: replace domID with thyID*)
1.376 -val e_domID = "e_domID" : domID;
1.377 -
1.378 -(* Since Isabelle2017 sessions in theory identifiers are enforced.
1.379 - However, we leave theory identifiers short, in particular in use as keys into KEStore. *)
1.380 -fun Thy_Info_get_theory thyID = Thy_Info.get_theory ("Isac." ^ thyID)
1.381 -fun thy2ctxt' thy' = Proof_Context.init_global (Thy_Info_get_theory thy');(*FIXXXME thy-ctxt*)
1.382 -fun thy2ctxt thy = Proof_Context.init_global thy;(*FIXXXME thy-ctxt*)
1.383 -fun Isac _ = Proof_Context.theory_of (thy2ctxt' "Isac"); (*@{theory "Isac"}*)
1.384 -
1.385 -fun string_of_thy thy = Context.theory_name thy: theory';
1.386 -val theory2domID = string_of_thy;
1.387 -val theory2thyID = (get_thy o string_of_thy) : theory -> thyID;
1.388 -val theory2theory' = string_of_thy;
1.389 -val theory2str = string_of_thy; (*WN050903 ..most consistent naming*)
1.390 -
1.391 -fun thyID2theory' (thyID:thyID) = thyID;
1.392 -fun theory'2thyID (theory':theory') = theory';
1.393 (* WN0509 discussion:
1.394 #############################################################################
1.395 # How to manage theorys in subproblems wrt. the requirement, #
1.396 @@ -495,50 +270,16 @@
1.397 # ???
1.398 *)
1.399
1.400 -
1.401 -
1.402 -
1.403 -
1.404 fun thm2str thm =
1.405 let
1.406 val t = Thm.prop_of thm
1.407 val ctxt = Proof_Context.init_global (Thy_Info.get_theory ("Isac.Isac"))
1.408 val ctxt' = Config.put show_markup false ctxt
1.409 in Print_Mode.setmp [] (Syntax.string_of_term ctxt') t end;
1.410 -fun term_to_string' ctxt t =
1.411 - let
1.412 - val ctxt' = Config.put show_markup false ctxt
1.413 - in Print_Mode.setmp [] (Syntax.string_of_term ctxt') t end;
1.414 -fun term_to_string'' thyID t =
1.415 - let
1.416 - val ctxt' = Config.put show_markup false (Proof_Context.init_global (Thy_Info_get_theory thyID))
1.417 - in Print_Mode.setmp [] (Syntax.string_of_term ctxt') t end;
1.418 -fun term_to_string''' thy t =
1.419 - let
1.420 - val ctxt' = Config.put show_markup false (Proof_Context.init_global thy)
1.421 - in Print_Mode.setmp [] (Syntax.string_of_term ctxt') t end;
1.422 -
1.423 -fun term2str t = term_to_string' (thy2ctxt' "Isac") t;
1.424 -fun t2str thy t = term_to_string' (thy2ctxt thy) t;
1.425 -fun ts2str thy ts = ts |> map (t2str thy) |> strs2str';
1.426 -fun terms2strs ts = map term2str ts; (* terms2strs [t1,t2] = ["1 + 2", "abc"]; *)
1.427 -val terms2str = strs2str o terms2strs; (* terms2str [t1,t2] = "[\"1 + 2\",\"abc\"]"; *)
1.428 -val terms2str' = strs2str' o terms2strs; (* terms2str' [t1,t2] = "[1 + 2,abc]"; *)
1.429 -fun termopt2str (SOME t) = "(SOME " ^ term2str t ^ ")"
1.430 - | termopt2str NONE = "NONE";
1.431 -
1.432 -fun type_to_string'' (thyID : thyID) t =
1.433 - let
1.434 - val ctxt' = Config.put show_markup false (Proof_Context.init_global (Thy_Info_get_theory thyID))
1.435 - in Print_Mode.setmp [] (Syntax.string_of_typ ctxt') t end;
1.436 -fun type2str typ = type_to_string'' "Isac" typ; (*TODO legacy*)
1.437 -val string_of_typ = type2str; (*legacy*)
1.438 -fun string_of_typ_thy thy typ = type_to_string'' thy typ; (*legacy*)
1.439
1.440 -val e_rule = Thm ("refl", @{thm refl});
1.441 -fun id_of_thm (Thm (id, _)) = id (* TODO re-arrange code for rule2str *)
1.442 +fun id_of_thm (Rule.Thm (id, _)) = id (* TODO re-arrange code for rule2str *)
1.443 | id_of_thm _ = raise ERROR ("id_of_thm: uncovered case " (* ^ rule2str r *))
1.444 -fun thm_of_thm (Thm (_, thm)) = thm (* TODO re-arrange code for rule2str *)
1.445 +fun thm_of_thm (Rule.Thm (_, thm)) = thm (* TODO re-arrange code for rule2str *)
1.446 | thm_of_thm _ = raise ERROR ("thm_of_thm: uncovered case " (* ^ rule2str r *))
1.447
1.448 fun thmID_of_derivation_name dn = last_elem (space_explode "." dn);
1.449 @@ -546,41 +287,9 @@
1.450 fun thyID_of_derivation_name dn = hd (space_explode "." dn);
1.451 fun thm''_of_thm thm = (thmID_of_derivation_name' thm, thm) : thm''
1.452
1.453 -(*check for [.] as caused by "fun assoc_thm'"*)
1.454 -fun string_of_thm thm = term_to_string' (thy2ctxt' "Isac") (Thm.prop_of thm)
1.455 -fun string_of_thm' thy thm = term_to_string' (thy2ctxt thy) (Thm.prop_of thm)
1.456 -fun string_of_thmI thm =
1.457 - let
1.458 - val str = (de_quote o string_of_thm) thm
1.459 - val (a, b) = split_nlast (5, Symbol.explode str)
1.460 - in
1.461 - case b of
1.462 - [" ", " ","[", ".", "]"] => implode a
1.463 - | _ => str
1.464 - end
1.465 +type rrlsstate = (* state for reverse rewriting, comments see type rule and scr | Rfuns *)
1.466 + (term * term * Rule.rule list list * (Rule.rule * (term * term list)) list);
1.467
1.468 -fun get_rules Erls = []
1.469 - | get_rules (Rls {rules, ...}) = rules
1.470 - | get_rules (Seq {rules, ...}) = rules
1.471 - | get_rules (Rrls _) = [];
1.472 -fun rule2str Erule = "Erule"
1.473 - | rule2str (Thm (str, thm)) = "Thm (\""^str^"\","^(string_of_thmI thm)^")"
1.474 - | rule2str (Calc (str, _)) = "Calc (\""^str^"\",fn)"
1.475 - | rule2str (Cal1 (str, _)) = "Cal1 (\""^str^"\",fn)"
1.476 - | rule2str (Rls_ rls) = "Rls_ (\""^id_rls rls^"\")";
1.477 -fun rule2str' Erule = "Erule"
1.478 - | rule2str' (Thm (str, _)) = "Thm (\""^str^"\",\"\")"
1.479 - | rule2str' (Calc (str, _)) = "Calc (\""^str^"\",fn)"
1.480 - | rule2str' (Cal1 (str, _)) = "Cal1 (\""^str^"\",fn)"
1.481 - | rule2str' (Rls_ rls) = "Rls_ (\""^id_rls rls^"\")";
1.482 -
1.483 -type rrlsstate = (* state for reverse rewriting, comments see type rule and scr | Rfuns *)
1.484 - (term * term * rule list list * (rule * (term * term list)) list);
1.485 -
1.486 -val e_type = Type ("empty",[]);
1.487 -val e_term = Const ("empty", e_type);
1.488 -val e_rrlsstate = (e_term,e_term, [[e_rule]], [(e_rule, (e_term, []))]);
1.489 -val e_term = Const ("empty", Type("'a", []));
1.490
1.491 (*the key into the hierarchy ob theory elements*)
1.492 type theID = string list;
1.493 @@ -595,12 +304,12 @@
1.494
1.495 (*the key into the hierarchy ob methods*)
1.496 type metID = string list;
1.497 -type spec = domID * pblID * metID;
1.498 +type spec = Rule.domID * pblID * metID;
1.499 fun spec2str (dom, pbl, met) =
1.500 "(" ^ quote dom ^ ", " ^ strs2str pbl ^ ", " ^ strs2str met ^ ")";
1.501 val e_metID = ["e_metID"];
1.502 val metID2str = strs2str;
1.503 -val empty_spec = (e_domID, e_pblID, e_metID);
1.504 +val empty_spec = (Rule.e_domID, e_pblID, e_metID);
1.505 val e_spec = empty_spec;
1.506
1.507 (* association list with cas-commands, for generating a complete calc-head *)
1.508 @@ -638,9 +347,9 @@
1.509 (* rewrite orders, also stored in 'type met' and type 'and rls'
1.510 The association list is required for 'rewrite.."rew_ord"..' *)
1.511 val rew_ord' = Unsynchronized.ref
1.512 - ([("e_rew_ord", e_rew_ord), ("dummy_ord", dummy_ord)]
1.513 - : (rew_ord' * (* the key for the association list *)
1.514 - (subst (* the bound variables - they get high order*)
1.515 + ([("e_rew_ord", Rule.e_rew_ord), ("dummy_ord", Rule.dummy_ord)]
1.516 + : (Rule.rew_ord' * (* the key for the association list *)
1.517 + (Rule.subst (* the bound variables - they get high order*)
1.518 -> (term * term) (* (t1, t2) to be compared *)
1.519 -> bool)) (* if t1 <= t2 then true else false *)
1.520 list); (* association list *)
1.521 @@ -661,10 +370,10 @@
1.522 Html of {guh: guh, coursedesign: authors, mathauthors: authors, html: string}
1.523 | Hthm of {guh: guh, coursedesign: authors, mathauthors: authors, fillpats: fillpat list,
1.524 thm: thm} (* here no sym_thm, thus no thmID required *)
1.525 -| Hrls of {guh: guh, coursedesign: authors, mathauthors: authors, thy_rls: (thyID * rls)}
1.526 -| Hcal of {guh: guh, coursedesign: authors, mathauthors: authors, calc: calc}
1.527 +| Hrls of {guh: guh, coursedesign: authors, mathauthors: authors, thy_rls: (Rule.thyID * Rule.rls)}
1.528 +| Hcal of {guh: guh, coursedesign: authors, mathauthors: authors, calc: Rule.calc}
1.529 | Hord of {guh: guh, coursedesign: authors, mathauthors: authors,
1.530 - ord: (subst -> (term * term) -> bool)};
1.531 + ord: (Rule.subst -> (term * term) -> bool)};
1.532 fun the2str (Html {guh, ...}) = guh
1.533 | the2str (Hthm {guh, ...}) = guh
1.534 | the2str (Hrls {guh, ...}) = guh
1.535 @@ -710,30 +419,30 @@
1.536 (* convert the data got via contextToThy to a globally unique handle.
1.537 there is another way to get the guh: get out of the 'theID' in the hierarchy *)
1.538 fun thm2guh (isa, thyID) thmID = case isa of
1.539 - "Isabelle" => "thy_isab_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID : guh
1.540 - | "IsacKnowledge" => "thy_isac_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
1.541 - | "IsacScripts" => "thy_scri_" ^ theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
1.542 + "Isabelle" => "thy_isab_" ^ Rule.theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID : guh
1.543 + | "IsacKnowledge" => "thy_isac_" ^ Rule.theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
1.544 + | "IsacScripts" => "thy_scri_" ^ Rule.theory'2thyID thyID ^ "-thm-" ^ strip_thy thmID
1.545 | _ => raise ERROR
1.546 ("thm2guh called with (isa, thyID) = (" ^ isa ^ ", " ^ thyID ^ ") for thm = \"" ^ thmID ^ "\"");
1.547
1.548 fun rls2guh (isa, thyID) rls' = case isa of
1.549 - "Isabelle" => "thy_isab_" ^ theory'2thyID thyID ^ "-rls-" ^ rls' : guh
1.550 - | "IsacKnowledge" => "thy_isac_" ^ theory'2thyID thyID ^ "-rls-" ^ rls'
1.551 - | "IsacScripts" => "thy_scri_" ^ theory'2thyID thyID ^ "-rls-" ^ rls'
1.552 + "Isabelle" => "thy_isab_" ^ Rule.theory'2thyID thyID ^ "-rls-" ^ rls' : guh
1.553 + | "IsacKnowledge" => "thy_isac_" ^ Rule.theory'2thyID thyID ^ "-rls-" ^ rls'
1.554 + | "IsacScripts" => "thy_scri_" ^ Rule.theory'2thyID thyID ^ "-rls-" ^ rls'
1.555 | _ => raise ERROR
1.556 ("rls2guh called with (isa, thyID) = (" ^ isa ^ ", " ^ thyID ^ ") for rls = \"" ^ rls' ^ "\"");
1.557
1.558 fun cal2guh (isa, thyID) calID = case isa of
1.559 - "Isabelle" => "thy_isab_" ^ theory'2thyID thyID ^ "-cal-" ^ calID : guh
1.560 - | "IsacKnowledge" => "thy_isac_" ^ theory'2thyID thyID ^ "-cal-" ^ calID
1.561 - | "IsacScripts" => "thy_scri_" ^ theory'2thyID thyID ^ "-cal-" ^ calID
1.562 + "Isabelle" => "thy_isab_" ^ Rule.theory'2thyID thyID ^ "-cal-" ^ calID : guh
1.563 + | "IsacKnowledge" => "thy_isac_" ^ Rule.theory'2thyID thyID ^ "-cal-" ^ calID
1.564 + | "IsacScripts" => "thy_scri_" ^ Rule.theory'2thyID thyID ^ "-cal-" ^ calID
1.565 | _ => raise ERROR
1.566 ("cal2guh called with (isa, thyID) = (" ^ isa ^ ", " ^ thyID ^ ") for cal = \"" ^ calID ^ "\"");
1.567
1.568 fun ord2guh (isa, thyID) rew_ord' = case isa of
1.569 - "Isabelle" => "thy_isab_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord' : guh
1.570 - | "IsacKnowledge" => "thy_isac_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord'
1.571 - | "IsacScripts" => "thy_scri_" ^ theory'2thyID thyID ^ "-ord-" ^ rew_ord'
1.572 + "Isabelle" => "thy_isab_" ^ Rule.theory'2thyID thyID ^ "-ord-" ^ rew_ord' : guh
1.573 + | "IsacKnowledge" => "thy_isac_" ^ Rule.theory'2thyID thyID ^ "-ord-" ^ rew_ord'
1.574 + | "IsacScripts" => "thy_scri_" ^ Rule.theory'2thyID thyID ^ "-ord-" ^ rew_ord'
1.575 | _ => raise ERROR
1.576 ("ord2guh called with (isa, thyID) = (" ^ isa ^ ", " ^ thyID ^ ") for ord = \"" ^ rew_ord' ^ "\"");
1.577
1.578 @@ -772,105 +481,13 @@
1.579 type path = string;
1.580 type filename = string;
1.581
1.582 -local
1.583 - fun ii (_: term) = e_rrlsstate;
1.584 - fun no (_: term) = SOME (e_term, [e_term]);
1.585 - fun lo (_: rule list list) (_: term) (_: rule) = [(e_rule, (e_term, [e_term]))];
1.586 - fun ne (_: rule list list) (_: term) = SOME e_rule;
1.587 - fun fo (_: rule list list) (_: term) (_: term) = [(e_rule, (e_term, [e_term]))];
1.588 -in
1.589 -val e_rfuns = Rfuns {init_state = ii, normal_form = no, locate_rule = lo,
1.590 - next_rule = ne, attach_form = fo};
1.591 -end;
1.592 -val e_rls =
1.593 - Rls {id = "e_rls", preconds = [], rew_ord = ("dummy_ord", dummy_ord), erls = Erls,
1.594 - srls = Erls, calc = [], rules = [], errpatts = [], scr = EmptyScr}: rls;
1.595 -val e_rrls =
1.596 - Rrls {id = "e_rrls", prepat = [], rew_ord = ("dummy_ord", dummy_ord), erls = Erls,
1.597 - calc = [], errpatts = [], scr=e_rfuns}:rls;
1.598
1.599 -fun rep_rls Erls = rep_rls e_rls
1.600 - | rep_rls (Rls {id, preconds, rew_ord, erls, srls, calc, errpatts, rules, scr}) =
1.601 - {id = id, preconds = preconds, rew_ord = rew_ord, erls = erls, srls = srls, errpats = errpatts,
1.602 - calc = calc, rules = rules, scr = scr}
1.603 - | rep_rls (Seq {id, preconds, rew_ord, erls, srls, calc, errpatts, rules, scr}) =
1.604 - {id = id, preconds = preconds, rew_ord = rew_ord, erls = erls, srls = srls, errpats = errpatts,
1.605 - calc = calc, rules = rules, scr = scr}
1.606 - | rep_rls (Rrls _) = rep_rls e_rls
1.607 -
1.608 -fun append_rls id Erls _ = raise ERROR ("append_rls: with \"" ^ id ^ "\" not for Erls")
1.609 - | append_rls id (Rls {id = _, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.610 - rules = rs, errpatts = errpatts, scr = sc}) r =
1.611 - Rls {id = id, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.612 - rules = rs @ r, errpatts = errpatts, scr = sc}
1.613 - | append_rls id (Seq {id = _, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.614 - rules = rs, errpatts = errpatts, scr = sc}) r =
1.615 - Seq {id = id, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.616 - rules = rs @ r, errpatts = errpatts, scr = sc}
1.617 - | append_rls id (Rrls _) _ = raise ERROR ("append_rls: not for reverse-rewrite-rule-set " ^ id);
1.618 -
1.619 -
1.620 -fun merge_ids rls1 rls2 =
1.621 - let
1.622 - val id1 = (#id o rep_rls) rls1
1.623 - val id2 = (#id o rep_rls) rls2
1.624 - in
1.625 - if id1 = id2 then id1 else "merged_" ^ id1 ^ "_" ^ id2
1.626 - end
1.627 -fun merge_rls _ Erls rls = rls
1.628 - | merge_rls _ rls Erls = rls
1.629 - | merge_rls _ (Rrls x) _ = Rrls x (* required for merging Theory_Data *)
1.630 - | merge_rls _ _ (Rrls x) = Rrls x
1.631 - | merge_rls id
1.632 - (Rls {preconds = pc1, rew_ord = ro1, erls = er1, srls = sr1, calc = ca1,
1.633 - rules = rs1, errpatts = eps1, scr = sc1, ...})
1.634 - (Rls {preconds = pc2, erls = er2, srls = sr2, calc = ca2,
1.635 - rules = rs2, errpatts = eps2, ...})
1.636 - =
1.637 - Rls {id = id, rew_ord = ro1, scr = sc1,
1.638 - preconds = union (op =) pc1 pc2,
1.639 - erls = merge_rls (merge_ids er1 er2) er1 er2,
1.640 - srls = merge_rls (merge_ids sr1 sr2) sr1 sr2,
1.641 - calc = union calc_eq ca1 ca2,
1.642 - rules = union eq_rule rs1 rs2,
1.643 - errpatts = union (op =) eps1 eps2}
1.644 - | merge_rls id
1.645 - (Seq {preconds = pc1, rew_ord = ro1, erls = er1, srls = sr1, calc = ca1,
1.646 - rules = rs1, errpatts = eps1, scr = sc1, ...})
1.647 - (Seq {preconds = pc2, erls = er2, srls = sr2, calc = ca2,
1.648 - rules = rs2, errpatts = eps2, ...})
1.649 - =
1.650 - Seq {id = id, rew_ord = ro1, scr = sc1,
1.651 - preconds = union (op =) pc1 pc2,
1.652 - erls = merge_rls (merge_ids er1 er2) er1 er2,
1.653 - srls = merge_rls (merge_ids sr1 sr2) sr1 sr2,
1.654 - calc = union calc_eq ca1 ca2,
1.655 - rules = union eq_rule rs1 rs2,
1.656 - errpatts = union (op =) eps1 eps2}
1.657 - | merge_rls id _ _ = error ("merge_rls: \"" ^ id ^
1.658 - "\"; not for reverse-rewrite-rule-sets and not for mixed Rls -- Seq");
1.659 -
1.660 -(* used only for one hack TODO remove *)
1.661 -fun remove_rls id (Rls {id = _, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.662 - rules = rs, errpatts = eps, scr = sc}) r =
1.663 - Rls {id = id, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.664 - rules = gen_rems eq_rule (rs, r),
1.665 - errpatts = eps,
1.666 - scr = sc}
1.667 - | remove_rls id (Seq {id = _, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.668 - rules = rs, errpatts = eps, scr = sc}) r =
1.669 - Seq {id = id, preconds = pc, rew_ord = ro, erls = er, srls = sr, calc = ca,
1.670 - rules = gen_rems eq_rule (rs, r),
1.671 - errpatts = eps,
1.672 - scr = sc}
1.673 - | remove_rls id (Rrls _) _ = raise ERROR ("remove_rls: not for reverse-rewrite-rule-set "^id)
1.674 - | remove_rls _ rls _ = raise ERROR ("remove_rls called with " ^ rls2str rls);
1.675
1.676 (* datastructure for KEStore_Elems, intermediate for thehier *)
1.677 type rlss_elem =
1.678 - (rls' * (* identifier unique within Isac *)
1.679 - (theory' * (* just for assignment in thehier, not appropriate for parsing etc *)
1.680 - rls)) (* ((#id o rep_rls) rls) = rls' by coding discipline *)
1.681 + (rls' * (* identifier unique within Isac *)
1.682 + (Rule.theory' * (* just for assignment in thehier, not appropriate for parsing etc *)
1.683 + Rule.rls)) (* ((#id o rep_rls) rls) = rls' by coding discipline *)
1.684 fun rls_eq ((id1, (_, _)), (id2, (_, _))) = id1 = id2
1.685
1.686 fun insert_merge_rls (re as (id, (thyID, r1)) : rlss_elem) ys =
1.687 @@ -878,7 +495,7 @@
1.688 NONE => re :: ys
1.689 | SOME (i, (_, (_, r2))) =>
1.690 let
1.691 - val r12 = merge_rls id r1 r2
1.692 + val r12 = Rule.merge_rls id r1 r2
1.693 in list_update ys i (id, (thyID, r12)) end
1.694 fun merge_rlss (s1, s2) = fold insert_merge_rls s1 s2;
1.695
1.696 @@ -888,8 +505,8 @@
1.697
1.698 fun assoc_thy thy =
1.699 if thy = "e_domID"
1.700 - then (Thy_Info_get_theory "Script") (*lower bound of Knowledge*)
1.701 - else (Thy_Info_get_theory thy) handle _ => error ("ME_Isa: thy \"" ^ thy ^ "\" not in system");
1.702 + then (Rule.Thy_Info_get_theory "Script") (*lower bound of Knowledge*)
1.703 + else (Rule.Thy_Info_get_theory thy) handle _ => error ("ME_Isa: thy \"" ^ thy ^ "\" not in system");
1.704
1.705 (* overwrite an element in an association list and pair it with a thyID
1.706 in order to create the thy_hierarchy;
1.707 @@ -901,8 +518,8 @@
1.708 in scripts...
1.709 actually a hack to get alltogether run again with minimal effort *)
1.710 fun insthy thy' (rls', rls) = (rls', (thy', rls));
1.711 -fun overwritelthy thy (al, bl:(rls' * rls) list) =
1.712 - let val bl' = map (insthy ((get_thy o theory2theory') thy)) bl
1.713 +fun overwritelthy thy (al, bl:(rls' * Rule.rls) list) =
1.714 + let val bl' = map (insthy ((get_thy o Rule.theory2theory') thy)) bl
1.715 in overwritel (al, bl') end;
1.716
1.717 fun assoc_rew_ord ro = ((the o assoc') (!rew_ord',ro))
1.718 @@ -911,17 +528,13 @@
1.719 fun subst2str s =
1.720 (strs2str o
1.721 (map (
1.722 - linefeed o pair2str o (apsnd term2str) o (apfst term2str)))) s;
1.723 -fun subst2str' (s:subst) =
1.724 + linefeed o pair2str o (apsnd Rule.term2str) o (apfst Rule.term2str)))) s;
1.725 +fun subst2str' s =
1.726 (strs2str' o
1.727 (map (
1.728 - pair2str o (apsnd term2str) o (apfst term2str)))) s;
1.729 + pair2str o (apsnd Rule.term2str) o (apfst Rule.term2str)))) s;
1.730 val env2str = subst2str;
1.731
1.732 -fun scr2str EmptyScr = "EmptyScr"
1.733 - | scr2str (Prog s) = "Prog " ^ term2str s
1.734 - | scr2str (Rfuns _) = "Rfuns";
1.735 -
1.736 fun maxthy thy1 thy2 = if Context.subthy (thy1, thy2) then thy2 else thy1;
1.737
1.738
1.739 @@ -956,7 +569,7 @@
1.740 (term * (* description *)
1.741 term)) (* id | arbitrary term *);
1.742 fun pat2str ((field, (dsc, id)) : pat) =
1.743 - pair2str (field, pair2str (term2str dsc, term2str id))
1.744 + pair2str (field, pair2str (Rule.term2str dsc, Rule.term2str id))
1.745 fun pats2str pats = (strs2str o (map pat2str)) pats
1.746
1.747 (* types for problems models (TODO rename to specification models) *)
1.748 @@ -974,7 +587,7 @@
1.749 because applied terms may be from 'subthy' as well as from super;
1.750 thus we take 'maxthy'; see match_ags ! *)
1.751 cas : term option, (* 'CAS-command' *)
1.752 - prls : rls, (* for preds in where_ *)
1.753 + prls : Rule.rls, (* for preds in where_ *)
1.754 where_ : term list, (* where - predicates *)
1.755 ppc : pat list, (* this is the model-pattern;
1.756 it contains "#Given","#Where","#Find","#Relate"-patterns
1.757 @@ -982,14 +595,14 @@
1.758 met : metID list} (* methods solving the pbt *)
1.759
1.760 val e_pbt = {guh = "pbl_empty", mathauthors = [], init = e_pblID, thy = Thy_Info.get_theory "Pure",
1.761 - cas = NONE, prls = Erls, where_ = [], ppc = [], met = []}
1.762 + cas = NONE, prls = Rule.Erls, where_ = [], ppc = [], met = []}
1.763 fun pbt2str ({cas = cas', guh = guh', init = init', mathauthors = ma', met = met', ppc = ppc',
1.764 prls = prls', thy = thy', where_ = w'} : pbt)
1.765 - = "{cas = " ^ (termopt2str cas') ^ ", guh = \"" ^ guh' ^ "\", init = "
1.766 + = "{cas = " ^ (Rule.termopt2str cas') ^ ", guh = \"" ^ guh' ^ "\", init = "
1.767 ^ (strs2str init') ^ ", mathauthors = " ^ (strs2str ma' |> quote) ^ ", met = "
1.768 ^ (strslist2strs met') ^ ", ppc = " ^ pats2str ppc' ^ ", prls = "
1.769 - ^ (rls2str prls' |> quote) ^ ", thy = {" ^ (theory2str thy') ^ "}, where_ = "
1.770 - ^ (terms2str w') ^ "}" |> linefeed;
1.771 + ^ (Rule.rls2str prls' |> quote) ^ ", thy = {" ^ (Rule.theory2str thy') ^ "}, where_ = "
1.772 + ^ (Rule.terms2str w') ^ "}" |> linefeed;
1.773 fun pbts2str pbts = map pbt2str pbts |> list2str;
1.774
1.775 val e_Ptyp = Ptyp ("e_pblID",[e_pbt],[])
1.776 @@ -1053,32 +666,32 @@
1.777
1.778 (* data for methods stored in 'methods'-database*)
1.779 type met =
1.780 - {guh : guh, (*unique within this isac-knowledge *)
1.781 - mathauthors: string list,(*copyright *)
1.782 - init : pblID, (*WN060721 introduced mistakenly--TODO.REMOVE!*)
1.783 - rew_ord' : rew_ord', (*for rules in Detail
1.784 - TODO.WN0509 store fun itself, see 'type pbt'*)
1.785 - erls : rls, (*the eval_rls for cond. in rules FIXME "rls'
1.786 - instead erls in "fun prep_met" *)
1.787 - srls : rls, (*for evaluating list expressions in scr *)
1.788 - prls : rls, (*for evaluating predicates in modelpattern *)
1.789 - crls : rls, (*for check_elementwise, ie. formulae in calc.*)
1.790 - nrls : rls, (*canonical simplifier specific for this met *)
1.791 - errpats : errpat list,(*error patterns expected in this method *)
1.792 - calc : calc list, (*Theory_Data in fun prep_met *)
1.793 + {guh : guh, (*unique within this isac-knowledge *)
1.794 + mathauthors: string list, (*copyright *)
1.795 + init : pblID, (*WN060721 introduced mistakenly--TODO.REMOVE!*)
1.796 + rew_ord' : Rule.rew_ord', (*for rules in Detail
1.797 + TODO.WN0509 store fun itself, see 'type pbt'*)
1.798 + erls : Rule.rls, (*the eval_rls for cond. in rules FIXME "rls'
1.799 + instead erls in "fun prep_met" *)
1.800 + srls : Rule.rls, (*for evaluating list expressions in scr *)
1.801 + prls : Rule.rls, (*for evaluating predicates in modelpattern *)
1.802 + crls : Rule.rls, (*for check_elementwise, ie. formulae in calc.*)
1.803 + nrls : Rule.rls, (*canonical simplifier specific for this met *)
1.804 + errpats : Rule.errpat list,(*error patterns expected in this method *)
1.805 + calc : Rule.calc list, (*Theory_Data in fun prep_met *)
1.806 (*branch : TransitiveB set in append_problem at generation ob pblobj
1.807 - FIXXXME.0308: set branch from met in Apply_Method ? *)
1.808 + FIXXXME.0308: set branch from met in Apply_Method ? *)
1.809 ppc : pat list, (*.items in given, find, relate;
1.810 items (in "#Find") which need not occur in the arg-list of a SubProblem
1.811 are 'copy-named' with an identifier "*'.'".
1.812 copy-named items are 'generating' if they are NOT "*'''" ?WN120516??
1.813 - see ME/calchead.sml 'fun is_copy_named'. *)
1.814 - pre : term list, (*preconditions in where *)
1.815 - scr : scr (*prep_met gets progam or string "empty_script"*)
1.816 + see ME/calchead.sml 'fun is_copy_named'. *)
1.817 + pre : term list, (*preconditions in where *)
1.818 + scr : Rule.scr (*prep_met gets progam or string "empty_script" *)
1.819 };
1.820 val e_met = {guh = "met_empty", mathauthors = [], init = e_metID, rew_ord' = "e_rew_ord'",
1.821 - erls = e_rls, srls = e_rls, prls = e_rls, calc = [], crls = e_rls, errpats = [], nrls= e_rls,
1.822 - ppc = [], pre = [], scr = EmptyScr};
1.823 + erls = Rule.e_rls, srls = Rule.e_rls, prls = Rule.e_rls, calc = [], crls = Rule.e_rls,
1.824 + errpats = [], nrls = Rule.e_rls, ppc = [], pre = [], scr = Rule.EmptyScr};
1.825 val e_Mets = Ptyp ("e_metID", [e_met],[]);
1.826
1.827 type mets = (met ptyp) list;
1.828 @@ -1128,14 +741,14 @@
1.829 let
1.830 val rls' =
1.831 case rls of
1.832 - Rls {id, preconds, rew_ord, erls, srls, calc, rules, scr, ...}
1.833 - => Rls {id = id, preconds = preconds, rew_ord = rew_ord, erls = erls, srls = srls,
1.834 + Rule.Rls {id, preconds, rew_ord, erls, srls, calc, rules, scr, ...}
1.835 + => Rule.Rls {id = id, preconds = preconds, rew_ord = rew_ord, erls = erls, srls = srls,
1.836 calc = calc, rules = rules, scr = scr, errpatts = errpatIDs}
1.837 - | Seq {id, preconds, rew_ord, erls, srls, calc, rules, scr, ...}
1.838 - => Seq {id = id, preconds = preconds, rew_ord = rew_ord, erls = erls, srls = srls,
1.839 + | Rule.Seq {id, preconds, rew_ord, erls, srls, calc, rules, scr, ...}
1.840 + => Rule.Seq {id = id, preconds = preconds, rew_ord = rew_ord, erls = erls, srls = srls,
1.841 calc = calc, rules = rules, scr = scr, errpatts = errpatIDs}
1.842 - | Rrls {id, prepat, rew_ord, erls, calc, scr, ...}
1.843 - => Rrls {id = id, prepat = prepat, rew_ord = rew_ord, erls = erls, calc = calc,
1.844 + | Rule.Rrls {id, prepat, rew_ord, erls, calc, scr, ...}
1.845 + => Rule.Rrls {id = id, prepat = prepat, rew_ord = rew_ord, erls = erls, calc = calc,
1.846 scr = scr, errpatts = errpatIDs}
1.847 | Erls => Erls
1.848 in
1.849 @@ -1174,7 +787,7 @@
1.850 section "Get and group the theories defined in Isac" *)
1.851 fun isabthys () = (*["Complex_Main", "Taylor", .., "Pure"]*)
1.852 let
1.853 - val allthys = Theory.ancestors_of (Thy_Info_get_theory "Build_Thydata")
1.854 + val allthys = Theory.ancestors_of (Rule.Thy_Info_get_theory "Build_Thydata")
1.855 in
1.856 drop ((find_index (curry Context.eq_thy (Thy_Info.get_theory "Complex_Main")) allthys), allthys)
1.857 end
1.858 @@ -1183,15 +796,15 @@
1.859 fun isacthys () = (* ["Isac", .., "KEStore"] without Build_Isac thys: "Interpret" etc *)
1.860 let
1.861 val allthys = filter_out (member Context.eq_thy
1.862 - [(*Thy_Info_get_theory "ProgLang",*) Thy_Info_get_theory "Interpret",
1.863 - Thy_Info_get_theory "xmlsrc", Thy_Info_get_theory "Frontend"])
1.864 - (Theory.ancestors_of (Thy_Info_get_theory "Build_Thydata"))
1.865 + [(*Thy_Info_get_theory "ProgLang",*) Rule.Thy_Info_get_theory "Interpret",
1.866 + Rule.Thy_Info_get_theory "xmlsrc", Rule.Thy_Info_get_theory "Frontend"])
1.867 + (Theory.ancestors_of (Rule.Thy_Info_get_theory "Build_Thydata"))
1.868 in
1.869 take ((find_index (curry Context.eq_thy (Thy_Info.get_theory "Complex_Main")) allthys),
1.870 allthys)
1.871 end
1.872 val isacthys' = isacthys ()
1.873 - val proglang_parent = Thy_Info_get_theory "ProgLang"
1.874 + val proglang_parent = Rule.Thy_Info_get_theory "ProgLang"
1.875 in
1.876 take ((find_index (curry Context.eq_thy proglang_parent) isacthys'), isacthys')
1.877 end
1.878 @@ -1199,17 +812,17 @@
1.879 fun progthys () = (*["Isac", .., "Descript", "Delete"]*)
1.880 let
1.881 fun isacthys () = (* ["Isac", .., "KEStore"] without Build_Isac thys: "Interpret" etc *)
1.882 - let
1.883 + let
1.884 val allthys = filter_out (member Context.eq_thy
1.885 - [(*Thy_Info_get_theory "ProgLang",*) Thy_Info_get_theory "Interpret",
1.886 - Thy_Info_get_theory "xmlsrc", Thy_Info_get_theory "Frontend"])
1.887 - (Theory.ancestors_of (Thy_Info_get_theory "Build_Thydata"))
1.888 + [(*Thy_Info_get_theory "ProgLang",*) Rule.Thy_Info_get_theory "Interpret",
1.889 + Rule.Thy_Info_get_theory "xmlsrc", Rule.Thy_Info_get_theory "Frontend"])
1.890 + (Theory.ancestors_of (Rule.Thy_Info_get_theory "Build_Thydata"))
1.891 in
1.892 take ((find_index (curry Context.eq_thy (Thy_Info.get_theory "Complex_Main")) allthys),
1.893 allthys)
1.894 end
1.895 val isacthys' = isacthys ()
1.896 - val proglang_parent = Thy_Info_get_theory "ProgLang"
1.897 + val proglang_parent = Rule.Thy_Info_get_theory "ProgLang"
1.898 in
1.899 drop ((find_index (curry Context.eq_thy proglang_parent) isacthys') + 1(*ProgLang*), isacthys')
1.900 end
1.901 @@ -1218,8 +831,8 @@
1.902 if member Context.eq_thy (knowthys ()) thy then "IsacKnowledge"
1.903 else if member Context.eq_thy (progthys ()) thy then "IsacScripts"
1.904 else if member Context.eq_thy (isabthys ()) thy then "Isabelle"
1.905 - else error ("closure of thys in Isac is broken by " ^ string_of_thy thy)
1.906 -fun partID' (thy' : theory') = partID (Thy_Info_get_theory thy')
1.907 + else error ("closure of thys in Isac is broken by " ^ Rule.string_of_thy thy)
1.908 +fun partID' thy' = partID (Rule.Thy_Info_get_theory thy')
1.909
1.910 end (*struct*)
1.911