author  wenzelm 
Mon, 25 Feb 2002 20:50:42 +0100  
changeset 12940  26c0566adf62 
parent 12926  cd0dd6e0bf5c 
child 12952  2d6156232994 
permissions  rwrr 
5832  1 
(* Title: Pure/Isar/isar_syn.ML 
2 
ID: $Id$ 

3 
Author: Markus Wenzel, TU Muenchen 

8807  4 
License: GPL (GNU GENERAL PUBLIC LICENSE) 
5832  5 

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

9 
signature ISAR_SYN = 

10 
sig 

11 
val keywords: string list 

12 
val parsers: OuterSyntax.parser list 

13 
end; 

14 

15 
structure IsarSyn: ISAR_SYN = 

16 
struct 

17 

6723  18 
structure P = OuterParse and K = OuterSyntax.Keyword; 
5832  19 

20 

21 
(** init and exit **) 

22 

23 
val theoryP = 

6723  24 
OuterSyntax.command "theory" "begin theory" K.thy_begin 
9129  25 
(ThyHeader.args >> (Toplevel.print oo IsarThy.theory)); 
5832  26 

6687  27 
val end_excursionP = 
6723  28 
OuterSyntax.command "end" "end current excursion" K.thy_end 
6687  29 
(Scan.succeed (Toplevel.print o Toplevel.exit)); 
30 

6245  31 
val contextP = 
7102  32 
OuterSyntax.improper_command "context" "switch theory context" K.thy_switch 
6723  33 
(P.name >> (Toplevel.print oo IsarThy.context)); 
6245  34 

5832  35 

36 

7749  37 
(** markup commands **) 
5832  38 

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

9129  42 
val chapterP = OuterSyntax.markup_command IsarOutput.Markup "chapter" "chapter heading" 
12940  43 
K.thy_heading (P.position P.text >> IsarCmd.add_chapter); 
5958  44 

9129  45 
val sectionP = OuterSyntax.markup_command IsarOutput.Markup "section" "section heading" 
12940  46 
K.thy_heading (P.position P.text >> IsarCmd.add_section); 
5958  47 

9129  48 
val subsectionP = OuterSyntax.markup_command IsarOutput.Markup "subsection" "subsection heading" 
12940  49 
K.thy_heading (P.position P.text >> IsarCmd.add_subsection); 
5958  50 

7749  51 
val subsubsectionP = 
9129  52 
OuterSyntax.markup_command IsarOutput.Markup "subsubsection" "subsubsection heading" 
12940  53 
K.thy_heading (P.position P.text >> IsarCmd.add_subsubsection); 
5832  54 

9129  55 
val textP = OuterSyntax.markup_command IsarOutput.MarkupEnv "text" "formal comment (theory)" 
12940  56 
K.thy_decl (P.position P.text >> IsarCmd.add_text); 
7172  57 

9129  58 
val text_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "text_raw" 
59 
"raw document preparation text" K.thy_decl 

12940  60 
(P.position P.text >> IsarCmd.add_text_raw); 
7172  61 

9552  62 
val sectP = OuterSyntax.markup_command IsarOutput.Markup "sect" "formal comment (proof)" 
12940  63 
K.prf_heading (P.position P.text >> IsarCmd.add_sect); 
7172  64 

9129  65 
val subsectP = OuterSyntax.markup_command IsarOutput.Markup "subsect" "formal comment (proof)" 
12940  66 
K.prf_heading (P.position P.text >> IsarCmd.add_subsect); 
7172  67 

9129  68 
val subsubsectP = OuterSyntax.markup_command IsarOutput.Markup "subsubsect" 
9552  69 
"formal comment (proof)" K.prf_heading 
12940  70 
(P.position P.text >> IsarCmd.add_subsubsect); 
7172  71 

9129  72 
val txtP = OuterSyntax.markup_command IsarOutput.MarkupEnv "txt" "formal comment (proof)" 
12940  73 
K.prf_decl (P.position P.text >> IsarCmd.add_txt); 
7172  74 

9129  75 
val txt_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "txt_raw" 
76 
"raw document preparation text (proof)" K.prf_decl 

12940  77 
(P.position P.text >> IsarCmd.add_txt_raw); 
7775  78 

5832  79 

6886  80 

81 
(** theory sections **) 

82 

5832  83 
(* classes and sorts *) 
84 

85 
val classesP = 

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

87 
(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

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

90 
val classrelP = 

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

92 
(P.xname  ((P.$$$ "\\<subseteq>"  P.$$$ "<")  P.!!! P.xname) 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

93 
>> (Toplevel.theory o Theory.add_classrel o single)); 
5832  94 

95 
val defaultsortP = 

6723  96 
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

97 
(P.sort >> (Toplevel.theory o Theory.add_defsort)); 
5832  98 

99 

100 
(* types *) 

101 

102 
val typedeclP = 

12624  103 
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

104 
(P.type_args  P.name  P.opt_infix >> (fn ((args, a), mx) => 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

105 
Toplevel.theory (PureThy.add_typedecls [(a, args, mx)]))); 
5832  106 

107 
val typeabbrP = 

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

110 
(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

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

112 
map (fn ((args, a), (T, mx)) => (a, args, T, mx)))); 
5832  113 

114 
val nontermP = 

6370  115 
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

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

118 
val aritiesP = 

6723  119 
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

120 
(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

121 
>> (Toplevel.theory o Theory.add_arities)); 
5832  122 

123 

124 
(* consts and syntax *) 

125 

8227  126 
val judgmentP = 
127 
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

128 
(P.const >> (Toplevel.theory o ObjectLogic.add_judgment)); 
8227  129 

5832  130 
val constsP = 
6723  131 
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

132 
(Scan.repeat1 P.const >> (Toplevel.theory o Theory.add_consts)); 
5832  133 

9731  134 

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

138 
val opt_mode = Scan.optional (P.$$$ "("  P.!!! (mode_spec  P.$$$ ")")) ("", true); 

5832  139 

140 
val syntaxP = 

6723  141 
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

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

144 

145 
(* translations *) 

146 

147 
val trans_pat = 

6723  148 
Scan.optional (P.$$$ "("  P.!!! (P.xname  P.$$$ ")")) "logic"  P.string; 
5832  149 

150 
fun trans_arrow toks = 

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

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

5832  154 

155 
val trans_line = 

6723  156 
trans_pat  P.!!! (trans_arrow  trans_pat) 
5832  157 
>> (fn (left, (arr, right)) => arr (left, right)); 
158 

159 
val translationsP = 

6723  160 
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

161 
(Scan.repeat1 trans_line >> (Toplevel.theory o Theory.add_trrules)); 
5832  162 

163 

164 
(* axioms and definitions *) 

165 

166 
val axiomsP = 

6723  167 
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

168 
(Scan.repeat1 P.spec_name >> (Toplevel.theory o IsarThy.add_axioms)); 
5832  169 

9323  170 
val opt_overloaded = 
171 
Scan.optional (P.$$$ "("  P.!!! ((P.$$$ "overloaded" >> K true)  P.$$$ ")")) false; 

172 

5832  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 

177 
val constdefsP = 

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

179 
(Scan.repeat1 (P.const  P.term) >> (Toplevel.theory o IsarThy.add_constdefs)); 
5832  180 

181 

5914  182 
(* theorems *) 
183 

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

184 
val name_facts = P.and_list1 (P.opt_thm_name "="  P.xthms1); 
5914  185 

12940  186 
fun theorems kind = P.locale_target  name_facts 
12712  187 
>> uncurry (#1 ooo IsarThy.smart_theorems kind); 
188 

5914  189 
val theoremsP = 
6723  190 
OuterSyntax.command "theorems" "define theorems" K.thy_decl 
12712  191 
(theorems Drule.theoremK >> Toplevel.theory); 
5914  192 

193 
val lemmasP = 

6723  194 
OuterSyntax.command "lemmas" "define lemmas" K.thy_decl 
12712  195 
(theorems Drule.lemmaK >> Toplevel.theory); 
5914  196 

9589  197 
val declareP = 
9776  198 
OuterSyntax.command "declare" "declare theorems (improper)" K.thy_script 
12940  199 
(P.locale_target  P.xthms1 >> (Toplevel.theory o uncurry IsarThy.declare_theorems)); 
9589  200 

5914  201 

5832  202 
(* name space entry path *) 
203 

204 
val globalP = 

6723  205 
OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

206 
(Scan.succeed (Toplevel.theory PureThy.global_path)); 
5832  207 

208 
val localP = 

6723  209 
OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

210 
(Scan.succeed (Toplevel.theory PureThy.local_path)); 
8723  211 

212 
val hideP = 

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

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

214 
(P.name  Scan.repeat1 P.xname >> (Toplevel.theory o IsarThy.hide_space)); 
5832  215 

216 

217 
(* use ML text *) 

218 

219 
val useP = 

6723  220 
OuterSyntax.command "use" "eval ML text from file" K.diag 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

221 
(P.name >> (Toplevel.no_timing oo IsarCmd.use)); 
5832  222 

223 
val mlP = 

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

225 
(P.text >> IsarCmd.use_mltext true); 
7891  226 

227 
val ml_commandP = 

228 
OuterSyntax.command "ML_command" "eval ML text" K.diag 

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

229 
(P.text >> (Toplevel.no_timing oo IsarCmd.use_mltext false)); 
7616  230 

231 
val ml_setupP = 

232 
OuterSyntax.command "ML_setup" "eval ML text (may change theory)" K.thy_decl 

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

233 
(P.text >> IsarCmd.use_mltext_theory); 
5832  234 

235 
val setupP = 

7616  236 
OuterSyntax.command "setup" "apply ML theory setup" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

237 
(P.text >> (Toplevel.theory o Context.use_setup)); 
5832  238 

9197  239 
val method_setupP = 
240 
OuterSyntax.command "method_setup" "define proof method in ML" K.thy_decl 

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

241 
(((P.name  P.!!! (P.$$$ "="  P.text  P.text) >> P.triple2)) 
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

242 
>> (Toplevel.theory o IsarThy.method_setup)); 
9197  243 

5832  244 

245 
(* translation functions *) 

246 

247 
val parse_ast_translationP = 

6723  248 
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

249 
(P.text >> (Toplevel.theory o IsarThy.parse_ast_translation)); 
5832  250 

251 
val parse_translationP = 

6723  252 
OuterSyntax.command "parse_translation" "install parse translation functions" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

253 
(P.text >> (Toplevel.theory o IsarThy.parse_translation)); 
5832  254 

255 
val print_translationP = 

6723  256 
OuterSyntax.command "print_translation" "install print translation functions" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

257 
(P.text >> (Toplevel.theory o IsarThy.print_translation)); 
5832  258 

259 
val typed_print_translationP = 

6370  260 
OuterSyntax.command "typed_print_translation" "install typed print translation functions" 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

261 
K.thy_decl (P.text >> (Toplevel.theory o IsarThy.typed_print_translation)); 
5832  262 

263 
val print_ast_translationP = 

6723  264 
OuterSyntax.command "print_ast_translation" "install print ast translation functions" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

265 
(P.text >> (Toplevel.theory o IsarThy.print_ast_translation)); 
5832  266 

267 
val token_translationP = 

6723  268 
OuterSyntax.command "token_translation" "install token translation functions" K.thy_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

269 
(P.text >> (Toplevel.theory o IsarThy.token_translation)); 
5832  270 

271 

272 
(* oracles *) 

273 

274 
val oracleP = 

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

276 
((P.name  P.$$$ "=")  P.text >> (Toplevel.theory o IsarThy.add_oracle)); 
5832  277 

278 

12061  279 
(* locales *) 
280 

12758  281 
val locale_val = 
282 
(P.locale_expr  

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

283 
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

284 
Scan.repeat1 P.locale_element >> pair Locale.empty); 
12061  285 

286 
val localeP = 

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

12768  288 
(P.name  (P.$$$ "="  P.!!! locale_val  Scan.succeed (Locale.empty, [])) 
289 
>> (Toplevel.theory o IsarThy.add_locale o P.triple2)); 

12061  290 

291 

5832  292 

293 
(** proof commands **) 

294 

295 
(* statements *) 

296 

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

297 
val statement = P.and_list1 (P.opt_thm_name ":"  Scan.repeat1 P.propp); 
12940  298 
val long_statement = 
299 
Scan.repeat P.locale_element  (P.$$$ "shows"  statement)  statement >> pair []; 

5832  300 

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

301 
fun gen_theorem k = 
282a92bc5655
multi_theorem: common statement header (covers *all* results);
wenzelm
parents:
12142
diff
changeset

302 
OuterSyntax.command k ("state " ^ k) K.thy_goal 
12940  303 
(Scan.optional (P.thm_name ":"  
304 
Scan.ahead (P.$$$ "("  P.locale_keyword  P.$$$ "shows")) ("", []) 

305 
 P.locale_target  long_statement >> (fn ((x, y), (z, w)) => 

306 
(Toplevel.print o Toplevel.theory_to_proof (IsarThy.smart_multi_theorem k x (y, z) w)))); 

5832  307 

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

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

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

310 
val corollaryP = gen_theorem Drule.corollaryK; 
5832  311 

312 
val showP = 

6723  313 
OuterSyntax.command "show" "state local goal, solving current obligation" K.prf_goal 
12006  314 
(statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.show)); 
5832  315 

316 
val haveP = 

6723  317 
OuterSyntax.command "have" "state local goal" K.prf_goal 
12006  318 
(statement >> ((Toplevel.print oo Toplevel.proof) o IsarThy.have)); 
5832  319 

6501  320 
val thusP = 
6723  321 
OuterSyntax.command "thus" "abbreviates \"then show\"" K.prf_goal 
12006  322 
(statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.thus)); 
6501  323 

