author  wenzelm 
Tue, 18 Oct 2005 17:59:33 +0200  
changeset 17900  5f44c71c4ca4 
parent 17854  44b6dde80bf4 
child 18136  51385f358b53 
permissions  rwrr 
5832  1 
(* Title: Pure/Isar/isar_syn.ML 
2 
ID: $Id$ 

3 
Author: Markus Wenzel, TU Muenchen 

4 

6353  5 
Isar/Pure outer syntax. 
5832  6 
*) 
7 

17353  8 
structure IsarSyn: sig end = 
5832  9 
struct 
10 

17068  11 
structure P = OuterParse and K = OuterKeyword; 
5832  12 

13 

14 
(** init and exit **) 

15 

16 
val theoryP = 

17068  17 
OuterSyntax.command "theory" "begin theory" (K.tag_theory K.thy_begin) 
9129  18 
(ThyHeader.args >> (Toplevel.print oo IsarThy.theory)); 
5832  19 

6687  20 
val end_excursionP = 
17068  21 
OuterSyntax.command "end" "end current excursion" (K.tag_theory K.thy_end) 
6687  22 
(Scan.succeed (Toplevel.print o Toplevel.exit)); 
23 

6245  24 
val contextP = 
17068  25 
OuterSyntax.improper_command "context" "switch theory context" (K.tag_theory K.thy_switch) 
6723  26 
(P.name >> (Toplevel.print oo IsarThy.context)); 
6245  27 

5832  28 

29 

7749  30 
(** markup commands **) 
5832  31 

9129  32 
val headerP = OuterSyntax.markup_command IsarOutput.Markup "header" "theory header" K.diag 
12940  33 
(P.position P.text >> IsarCmd.add_header); 
6353  34 

9129  35 
val chapterP = OuterSyntax.markup_command IsarOutput.Markup "chapter" "chapter heading" 
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

36 
K.thy_heading (P.opt_locale_target  P.position P.text >> IsarCmd.add_chapter); 
5958  37 

9129  38 
val sectionP = OuterSyntax.markup_command IsarOutput.Markup "section" "section heading" 
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

39 
K.thy_heading (P.opt_locale_target  P.position P.text >> IsarCmd.add_section); 
5958  40 

9129  41 
val subsectionP = OuterSyntax.markup_command IsarOutput.Markup "subsection" "subsection heading" 
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

42 
K.thy_heading (P.opt_locale_target  P.position P.text >> IsarCmd.add_subsection); 
5958  43 

7749  44 
val subsubsectionP = 
9129  45 
OuterSyntax.markup_command IsarOutput.Markup "subsubsection" "subsubsection heading" 
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

46 
K.thy_heading (P.opt_locale_target  P.position P.text >> IsarCmd.add_subsubsection); 
5832  47 

9129  48 
val textP = OuterSyntax.markup_command IsarOutput.MarkupEnv "text" "formal comment (theory)" 
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

49 
K.thy_decl (P.opt_locale_target  P.position P.text >> IsarCmd.add_text); 
7172  50 

9129  51 
val text_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "text_raw" 
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

52 
"raw document preparation text" 
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset

53 
K.thy_decl (P.position P.text >> IsarCmd.add_text_raw); 
7172  54 

9552  55 
val sectP = OuterSyntax.markup_command IsarOutput.Markup "sect" "formal comment (proof)" 
17068  56 
(K.tag_proof K.prf_heading) (P.position P.text >> IsarCmd.add_sect); 
7172  57 

9129  58 
val subsectP = OuterSyntax.markup_command IsarOutput.Markup "subsect" "formal comment (proof)" 
17068  59 
(K.tag_proof K.prf_heading) (P.position P.text >> IsarCmd.add_subsect); 
7172  60 

9129  61 
val subsubsectP = OuterSyntax.markup_command IsarOutput.Markup "subsubsect" 
17068  62 
"formal comment (proof)" (K.tag_proof K.prf_heading) 
12940  63 
(P.position P.text >> IsarCmd.add_subsubsect); 
7172  64 

9129  65 
val txtP = OuterSyntax.markup_command IsarOutput.MarkupEnv "txt" "formal comment (proof)" 
17068  66 
(K.tag_proof K.prf_decl) (P.position P.text >> IsarCmd.add_txt); 
7172  67 

9129  68 
val txt_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "txt_raw" 
17068  69 
"raw document preparation text (proof)" (K.tag_proof K.prf_decl) 
12940  70 
(P.position P.text >> IsarCmd.add_txt_raw); 
7775  71 

5832  72 

6886  73 

74 
(** theory sections **) 

75 

5832  76 
(* classes and sorts *) 
77 

78 
val classesP = 

6723  79 
OuterSyntax.command "classes" "declare type classes" K.thy_decl 
11101
014e7b5c77ba
support \<subseteq> syntax in classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset

80 
(Scan.repeat1 (P.name  Scan.optional ((P.$$$ "\\<subseteq>"  P.$$$ "<")  
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

81 
P.!!! (P.list1 P.xname)) []) >> (Toplevel.theory o Theory.add_classes)); 
5832  82 

83 
val classrelP = 

6723  84 
OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl 
14779  85 
(P.and_list1 (P.xname  ((P.$$$ "\\<subseteq>"  P.$$$ "<")  P.!!! P.xname)) 
86 
>> (Toplevel.theory o Theory.add_classrel)); 

5832  87 

88 
val defaultsortP = 

6723  89 
OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

90 
(P.sort >> (Toplevel.theory o Theory.add_defsort)); 
5832  91 

92 

93 
(* types *) 

94 

95 
val typedeclP = 

12624  96 
OuterSyntax.command "typedecl" "type declaration" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

97 
(P.type_args  P.name  P.opt_infix >> (fn ((args, a), mx) => 
16447  98 
Toplevel.theory (Theory.add_typedecls [(a, args, mx)]))); 
5832  99 

100 
val typeabbrP = 

