| author | blanchet | 
| Sat, 26 Oct 2013 13:01:41 +0200 | |
| changeset 54209 | 16723c834406 | 
| parent 52629 | d6f2a7c196f7 | 
| child 54503 | b490e15a5e19 | 
| permissions | -rw-r--r-- | 
| 50264 
a9ec48b98734
renamed sledgehammer_isar_reconstruct to sledgehammer_proof
 smolkas parents: 
50263diff
changeset | 1 | (* Title: HOL/Tools/Sledgehammer/sledgehammer_proof.ML | 
| 50263 | 2 | Author: Jasmin Blanchette, TU Muenchen | 
| 3 | Author: Steffen Juilf Smolka, TU Muenchen | |
| 4 | ||
| 5 | Basic data structures for representing and basic methods | |
| 6 | for dealing with Isar proof texts. | |
| 7 | *) | |
| 8 | ||
| 50268 | 9 | signature SLEDGEHAMMER_PROOF = | 
| 50259 | 10 | sig | 
| 51239 | 11 | type label = string * int | 
| 52454 | 12 | type facts = label list * string list (* local & global facts *) | 
| 50268 | 13 | |
| 51178 | 14 | datatype isar_qualifier = Show | Then | 
| 50268 | 15 | |
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 16 | datatype fix = Fix of (string * typ) list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 17 | datatype assms = Assume of (label * term) list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 18 | |
| 52454 | 19 | datatype isar_proof = | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 20 | Proof of fix * assms * isar_step list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 21 | and isar_step = | 
| 50268 | 22 | Let of term * term | | 
| 52590 | 23 | (* for |fix|>0, this is an obtain step; step may contain subproofs *) | 
| 24 | Prove of isar_qualifier list * fix * label * term * isar_proof list * byline | |
| 50268 | 25 | and byline = | 
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 26 | By of facts * proof_method | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 27 | and proof_method = | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 28 | MetisM | | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 29 | SimpM | | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 30 | AutoM | | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 31 | FastforceM | | 
| 52629 | 32 | ForceM | | 
| 33 | ArithM | | |
| 34 | BlastM | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 35 | |
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 36 | (* legacy *) | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 37 | val By_Metis : facts -> byline | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 38 | |
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 39 | val no_label : label | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 40 | val no_facts : facts | 
| 50268 | 41 | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 42 | val label_ord : label * label -> order | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 43 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 44 | val dummy_isar_step : isar_step | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 45 | |
| 51998 
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
 blanchet parents: 
51239diff
changeset | 46 | val string_of_label : label -> string | 
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 47 | |
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 48 | val fix_of_proof : isar_proof -> fix | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 49 | val assms_of_proof : isar_proof -> assms | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 50 | val steps_of_proof : isar_proof -> isar_step list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 51 | |
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 52 | val label_of_step : isar_step -> label option | 
| 52454 | 53 | val subproofs_of_step : isar_step -> isar_proof list option | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 54 | val byline_of_step : isar_step -> byline option | 
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 55 | val proof_method_of_step : isar_step -> proof_method option | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 56 | |
| 52454 | 57 | val fold_isar_step : (isar_step -> 'a -> 'a) -> isar_step -> 'a -> 'a | 
| 58 | val fold_isar_steps : | |
| 59 | (isar_step -> 'a -> 'a) -> isar_step list -> 'a -> 'a | |
| 60 | ||
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 61 | val map_isar_steps : (isar_step -> isar_step) -> isar_proof -> isar_proof | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 62 | |
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 63 | val map_facts_of_byline : (facts -> facts) -> byline -> byline | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 64 | |
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 65 | val add_proof_steps : isar_step list -> int -> int | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 66 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 67 | (** canonical proof labels: 1, 2, 3, ... in post traversal order **) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 68 | val canonical_label_ord : (label * label) -> order | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 69 | val relabel_proof_canonically : isar_proof -> isar_proof | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 70 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 71 | structure Canonical_Lbl_Tab : TABLE | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 72 | |
| 50259 | 73 | end | 
| 74 | ||
| 50672 
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
 blanchet parents: 
50269diff
changeset | 75 | structure Sledgehammer_Proof : SLEDGEHAMMER_PROOF = | 
| 50259 | 76 | struct | 
| 77 | ||
| 78 | type label = string * int | |
| 52454 | 79 | type facts = label list * string list (* local & global facts *) | 
| 50259 | 80 | |
| 51178 | 81 | datatype isar_qualifier = Show | Then | 
| 50259 | 82 | |
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 83 | datatype fix = Fix of (string * typ) list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 84 | datatype assms = Assume of (label * term) list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 85 | |
| 52454 | 86 | datatype isar_proof = | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 87 | Proof of fix * assms * isar_step list | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 88 | and isar_step = | 
| 50259 | 89 | Let of term * term | | 
| 52454 | 90 | (* for |fix|>0, this is an obtain step; step may contain subproofs *) | 
| 91 | Prove of isar_qualifier list * fix * label * term * isar_proof list * byline | |
| 50259 | 92 | and byline = | 
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 93 | By of facts * proof_method | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 94 | and proof_method = | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 95 | MetisM | | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 96 | SimpM | | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 97 | AutoM | | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 98 | FastforceM | | 
| 52629 | 99 | ForceM | | 
| 100 | ArithM | | |
| 101 | BlastM | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 102 | |
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 103 | (* legacy *) | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 104 | fun By_Metis facts = By (facts, MetisM) | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 105 | |
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 106 | val no_label = ("", ~1)
 | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 107 | val no_facts = ([],[]) | 