324 
val henceP = 

6723  325 
OuterSyntax.command "hence" "abbreviates \"then have\"" K.prf_goal 
12006  326 
(statement >> ((Toplevel.print oo Toplevel.proof) o IsarThy.hence)); 
6501  327 

5832  328 

5914  329 
(* facts *) 
5832  330 

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

331 
val facts = P.and_list1 P.xthms1; 
9197  332 

5832  333 
val thenP = 
6723  334 
OuterSyntax.command "then" "forward chaining" K.prf_chain 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

335 
(Scan.succeed (Toplevel.print o (Toplevel.proof IsarThy.chain))); 
5832  336 

337 
val fromP = 

6723  338 
OuterSyntax.command "from" "forward chaining from given facts" K.prf_chain 
9197  339 
(facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.from_facts))); 
5914  340 

6878  341 
val withP = 
342 
OuterSyntax.command "with" "forward chaining from given and current facts" K.prf_chain 

9197  343 
(facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.with_facts))); 
6878  344 

6773  345 
val noteP = 
6723  346 
OuterSyntax.command "note" "define facts" K.prf_decl 
9197  347 
(name_facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.have_facts))); 
5832  348 

12926  349 
val usingP = 
350 
OuterSyntax.command "using" "augment goal facts" K.prf_decl 

