39 val single_to_string_POS': single_POS -> string |
39 val single_to_string_POS': single_POS -> string |
40 val to_string: Proof.context -> T -> string |
40 val to_string: Proof.context -> T -> string |
41 val to_string_POS: Proof.context -> T_POS -> string |
41 val to_string_POS: Proof.context -> T_POS -> string |
42 |
42 |
43 val feedback_OLD_to_POS: feedback -> feedback_POS |
43 val feedback_OLD_to_POS: feedback -> feedback_POS |
44 |
44 val feedback_POS_to_OLD: feedback_POS -> feedback |
45 datatype add_single = Add of single | Err of string |
45 val OLD_to_POS_single: single -> single_POS |
|
46 val TEST_to_OLD_single: single_POS -> single |
|
47 |
|
48 datatype add_single = Add of single_POS | Err of string |
46 val init: Model_Pattern.T -> T |
49 val init: Model_Pattern.T -> T |
47 val init_POS: Proof.context -> O_Model.T -> Model_Pattern.T -> T_POS |
50 val init_POS: Proof.context -> O_Model.T -> Model_Pattern.T -> T_POS |
48 val check_single: Proof.context -> m_field -> O_Model.T -> T -> Model_Pattern.T -> |
51 val check_single: Proof.context -> m_field -> O_Model.T -> T -> Model_Pattern.T -> |
49 TermC.as_string -> add_single |
52 TermC.as_string -> add_single |
|
53 (*probably unused in PIDE, thus-----v----v*) |
50 val add_single: theory -> single -> T -> T |
54 val add_single: theory -> single -> T -> T |
51 |
55 |
52 val make_tactic: m_field -> TermC.as_string * T -> Tactic.T |
56 val make_tactic: m_field -> TermC.as_string * T -> Tactic.T |
53 (*--*) |
57 |
54 val descriptor: feedback -> descriptor |
58 val descriptor: feedback -> descriptor |
55 (*--*) |
|
56 val descriptor_POS: feedback_POS -> descriptor |
59 val descriptor_POS: feedback_POS -> descriptor |
57 val values: feedback -> values option |
60 val values: feedback -> values option |
58 val o_model_values: feedback -> values |
61 val o_model_values: feedback -> values |
59 val values_POS': feedback_POS -> values |
62 val values_POS': feedback_POS -> values |
60 val descr_pairs_to_string: Proof.context -> (Model_Pattern.single * single_POS) list -> string |
63 val descr_pairs_to_string: Proof.context -> (Model_Pattern.single * single_POS) list -> string |
61 val variables: Model_Pattern.T -> Model_Def.i_model_POS -> term list |
64 val variables: Model_Pattern.T -> Model_Def.i_model_POS -> term list |
62 val is_notyet_input : Proof.context -> T -> O_Model.values -> O_Model.single -> Model_Pattern.T |
65 val is_notyet_input: Proof.context -> T_POS -> O_Model.values -> O_Model.single -> |
63 -> message * single |
66 Model_Pattern.T -> message * single_POS |
64 val get_field_term: theory -> O_Model.single -> single -> m_field * TermC.as_string |
67 val get_field_term: theory -> O_Model.single -> single -> m_field * TermC.as_string |
65 |
68 |
66 val fill_from_o: O_Model.T -> single_POS -> single_POS option |
69 val fill_from_o: O_Model.T -> single_POS -> single_POS option |
67 |
70 |
68 val add_other: variant -> T_POS -> single_POS -> single_POS |
71 val add_other: variant -> T_POS -> single_POS -> single_POS |
139 | feedback_OLD_to_POS (Inc ((d, ts), _)) = (Model_Def.Inc_POS (d, ts)) |
141 | feedback_OLD_to_POS (Inc ((d, ts), _)) = (Model_Def.Inc_POS (d, ts)) |
140 | feedback_OLD_to_POS (Sup (d, ts)) = (Model_Def.Sup_POS (d, ts)) |
142 | feedback_OLD_to_POS (Sup (d, ts)) = (Model_Def.Sup_POS (d, ts)) |
141 | feedback_OLD_to_POS (Mis (d, pid)) = Model_Def.Syn_POS ((UnparseC.term (ContextC.for_ERROR ()) d) ^ " " ^ |
143 | feedback_OLD_to_POS (Mis (d, pid)) = Model_Def.Syn_POS ((UnparseC.term (ContextC.for_ERROR ()) d) ^ " " ^ |
142 (UnparseC.term (ContextC.for_ERROR ()) pid)) |
144 (UnparseC.term (ContextC.for_ERROR ()) pid)) |
143 | feedback_OLD_to_POS (Par s) = (Model_Def.Syn_POS s) |
145 | feedback_OLD_to_POS (Par s) = (Model_Def.Syn_POS s) |
144 fun OLD_to_POS i_old = |
146 fun OLD_to_POS_single (a, b, c, d, e) = (a, b, c, d, (feedback_OLD_to_POS e, Position.none)) |
145 map (fn (a, b, c, d, e) => (a, b, c, d, (feedback_OLD_to_POS e, Position.none))) i_old |
147 fun OLD_to_POS i_old = map OLD_to_POS_single i_old |
146 |
148 |
147 fun feedback_POS_to_OLD (Model_Def.Cor_POS (d, ts)) = (Cor ((d, ts), (TermC.empty, []))) |
149 fun feedback_POS_to_OLD (Model_Def.Cor_POS (d, ts)) = (Cor ((d, ts), (TermC.empty, []))) |
148 | feedback_POS_to_OLD (Model_Def.Syn_POS c) = (Syn c) |
150 | feedback_POS_to_OLD (Model_Def.Syn_POS c) = (Syn c) |
149 | feedback_POS_to_OLD (Model_Def.Inc_POS (d, ts)) = (Inc ((d, ts), (TermC.empty, []))) |
151 | feedback_POS_to_OLD (Model_Def.Inc_POS (d, ts)) = (Inc ((d, ts), (TermC.empty, []))) |
150 | feedback_POS_to_OLD (Model_Def.Sup_POS (d, ts)) = (Sup (d, ts)) |
152 | feedback_POS_to_OLD (Model_Def.Sup_POS (d, ts)) = (Sup (d, ts)) |
151 fun TEST_to_OLD i_model = |
153 fun TEST_to_OLD_single (a, b, c, d, (e, _)) = (a, b, c, d, feedback_POS_to_OLD e) |
152 map (fn (a, b, c, d, (e, _)) => (a, b, c, d, feedback_POS_to_OLD e)) i_model |
154 fun TEST_to_OLD i_model = map TEST_to_OLD_single i_model |
153 |
155 |
154 type message = string; |
156 type message = string; |
155 |
157 |
156 fun feedback_to_string ctxt (Cor ((d, ts), _)) = |
158 fun feedback_to_string ctxt (Cor ((d, ts), _)) = |
157 "Cor " ^ UnparseC.term ctxt (Input_Descript.join (d, ts)) ^ " , pen2str" |
159 "Cor " ^ UnparseC.term ctxt (Input_Descript.join (d, ts)) ^ " , pen2str" |
285 |
287 |
286 fun variables model_patt i_model = |
288 fun variables model_patt i_model = |
287 Pre_Conds.environment_POS model_patt i_model |
289 Pre_Conds.environment_POS model_patt i_model |
288 |> map snd |
290 |> map snd |
289 |
291 |
|
292 (* |
290 val unknown_descriptor = Syntax.read_term\<^context> "unknown::'a => unknow"; |
293 val unknown_descriptor = Syntax.read_term\<^context> "unknown::'a => unknow"; |
291 |
294 *) |
292 (* get a term from O_Model, notyet input in I_Model. |
295 (* get a term from O_Model, notyet input in I_Model. |
293 the term from O_Model is thrown back to a string in order to reuse |
296 the term from O_Model is thrown back to a string in order to reuse |
294 machinery for immediate input by the user. *) |
297 machinery for immediate input by the user. *) |
295 fun get_field_term thy (_, _, _, d, ts) (_, _, _, fd, itm_) = |
298 fun get_field_term thy (_, _, _, d, ts) (_, _, _, fd, itm_) = |
296 (fd, ((UnparseC.term_in_thy thy) o Input_Descript.join) (d, subtract op = (o_model_values itm_) ts)) |
299 (fd, ((UnparseC.term_in_thy thy) o Input_Descript.join) (d, subtract op = (o_model_values itm_) ts)) |
297 |
300 |
298 (*update the itm_ already input, all..from ori*) |
301 (*update the itm_ already input, all..from ori*) |
299 fun ori_2itm itm_ pid all (id, vt, fd, d, ts) = |
302 fun ori_2itm (feedb:feedback_POS) _ all (id, vt, fd, d, ts) = |
300 let |
303 let |
301 val ts' = union op = (o_model_values itm_) ts; |
304 val ts' = union op = (values_POS' feedb) ts; |
302 val pval = [Input_Descript.join'''' (d, ts')] |
|
303 (*WN.9.5.03: FIXXXME [#0, epsilon] here would upd_penv be called for [#0, epsilon] etc*) |
|
304 val complete = if eq_set op = (ts', all) then true else false |
305 val complete = if eq_set op = (ts', all) then true else false |
305 in |
306 in |
306 case itm_ of |
307 case feedb of |
307 (Cor _) => |
308 Cor_POS _ => if fd = "#undef" |
308 (if fd = "#undef" then (id, vt, complete, fd, Sup (d, ts')) |
309 then (id, vt, complete, fd, (Sup_POS (d, ts'), Position.none)) |
309 else (id, vt, complete, fd, Cor ((d, ts'), (pid, pval)))) |
310 else (id, vt, complete, fd, (Cor_POS (d, ts'), Position.none)) |
310 | (Syn c) => raise ERROR ("ori_2itm wants to overwrite " ^ c) |
311 | Inc_POS _ => if complete |
311 | (Typ c) => raise ERROR ("ori_2itm wants to overwrite " ^ c) |
312 then (id, vt, true, fd, (Cor_POS (d, ts'), Position.none)) |
312 | (Inc _) => |
313 else (id, vt, false, fd, (Inc_POS (d, ts'), Position.none)) |
313 if complete |
314 | Sup_POS (d, ts') => |
314 then (id, vt, true, fd, Cor ((d, ts'), (pid, pval))) |
315 (id, vt, complete, fd, (Sup_POS (d, ts'), Position.none)) |
315 else (id, vt, false, fd, Inc ((d, ts'), (pid, pval))) |
316 | i => raise ERROR ("ori_2itm: uncovered case of " ^ feedback_POS_to_string (ContextC.for_ERROR ()) i) |
316 | (Sup (d,ts')) => (*4.9.01 lost env*) |
|
317 (*if fd = "#undef" then*) (id,vt,complete,fd,Sup(d,ts')) |
|
318 (*else (id,vt,complete,fd,Cor((d,ts'),e))*) |
|
319 (* 28.1.00: not completely clear ---^^^ etc.*) |
|
320 | (Mis _) => (* 4.9.01: Mis just copied *) |
|
321 if complete |
|
322 then (id, vt, true, fd, Cor ((d,ts'), (pid, pval))) |
|
323 else (id, vt, false, fd, Inc ((d,ts'), (pid, pval))) |
|
324 | i => raise ERROR ("ori_2itm: uncovered case of " ^ feedback_to_string (ContextC.for_ERROR ()) i) |
|
325 end |
317 end |
326 |
318 |
327 |
319 |
328 (** find next step **) |
320 (** find next step **) |
329 |
321 |
330 fun eq1 d (_, (d', _)) = (d = d') |
322 (*old code kept for test/*) |
331 fun eq3 f d (_, _, _, f', itm_) = f = f' andalso d = (descriptor itm_) |
|
332 |
|
333 fun is_notyet_input ctxt itms all (i, v, f, d, ts) pbt = |
323 fun is_notyet_input ctxt itms all (i, v, f, d, ts) pbt = |
334 case find_first (eq1 d) pbt of |
324 case find_first (fn (_, (d', _)) => d = d') pbt of |
335 SOME (_, (_, pid)) => |
325 SOME (_, (_, pid)) => |
336 (case find_first (eq3 f d) itms of |
326 (case find_first (fn (_, _, _, f', (feedb, _)) => |
337 SOME (_, _, _, _, itm_) => |
327 f = f' andalso d = (descriptor_POS feedb)) itms of |
338 let val ts' = inter op = (o_model_values itm_) ts |
328 SOME (_, _, _, _, (feedb, _)) => |
339 in |
329 let val ts' = inter op = (values_POS' feedb) ts |
|
330 in |
340 if subset op = (ts, ts') |
331 if subset op = (ts, ts') |
341 then (((strs2str' o map (UnparseC.term ctxt)) ts') ^ " already input", empty_single) |
332 then (((strs2str' o map (UnparseC.term ctxt)) ts') ^ " already input", empty_single_POS) |
342 else ("", ori_2itm itm_ pid all (i, v, f, d, subtract op = ts' ts)) |
333 else ("", ori_2itm feedb pid all (i, v, f, d, subtract op = ts' ts)) |
343 end |
334 end |
344 | NONE => ("", ori_2itm (Inc ((TermC.empty, []), (pid, []))) pid all (i, v, f, d, ts))) |
335 | NONE => ("", ori_2itm (Inc_POS (TermC.empty, [])) pid all (i, v, f, d, ts))) |
345 | NONE => ("", ori_2itm (Sup (d, ts)) TermC.empty all (i, v, f, d, ts)) |
336 | NONE => ("", ori_2itm (Sup_POS (d, ts)) TermC.empty all (i, v, f, d, ts)) |
346 |
337 |
347 datatype add_single = |
338 datatype add_single = |
348 Add of single (* return-value of check_single *) |
339 Add of single_POS (* return-value of check_single *) |
349 | Err of string (* error-message *) |
340 | Err of string (* error-message *) |
350 |
341 |
351 (* |
342 (* |
352 Create feedback for input of TermC.as_string to m_field; |
343 Create feedback for input of TermC.as_string to m_field; |
353 check w.r.t. O_Model.T and Model_Pattern.T. |
344 check w.r.t. O_Model.T and Model_Pattern.T. |
363 val t = Syntax.read_term ctxt ct |
354 val t = Syntax.read_term ctxt ct |
364 handle ERROR msg => error (msg (*^ Position.here pos*)) |
355 handle ERROR msg => error (msg (*^ Position.here pos*)) |
365 (*\------------ replace by ParseC.term_position -----------/*) |
356 (*\------------ replace by ParseC.term_position -----------/*) |
366 (*NONE => Add (i, [], false, m_field, Syn ct)*) |
357 (*NONE => Add (i, [], false, m_field, Syn ct)*) |
367 val (d, ts) = Input_Descript.split t |
358 val (d, ts) = Input_Descript.split t |
368 in |
359 in |
369 if d = TermC.empty then |
360 (*if d = TermC.empty then .. *) |
370 Add (i, [], false, m_field, Mis (unknown_descriptor, hd ts)) |
361 (case find_first (fn (_, (d', _)) => d = d') m_patt of |
371 else |
362 NONE => Add (i, [], true, m_field, (Sup_POS (d,ts), Position.none)) |
372 (case find_first (eq1 d) m_patt of |
|
373 NONE => Add (i, [], true, m_field, Sup (d,ts)) |
|
374 | SOME (f, (_, id)) => |
363 | SOME (f, (_, id)) => |
375 let |
364 case find_first (fn (i, _, _, _, feedb) => d = (descriptor feedb) andalso i <> 0) i_model of |
376 fun eq2 d (i, _, _, _, itm_) = d = (descriptor itm_) andalso i <> 0 |
365 NONE => |
377 in |
366 Add (i, [], true, f, (Cor_POS (d, ts), Position.none)) |
378 case find_first (eq2 d) i_model of |
367 | SOME (i', _, _, _, itm_) => |
379 NONE => Add (i, [], true, f,Cor ((d, ts), (id, [Input_Descript.join'''' (d, ts)]))) |
368 if Input_Descript.for_list d then |
380 | SOME (i', _, _, _, itm_) => |
369 let |
381 if Input_Descript.for_list d then |
370 val in_itm = o_model_values itm_ |
382 let |
371 val ts' = union op = ts in_itm |
383 val in_itm = o_model_values itm_ |
372 val i'' = if in_itm = [] then i else i' |
384 val ts' = union op = ts in_itm |
373 in Add (i'', [], true, f, (Cor_POS (d, ts'), Position.none)) end |
385 val i'' = if in_itm = [] then i else i' |
374 else Add (i', [], true, f, (Cor_POS (d, ts), Position.none))) |
386 in Add (i'', [], true, f, Cor ((d, ts'), (id, [Input_Descript.join'''' (d, ts')])))end |
|
387 else Add (i', [], true, f, Cor ((d, ts), (id, [Input_Descript.join'''' (d, ts)]))) |
|
388 end) |
|
389 end |
375 end |
390 (*will come directly from PIDE ----------------------vvvvvvvvvvv*) |
376 (*will come directly from PIDE ----------------------vvvvvvvvvvv*) |
391 | check_single ctxt m_field o_model i_model m_patt (str(*, pos*)) = |
377 | check_single ctxt m_field o_model i_model m_patt (str(*, pos*)) = |
392 let |
378 let |
393 val (t as (descriptor $ _)) = Syntax.read_term ctxt str |
379 val (t as (descriptor $ _)) = Syntax.read_term ctxt str |