6723  101 
OuterSyntax.command "types" "declare type abbreviations" K.thy_decl 
6727  102 
(Scan.repeat1 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

103 
(P.type_args  P.name  (P.$$$ "="  P.!!! (P.typ  P.opt_infix'))) 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

104 
>> (Toplevel.theory o Theory.add_tyabbrs o 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

105 
map (fn ((args, a), (T, mx)) => (a, args, T, mx)))); 
5832  106 

107 
val nontermP = 

6370  108 
OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols" 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

109 
K.thy_decl (Scan.repeat1 P.name >> (Toplevel.theory o Theory.add_nonterminals)); 
5832  110 

111 
val aritiesP = 

6723  112 
OuterSyntax.command "arities" "state type arities (axiomatic!)" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

113 
(Scan.repeat1 (P.xname  (P.$$$ "::"  P.!!! P.arity) >> P.triple2) 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

114 
>> (Toplevel.theory o Theory.add_arities)); 
5832  115 

116 

117 
(* consts and syntax *) 

118 

8227  119 
val judgmentP = 
120 
OuterSyntax.command "judgment" "declare objectlogic judgment" K.thy_decl 

12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

121 
(P.const >> (Toplevel.theory o ObjectLogic.add_judgment)); 
8227  122 

5832  123 
val constsP = 
6723  124 
OuterSyntax.command "consts" "declare constants" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

125 
(Scan.repeat1 P.const >> (Toplevel.theory o Theory.add_consts)); 
5832  126 

14642  127 
val opt_overloaded = P.opt_keyword "overloaded"; 
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset

128 

0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset

129 
val finalconstsP = 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset

130 
OuterSyntax.command "finalconsts" "declare constants as final" K.thy_decl 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset

131 
(opt_overloaded  Scan.repeat1 P.term >> (uncurry (Toplevel.theory oo Theory.add_finals))); 
9731  132 

12142  133 
val mode_spec = 
9731  134 
(P.$$$ "output" >> K ("", false))  P.name  Scan.optional (P.$$$ "output" >> K false) true; 
135 

14900  136 
val opt_mode = 
137 
Scan.optional (P.$$$ "("  P.!!! (mode_spec  P.$$$ ")")) Syntax.default_mode; 

5832  138 

139 
val syntaxP = 

6723  140 
OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

141 
(opt_mode  Scan.repeat1 P.const >> (Toplevel.theory o uncurry Theory.add_modesyntax)); 
5832  142 

15748  143 
val no_syntaxP = 
144 
OuterSyntax.command "no_syntax" "delete syntax declarations" K.thy_decl 

145 
(opt_mode  Scan.repeat1 P.const >> (Toplevel.theory o uncurry Theory.del_modesyntax)); 

146 

5832  147 

148 
(* translations *) 

149 

150 
val trans_pat = 

6723  151 
Scan.optional (P.$$$ "("  P.!!! (P.xname  P.$$$ ")")) "logic"  P.string; 
5832  152 

153 
fun trans_arrow toks = 

10688  154 
((P.$$$ "\\<rightharpoonup>"  P.$$$ "=>") >> K Syntax.ParseRule  
155 
(P.$$$ "\\<leftharpoondown>"  P.$$$ "<=") >> K Syntax.PrintRule  

156 
(P.$$$ "\\<rightleftharpoons>"  P.$$$ "==") >> K Syntax.ParsePrintRule) toks; 

5832  157 

158 
val trans_line = 

6723  159 
trans_pat  P.!!! (trans_arrow  trans_pat) 
5832  160 
>> (fn (left, (arr, right)) => arr (left, right)); 
161 

162 
val translationsP = 

6723  163 
OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

164 
(Scan.repeat1 trans_line >> (Toplevel.theory o Theory.add_trrules)); 
5832  165 

166 

167 
(* axioms and definitions *) 

168 

169 
val axiomsP = 

6723  170 
OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

171 
(Scan.repeat1 P.spec_name >> (Toplevel.theory o IsarThy.add_axioms)); 
5832  172 

173 
val defsP = 

6723  174 
OuterSyntax.command "defs" "define constants" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

175 
(opt_overloaded  Scan.repeat1 P.spec_name >> (Toplevel.theory o IsarThy.add_defs)); 
6370  176 

14642  177 

178 
(* constant definitions *) 

179 

180 
val vars = P.and_list1 (Scan.repeat1 P.name  Scan.option (P.$$$ "::"  P.typ)); 

181 

182 
val structs = 

183 
Scan.optional ((P.$$$ "("  P.$$$ "structure")  P.!!! (vars  P.$$$ ")")) []; 

184 

185 
val constdecl = 

15531  186 
(P.name  P.$$$ "where") >> (fn x => (x, NONE, Syntax.NoSyn))  
187 
P.name  (P.$$$ "::"  P.!!! P.typ >> SOME)  P.opt_mixfix' >> P.triple1  

188 
P.name  (P.mixfix' >> pair NONE) >> P.triple2; 

14642  189 

190 
val constdef = Scan.option constdecl  (P.opt_thm_name ":"  P.prop); 

191 

6370  192 
val constdefsP = 
14642  193 
OuterSyntax.command "constdefs" "standard constant definitions" K.thy_decl 
194 
(structs  Scan.repeat1 constdef >> (Toplevel.theory o Constdefs.add_constdefs)); 

5832  195 

196 

5914  197 
(* theorems *) 
198 

17353  199 
fun theorems kind = P.opt_locale_target  P.name_facts 
200 
>> (Toplevel.theory_context o uncurry (IsarThy.smart_theorems kind)); 

12712  201 

5914  202 
val theoremsP = 
17353  203 
OuterSyntax.command "theorems" "define theorems" K.thy_decl (theorems Drule.theoremK); 
5914  204 

205 
val lemmasP = 

17353  206 
OuterSyntax.command "lemmas" "define lemmas" K.thy_decl (theorems Drule.lemmaK); 
5914  207 

9589  208 
val declareP = 
9776  209 
OuterSyntax.command "declare" "declare theorems (improper)" K.thy_script 
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset

210 
(P.opt_locale_target  (P.and_list1 P.xthms1 >> List.concat) 
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

211 
>> (Toplevel.theory_context o uncurry IsarThy.declare_theorems)); 
9589  212 

5914  213 

5832  214 
(* name space entry path *) 
215 

216 
val globalP = 

6723  217 
OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl 
16447  218 
(Scan.succeed (Toplevel.theory Sign.root_path)); 
5832  219 

220 
val localP = 

6723  221 
OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl 
16447  222 
(Scan.succeed (Toplevel.theory Sign.local_path)); 
8723  223 

224 
val hideP = 

225 
OuterSyntax.command "hide" "hide names from given name space" K.thy_decl 

17397  226 
((P.opt_keyword "open" >> not)  (P.name  Scan.repeat1 P.xname) >> 
227 
(Toplevel.theory o uncurry Sign.hide_names)); 

5832  228 

229 

230 
(* use ML text *) 

231 

232 
val useP = 

17068  233 
OuterSyntax.command "use" "eval ML text from file" (K.tag_ml K.diag) 
14950  234 
(P.path >> (Toplevel.no_timing oo IsarCmd.use)); 
5832  235 

236 
val mlP = 

17068  237 
OuterSyntax.command "ML" "eval ML text (diagnostic)" (K.tag_ml K.diag) 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

238 
(P.text >> IsarCmd.use_mltext true); 
7891  239 

240 
val ml_commandP = 

17068  241 
OuterSyntax.command "ML_command" "eval ML text" (K.tag_ml K.diag) 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

242 
(P.text >> (Toplevel.no_timing oo IsarCmd.use_mltext false)); 
7616  243 

244 
val ml_setupP = 

17068  245 
OuterSyntax.command "ML_setup" "eval ML text (may change theory)" (K.tag_ml K.thy_decl) 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

246 
(P.text >> IsarCmd.use_mltext_theory); 
5832  247 

248 
val setupP = 

17068  249 
OuterSyntax.command "setup" "apply ML theory setup" (K.tag_ml K.thy_decl) 
17353  250 
(P.text >> (Toplevel.theory o PureThy.generic_setup)); 
5832  251 

9197  252 
val method_setupP = 
17068  253 
OuterSyntax.command "method_setup" "define proof method in ML" (K.tag_ml K.thy_decl) 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

254 
(((P.name  P.!!! (P.$$$ "="  P.text  P.text) >> P.triple2)) 
17353  255 
>> (Toplevel.theory o Method.method_setup)); 
9197  256 

5832  257 

258 
(* translation functions *) 

259 

14642  260 
val trfun = P.opt_keyword "advanced"  P.text; 
261 

5832  262 
val parse_ast_translationP = 
17068  263 
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" 
264 
(K.tag_ml K.thy_decl) 

17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

265 
(trfun >> (Toplevel.theory o Sign.parse_ast_translation)); 
5832  266 

267 
val parse_translationP = 

17068  268 
OuterSyntax.command "parse_translation" "install parse translation functions" 
269 
(K.tag_ml K.thy_decl) 

17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

270 
(trfun >> (Toplevel.theory o Sign.parse_translation)); 
5832  271 

272 
val print_translationP = 

17068  273 
OuterSyntax.command "print_translation" "install print translation functions" 
274 
(K.tag_ml K.thy_decl) 

17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

275 
(trfun >> (Toplevel.theory o Sign.print_translation)); 
5832  276 

277 
val typed_print_translationP = 

6370  278 
OuterSyntax.command "typed_print_translation" "install typed print translation functions" 
17068  279 
(K.tag_ml K.thy_decl) 
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

280 
(trfun >> (Toplevel.theory o Sign.typed_print_translation)); 
5832  281 

282 
val print_ast_translationP = 

17068  283 
OuterSyntax.command "print_ast_translation" "install print ast translation functions" 
284 
(K.tag_ml K.thy_decl) 

17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

285 
(trfun >> (Toplevel.theory o Sign.print_ast_translation)); 
5832  286 

287 
val token_translationP = 

17068  288 
OuterSyntax.command "token_translation" "install token translation functions" 
289 
(K.tag_ml K.thy_decl) 

17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

290 
(P.text >> (Toplevel.theory o Sign.token_translation)); 
5832  291 

292 

293 
(* oracles *) 

294 

295 
val oracleP = 

17068  296 
OuterSyntax.command "oracle" "declare oracle" (K.tag_ml K.thy_decl) 
16849  297 
(P.name  (P.$$$ "("  P.text  P.$$$ ")"  P.$$$ "=") 
17353  298 
 P.text >> (Toplevel.theory o PureThy.add_oracle o P.triple1)); 
5832  299 

300 

12061  301 
(* locales *) 
302 

12758  303 
val locale_val = 
304 
(P.locale_expr  

12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

305 
Scan.optional (P.$$$ "+"  P.!!! (Scan.repeat1 P.locale_element)) []  
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

306 
Scan.repeat1 P.locale_element >> pair Locale.empty); 
12061  307 

308 
val localeP = 

309 
OuterSyntax.command "locale" "define named proof context" K.thy_decl 

14642  310 
((P.opt_keyword "open" >> not)  P.name 
311 
 Scan.optional (P.$$$ "="  P.!!! locale_val) (Locale.empty, []) 

17142
76a5a2cc3171
add_locale_context(_i) now exporting elements (still some refinements to be done)
haftmann
parents:
17139
diff
changeset

312 
>> (Toplevel.theory_context o (fn ((x, y), (z, w)) => Locale.add_locale_context x y z w #> (fn ((_, ctxt), thy) => (thy, ctxt))))); 
12061  313 

16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset

314 
val opt_inst = 
17353  315 
Scan.optional (P.$$$ "["  P.!!! (Scan.repeat1 (P.maybe P.term)  P.$$$ "]")) []; 
15596  316 

15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset

317 
val interpretationP = 
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset

318 
OuterSyntax.command "interpretation" 
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset

319 
"prove and register interpretation of locale expression in theory or locale" K.thy_goal 
17353  320 
(P.xname  (P.$$$ "\\<subseteq>"  P.$$$ "<")  P.!!! P.locale_expr 
321 
>> (Toplevel.print oo (Toplevel.theory_to_proof o Locale.interpretation_in_locale))  

322 
P.opt_thm_name ":"  P.locale_expr  opt_inst >> (fn ((x, y), z) => 

323 
Toplevel.print o Toplevel.theory_to_proof (Locale.interpretation x y z))); 

12061  324 

15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset

325 
val interpretP = 
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset

326 
OuterSyntax.command "interpret" 
17068  327 
"prove and register interpretation of locale expression in proof context" 
328 
(K.tag_proof K.prf_goal) 

17353  329 
(P.opt_thm_name ":"  P.locale_expr  opt_inst >> (fn ((x, y), z) => 
17900  330 
Toplevel.print o Toplevel.proof' (Locale.interpret x y z))); 
15703  331 

332 

5832  333 

334 
(** proof commands **) 

335 

336 
(* statements *) 

337 

12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

338 
val statement = P.and_list1 (P.opt_thm_name ":"  Scan.repeat1 P.propp); 
12956  339 
val general_statement = 
15127  340 
statement >> pair []  Scan.repeat P.locale_elem_or_expr  (P.$$$ "shows"  statement); 
5832  341 

17353  342 
fun gen_theorem kind = 
343 
OuterSyntax.command kind ("state " ^ kind) K.thy_goal 

16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset

344 
(P.opt_locale_target  Scan.optional (P.opt_thm_name ":"  
12956  345 
Scan.ahead (P.locale_keyword  P.$$$ "shows")) ("", [])  
346 
general_statement >> (fn ((x, y), (z, w)) => 

17353  347 
(Toplevel.print o Toplevel.theory_to_proof (Locale.smart_theorem kind x y z w)))); 
5832  348 

12242
282a92bc5655
multi_theorem: common statement header (covers *all* results);
wenzelm
parents:
12142
diff
changeset

349 
val theoremP = gen_theorem Drule.theoremK; 
282a92bc5655
multi_theorem: common statement header (covers *all* results);
wenzelm
parents:
12142
diff
changeset

350 
val lemmaP = gen_theorem Drule.lemmaK; 
282a92bc5655
multi_theorem: common statement header (covers *all* results);
wenzelm
parents:
12142
diff
changeset

351 
val corollaryP = gen_theorem Drule.corollaryK; 
5832  352 

17353  353 
val haveP = 
354 
OuterSyntax.command "have" "state local goal" 

355 
(K.tag_proof K.prf_goal) 

17900  356 
(statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.have)); 
17353  357 

358 
val henceP = 

359 
OuterSyntax.command "hence" "abbreviates \"then have\"" 

360 
(K.tag_proof K.prf_goal) 

17900  361 
(statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.hence)); 
17353  362 

5832  363 
val showP = 
17068  364 
OuterSyntax.command "show" "state local goal, solving current obligation" 
365 
(K.tag_proof K.prf_goal) 

17900  366 
(statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.show)); 
5832  367 

6501  368 
val thusP = 
17068  369 
OuterSyntax.command "thus" "abbreviates \"then show\"" 
370 
(K.tag_proof K.prf_goal) 

17900  371 
(statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.thus)); 
6501  372 

5832  373 

5914  374 
(* facts *) 
5832  375 

12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

376 
val facts = P.and_list1 P.xthms1; 
9197  377 

5832  378 
val thenP = 
17068  379 
OuterSyntax.command "then" "forward chaining" 
380 
(K.tag_proof K.prf_chain) 

17900  381 
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); 
5832  382 

383 
val fromP = 

17068  384 
OuterSyntax.command "from" "forward chaining from given facts" 
385 
(K.tag_proof K.prf_chain) 

17900  386 
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss))); 
5914  387 

6878  388 
val withP = 
17068  389 
OuterSyntax.command "with" "forward chaining from given and current facts" 
390 
(K.tag_proof K.prf_chain) 

17900  391 
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss))); 
6878  392 