351 
(facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.using_facts))); 

352 

5832  353 

354 
(* proof context *) 

355 

11890  356 
val fixP = 
357 
OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm 

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

358 
(P.and_list1 (Scan.repeat1 P.name  Scan.option (P.$$$ "::"  P.typ)) 
11890  359 
>> (Toplevel.print oo (Toplevel.proof o IsarThy.fix))); 
360 

5832  361 
val assumeP = 
6869  362 
OuterSyntax.command "assume" "assume propositions" K.prf_asm 
12142  363 
(statement >> (Toplevel.print oo (Toplevel.proof o IsarThy.assume))); 
5832  364 

6850  365 
val presumeP = 
6869  366 
OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm 
12142  367 
(statement >> (Toplevel.print oo (Toplevel.proof o IsarThy.presume))); 
6850  368 

6953  369 
val defP = 
370 
OuterSyntax.command "def" "local definition" K.prf_asm 

10688  371 
(P.opt_thm_name ":"  (P.name  ((P.$$$ "\\<equiv>"  P.$$$ "==")  P.!!! P.termp)) 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

372 
>> (Toplevel.print oo (Toplevel.proof o IsarThy.local_def))); 
6953  373 

11890  374 
val obtainP = 
375 
OuterSyntax.command "obtain" "generalized existence" 

