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