src/Pure/Isar/skip_proof.ML
author wenzelm
Thu Apr 17 22:22:21 2008 +0200 (2008-04-17 ago)
changeset 26711 3a478bfa1650
parent 26530 777f334ff652
child 28290 4cc2b6046258
permissions -rw-r--r--
prove_global: pass context;
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@11892
    23
exception SkipProof of term;
wenzelm@6888
    24
wenzelm@17362
    25
fun skip_proof (_, SkipProof prop) =
wenzelm@17362
    26
  if ! quick_and_dirty then prop
wenzelm@12318
    27
  else error "Proof may be skipped in quick_and_dirty mode only!";
wenzelm@6888
    28
wenzelm@26463
    29
val _ = Context.>> (Context.map_theory
wenzelm@26463
    30
  (Theory.add_oracle ("skip_proof", skip_proof)));
wenzelm@6888
    31
wenzelm@11892
    32
wenzelm@11972
    33
(* basic cheating *)
wenzelm@11892
    34
wenzelm@17362
    35
fun make_thm thy prop =
wenzelm@17362
    36
  Thm.invoke_oracle_i thy "Pure.skip_proof" (thy, SkipProof prop);
wenzelm@11892
    37
wenzelm@8539
    38
fun cheat_tac thy st =
wenzelm@11892
    39
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
wenzelm@6888
    40
wenzelm@20049
    41
fun prove ctxt xs asms prop tac =
wenzelm@24502
    42
  Goal.prove ctxt xs asms prop (fn args => fn st =>
wenzelm@24502
    43
    if ! quick_and_dirty
wenzelm@24502
    44
    then setmp quick_and_dirty true (cheat_tac (ProofContext.theory_of ctxt)) st
wenzelm@24502
    45
    else tac args st);
wenzelm@11972
    46
berghofe@26530
    47
fun prove_global thy xs asms prop tac =
wenzelm@26711
    48
  Drule.standard (prove (ProofContext.init thy) xs asms prop tac);
berghofe@26530
    49
wenzelm@6888
    50
end;