376 
K.prf_asm_goal 

377 
(Scan.optional 

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

378 
(P.and_list1 (Scan.repeat1 P.name  Scan.option (P.$$$ "::"  P.typ)) 
12142  379 
 P.$$$ "where") []  statement 
11890  380 
>> (Toplevel.print oo (Toplevel.proof o IsarThy.obtain))); 
5832  381 

382 
val letP = 

6723  383 
OuterSyntax.command "let" "bind text variables" K.prf_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

384 
(P.and_list1 (P.enum1 "and" P.term  (P.$$$ "="  P.term)) 
8615  385 
>> (Toplevel.print oo (Toplevel.proof o IsarThy.let_bind))); 
5832  386 

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

387 
val case_spec = 
12267  388 
(P.$$$ "("  P.!!! (P.xname  Scan.repeat1 P.uname  P.$$$ ")")  
389 
P.xname >> rpair [])  P.opt_attribs >> P.triple1; 

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

390 

8370  391 
val caseP = 
392 
OuterSyntax.command "case" "invoke local context" K.prf_asm 

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

393 
(case_spec >> (Toplevel.print oo (Toplevel.proof o IsarThy.invoke_case))); 
8370  394 

5832  395 

396 
(* proof structure *) 

397 

398 
val beginP = 

9056  399 
OuterSyntax.command "{" "begin explicit proof block" K.prf_open 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