6773  393 
val noteP = 
17068  394 
OuterSyntax.command "note" "define facts" 
395 
(K.tag_proof K.prf_decl) 

17900  396 
(P.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss))); 
5832  397 

12926  398 
val usingP = 
17068  399 
OuterSyntax.command "using" "augment goal facts" 
400 
(K.tag_proof K.prf_decl) 

17900  401 
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_thmss))); 
12926  402 

5832  403 

404 
(* proof context *) 

405 

11890  406 
val fixP = 
17068  407 
OuterSyntax.command "fix" "fix local variables (Skolem constants)" 
408 
(K.tag_proof K.prf_asm) 

17900  409 
(vars >> (Toplevel.print oo (Toplevel.proof o Proof.fix))); 
11890  410 

5832  411 
val assumeP = 
17068  412 
OuterSyntax.command "assume" "assume propositions" 
413 
(K.tag_proof K.prf_asm) 

17900  414 
(statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume))); 
5832  415 

6850  416 
val presumeP = 
17068  417 
OuterSyntax.command "presume" "assume propositions, to be established later" 
418 
(K.tag_proof K.prf_asm) 

17900  419 
(statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume))); 
6850  420 

6953  421 
val defP = 
17068  422 
OuterSyntax.command "def" "local definition" 
423 
(K.tag_proof K.prf_asm) 

