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