400 
(Scan.succeed (Toplevel.print o (Toplevel.proof IsarThy.begin_block))); 
5832  401 

6687  402 
val endP = 
9056  403 
OuterSyntax.command "}" "end explicit proof block" K.prf_close 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

404 
(Scan.succeed (Toplevel.print o (Toplevel.proof IsarThy.end_block))); 
6687  405 

5832  406 
val nextP = 
6723  407 
OuterSyntax.command "next" "enter next proof block" K.prf_block 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

408 
(Scan.succeed (Toplevel.print o (Toplevel.proof IsarThy.next_block))); 
5832  409 

410 

411 
(* end proof *) 

412 

6404  413 
val qedP = 
6735  414 
OuterSyntax.command "qed" "conclude (sub)proof" K.qed_block 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

415 
(Scan.option P.method >> IsarThy.qed); 
5832  416 

6404  417 
val terminal_proofP = 
6723  418 
OuterSyntax.command "by" "terminal backward proof" K.qed 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

419 
(P.method  Scan.option P.method >> IsarThy.terminal_proof); 
6404  420 

8966  421 
val default_proofP = 
422 
OuterSyntax.command ".." "default proof" K.qed 

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

423 
(Scan.succeed IsarThy.default_proof); 
8966  424 

6404  425 
val immediate_proofP = 
6723  426 
OuterSyntax.command "." "immediate proof" K.qed 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

427 
(Scan.succeed IsarThy.immediate_proof); 
6404  428 

8966  429 
val done_proofP = 
430 
OuterSyntax.command "done" "done proof" K.qed 

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

431 
(Scan.succeed IsarThy.done_proof); 
5832  432 

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

433 
val skip_proofP = 
7172  434 
OuterSyntax.improper_command "sorry" "skip proof (quickanddirty mode only!)" K.qed 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

435 
(Scan.succeed IsarThy.skip_proof); 
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset

436 

8210  437 
val forget_proofP = 
8521  438 
OuterSyntax.command "oops" "forget proof" K.qed_global 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

439 
(Scan.succeed IsarThy.forget_proof); 
8210  440 

5832  441 

442 
(* proof steps *) 

443 

8165  444 
val deferP = 
8681  445 
OuterSyntax.command "defer" "shuffle internal proof state" K.prf_script 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

446 
(Scan.option P.nat >> (Toplevel.print oo (Toplevel.proof o IsarThy.defer))); 
8165  447 

448 
val preferP = 

