src/Pure/Isar/skip_proof.ML
author wenzelm
Thu Jul 14 19:28:24 2005 +0200 (2005-07-14 ago)
changeset 16842 5979c46853d1
parent 15831 aa58e4ec3a1f
child 17114 8638a0a0a668
permissions -rw-r--r--
tuned;
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@8539
    10
  val quick_and_dirty: bool ref
wenzelm@11892
    11
  val make_thm: theory -> term -> thm
wenzelm@11892
    12
  val cheat_tac: theory -> tactic
wenzelm@11972
    13
  val prove: theory -> string list -> term list -> term -> (thm list -> tactic) -> thm
wenzelm@12148
    14
  val local_skip_proof: (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12318
    15
    (Proof.context -> thm -> unit) -> bool -> Proof.state -> Proof.state Seq.seq
wenzelm@12318
    16
  val global_skip_proof:
wenzelm@12318
    17
    bool -> Proof.state -> theory * ((string * string) * (string * thm list) list)
wenzelm@6888
    18
end;
wenzelm@6888
    19
wenzelm@6888
    20
structure SkipProof: SKIP_PROOF =
wenzelm@6888
    21
struct
wenzelm@6888
    22
wenzelm@6888
    23
wenzelm@8539
    24
(* quick_and_dirty *)
wenzelm@8539
    25
wenzelm@8539
    26
(*if true then some packages will OMIT SOME PROOFS*)
wenzelm@8539
    27
val quick_and_dirty = ref false;
wenzelm@8539
    28
wenzelm@8539
    29
wenzelm@11892
    30
(* oracle setup *)
wenzelm@6888
    31
wenzelm@11892
    32
exception SkipProof of term;
wenzelm@6888
    33
wenzelm@11892
    34
fun skip_proof (_, SkipProof t) =
wenzelm@11892
    35
  if ! quick_and_dirty then t
wenzelm@12318
    36
  else error "Proof may be skipped in quick_and_dirty mode only!";
wenzelm@6888
    37
wenzelm@15831
    38
val _ = Context.add_setup [Theory.add_oracle ("skip_proof", skip_proof)];
wenzelm@6888
    39
wenzelm@11892
    40
wenzelm@11972
    41
(* basic cheating *)
wenzelm@11892
    42
wenzelm@11892
    43
fun make_thm thy t =
wenzelm@16842
    44
  Thm.invoke_oracle_i thy "Pure.skip_proof" (thy, SkipProof t);
wenzelm@11892
    45
wenzelm@8539
    46
fun cheat_tac thy st =
wenzelm@11892
    47
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
wenzelm@6888
    48
wenzelm@11972
    49
fun prove thy xs asms prop tac =
wenzelm@16842
    50
  Tactic.prove thy xs asms prop
wenzelm@11972
    51
    (if ! quick_and_dirty then (K (cheat_tac thy)) else tac);
wenzelm@11972
    52
wenzelm@6888
    53
wenzelm@8539
    54
(* "sorry" proof command *)
wenzelm@8539
    55
wenzelm@12318
    56
fun cheating int ctxt = Method.METHOD (K (setmp quick_and_dirty (int orelse ! quick_and_dirty)
wenzelm@12318
    57
    (cheat_tac (ProofContext.theory_of ctxt))));
wenzelm@8539
    58
skalberg@15531
    59
fun local_skip_proof x int = Method.local_terminal_proof (Method.Basic (cheating int), NONE) x;
skalberg@15531
    60
fun global_skip_proof int = Method.global_terminal_proof (Method.Basic (cheating int), NONE);
wenzelm@8539
    61
wenzelm@6888
    62
end;
wenzelm@8539
    63
wenzelm@8539
    64
wenzelm@8539
    65
val quick_and_dirty = SkipProof.quick_and_dirty;