10688  424 
(P.opt_thm_name ":"  (P.name  ((P.$$$ "\\<equiv>"  P.$$$ "==")  P.!!! P.termp)) 
17900  425 
>> (Toplevel.print oo (Toplevel.proof o uncurry Proof.def))); 
6953  426 

11890  427 
val obtainP = 
428 
OuterSyntax.command "obtain" "generalized existence" 

17068  429 
(K.tag_proof K.prf_asm_goal) 
11890  430 
(Scan.optional 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

431 
(P.and_list1 (Scan.repeat1 P.name  Scan.option (P.$$$ "::"  P.typ)) 
17353  432 
 P.$$$ "where") []  statement 
17900  433 
>> (Toplevel.print oo (Toplevel.proof' o uncurry Obtain.obtain))); 
5832  434 

17854  435 
val guessP = 
436 
OuterSyntax.command "guess" "wild guessing (unstructured)" 

437 
(K.tag_proof K.prf_asm_goal) 

438 
(P.and_list (Scan.repeat1 P.name  Scan.option (P.$$$ "::"  P.typ)) 

17900  439 
>> (Toplevel.print oo (Toplevel.proofs' o Obtain.guess))); 
17854  440 

5832  441 
val letP = 
17068  442 
OuterSyntax.command "let" "bind text variables" 
443 
(K.tag_proof K.prf_decl) 

12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

444 
(P.and_list1 (P.enum1 "and" P.term  (P.$$$ "="  P.term)) 
17900  445 
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind))); 
5832  446 

11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset

447 
val case_spec = 
15703  448 
(P.$$$ "("  P.!!! (P.xname  Scan.repeat1 (P.maybe P.name)  P.$$$ ")")  
12267  449 
P.xname >> rpair [])  P.opt_attribs >> P.triple1; 
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset

450 

8370  451 
val caseP = 
17068  452 
OuterSyntax.command "case" "invoke local context" 
453 
(K.tag_proof K.prf_asm) 

17900  454 
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case))); 
8370  455 

5832  456 

457 
(* proof structure *) 

458 

459 
val beginP = 

17068  460 
OuterSyntax.command "{" "begin explicit proof block" 
461 
(K.tag_proof K.prf_open) 

17900  462 
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); 
5832  463 

