equal
deleted
inserted
replaced
36 val try_intros_tac: thm list -> thm list -> tactic |
36 val try_intros_tac: thm list -> thm list -> tactic |
37 val rule: Proof.context -> thm list -> method |
37 val rule: Proof.context -> thm list -> method |
38 val erule: Proof.context -> int -> thm list -> method |
38 val erule: Proof.context -> int -> thm list -> method |
39 val drule: Proof.context -> int -> thm list -> method |
39 val drule: Proof.context -> int -> thm list -> method |
40 val frule: Proof.context -> int -> thm list -> method |
40 val frule: Proof.context -> int -> thm list -> method |
41 val set_tactic: (thm list -> tactic) -> Context.generic -> Context.generic |
41 val set_tactic: (morphism -> thm list -> tactic) -> Context.generic -> Context.generic |
42 val tactic: Symbol_Pos.source -> Proof.context -> method |
|
43 val raw_tactic: Symbol_Pos.source -> Proof.context -> method |
|
44 type combinator_info |
42 type combinator_info |
45 val no_combinator_info: combinator_info |
43 val no_combinator_info: combinator_info |
46 datatype combinator = Then | Orelse | Try | Repeat1 | Select_Goals of int |
44 datatype combinator = Then | Orelse | Try | Repeat1 | Select_Goals of int |
47 datatype text = |
45 datatype text = |
48 Source of Token.src | |
46 Source of Token.src | |
254 |
252 |
255 structure Data = Generic_Data |
253 structure Data = Generic_Data |
256 ( |
254 ( |
257 type T = |
255 type T = |
258 ((Token.src -> Proof.context -> method) * string) Name_Space.table * (*methods*) |
256 ((Token.src -> Proof.context -> method) * string) Name_Space.table * (*methods*) |
259 (thm list -> tactic) option; (*ML tactic*) |
257 (morphism -> thm list -> tactic) option; (*ML tactic*) |
260 val empty : T = (Name_Space.empty_table "method", NONE); |
258 val empty : T = (Name_Space.empty_table "method", NONE); |
261 val extend = I; |
259 val extend = I; |
262 fun merge ((tab, tac), (tab', tac')) : T = |
260 fun merge ((tab, tac), (tab', tac')) : T = |
263 (Name_Space.merge_tables (tab, tab'), merge_options (tac, tac')); |
261 (Name_Space.merge_tables (tab, tab'), merge_options (tac, tac')); |
264 ); |
262 ); |
274 fun the_tactic context = |
272 fun the_tactic context = |
275 (case snd (Data.get context) of |
273 (case snd (Data.get context) of |
276 SOME tac => tac |
274 SOME tac => tac |
277 | NONE => raise Fail "Undefined ML tactic"); |
275 | NONE => raise Fail "Undefined ML tactic"); |
278 |
276 |
279 fun ml_tactic source ctxt = |
277 val parse_tactic = |
280 let |
278 Scan.state :|-- (fn context => |
281 val context = Context.Proof ctxt |
279 Scan.lift (Args.text_declaration (fn source => |
282 val context' = context |> |
280 let |
283 (ML_Context.expression (#pos source) |
281 val context' = context |> |
284 "fun tactic (facts: thm list) : tactic" |
282 ML_Context.expression (#pos source) |
285 "Method.set_tactic tactic" (ML_Lex.read_source false source)); |
283 "fun tactic (morphism: morphism) (facts: thm list) : tactic" |
286 in Context.setmp_thread_data (SOME context) (the_tactic context') end; |
284 "Method.set_tactic tactic" (ML_Lex.read_source false source); |
287 |
285 val tac = the_tactic context'; |
288 fun tactic source ctxt = METHOD (ml_tactic source ctxt); |
286 in |
289 fun raw_tactic source ctxt = NO_CASES o ml_tactic source ctxt; |
287 fn phi => |
|
288 set_tactic (fn _ => Context.setmp_thread_data (SOME context) (tac phi)) |
|
289 end)) >> (fn decl => Morphism.form (the_tactic (Morphism.form decl context)))); |
290 |
290 |
291 |
291 |
292 (* method text *) |
292 (* method text *) |
293 |
293 |
294 datatype combinator_info = Combinator_Info of {keywords: Position.T list}; |
294 datatype combinator_info = Combinator_Info of {keywords: Position.T list}; |
576 (fn (quant, xs) => K (SIMPLE_METHOD'' quant (rename_tac xs)))) |
576 (fn (quant, xs) => K (SIMPLE_METHOD'' quant (rename_tac xs)))) |
577 "rename parameters of goal" #> |
577 "rename parameters of goal" #> |
578 setup @{binding rotate_tac} (Args.goal_spec -- Scan.lift (Scan.optional Parse.int 1) >> |
578 setup @{binding rotate_tac} (Args.goal_spec -- Scan.lift (Scan.optional Parse.int 1) >> |
579 (fn (quant, i) => K (SIMPLE_METHOD'' quant (rotate_tac i)))) |
579 (fn (quant, i) => K (SIMPLE_METHOD'' quant (rotate_tac i)))) |
580 "rotate assumptions of goal" #> |
580 "rotate assumptions of goal" #> |
581 setup @{binding tactic} (Scan.lift Args.text_source_position >> tactic) |
581 setup @{binding tactic} (parse_tactic >> (K o METHOD)) |
582 "ML tactic as proof method" #> |
582 "ML tactic as proof method" #> |
583 setup @{binding raw_tactic} (Scan.lift Args.text_source_position >> raw_tactic) |
583 setup @{binding raw_tactic} (parse_tactic >> (fn tac => fn _ => NO_CASES o tac)) |
584 "ML tactic as raw proof method"); |
584 "ML tactic as raw proof method"); |
585 |
585 |
586 |
586 |
587 (*final declarations of this structure!*) |
587 (*final declarations of this structure!*) |
588 val unfold = unfold_meth; |
588 val unfold = unfold_meth; |