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