6687  464 
val endP = 
17068  465 
OuterSyntax.command "}" "end explicit proof block" 
466 
(K.tag_proof K.prf_close) 

17900  467 
(Scan.succeed (Toplevel.print o Toplevel.proofs Proof.end_block)); 
6687  468 

5832  469 
val nextP = 
17068  470 
OuterSyntax.command "next" "enter next proof block" 
471 
(K.tag_proof K.prf_block) 

17900  472 
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); 
5832  473 

474 

475 
(* end proof *) 

476 

6404  477 
val qedP = 
17068  478 
OuterSyntax.command "qed" "conclude (sub)proof" 
479 
(K.tag_proof K.qed_block) 

17353  480 
(Scan.option P.method >> (Toplevel.print3 oo IsarThy.qed)); 
5832  481 

6404  482 
val terminal_proofP = 
17068  483 
OuterSyntax.command "by" "terminal backward proof" 
484 
(K.tag_proof K.qed) 

17353  485 
(P.method  Scan.option P.method >> (Toplevel.print3 oo IsarThy.terminal_proof)); 
6404  486 

8966  487 
val default_proofP = 
17068  488 
OuterSyntax.command ".." "default proof" 
489 
(K.tag_proof K.qed) 

17353  490 
(Scan.succeed (Toplevel.print3 o IsarThy.default_proof)); 
8966  491 

6404  492 
val immediate_proofP = 
17068  493 
OuterSyntax.command "." "immediate proof" 
494 
(K.tag_proof K.qed) 

17353  495 
(Scan.succeed (Toplevel.print3 o IsarThy.immediate_proof)); 
6404  496 

8966  497 
val done_proofP = 
17068  498 
OuterSyntax.command "done" "done proof" 
499 
(K.tag_proof K.qed) 

17353  500 
(Scan.succeed (Toplevel.print3 o IsarThy.done_proof)); 
5832  501 

6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset

502 
val skip_proofP = 
17068  503 
OuterSyntax.improper_command "sorry" "skip proof (quickanddirty mode only!)" 
504 
(K.tag_proof K.qed) 

17353  505 
(Scan.succeed (Toplevel.print3 o IsarThy.skip_proof)); 
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset

506 

8210  507 
val forget_proofP = 
17068  508 
OuterSyntax.command "oops" "forget proof" 
509 
(K.tag_proof K.qed_global) 

12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

510 
(Scan.succeed IsarThy.forget_proof); 
8210  511 

5832  512 

513 
(* proof steps *) 

514 

8165  515 
val deferP = 
17068  516 
OuterSyntax.command "defer" "shuffle internal proof state" 
517 
(K.tag_proof K.prf_script) 

17900  518 
(Scan.option P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); 
8165  519 

520 
val preferP = 

17068  521 
OuterSyntax.command "prefer" "shuffle internal proof state" 
522 
(K.tag_proof K.prf_script) 

17900  523 
(P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); 
8165  524 

6850  525 
val applyP = 
17068  526 
OuterSyntax.command "apply" "initial refinement step (unstructured)" 
527 
(K.tag_proof K.prf_script) 

17900  528 
(P.method >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); 
5832  529 

8235  530 
val apply_endP = 
17068  531 
OuterSyntax.command "apply_end" "terminal refinement (unstructured)" 
532 
(K.tag_proof K.prf_script) 

17900  533 
(P.method >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); 
5832  534 

6404  535 
val proofP = 
17068  536 
OuterSyntax.command "proof" "backward proof" 
537 
(K.tag_proof K.prf_block) 

16812  538 
(Scan.option P.method >> (fn m => Toplevel.print o 
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset

539 
Toplevel.actual_proof (ProofHistory.applys (Proof.proof m)) o 
15237
250e9be7a09d
Some changes to allow skipping of proof scripts.
berghofe
parents:
15141
diff
changeset

540 
Toplevel.skip_proof (History.apply (fn i => i + 1)))); 
5832  541 

