src/Pure/Isar/skip_proof.ML
author wenzelm
Sat, 12 Apr 2008 17:00:35 +0200
changeset 26626 c6231d64d264
parent 26530 777f334ff652
child 26711 3a478bfa1650
permissions -rw-r--r--
rep_cterm/rep_thm: no longer dereference theory_ref;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/skip_proof.ML
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     4
8539
3cbe48a112f7 added prove_goalw_cterm;
wenzelm
parents: 6984
diff changeset
     5
Skipping proofs -- quick_and_dirty mode.
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     6
*)
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     7
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     8
signature SKIP_PROOF =
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
     9
sig
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    10
  val make_thm: theory -> term -> thm
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    11
  val cheat_tac: theory -> tactic
20289
ba7a7c56bed5 normalized Proof.context/method type aliases;
wenzelm
parents: 20248
diff changeset
    12
  val prove: Proof.context -> string list -> term list -> term ->
ba7a7c56bed5 normalized Proof.context/method type aliases;
wenzelm
parents: 20248
diff changeset
    13
    ({prems: thm list, context: Proof.context} -> tactic) -> thm
26530
777f334ff652 Added prove_global.
berghofe
parents: 26463
diff changeset
    14
  val prove_global: theory -> string list -> term list -> term ->
777f334ff652 Added prove_global.
berghofe
parents: 26463
diff changeset
    15
    (thm list -> tactic) -> thm
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    16
end;
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    17
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    18
structure SkipProof: SKIP_PROOF =
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    19
struct
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    20
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    21
(* oracle setup *)
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    22
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    23
exception SkipProof of term;
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    24
17362
c089fa02c1e5 load before proof.ML;
wenzelm
parents: 17114
diff changeset
    25
fun skip_proof (_, SkipProof prop) =
c089fa02c1e5 load before proof.ML;
wenzelm
parents: 17114
diff changeset
    26
  if ! quick_and_dirty then prop
12318
72348ff7d4a0 skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents: 12244
diff changeset
    27
  else error "Proof may be skipped in quick_and_dirty mode only!";
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    28
26463
9283b4185fdf Context.>> : operate on Context.generic;
wenzelm
parents: 26435
diff changeset
    29
val _ = Context.>> (Context.map_theory
9283b4185fdf Context.>> : operate on Context.generic;
wenzelm
parents: 26435
diff changeset
    30
  (Theory.add_oracle ("skip_proof", skip_proof)));
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    31
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    32
11972
15da572c3c27 added prove;
wenzelm
parents: 11892
diff changeset
    33
(* basic cheating *)
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    34
17362
c089fa02c1e5 load before proof.ML;
wenzelm
parents: 17114
diff changeset
    35
fun make_thm thy prop =
c089fa02c1e5 load before proof.ML;
wenzelm
parents: 17114
diff changeset
    36
  Thm.invoke_oracle_i thy "Pure.skip_proof" (thy, SkipProof prop);
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    37
8539
3cbe48a112f7 added prove_goalw_cterm;
wenzelm
parents: 6984
diff changeset
    38
fun cheat_tac thy st =
11892
4a8834757140 moved prove_goalw_cterm to goals.ML;
wenzelm
parents: 11732
diff changeset
    39
  ALLGOALS (Tactic.rtac (make_thm thy (Var (("A", 0), propT)))) st;
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    40
20049
f48c4a3a34bc Goal.prove: context;
wenzelm
parents: 18708
diff changeset
    41
fun prove ctxt xs asms prop tac =
24502
8d5326f0098b prove: setmp quick_and_dirty (avoids race condition);
wenzelm
parents: 20289
diff changeset
    42
  Goal.prove ctxt xs asms prop (fn args => fn st =>
8d5326f0098b prove: setmp quick_and_dirty (avoids race condition);
wenzelm
parents: 20289
diff changeset
    43
    if ! quick_and_dirty
8d5326f0098b prove: setmp quick_and_dirty (avoids race condition);
wenzelm
parents: 20289
diff changeset
    44
    then setmp quick_and_dirty true (cheat_tac (ProofContext.theory_of ctxt)) st
8d5326f0098b prove: setmp quick_and_dirty (avoids race condition);
wenzelm
parents: 20289
diff changeset
    45
    else tac args st);
11972
15da572c3c27 added prove;
wenzelm
parents: 11892
diff changeset
    46
26530
777f334ff652 Added prove_global.
berghofe
parents: 26463
diff changeset
    47
fun prove_global thy xs asms prop tac =
777f334ff652 Added prove_global.
berghofe
parents: 26463
diff changeset
    48
  Drule.standard (prove (ProofContext.init thy) xs asms prop (fn {prems, ...} => tac prems));
777f334ff652 Added prove_global.
berghofe
parents: 26463
diff changeset
    49
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
diff changeset
    50
end;