src/Pure/Isar/isar_syn.ML
changeset 6936 ca17f1b02cde
parent 6904 4125d6b6d8f9
child 6953 b3f6c39aaa2e
equal deleted inserted replaced
6935:a3f3f4128cab 6936:ca17f1b02cde
   243 
   243 
   244 (** proof commands **)
   244 (** proof commands **)
   245 
   245 
   246 (* statements *)
   246 (* statements *)
   247 
   247 
   248 val is_props = P.$$$ "(" |-- P.!!! (Scan.repeat1 (P.$$$ "is" |-- P.prop) --| P.$$$ ")");
   248 fun statement f = (P.opt_thm_name ":" -- P.propp >> P.triple1) -- P.marg_comment >> f;
   249 val propp = P.prop -- Scan.optional is_props [];
       
   250 fun statement f = (P.opt_thm_name ":" -- propp >> P.triple1) -- P.marg_comment >> f;
       
   251 
   249 
   252 val theoremP =
   250 val theoremP =
   253   OuterSyntax.command "theorem" "state theorem" K.thy_goal
   251   OuterSyntax.command "theorem" "state theorem" K.thy_goal
   254     (statement IsarThy.theorem >> (fn f => Toplevel.print o Toplevel.theory_to_proof f));
   252     (statement IsarThy.theorem >> (fn f => Toplevel.print o Toplevel.theory_to_proof f));
   255 
   253 
   278 
   276 
   279 val thenP =
   277 val thenP =
   280   OuterSyntax.command "then" "forward chaining" K.prf_chain
   278   OuterSyntax.command "then" "forward chaining" K.prf_chain
   281     (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.chain)));
   279     (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.chain)));
   282 
   280 
       
   281 val thenceP =
       
   282   OuterSyntax.command "thence" "forward chaining, including full export" K.prf_chain
       
   283     (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.export_chain)));
       
   284 
   283 val fromP =
   285 val fromP =
   284   OuterSyntax.command "from" "forward chaining from given facts" K.prf_chain
   286   OuterSyntax.command "from" "forward chaining from given facts" K.prf_chain
   285     (P.xthms1 -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.from_facts)));
   287     (P.xthms1 -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.from_facts)));
   286 
   288 
   287 val withP =
   289 val withP =
   295 
   297 
   296 (* proof context *)
   298 (* proof context *)
   297 
   299 
   298 val assumeP =
   300 val assumeP =
   299   OuterSyntax.command "assume" "assume propositions" K.prf_asm
   301   OuterSyntax.command "assume" "assume propositions" K.prf_asm
   300     ((P.opt_thm_name ":" -- Scan.repeat1 propp >> P.triple1) -- P.marg_comment
   302     ((P.opt_thm_name ":" -- Scan.repeat1 P.propp >> P.triple1) -- P.marg_comment
   301       >> (Toplevel.print oo (Toplevel.proof o IsarThy.assume)));
   303       >> (Toplevel.print oo (Toplevel.proof o IsarThy.assume)));
   302 
   304 
   303 val presumeP =
   305 val presumeP =
   304   OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm
   306   OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm
   305     ((P.opt_thm_name ":" -- Scan.repeat1 propp >> P.triple1) -- P.marg_comment
   307     ((P.opt_thm_name ":" -- Scan.repeat1 P.propp >> P.triple1) -- P.marg_comment
   306       >> (Toplevel.print oo (Toplevel.proof o IsarThy.presume)));
   308       >> (Toplevel.print oo (Toplevel.proof o IsarThy.presume)));
   307 
   309 
   308 val fixP =
   310 val fixP =
   309   OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm
   311   OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm
   310     (Scan.repeat1 (P.name -- Scan.option (P.$$$ "::" |-- P.typ)) -- P.marg_comment
   312     (Scan.repeat1 (P.name -- Scan.option (P.$$$ "::" |-- P.typ)) -- P.marg_comment
   343   OuterSyntax.command "qed" "conclude (sub-)proof" K.qed_block
   345   OuterSyntax.command "qed" "conclude (sub-)proof" K.qed_block
   344     (Scan.option (P.method -- P.interest) >> IsarThy.qed);
   346     (Scan.option (P.method -- P.interest) >> IsarThy.qed);
   345 
   347 
   346 val terminal_proofP =
   348 val terminal_proofP =
   347   OuterSyntax.command "by" "terminal backward proof" K.qed
   349   OuterSyntax.command "by" "terminal backward proof" K.qed
   348     (P.method -- P.interest >> IsarThy.terminal_proof);
   350     (P.method -- P.interest -- Scan.option (P.method -- P.interest) >> IsarThy.terminal_proof);
   349 
   351 
   350 val immediate_proofP =
   352 val immediate_proofP =
   351   OuterSyntax.command "." "immediate proof" K.qed
   353   OuterSyntax.command "." "immediate proof" K.qed
   352     (Scan.succeed IsarThy.immediate_proof);
   354     (Scan.succeed IsarThy.immediate_proof);
   353 
   355 
   532 (*keep keywords consistent with the parsers, including those in
   534 (*keep keywords consistent with the parsers, including those in
   533   outer_parse.ML, otherwise be prepared for unexpected errors*)
   535   outer_parse.ML, otherwise be prepared for unexpected errors*)
   534 
   536 
   535 val keywords =
   537 val keywords =
   536  ["!", "%", "(", ")", "*", "+", ",", "--", ":", "::", ";", "<", "<=",
   538  ["!", "%", "(", ")", "*", "+", ",", "--", ":", "::", ";", "<", "<=",
   537   "=", "==", "=>", "?", "[", "]", "and", "as", "binder", "files",
   539   "=", "==", "=>", "?", "[", "]", "and", "as", "binder", "concl",
   538   "infixl", "infixr", "is", "output", "{", "|", "}"];
   540   "files", "infixl", "infixr", "is", "output", "{", "|", "}"];
   539 
   541 
   540 val parsers = [
   542 val parsers = [
   541   (*theory structure*)
   543   (*theory structure*)
   542   theoryP, end_excursionP, kill_excursionP, contextP, update_contextP,
   544   theoryP, end_excursionP, kill_excursionP, contextP, update_contextP,
   543   (*theory sections*)
   545   (*theory sections*)
   548   pathP, useP, mlP, setupP, parse_ast_translationP,
   550   pathP, useP, mlP, setupP, parse_ast_translationP,
   549   parse_translationP, print_translationP, typed_print_translationP,
   551   parse_translationP, print_translationP, typed_print_translationP,
   550   print_ast_translationP, token_translationP, oracleP,
   552   print_ast_translationP, token_translationP, oracleP,
   551   (*proof commands*)
   553   (*proof commands*)
   552   theoremP, lemmaP, showP, haveP, thusP, henceP, assumeP, presumeP,
   554   theoremP, lemmaP, showP, haveP, thusP, henceP, assumeP, presumeP,
   553   fixP, letP, thenP, fromP, withP, noteP, beginP, endP, nextP,
   555   fixP, letP, thenP, thenceP, fromP, withP, noteP, beginP, endP,
   554   qed_withP, qedP, terminal_proofP, immediate_proofP, default_proofP,
   556   nextP, qed_withP, qedP, terminal_proofP, immediate_proofP,
   555   skip_proofP, applyP, then_applyP, proofP, alsoP, finallyP, backP,
   557   default_proofP, skip_proofP, applyP, then_applyP, proofP, alsoP,
   556   cannot_undoP, clear_undoP, redoP, undos_proofP,
   558   finallyP, backP, cannot_undoP, clear_undoP, redoP, undos_proofP,
   557   kill_proofP, undoP,
   559   kill_proofP, undoP,
   558   (*diagnostic commands*)
   560   (*diagnostic commands*)
   559   print_commandsP, print_theoryP, print_syntaxP, print_attributesP,
   561   print_commandsP, print_theoryP, print_syntaxP, print_attributesP,
   560   print_methodsP, print_theoremsP, print_bindsP, print_lthmsP,
   562   print_methodsP, print_theoremsP, print_bindsP, print_lthmsP,
   561   print_thmsP, print_propP, print_termP, print_typeP,
   563   print_thmsP, print_propP, print_termP, print_typeP,