542 

6773  543 
(* calculational proof commands *) 
544 

6878  545 
val calc_args = 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

546 
Scan.option (P.$$$ "("  P.!!! ((P.xthms1  P.$$$ ")"))); 
6878  547 

6773  548 
val alsoP = 
17068  549 
OuterSyntax.command "also" "combine calculation and current facts" 
550 
(K.tag_proof K.prf_decl) 

17900  551 
(calc_args >> (Toplevel.proofs' o Calculation.also)); 
6773  552 

553 
val finallyP = 

17068  554 
OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" 
555 
(K.tag_proof K.prf_chain) 

17900  556 
(calc_args >> (Toplevel.proofs' o Calculation.finally)); 
6773  557 

8562  558 
val moreoverP = 
17068  559 
OuterSyntax.command "moreover" "augment calculation by current facts" 
560 
(K.tag_proof K.prf_decl) 

17900  561 
(Scan.succeed (Toplevel.proof' Calculation.moreover)); 
8562  562 

8588  563 
val ultimatelyP = 
564 
OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result" 

17068  565 
(K.tag_proof K.prf_chain) 
17900  566 
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); 
8588  567 

6773  568 

6742  569 
(* proof navigation *) 
5944  570 

5832  571 
val backP = 
17068  572 
OuterSyntax.command "back" "backtracking of proof command" 
573 
(K.tag_proof K.prf_script) 

574 
(Scan.succeed (Toplevel.print o IsarCmd.back)); 

5832  575 

576 

6742  577 
(* history *) 
578 

579 
val cannot_undoP = 

580 
OuterSyntax.improper_command "cannot_undo" "report 'cannot undo' error message" K.control 

9010  581 
(P.name >> (Toplevel.no_timing oo IsarCmd.cannot_undo)); 
6742  582 

7733  583 
val clear_undosP = 
584 
OuterSyntax.improper_command "clear_undos" "clear theorylevel undo information" K.control 

9010  585 
(P.nat >> (Toplevel.no_timing oo IsarCmd.clear_undos_theory)); 
6742  586 

587 
val redoP = 

588 
OuterSyntax.improper_command "redo" "redo last command" K.control 

9010  589 
(Scan.succeed (Toplevel.no_timing o Toplevel.print o IsarCmd.redo)); 
6742  590 

591 
val undos_proofP = 

592 
OuterSyntax.improper_command "undos_proof" "undo last proof commands" K.control 

9010  593 
(P.nat >> ((Toplevel.no_timing o Toplevel.print) oo IsarCmd.undos_proof)); 
6742  594 

595 
val undoP = 

596 
OuterSyntax.improper_command "undo" "undo last command" K.control 

9010  597 
(Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.undo)); 
6742  598 

8500  599 
val killP = 
600 
OuterSyntax.improper_command "kill" "kill current history node" K.control 

9010  601 
(Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.kill)); 
8500  602 

6742  603 

5832  604 

605 
(** diagnostic commands (for interactive mode only) **) 

606 

8464  607 
val opt_modes = Scan.optional (P.$$$ "("  P.!!! (Scan.repeat1 P.xname  P.$$$ ")")) []; 
608 

609 

7124  610 
val pretty_setmarginP = 
611 
OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing" 

9010  612 
K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin)); 
7124  613 

5832  614 
val print_commandsP = 
9221  615 
OuterSyntax.improper_command "print_commands" "print outer syntax (global)" K.diag 
616 
(Scan.succeed (Toplevel.no_timing o OuterSyntax.print_commands)); 

5832  617 

7308  618 
val print_contextP = 
619 
OuterSyntax.improper_command "print_context" "print theory context name" K.diag 

9010  620 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_context)); 
7308  621 

5832  622 
val print_theoryP = 
6723  623 
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag 
9010  624 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_theory)); 
5832  625 

626 
val print_syntaxP = 

6723  627 
OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)" K.diag 
9010  628 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax)); 
5832  629 

5881  630 
val print_theoremsP = 
17068  631 
OuterSyntax.improper_command "print_theorems" 
632 
"print theorems of local theory or proof context" K.diag 

9010  633 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_theorems)); 
5881  634 

12061  635 
val print_localesP = 
636 
OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag 

637 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_locales)); 

638 

639 
val print_localeP = 

15596  640 
OuterSyntax.improper_command "print_locale" "print locale expression in this theory" K.diag 
17228  641 
(Scan.optional (P.$$$ "!" >> K true) false  locale_val >> (Toplevel.no_timing oo IsarCmd.print_locale)); 
12061  642 

15596  643 
val print_registrationsP = 
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset

644 
OuterSyntax.improper_command "print_interps" 
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16074
diff
changeset

645 
"print interpretations of named locale" K.diag 
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17107
diff
changeset

646 
(Scan.optional (P.$$$ "!" >> K true) false  P.xname >> 
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17107
diff
changeset

647 
(Toplevel.no_timing oo uncurry IsarCmd.print_registrations)); 
15596  648 

5832  649 
val print_attributesP = 
12061  650 
OuterSyntax.improper_command "print_attributes" "print attributes of this theory" K.diag 
9010  651 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes)); 
5832  652 

16027  653 
val print_simpsetP = 
654 
OuterSyntax.improper_command "print_simpset" "print context of Simplifier" K.diag 

655 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_simpset)); 

656 

12383  657 
val print_rulesP = 
658 
OuterSyntax.improper_command "print_rules" "print intro/elim rules" K.diag 

659 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_rules)); 

660 

11666  661 
val print_induct_rulesP = 
662 
OuterSyntax.improper_command "print_induct_rules" "print induction and cases rules" K.diag 

663 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_induct_rules)); 

664 

9221  665 
val print_trans_rulesP = 
11666  666 
OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag 
9221  667 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules)); 
668 

