author | smolkas |
Wed, 26 Jun 2013 18:26:00 +0200 | |
changeset 52454 | b528a975b256 |
parent 52453 | 2cba5906d836 |
child 52556 | c8357085217c |
permissions | -rw-r--r-- |
50264
a9ec48b98734
renamed sledgehammer_isar_reconstruct to sledgehammer_proof
smolkas
parents:
50263
diff
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:
51178
diff
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:
51178
diff
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:
51178
diff
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:
51178
diff
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:
51178
diff
changeset
|
21 |
and isar_step = |
50268 | 22 |
Let of term * term | |
52454 | 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 = |
52454 | 26 |
By_Metis of facts |
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:
51178
diff
changeset
|
27 |
|
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:
51178
diff
changeset
|
28 |
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:
51178
diff
changeset
|
29 |
val no_facts : facts |
50268 | 30 |
|
51998
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
blanchet
parents:
51239
diff
changeset
|
31 |
val string_of_label : label -> string |
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:
51178
diff
changeset
|
32 |
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:
51178
diff
changeset
|
33 |
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:
51178
diff
changeset
|
34 |
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:
51178
diff
changeset
|
35 |
|
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:
51178
diff
changeset
|
36 |
val label_of_step : isar_step -> label option |
52454 | 37 |
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:
51178
diff
changeset
|
38 |
val byline_of_step : isar_step -> byline option |
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:
51178
diff
changeset
|
39 |
|
52454 | 40 |
val fold_isar_step : (isar_step -> 'a -> 'a) -> isar_step -> 'a -> 'a |
41 |
val fold_isar_steps : |
|
42 |
(isar_step -> 'a -> 'a) -> isar_step list -> 'a -> 'a |
|
43 |
||
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:
51178
diff
changeset
|
44 |
val add_metis_steps_top_level : isar_step list -> int -> int |
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:
51178
diff
changeset
|
45 |
val add_metis_steps : isar_step list -> int -> int |
50259 | 46 |
end |
47 |
||
50672
ab5b8b5c9cbe
added "obtain" to Isar proof construction data structure
blanchet
parents:
50269
diff
changeset
|
48 |
structure Sledgehammer_Proof : SLEDGEHAMMER_PROOF = |
50259 | 49 |
struct |
50 |
||
51 |
type label = string * int |
|
52454 | 52 |
type facts = label list * string list (* local & global facts *) |
50259 | 53 |
|
51178 | 54 |
datatype isar_qualifier = Show | Then |
50259 | 55 |
|
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:
51178
diff
changeset
|
56 |
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:
51178
diff
changeset
|
57 |
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:
51178
diff
changeset
|
58 |
|
52454 | 59 |
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:
51178
diff
changeset
|
60 |
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:
51178
diff
changeset
|
61 |
and isar_step = |
50259 | 62 |
Let of term * term | |
52454 | 63 |
(* for |fix|>0, this is an obtain step; step may contain subproofs *) |
64 |
Prove of isar_qualifier list * fix * label * term * isar_proof list * byline |
|
50259 | 65 |
and byline = |
52454 | 66 |
By_Metis of facts |
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:
51178
diff
changeset
|
67 |
|
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:
51178
diff
changeset
|
68 |
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:
51178
diff
changeset
|
69 |
val no_facts = ([],[]) |
50259 | 70 |
|
51998
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
blanchet
parents:
51239
diff
changeset
|
71 |
fun string_of_label (s, num) = s ^ string_of_int num |
50259 | 72 |
|
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:
51178
diff
changeset
|
73 |
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:
51178
diff
changeset
|
74 |
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:
51178
diff
changeset
|
75 |
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:
51178
diff
changeset
|
76 |
|
52454 | 77 |
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:
51178
diff
changeset
|
78 |
| label_of_step _ = NONE |
51178 | 79 |
|
52454 | 80 |
fun subproofs_of_step (Prove (_, _, _, _, subproofs, _)) = SOME subproofs |
81 |
| subproofs_of_step _ = NONE |
|
82 |
||
83 |
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:
51178
diff
changeset
|
84 |
| 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:
51178
diff
changeset
|
85 |
|
52454 | 86 |
fun fold_isar_step f step s = |
87 |
fold (steps_of_proof #> fold (fold_isar_step f)) |
|
88 |
(the_default [] (subproofs_of_step step)) s |
|
89 |
|> f step |
|
90 |
||
91 |
fun fold_isar_steps f = fold (fold_isar_step f) |
|
92 |
||
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:
51178
diff
changeset
|
93 |
val add_metis_steps_top_level = |
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:
51178
diff
changeset
|
94 |
fold (byline_of_step #> (fn SOME (By_Metis _) => Integer.add 1 | _ => I)) |
51178 | 95 |
|
52454 | 96 |
val add_metis_steps = |
97 |
fold_isar_steps |
|
98 |
(byline_of_step #> (fn SOME (By_Metis _) => Integer.add 1 | _ => I)) |
|
50260 | 99 |
end |