# HG changeset patch # User wenzelm # Date 1390163625 -3600 # Node ID ce34a293438651dd8d618e28f28bec7c04cd88e7 # Parent 660398f1d806c1344b1241661da589649c6a8a2b implicit "cartouche" method (experimental, undocumented); diff -r 660398f1d806 -r ce34a2934386 src/HOL/ex/Cartouche_Examples.thy --- a/src/HOL/ex/Cartouche_Examples.thy Sun Jan 19 21:00:42 2014 +0100 +++ b/src/HOL/ex/Cartouche_Examples.thy Sun Jan 19 21:33:45 2014 +0100 @@ -82,6 +82,9 @@ end; *} + +subsection {* Explicit version: method with cartouche argument *} + method_setup ml_tactic = {* Scan.lift Args.cartouche_source_position >> (fn arg => fn ctxt => SIMPLE_METHOD (ML_Tactic.ml_tactic arg ctxt)) @@ -100,4 +103,22 @@ text {* @{ML "@{lemma \"A \ B \ B \ A\" by (ml_tactic \blast_tac ctxt 1\)}"} *} + +subsection {* Implicit version: method with special name "cartouche" (dynamic!) *} + +method_setup "cartouche" = {* + Scan.lift Args.cartouche_source_position + >> (fn arg => fn ctxt => SIMPLE_METHOD (ML_Tactic.ml_tactic arg ctxt)) +*} + +lemma "A \ B \ B \ A" + apply \rtac @{thm impI} 1\ + apply \etac @{thm conjE} 1\ + apply \rtac @{thm conjI} 1\ + apply \ALLGOALS atac\ + done + +lemma "A \ B \ B \ A" + by (\rtac @{thm impI} 1\, \etac @{thm conjE} 1\, \rtac @{thm conjI} 1\, \atac 1\+) + end diff -r 660398f1d806 -r ce34a2934386 src/Pure/Isar/method.ML --- a/src/Pure/Isar/method.ML Sun Jan 19 21:00:42 2014 +0100 +++ b/src/Pure/Isar/method.ML Sun Jan 19 21:33:45 2014 +0100 @@ -406,6 +406,9 @@ fun meth4 x = (Parse.position (Parse.xname >> rpair []) >> (Source o Args.src) || + (* FIXME implicit "cartouche" method (experimental, undocumented) *) + Scan.ahead Parse.cartouche |-- Parse.not_eof >> (fn tok => + Source (Args.src (("cartouche", [tok]), Token.position_of tok))) || Parse.$$$ "(" |-- Parse.!!! (meth0 --| Parse.$$$ ")")) x and meth3 x = (meth4 --| Parse.$$$ "?" >> Try ||