src/Pure/Isar/skip_proof.ML
author wenzelm
Sat Oct 17 15:57:51 2009 +0200 (2009-10-17 ago)
changeset 32966 5b21661fe618
parent 30288 a32700e45ab3
child 32970 fbd2bb2489a8
permissions -rw-r--r--
indicate CRITICAL nature of various setmp combinators;
wenzelm@6888
     1
(*  Title:      Pure/Isar/skip_proof.ML
wenzelm@6888
     2
    Author:     Markus Wenzel, TU Muenchen
wenzelm@6888
     3
wenzelm@8539
     4
Skipping proofs -- quick_and_dirty mode.
wenzelm@6888
     5
*)
wenzelm@6888
     6
wenzelm@6888
     7
signature SKIP_PROOF =
wenzelm@6888
     8
sig
wenzelm@11892
     9
  val make_thm: theory -> term -> thm
wenzelm@11892
    10
  val cheat_tac: theory -> tactic
wenzelm@20289
    11
  val prove: Proof.context -> string list -> term list -> term ->
wenzelm@20289
    12
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
berghofe@26530
    13
  val prove_global: theory -> string list -> term list -> term ->
wenzelm@26711
    14
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
wenzelm@6888
    15
end;
wenzelm@6888
    16
wenzelm@6888
    17
structure SkipProof: SKIP_PROOF =
wenzelm@6888
    18
struct
wenzelm@6888
    19
wenzelm@11892
    20
(* oracle setup *)
wenzelm@6888
    21
wenzelm@28290
    22
val (_, skip_proof) = Context.>>> (Context.map_theory_result
wenzelm@30288
    23
  (Thm.add_oracle (Binding.name "skip_proof", fn (thy, prop) =>
wenzelm@28290
    24
    if ! quick_and_dirty then Thm.cterm_of thy prop
wenzelm@28290
    25
    else error "Proof may be skipped in quick_and_dirty mode only!")));
wenzelm@6888
    26
wenzelm@11892
    27
wenzelm@11972
    28
(* basic cheating *)
wenzelm@11892
    29
wenzelm@28290
    30
fun make_thm thy prop = skip_proof (thy, prop);
wenzelm@11892
    31
wenzelm@8539
    32
fun cheat_tac thy st =
wenzelm@11892
    33
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
wenzelm@6888
    34
wenzelm@20049
    35
fun prove ctxt xs asms prop tac =
wenzelm@29448
    36
  (if Goal.future_enabled () then Goal.prove_future else Goal.prove) ctxt xs asms prop
wenzelm@28365
    37
    (fn args => fn st =>
wenzelm@28365
    38
      if ! quick_and_dirty
wenzelm@32966
    39
      then setmp_CRITICAL quick_and_dirty true (cheat_tac (ProofContext.theory_of ctxt)) st
wenzelm@28365
    40
      else tac args st);
wenzelm@11972
    41
berghofe@26530
    42
fun prove_global thy xs asms prop tac =
wenzelm@26711
    43
  Drule.standard (prove (ProofContext.init thy) xs asms prop tac);
berghofe@26530
    44
wenzelm@6888
    45
end;