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