5832  669 
val print_methodsP = 
12061  670 
OuterSyntax.improper_command "print_methods" "print methods of this theory" K.diag 
9010  671 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods)); 
5832  672 

9221  673 
val print_antiquotationsP = 
674 
OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag 

675 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations)); 

676 

9454  677 
val thm_depsP = 
678 
OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies" 

679 
K.diag (P.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps)); 

680 

16027  681 
val criterion = 
682 
P.reserved "name"  P.!!! (P.$$$ ":"  P.xname) >> FindTheorems.Name  

683 
P.reserved "intro" >> K FindTheorems.Intro  

684 
P.reserved "elim" >> K FindTheorems.Elim  

685 
P.reserved "dest" >> K FindTheorems.Dest  

16074  686 
P.reserved "simp"  P.!!! (P.$$$ ":"  P.term) >> FindTheorems.Simp  
16027  687 
P.term >> FindTheorems.Pattern; 
688 

689 
val find_theoremsP = 

17219
515badbfc4d6
renamed 'thms_containing' to 'find_theorems'  keep old version for the time being;
wenzelm
parents:
17142
diff
changeset

690 
OuterSyntax.improper_command "find_theorems" 
515badbfc4d6
renamed 'thms_containing' to 'find_theorems'  keep old version for the time being;
wenzelm
parents:
17142
diff
changeset

691 
"print theorems meeting specified criteria" K.diag 
515badbfc4d6
renamed 'thms_containing' to 'find_theorems'  keep old version for the time being;
wenzelm
parents:
17142
diff
changeset

692 
(Scan.option (P.$$$ "("  P.!!! (P.nat  P.$$$ ")"))  
515badbfc4d6
renamed 'thms_containing' to 'find_theorems'  keep old version for the time being;
wenzelm
parents:
17142
diff
changeset

693 
Scan.repeat (((Scan.option P.minus >> is_none)  criterion)) 
515badbfc4d6
renamed 'thms_containing' to 'find_theorems'  keep old version for the time being;
wenzelm
parents:
17142
diff
changeset

694 
>> (Toplevel.no_timing oo IsarCmd.find_theorems)); 
515badbfc4d6
renamed 'thms_containing' to 'find_theorems'  keep old version for the time being;
wenzelm
parents:
17142
diff
changeset

695 

5832  696 
val print_bindsP = 
6723  697 
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag 
9010  698 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds)); 
5832  699 

700 
val print_lthmsP = 

8370  701 
OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag 
9010  702 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_lthms)); 
5832  703 

8370  704 
val print_casesP = 
705 
OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag 

9010  706 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases)); 
8370  707 

5896  708 
val print_thmsP = 
8464  709 
OuterSyntax.improper_command "thm" "print theorems" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

710 
(opt_modes  P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_thms)); 
5832  711 

11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset

712 
val print_prfsP = 
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset

713 
OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

714 
(opt_modes  Scan.option P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_prfs false)); 
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset

715 

197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset

716 
val print_full_prfsP = 
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset

717 
OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

718 
(opt_modes  Scan.option P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_prfs true)); 
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset

719 

5832  720 
val print_propP = 
6723  721 
OuterSyntax.improper_command "prop" "read and print proposition" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

722 
(opt_modes  P.term >> (Toplevel.no_timing oo IsarCmd.print_prop)); 
5832  723 

724 
val print_termP = 

6723  725 
OuterSyntax.improper_command "term" "read and print term" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

726 
(opt_modes  P.term >> (Toplevel.no_timing oo IsarCmd.print_term)); 
5832  727 

728 
val print_typeP = 

6723  729 
OuterSyntax.improper_command "typ" "read and print type" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

730 
(opt_modes  P.typ >> (Toplevel.no_timing oo IsarCmd.print_type)); 
5832  731 

732 

733 

734 
(** system commands (for interactive mode only) **) 

735 

736 
val cdP = 

8650  737 
OuterSyntax.improper_command "cd" "change current working directory" K.diag 
14950  738 
(P.path >> (Toplevel.no_timing oo IsarCmd.cd)); 
5832  739 

740 
val pwdP = 

6723  741 
OuterSyntax.improper_command "pwd" "print current working directory" K.diag 
9010  742 
(Scan.succeed (Toplevel.no_timing o IsarCmd.pwd)); 
5832  743 

744 
val use_thyP = 

6723  745 
OuterSyntax.improper_command "use_thy" "use theory file" K.diag 
9010  746 
(P.name >> (Toplevel.no_timing oo IsarCmd.use_thy)); 
5832  747 

6694  748 
val use_thy_onlyP = 
7102  749 
OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML" 
9010  750 
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy_only)); 
6694  751 

6196  752 
val update_thyP = 
6723  753 
OuterSyntax.improper_command "update_thy" "update theory file" K.diag 
9010  754 
(P.name >> (Toplevel.no_timing oo IsarCmd.update_thy)); 
5832  755 

7102  756 
val update_thy_onlyP = 
757 
OuterSyntax.improper_command "update_thy_only" "update theory file, ignoring associated ML" 

9010  758 
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.update_thy_only)); 
7102  759 

760 
val touch_thyP = 

761 
OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag 

9010  762 
(P.name >> (Toplevel.no_timing oo IsarCmd.touch_thy)); 
7102  763 

764 
val touch_all_thysP = 

765 
OuterSyntax.improper_command "touch_all_thys" "outdate all nonfinished theories" K.diag 

9010  766 
(Scan.succeed (Toplevel.no_timing o IsarCmd.touch_all_thys)); 
7102  767 

7908  768 
val touch_child_thysP = 
769 
OuterSyntax.improper_command "touch_child_thys" "outdate child theories" K.diag 

9010  770 
(P.name >> (Toplevel.no_timing oo IsarCmd.touch_child_thys)); 
7908  771 

7102  772 
val remove_thyP = 
773 
OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag 