| 50259 | 108 | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 109 | val label_ord = pairself swap #> prod_ord int_ord fast_string_ord | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 110 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 111 | val dummy_isar_step = Let (Term.dummy, Term.dummy) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 112 | |
| 51998 
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
 blanchet parents: 
51239diff
changeset | 113 | fun string_of_label (s, num) = s ^ string_of_int num | 
| 50259 | 114 | |
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 115 | fun fix_of_proof (Proof (fix, _, _)) = fix | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 116 | fun assms_of_proof (Proof (_, assms, _)) = assms | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 117 | fun steps_of_proof (Proof (_, _, steps)) = steps | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 118 | |
| 52454 | 119 | fun label_of_step (Prove (_, _, l, _, _, _)) = SOME l | 
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 120 | | label_of_step _ = NONE | 
| 51178 | 121 | |
| 52454 | 122 | fun subproofs_of_step (Prove (_, _, _, _, subproofs, _)) = SOME subproofs | 
| 123 | | subproofs_of_step _ = NONE | |
| 124 | ||
| 125 | fun byline_of_step (Prove (_, _, _, _, _, byline)) = SOME byline | |
| 51179 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 126 | | byline_of_step _ = NONE | 
| 
0d5f8812856f
split isar_step into isar_step, fix, assms; made isar_proof explicit; register fixed variables in ctxt and auto_fix terms to avoid superfluous annotations
 smolkas parents: 
51178diff
changeset | 127 | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 128 | fun proof_method_of_step (Prove (_, _, _, _, _, By(_, method))) = SOME method | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 129 | | proof_method_of_step _ = NONE | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 130 | |
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 131 | fun fold_isar_steps f = fold (fold_isar_step f) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 132 | and fold_isar_step f step s = | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 133 | fold (steps_of_proof #> fold_isar_steps f) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 134 | (these (subproofs_of_step step)) s | 
| 52454 | 135 | |> f step | 
| 136 | ||
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 137 | fun map_isar_steps f proof = | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 138 | let | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 139 | fun do_proof (Proof (fix, assms, steps)) = | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 140 | Proof (fix, assms, map do_step steps) | 
| 51178 | 141 | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 142 | and do_step (step as Let _) = f step | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 143 | | do_step (Prove (qs, xs, l, t, subproofs, by)) = | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 144 | let | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 145 | val subproofs = map do_proof subproofs | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 146 | val step = Prove (qs, xs, l, t, subproofs, by) | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 147 | in | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 148 | f step | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 149 | end | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 150 | in | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 151 | do_proof proof | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 152 | end | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 153 | |
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 154 | fun map_facts_of_byline f (By (facts, method)) = By (f facts, method) | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 155 | |
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 156 | val add_proof_steps = fold_isar_steps (fn Prove _ => Integer.add 1 | _ => I) | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 157 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 158 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 159 | (** canonical proof labels: 1, 2, 3, ... in post traversal order **) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 160 | |
| 52557 | 161 | fun canonical_label_ord (((_, i1), (_, i2)) : label * label) = int_ord (i1, i2) | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 162 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 163 | structure Canonical_Lbl_Tab = Table( | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 164 | type key = label | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 165 | val ord = canonical_label_ord) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 166 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 167 | fun relabel_proof_canonically proof = | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 168 | let | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 169 | val lbl = pair "" | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 170 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 171 | fun next_label l (next, subst) = | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 172 | (lbl next, (next + 1, (l, lbl next) :: subst)) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 173 | |
| 52592 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 174 | fun do_byline by (_, subst) = | 
| 
8a25b17e3d79
optimize isar-proofs by trying different proof methods
 smolkas parents: 
52590diff
changeset | 175 | by |> map_facts_of_byline (apfst (map (AList.lookup (op =) subst #> the))) | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 176 | handle Option.Option => | 
| 52627 | 177 | raise Fail "Sledgehammer_Proof: relabel_proof_canonically" | 
| 52556 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 178 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 179 | fun do_assm (l, t) state = | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 180 | let | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 181 | val (l, state) = next_label l state | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 182 | in ((l, t), state) end | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 183 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 184 | fun do_proof (Proof (fix, Assume assms, steps)) state = | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 185 | let | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 186 | val (assms, state) = fold_map do_assm assms state | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 187 | val (steps, state) = fold_map do_step steps state | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 188 | in | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 189 | (Proof (fix, Assume assms, steps), state) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 190 | end | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 191 | |
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 192 | and do_step (step as Let _) state = (step, state) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 193 | | do_step (Prove (qs, fix, l, t, subproofs, by)) state= | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 194 | let | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 195 | val by = do_byline by state | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 196 | val (subproofs, state) = fold_map do_proof subproofs state | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 197 | val (l, state) = next_label l state | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 198 | in | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 199 | (Prove (qs, fix, l, t, subproofs, by), state) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 200 | end | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 201 | in | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 202 | fst (do_proof proof (0, [])) | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 203 | end | 
| 
c8357085217c
completely rewrote SH compress; added two parameters for experimentation/fine grained control
 smolkas parents: 
52454diff
changeset | 204 | |
| 50260 | 205 | end |