src/Pure/Isar/skip_proof.ML
author wenzelm
Fri May 05 22:09:41 2000 +0200 (2000-05-05 ago)
changeset 8807 0046be1769f9
parent 8539 3cbe48a112f7
child 11732 139aaced13f4
permissions -rw-r--r--
GPLed;
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@6984
    12
  val local_skip_proof: ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
wenzelm@6888
    13
    -> Proof.state -> Proof.state Seq.seq
wenzelm@6888
    14
  val global_skip_proof: Proof.state -> theory * {kind: string, name: string, thm: thm}
wenzelm@8539
    15
  val prove_goalw_cterm: theory -> thm list -> cterm -> (thm list -> tactic list) -> thm
wenzelm@6888
    16
  val setup: (theory -> theory) list
wenzelm@6888
    17
end;
wenzelm@6888
    18
wenzelm@6888
    19
structure SkipProof: SKIP_PROOF =
wenzelm@6888
    20
struct
wenzelm@6888
    21
wenzelm@6888
    22
wenzelm@8539
    23
(* quick_and_dirty *)
wenzelm@8539
    24
wenzelm@8539
    25
(*if true then some packages will OMIT SOME PROOFS*)
wenzelm@8539
    26
val quick_and_dirty = ref false;
wenzelm@8539
    27
wenzelm@8539
    28
wenzelm@8539
    29
(* cheat_tac *)
wenzelm@6888
    30
wenzelm@6888
    31
val skip_proofN = "skip_proof";
wenzelm@6888
    32
wenzelm@6888
    33
exception SkipProof;
wenzelm@6888
    34
val any_prop = Var (("A", 0), propT);
wenzelm@6888
    35
wenzelm@6888
    36
fun any_thm (_, SkipProof) =
wenzelm@6888
    37
  if ! quick_and_dirty then any_prop
wenzelm@6888
    38
  else error "Proofs may be skipped in quick_and_dirty mode only!";
wenzelm@6888
    39
wenzelm@6888
    40
wenzelm@8539
    41
(*too bad -- dynamic scoping of the oracle, cannot even qualify the name*)
wenzelm@8539
    42
fun cheat_tac thy st =
wenzelm@8539
    43
  ALLGOALS (Tactic.rtac (Thm.invoke_oracle thy skip_proofN (Theory.sign_of thy, SkipProof))) st;
wenzelm@6888
    44
wenzelm@6888
    45
wenzelm@8539
    46
(* "sorry" proof command *)
wenzelm@8539
    47
wenzelm@8539
    48
fun cheating ctxt = Method.METHOD (K (cheat_tac (ProofContext.theory_of ctxt)));
wenzelm@8539
    49
wenzelm@8539
    50
val local_skip_proof = Method.local_terminal_proof (Method.Basic cheating, None);
wenzelm@8539
    51
val global_skip_proof = Method.global_terminal_proof (Method.Basic cheating, None);
wenzelm@8539
    52
wenzelm@8539
    53
wenzelm@8539
    54
(* conditional prove_goalw_cterm *)
wenzelm@8539
    55
wenzelm@8539
    56
fun prove_goalw_cterm thy rews ct tacs =
wenzelm@8539
    57
  Goals.prove_goalw_cterm rews ct
wenzelm@8539
    58
    (if ! quick_and_dirty then (K [cheat_tac thy]) else tacs);
wenzelm@6888
    59
wenzelm@6888
    60
wenzelm@6888
    61
(* theory setup *)
wenzelm@6888
    62
wenzelm@6888
    63
val setup = [Theory.add_oracle (skip_proofN, any_thm)];
wenzelm@6888
    64
wenzelm@6888
    65
wenzelm@6888
    66
end;
wenzelm@8539
    67
wenzelm@8539
    68
wenzelm@8539
    69
val quick_and_dirty = SkipProof.quick_and_dirty;