src/Pure/Isar/skip_proof.ML
author wenzelm
Fri Dec 12 12:14:02 2008 +0100 (2008-12-12 ago)
changeset 29088 95a239a5e055
parent 28552 f8719bcc5006
child 29435 a5f84ac14609
permissions -rw-r--r--
future proofs: more robust check via Future.enabled;
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@29088
    37
  (if Future.enabled () then Goal.prove_future else Goal.prove) ctxt xs asms prop
wenzelm@28365
    38
    (fn args => fn st =>
wenzelm@28365
    39
      if ! quick_and_dirty
wenzelm@28365
    40
      then setmp quick_and_dirty true (cheat_tac (ProofContext.theory_of ctxt)) st
wenzelm@28365
    41
      else tac args st);
wenzelm@11972
    42
berghofe@26530
    43
fun prove_global thy xs asms prop tac =
wenzelm@26711
    44
  Drule.standard (prove (ProofContext.init thy) xs asms prop tac);
berghofe@26530
    45
wenzelm@6888
    46
end;