8681  449 
OuterSyntax.command "prefer" "shuffle internal proof state" K.prf_script 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

450 
(P.nat >> (Toplevel.print oo (Toplevel.proof o IsarThy.prefer))); 
8165  451 

6850  452 
val applyP = 
8681  453 
OuterSyntax.command "apply" "initial refinement step (unstructured)" K.prf_script 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

454 
(P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply))); 
5832  455 

8235  456 
val apply_endP = 
8681  457 
OuterSyntax.command "apply_end" "terminal refinement (unstructured)" K.prf_script 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

458 
(P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply_end))); 
5832  459 

6404  460 
val proofP = 
6723  461 
OuterSyntax.command "proof" "backward proof" K.prf_block 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

462 
(Scan.option P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.proof))); 
5832  463 

464 

6773  465 
(* calculational proof commands *) 
466 

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

468 
Scan.option (P.$$$ "("  P.!!! ((P.xthms1  P.$$$ ")"))); 
6878  469 

6773  470 
val alsoP = 
8562  471 
OuterSyntax.command "also" "combine calculation and current facts" K.prf_decl 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

472 
(calc_args >> IsarThy.also); 
6773  473 

474 
val finallyP = 

8562  475 
OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" K.prf_chain 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

476 
(calc_args >> IsarThy.finally); 
6773  477 

8562  478 
val moreoverP = 
479 
OuterSyntax.command "moreover" "augment calculation by current facts" K.prf_decl 

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

480 
(Scan.succeed IsarThy.moreover); 
8562  481 

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

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

484 
K.prf_chain (Scan.succeed IsarThy.ultimately); 
8588  485 

6773  486 

6742  487 
(* proof navigation *) 
5944  488 

5832  489 
val backP = 
8235  490 
OuterSyntax.command "back" "backtracking of proof command" K.prf_script 
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset

491 
(Scan.optional (P.$$$ "!" >> K true) false >> (Toplevel.print oo IsarCmd.back)); 
5832  492 

493 

6742  494 
(* history *) 
495 

496 
val cannot_undoP = 

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

9010  498 
(P.name >> (Toplevel.no_timing oo IsarCmd.cannot_undo)); 
6742  499 

7733  500 
val clear_undosP = 
501 
OuterSyntax.improper_command "clear_undos" "clear theorylevel undo information" K.control 

9010  502 
(P.nat >> (Toplevel.no_timing oo IsarCmd.clear_undos_theory)); 
6742  503 

504 
val redoP = 

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

9010  506 
(Scan.succeed (Toplevel.no_timing o Toplevel.print o IsarCmd.redo)); 
6742  507 

508 
val undos_proofP = 

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

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

512 
val undoP = 

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

9010  514 
(Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.undo)); 
6742  515 

8500  516 
val killP = 
517 
OuterSyntax.improper_command "kill" "kill current history node" K.control 

9010  518 
(Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.kill)); 
8500  519 

6742  520 

5832  521 

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

523 

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

526 

7124  527 
val pretty_setmarginP = 
528 
OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing" 

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

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

5832  534 

7308  535 
val print_contextP = 
536 
OuterSyntax.improper_command "print_context" "print theory context name" K.diag 

9010  537 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_context)); 
7308  538 

5832  539 
val print_theoryP = 
6723  540 
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag 
9010  541 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_theory)); 
5832  542 

543 
val print_syntaxP = 

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

5881  547 
val print_theoremsP = 
12061  548 
OuterSyntax.improper_command "print_theorems" "print theorems of this theory" K.diag 
9010  549 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_theorems)); 
5881  550 

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

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

554 

555 
val print_localeP = 

556 
OuterSyntax.improper_command "print_locale" "print named locale of this theory" K.diag 

12758  557 
(locale_val >> (Toplevel.no_timing oo IsarCmd.print_locale)); 
12061  558 

5832  559 
val print_attributesP = 
12061  560 
OuterSyntax.improper_command "print_attributes" "print attributes of this theory" K.diag 
9010  561 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes)); 
5832  562 

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

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

566 

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

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

570 

9221  571 
val print_trans_rulesP = 
11666  572 
OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag 
9221  573 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules)); 
574 

