src/Pure/Isar/skip_proof.ML
author wenzelm
Wed Nov 28 23:31:47 2001 +0100 (2001-11-28 ago)
changeset 12318 72348ff7d4a0
parent 12244 179f142ffb03
child 14981 e73f8140af78
permissions -rw-r--r--
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm@6888
     1
(*  Title:      Pure/Isar/skip_proof.ML
wenzelm@6888
     2
    ID:         $Id$
wenzelm@6888
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@8807
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@6888
     5
wenzelm@8539
     6
Skipping proofs -- quick_and_dirty mode.
wenzelm@6888
     7
*)
wenzelm@6888
     8
wenzelm@6888
     9
signature SKIP_PROOF =
wenzelm@6888
    10
sig
wenzelm@8539
    11
  val quick_and_dirty: bool ref
wenzelm@11892
    12
  val make_thm: theory -> term -> thm
wenzelm@11892
    13
  val cheat_tac: theory -> tactic
wenzelm@11972
    14
  val prove: theory -> string list -> term list -> term -> (thm list -> tactic) -> thm
wenzelm@12148
    15
  val local_skip_proof: (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12318
    16
    (Proof.context -> thm -> unit) -> bool -> Proof.state -> Proof.state Seq.seq
wenzelm@12318
    17
  val global_skip_proof:
wenzelm@12318
    18
    bool -> Proof.state -> theory * ((string * string) * (string * thm list) list)
wenzelm@6888
    19
  val setup: (theory -> theory) list
wenzelm@6888
    20
end;
wenzelm@6888
    21
wenzelm@6888
    22
structure SkipProof: SKIP_PROOF =
wenzelm@6888
    23
struct
wenzelm@6888
    24
wenzelm@6888
    25
wenzelm@8539
    26
(* quick_and_dirty *)
wenzelm@8539
    27
wenzelm@8539
    28
(*if true then some packages will OMIT SOME PROOFS*)
wenzelm@8539
    29
val quick_and_dirty = ref false;
wenzelm@8539
    30
wenzelm@8539
    31
wenzelm@11892
    32
(* oracle setup *)
wenzelm@6888
    33
wenzelm@6888
    34
val skip_proofN = "skip_proof";
wenzelm@6888
    35
wenzelm@11892
    36
exception SkipProof of term;
wenzelm@6888
    37
wenzelm@11892
    38
fun skip_proof (_, SkipProof t) =
wenzelm@11892
    39
  if ! quick_and_dirty then t
wenzelm@12318
    40
  else error "Proof may be skipped in quick_and_dirty mode only!";
wenzelm@6888
    41
wenzelm@11892
    42
val setup = [Theory.add_oracle (skip_proofN, skip_proof)];
wenzelm@6888
    43
wenzelm@11892
    44
wenzelm@11972
    45
(* basic cheating *)
wenzelm@11892
    46
wenzelm@11892
    47
fun make_thm thy t =
wenzelm@11892
    48
  (*dynamic scoping of the oracle, cannot even qualify the name due to Pure/CPure!*)
wenzelm@11892
    49
  Thm.invoke_oracle thy skip_proofN (Theory.sign_of thy, SkipProof t);
wenzelm@11892
    50
wenzelm@8539
    51
fun cheat_tac thy st =
wenzelm@11892
    52
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
wenzelm@6888
    53
wenzelm@11972
    54
fun prove thy xs asms prop tac =
wenzelm@11972
    55
  Tactic.prove (Theory.sign_of thy) xs asms prop
wenzelm@11972
    56
    (if ! quick_and_dirty then (K (cheat_tac thy)) else tac);
wenzelm@11972
    57
wenzelm@6888
    58
wenzelm@8539
    59
(* "sorry" proof command *)
wenzelm@8539
    60
wenzelm@12318
    61
fun cheating int ctxt = Method.METHOD (K (setmp quick_and_dirty (int orelse ! quick_and_dirty)
wenzelm@12318
    62
    (cheat_tac (ProofContext.theory_of ctxt))));
wenzelm@8539
    63
wenzelm@12318
    64
fun local_skip_proof x int = Method.local_terminal_proof (Method.Basic (cheating int), None) x;
wenzelm@12318
    65
fun global_skip_proof int = Method.global_terminal_proof (Method.Basic (cheating int), None);
wenzelm@8539
    66
wenzelm@6888
    67
end;
wenzelm@8539
    68
wenzelm@8539
    69
wenzelm@8539
    70
val quick_and_dirty = SkipProof.quick_and_dirty;