src/HOL/Tools/Sledgehammer/sledgehammer_isar_try0.ML
author blanchet
Mon, 03 Feb 2014 10:14:18 +0100
changeset 55266 d9d31354834e
parent 55264 43473497fb65
permissions -rw-r--r--
centralize more preplaying
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55202
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
     1
(*  Title:      HOL/Tools/Sledgehammer/sledgehammer_isar_try0.ML
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
     2
    Author:     Steffen Juilf Smolka, TU Muenchen
54766
6ac273f176cd store alternative proof methods in Isar data structure
blanchet
parents: 54765
diff changeset
     3
    Author:     Jasmin Blanchette, TU Muenchen
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
     4
55202
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
     5
Try replacing calls to "metis" with calls to other proof methods to speed up proofs, eliminate
54766
6ac273f176cd store alternative proof methods in Isar data structure
blanchet
parents: 54765
diff changeset
     6
dependencies, and repair broken proof steps.
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
     7
*)
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
     8
55202
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
     9
signature SLEDGEHAMMER_ISAR_TRY0 =
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    10
sig
55202
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
    11
  type isar_proof = Sledgehammer_Isar_Proof.isar_proof
55213
dcb36a2540bc tuned ML function names
blanchet
parents: 55212
diff changeset
    12
  type isar_preplay_data = Sledgehammer_Isar_Preplay.isar_preplay_data
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    13
55260
ada3ae6458d4 more data structure rationalization
blanchet
parents: 55258
diff changeset
    14
  val try0_isar_proof : Proof.context -> Time.time -> isar_preplay_data Unsynchronized.ref ->
ada3ae6458d4 more data structure rationalization
blanchet
parents: 55258
diff changeset
    15
    isar_proof -> isar_proof
54504
blanchet
parents: 52629
diff changeset
    16
end;
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    17
55202
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
    18
structure Sledgehammer_Isar_Try0 : SLEDGEHAMMER_ISAR_TRY0 =
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    19
struct
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    20
54712
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    21
open Sledgehammer_Util
54828
b2271ad695db don't do 'isar_try0' if preplaying is off
blanchet
parents: 54827
diff changeset
    22
open Sledgehammer_Reconstructor
55202
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
    23
open Sledgehammer_Isar_Proof
824c48a539c9 renamed many Sledgehammer ML files to clarify structure
blanchet
parents: 54828
diff changeset
    24
open Sledgehammer_Isar_Preplay
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    25
55255
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    26
fun step_with_method meth (Prove (qs, xs, l, t, subproofs, (facts, _))) =
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    27
  Prove (qs, xs, l, t, subproofs, (facts, [meth]))
54712
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    28
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    29
val slack = seconds 0.05
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    30
55258
8cc42c1f9bb5 more data structure rationalization
blanchet
parents: 55255
diff changeset
    31
fun try0_step _ _ _ (step as Let _) = step
55260
ada3ae6458d4 more data structure rationalization
blanchet
parents: 55258
diff changeset
    32
  | try0_step ctxt preplay_timeout preplay_data
55255
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    33
      (step as Prove (_, _, l, _, _, (_, meths as meth :: _))) =
54712
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    34
    let
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    35
      val timeout =
55266
d9d31354834e centralize more preplaying
blanchet
parents: 55264
diff changeset
    36
        (case Lazy.force (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth) of
54828
b2271ad695db don't do 'isar_try0' if preplaying is off
blanchet
parents: 54827
diff changeset
    37
          Played time => Time.+ (time, slack)
54826
79745ba60a5a data structure rationalization
blanchet
parents: 54767
diff changeset
    38
        | _ => preplay_timeout)
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    39
55255
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    40
      fun try_method meth =
55258
8cc42c1f9bb5 more data structure rationalization
blanchet
parents: 55255
diff changeset
    41
        (case preplay_isar_step ctxt timeout meth step of
55255
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    42
          outcome as Played _ => SOME (meth, outcome)
54827
14e2c7616209 more data structure refactoring
blanchet
parents: 54826
diff changeset
    43
        | _ => NONE)
54712
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    44
    in
55243
66709d41601e reset timing information after changes
blanchet
parents: 55223
diff changeset
    45
      (* FIXME: create variant after success *)
55255
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    46
      (case Par_List.get_some try_method meths of
eceebcea3e00 refactoring of data structure (step 2)
blanchet
parents: 55252
diff changeset
    47
        SOME (meth', outcome) =>
55264
43473497fb65 centralize preplaying
blanchet
parents: 55260
diff changeset
    48
        let val step' = step_with_method meth' step in
43473497fb65 centralize preplaying
blanchet
parents: 55260
diff changeset
    49
          (set_preplay_outcomes_of_isar_step ctxt timeout preplay_data step'
43473497fb65 centralize preplaying
blanchet
parents: 55260
diff changeset
    50
             [(meth', Lazy.value outcome)];
43473497fb65 centralize preplaying
blanchet
parents: 55260
diff changeset
    51
           step')
43473497fb65 centralize preplaying
blanchet
parents: 55260
diff changeset
    52
        end
54712
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    53
      | NONE => step)
cbebe2cf77f1 more work on Z3 Isar proofs
blanchet
parents: 54700
diff changeset
    54
    end
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    55
55258
8cc42c1f9bb5 more data structure rationalization
blanchet
parents: 55255
diff changeset
    56
val try0_isar_proof = map_isar_steps ooo try0_step
52592
8a25b17e3d79 optimize isar-proofs by trying different proof methods
smolkas
parents:
diff changeset
    57
54504
blanchet
parents: 52629
diff changeset
    58
end;