5832  575 
val print_methodsP = 
12061  576 
OuterSyntax.improper_command "print_methods" "print methods of this theory" K.diag 
9010  577 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods)); 
5832  578 

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

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

582 

7616  583 
val thms_containingP = 
11017  584 
OuterSyntax.improper_command "thms_containing" "print theorems containing certain constants" 
585 
K.diag (Scan.repeat P.term >> (Toplevel.no_timing oo IsarCmd.print_thms_containing)); 

7616  586 

9454  587 
val thm_depsP = 
588 
OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies" 

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

590 

5832  591 
val print_bindsP = 
6723  592 
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag 
9010  593 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds)); 
5832  594 

595 
val print_lthmsP = 

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

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

9010  601 
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases)); 
8370  602 

5896  603 
val print_thmsP = 
8464  604 
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

605 
(opt_modes  P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_thms)); 
5832  606 

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

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

608 
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

609 
(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

610 

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

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

612 
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

613 
(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

614 

5832  615 
val print_propP = 
6723  616 
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

617 
(opt_modes  P.term >> (Toplevel.no_timing oo IsarCmd.print_prop)); 
5832  618 

619 
val print_termP = 

6723  620 
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

621 
(opt_modes  P.term >> (Toplevel.no_timing oo IsarCmd.print_term)); 
5832  622 

623 
val print_typeP = 

6723  624 
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

625 
(opt_modes  P.typ >> (Toplevel.no_timing oo IsarCmd.print_type)); 
5832  626 

627 

628 

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

630 

631 
val cdP = 

8650  632 
OuterSyntax.improper_command "cd" "change current working directory" K.diag 
9010  633 
(P.name >> (Toplevel.no_timing oo IsarCmd.cd)); 
5832  634 

635 
val pwdP = 

6723  636 
OuterSyntax.improper_command "pwd" "print current working directory" K.diag 
9010  637 
(Scan.succeed (Toplevel.no_timing o IsarCmd.pwd)); 
5832  638 

639 
val use_thyP = 

6723  640 
OuterSyntax.improper_command "use_thy" "use theory file" K.diag 
9010  641 
(P.name >> (Toplevel.no_timing oo IsarCmd.use_thy)); 
5832  642 

6694  643 
val use_thy_onlyP = 
7102  644 
OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML" 
9010  645 
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy_only)); 
6694  646 

6196  647 
val update_thyP = 
6723  648 
OuterSyntax.improper_command "update_thy" "update theory file" K.diag 
9010  649 
(P.name >> (Toplevel.no_timing oo IsarCmd.update_thy)); 
5832  650 

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

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

655 
val touch_thyP = 

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

9010  657 
(P.name >> (Toplevel.no_timing oo IsarCmd.touch_thy)); 
7102  658 

659 
val touch_all_thysP = 

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

9010  661 
(Scan.succeed (Toplevel.no_timing o IsarCmd.touch_all_thys)); 
7102  662 

7908  663 
val touch_child_thysP = 
664 
OuterSyntax.improper_command "touch_child_thys" "outdate child theories" K.diag 

9010  665 
(P.name >> (Toplevel.no_timing oo IsarCmd.touch_child_thys)); 
7908  666 

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

9010  669 
(P.name >> (Toplevel.no_timing oo IsarCmd.remove_thy)); 
7102  670 

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

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

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

677 

5832  678 
val prP = 
8886  679 
OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag 
9731  680 
(opt_modes  opt_limits >> (Toplevel.no_timing oo IsarCmd.pr)); 
7199  681 

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

9010  684 
(Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr)); 
5832  685 

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

9010  688 
(Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr)); 
7222  689 

5832  690 
val commitP = 
6723  691 
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag 
9010  692 
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.use_commit)); 
5832  693 

694 
val quitP = 

6723  695 
OuterSyntax.improper_command "quit" "quit Isabelle" K.control 
9010  696 
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit)); 
5832  697 

698 
val exitP = 

6723  699 
OuterSyntax.improper_command "exit" "exit Isar loop" K.control 
9010  700 
(Scan.succeed (Toplevel.no_timing o IsarCmd.exit)); 
5832  701 

