src/Pure/Isar/skip_proof.ML
author wenzelm
Sat Jan 10 21:32:30 2009 +0100 (2009-01-10 ago)
changeset 29435 a5f84ac14609
parent 29088 95a239a5e055
child 29448 34b9652b2f45
permissions -rw-r--r--
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm@6888
     1
(*  Title:      Pure/Isar/skip_proof.ML
wenzelm@6888
     2
    ID:         $Id$
wenzelm@6888
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@6888
     4
wenzelm@8539
     5
Skipping proofs -- quick_and_dirty mode.
wenzelm@6888
     6
*)
wenzelm@6888
     7
wenzelm@6888
     8
signature SKIP_PROOF =
wenzelm@6888
     9
sig
wenzelm@11892
    10
  val make_thm: theory -> term -> thm
wenzelm@11892
    11
  val cheat_tac: theory -> tactic
wenzelm@20289
    12
  val prove: Proof.context -> string list -> term list -> term ->
wenzelm@20289
    13
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
berghofe@26530
    14
  val prove_global: theory -> string list -> term list -> term ->
wenzelm@26711
    15
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
wenzelm@6888
    16
end;
wenzelm@6888
    17
wenzelm@6888
    18
structure SkipProof: SKIP_PROOF =
wenzelm@6888
    19
struct
wenzelm@6888
    20
wenzelm@11892
    21
(* oracle setup *)
wenzelm@6888
    22
wenzelm@28290
    23
val (_, skip_proof) = Context.>>> (Context.map_theory_result
wenzelm@28290
    24
  (Thm.add_oracle ("skip_proof", fn (thy, prop) =>
wenzelm@28290
    25
    if ! quick_and_dirty then Thm.cterm_of thy prop
wenzelm@28290
    26
    else error "Proof may be skipped in quick_and_dirty mode only!")));
wenzelm@6888
    27
wenzelm@11892
    28
wenzelm@11972
    29
(* basic cheating *)
wenzelm@11892
    30
wenzelm@28290
    31
fun make_thm thy prop = skip_proof (thy, prop);
wenzelm@11892
    32
wenzelm@8539
    33
fun cheat_tac thy st =
wenzelm@11892
    34
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
wenzelm@6888
    35
wenzelm@20049
    36
fun prove ctxt xs asms prop tac =
wenzelm@29435
    37
  (if Future.enabled () andalso ! Goal.parallel_proofs then Goal.prove_future else Goal.prove)
wenzelm@29435
    38
    ctxt xs asms prop
wenzelm@28365
    39
    (fn args => fn st =>
wenzelm@28365
    40
      if ! quick_and_dirty
wenzelm@28365
    41
      then setmp quick_and_dirty true (cheat_tac (ProofContext.theory_of ctxt)) st
wenzelm@28365
    42
      else tac args st);
wenzelm@11972
    43
berghofe@26530
    44
fun prove_global thy xs asms prop tac =
wenzelm@26711
    45
  Drule.standard (prove (ProofContext.init thy) xs asms prop tac);
berghofe@26530
    46
wenzelm@6888
    47
end;