src/Pure/Isar/skip_proof.ML
author wenzelm
Mon Nov 19 23:37:01 2001 +0100 (2001-11-19 ago)
changeset 12244 179f142ffb03
parent 12148 a57873aec3bf
child 12318 72348ff7d4a0
permissions -rw-r--r--
improved treatment of common result name;
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@12055
    16
    (Proof.context -> thm -> unit) -> Proof.state -> Proof.state Seq.seq
wenzelm@12244
    17
  val global_skip_proof: Proof.state -> theory * ((string * string) * (string * thm list) list)
wenzelm@6888
    18
  val setup: (theory -> theory) list
wenzelm@6888
    19
end;
wenzelm@6888
    20
wenzelm@6888
    21
structure SkipProof: SKIP_PROOF =
wenzelm@6888
    22
struct
wenzelm@6888
    23
wenzelm@6888
    24
wenzelm@8539
    25
(* quick_and_dirty *)
wenzelm@8539
    26
wenzelm@8539
    27
(*if true then some packages will OMIT SOME PROOFS*)
wenzelm@8539
    28
val quick_and_dirty = ref false;
wenzelm@8539
    29
wenzelm@8539
    30
wenzelm@11892
    31
(* oracle setup *)
wenzelm@6888
    32
wenzelm@6888
    33
val skip_proofN = "skip_proof";
wenzelm@6888
    34
wenzelm@11892
    35
exception SkipProof of term;
wenzelm@6888
    36
wenzelm@11892
    37
fun skip_proof (_, SkipProof t) =
wenzelm@11892
    38
  if ! quick_and_dirty then t
wenzelm@6888
    39
  else error "Proofs may be skipped in quick_and_dirty mode only!";
wenzelm@6888
    40
wenzelm@11892
    41
val setup = [Theory.add_oracle (skip_proofN, skip_proof)];
wenzelm@6888
    42
wenzelm@11892
    43
wenzelm@11972
    44
(* basic cheating *)
wenzelm@11892
    45
wenzelm@11892
    46
fun make_thm thy t =
wenzelm@11892
    47
  (*dynamic scoping of the oracle, cannot even qualify the name due to Pure/CPure!*)
wenzelm@11892
    48
  Thm.invoke_oracle thy skip_proofN (Theory.sign_of thy, SkipProof t);
wenzelm@11892
    49
wenzelm@8539
    50
fun cheat_tac thy st =
wenzelm@11892
    51
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
wenzelm@6888
    52
wenzelm@11972
    53
fun prove thy xs asms prop tac =
wenzelm@11972
    54
  Tactic.prove (Theory.sign_of thy) xs asms prop
wenzelm@11972
    55
    (if ! quick_and_dirty then (K (cheat_tac thy)) else tac);
wenzelm@11972
    56
wenzelm@6888
    57
wenzelm@8539
    58
(* "sorry" proof command *)
wenzelm@8539
    59
wenzelm@8539
    60
fun cheating ctxt = Method.METHOD (K (cheat_tac (ProofContext.theory_of ctxt)));
wenzelm@8539
    61
wenzelm@8539
    62
val local_skip_proof = Method.local_terminal_proof (Method.Basic cheating, None);
wenzelm@8539
    63
val global_skip_proof = Method.global_terminal_proof (Method.Basic cheating, None);
wenzelm@8539
    64
wenzelm@6888
    65
end;
wenzelm@8539
    66
wenzelm@8539
    67
wenzelm@8539
    68
val quick_and_dirty = SkipProof.quick_and_dirty;