7102  702 
val init_toplevelP = 
703 
OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control 

9010  704 
(Scan.succeed (Toplevel.no_timing o IsarCmd.init_toplevel)); 
5991  705 

7462  706 
val welcomeP = 
8678  707 
OuterSyntax.improper_command "welcome" "print welcome message" K.diag 
9010  708 
(Scan.succeed (Toplevel.no_timing o IsarCmd.welcome)); 
7462  709 

5832  710 

711 

712 
(** the Pure outer syntax **) 

713 

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

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

716 

717 
val keywords = 

7415  718 
["!", "!!", "%", "%%", "(", ")", "+", ",", "", ":", "::", ";", "<", 
12044  719 
"<=", "=", "==", "=>", "?", "[", "]", "and", "assumes", "binder", 
720 
"concl", "defines", "files", "fixes", "in", "infix", "infixl", 

12940  721 
"infixr", "is", "notes", "output", "overloaded", "shows", 
722 
"structure", "uses", "where", "", "\\<equiv>", 

723 
"\\<leftharpoondown>", "\\<rightharpoonup>", 

724 
"\\<rightleftharpoons>", "\\<subseteq>"]; 

5832  725 

726 
val parsers = [ 

727 
(*theory structure*) 

8500  728 
theoryP, end_excursionP, contextP, 
7775  729 
(*markup commands*) 
7733  730 
headerP, chapterP, sectionP, subsectionP, subsubsectionP, textP, 
7862  731 
text_rawP, sectP, subsectP, subsubsectP, txtP, txt_rawP, 
5832  732 
(*theory sections*) 
7172  733 
classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP, 
8227  734 
aritiesP, judgmentP, constsP, syntaxP, translationsP, axiomsP, 
9589  735 
defsP, constdefsP, theoremsP, lemmasP, declareP, globalP, localP, 
736 
hideP, useP, mlP, ml_commandP, ml_setupP, setupP, method_setupP, 

9197  737 
parse_ast_translationP, parse_translationP, print_translationP, 
738 
typed_print_translationP, print_ast_translationP, 

12061  739 
token_translationP, oracleP, localeP, 
5832  740 
(*proof commands*) 
11890  741 
theoremP, lemmaP, corollaryP, showP, haveP, thusP, henceP, fixP, 
742 
assumeP, presumeP, defP, obtainP, letP, caseP, thenP, fromP, withP, 

12926  743 
noteP, usingP, beginP, endP, nextP, qedP, terminal_proofP, 
744 
default_proofP, immediate_proofP, done_proofP, skip_proofP, 

745 
forget_proofP, deferP, preferP, applyP, apply_endP, proofP, alsoP, 

746 
finallyP, moreoverP, ultimatelyP, backP, cannot_undoP, clear_undosP, 

747 
redoP, undos_proofP, undoP, killP, 

5832  748 
(*diagnostic commands*) 
7308  749 
pretty_setmarginP, print_commandsP, print_contextP, print_theoryP, 
12061  750 
print_syntaxP, print_theoremsP, print_localesP, print_localeP, 
12383  751 
print_attributesP, print_rulesP, print_induct_rulesP, 
752 
print_trans_rulesP, print_methodsP, print_antiquotationsP, 

753 
thms_containingP, thm_depsP, print_bindsP, print_lthmsP, 

754 
print_casesP, print_thmsP, print_prfsP, print_full_prfsP, 

755 
print_propP, print_termP, print_typeP, 

5832  756 
(*system commands*) 
7102  757 
cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP, 
7931  758 
touch_thyP, touch_all_thysP, touch_child_thysP, remove_thyP, 
759 
kill_thyP, prP, disable_prP, enable_prP, commitP, quitP, exitP, 

760 
init_toplevelP, welcomeP]; 

5832  761 

762 
end; 

763 

764 

6196  765 
(*install the Pure outer syntax*) 
5832  766 
OuterSyntax.add_keywords IsarSyn.keywords; 
767 
OuterSyntax.add_parsers IsarSyn.parsers; 