9010  774 
(P.name >> (Toplevel.no_timing oo IsarCmd.remove_thy)); 
7102  775 

7931  776 
val kill_thyP = 
777 
OuterSyntax.improper_command "kill_thy" "kill theory  try to remove from loader database" 

9010  778 
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.kill_thy)); 
7931  779 

14934  780 
val display_draftsP = 
781 
OuterSyntax.improper_command "display_drafts" "display raw source files with symbols" 

14950  782 
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.display_drafts)); 
14934  783 

784 
val print_draftsP = 

785 
OuterSyntax.improper_command "print_drafts" "print raw source files with symbols" 

14950  786 
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.print_drafts)); 
14934  787 

9731  788 
val opt_limits = 
789 
Scan.option P.nat  Scan.option (P.$$$ ","  P.!!! P.nat); 

790 

5832  791 
val prP = 
8886  792 
OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag 
9731  793 
(opt_modes  opt_limits >> (Toplevel.no_timing oo IsarCmd.pr)); 
7199  794 

7222  795 
val disable_prP = 
796 
OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag 

9010  797 
(Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr)); 
5832  798 

7222  799 
val enable_prP = 
800 
OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag 

9010  801 
(Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr)); 
7222  802 

5832  803 
val commitP = 
6723  804 
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag 
9010  805 
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.use_commit)); 
5832  806 

807 
val quitP = 

6723  808 
OuterSyntax.improper_command "quit" "quit Isabelle" K.control 
9010  809 
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit)); 
5832  810 

811 
val exitP = 

6723  812 
OuterSyntax.improper_command "exit" "exit Isar loop" K.control 
9010  813 
(Scan.succeed (Toplevel.no_timing o IsarCmd.exit)); 
5832  814 

7102  815 
val init_toplevelP = 
816 
OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control 

9010  817 
(Scan.succeed (Toplevel.no_timing o IsarCmd.init_toplevel)); 
5991  818 

7462  819 
val welcomeP = 
8678  820 
OuterSyntax.improper_command "welcome" "print welcome message" K.diag 
9010  821 
(Scan.succeed (Toplevel.no_timing o IsarCmd.welcome)); 
7462  822 

5832  823 

824 

825 
(** the Pure outer syntax **) 

826 

827 
(*keep keywords consistent with the parsers, including those in 

828 
outer_parse.ML, otherwise be prepared for unexpected errors*) 

829 

16038  830 
val _ = OuterSyntax.add_keywords 
17068  831 
["!", "!!", "%", "(", ")", "+", ",", "", ":", "::", ";", "<", "<=", 
832 
"=", "==", "=>", "?", "[", "]", "advanced", "and", "assumes", 

16264  833 
"begin", "binder", "concl", "constrains", "defines", "files", 
834 
"fixes", "imports", "in", "includes", "infix", "infixl", "infixr", 

835 
"is", "notes", "open", "output", "overloaded", "shows", "structure", 

836 
"uses", "where", "", "\\<equiv>", "\\<leftharpoondown>", 

837 
"\\<rightharpoonup>", "\\<rightleftharpoons>", "\\<subseteq>"]; 

5832  838 

16038  839 
val _ = OuterSyntax.add_parsers [ 
5832  840 
(*theory structure*) 
8500  841 
theoryP, end_excursionP, contextP, 
7775  842 
(*markup commands*) 
7733  843 
headerP, chapterP, sectionP, subsectionP, subsubsectionP, textP, 
7862  844 
text_rawP, sectP, subsectP, subsubsectP, txtP, txt_rawP, 
5832  845 
(*theory sections*) 
7172  846 
classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP, 
15748  847 
aritiesP, judgmentP, constsP, finalconstsP, syntaxP, no_syntaxP, 
848 
translationsP, axiomsP, defsP, constdefsP, theoremsP, lemmasP, 

849 
declareP, globalP, localP, hideP, useP, mlP, ml_commandP, ml_setupP, 

850 
setupP, method_setupP, parse_ast_translationP, parse_translationP, 

14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset

851 
print_translationP, typed_print_translationP, 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset

852 
print_ast_translationP, token_translationP, oracleP, localeP, 
5832  853 
(*proof commands*) 
17353  854 
theoremP, lemmaP, corollaryP, haveP, henceP, showP, thusP, fixP, 
17854  855 
assumeP, presumeP, defP, obtainP, guessP, letP, caseP, thenP, fromP, 
856 
withP, noteP, usingP, beginP, endP, nextP, qedP, terminal_proofP, 

12926  857 
default_proofP, immediate_proofP, done_proofP, skip_proofP, 
858 
forget_proofP, deferP, preferP, applyP, apply_endP, proofP, alsoP, 

859 
finallyP, moreoverP, ultimatelyP, backP, cannot_undoP, clear_undosP, 

16027  860 
redoP, undos_proofP, undoP, killP, interpretationP, interpretP, 
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset

861 
(*diagnostic commands*) 
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset

862 
pretty_setmarginP, 
16027  863 
print_commandsP, print_contextP, print_theoryP, print_syntaxP, 
864 
print_theoremsP, print_localesP, print_localeP, 

865 
print_registrationsP, print_attributesP, print_simpsetP, 

866 
print_rulesP, print_induct_rulesP, print_trans_rulesP, 

867 
print_methodsP, print_antiquotationsP, thm_depsP, find_theoremsP, 

868 
print_bindsP, print_lthmsP, print_casesP, print_thmsP, print_prfsP, 

869 
print_full_prfsP, print_propP, print_termP, print_typeP, 

5832  870 
(*system commands*) 
7102  871 
cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP, 
7931  872 
touch_thyP, touch_all_thysP, touch_child_thysP, remove_thyP, 
14934  873 
kill_thyP, display_draftsP, print_draftsP, prP, disable_prP, 
874 
enable_prP, commitP, quitP, exitP, init_toplevelP, welcomeP]; 

5832  875 

876 
end; 