| author | immler |
| Tue, 12 Apr 2016 11:18:29 +0200 | |
| changeset 62951 | f59ef58f420b |
| parent 62922 | 96691631c1eb |
| child 64986 | b81a048960a3 |
| permissions | -rw-r--r-- |
| 52424 | 1 |
(* Title: HOL/Proofs/ex/XML_Data.thy |
2 |
Author: Makarius |
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
3 |
Author: Stefan Berghofer |
| 52424 | 4 |
|
5 |
XML data representation of proof terms. |
|
6 |
*) |
|
7 |
||
8 |
theory XML_Data |
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
9 |
imports "~~/src/HOL/Isar_Examples/Drinker" |
| 52424 | 10 |
begin |
11 |
||
| 61986 | 12 |
subsection \<open>Export and re-import of global proof terms\<close> |
| 52424 | 13 |
|
| 61986 | 14 |
ML \<open> |
| 62922 | 15 |
fun export_proof ctxt thm = |
| 52424 | 16 |
let |
| 62922 | 17 |
val thy = Proof_Context.theory_of ctxt; |
| 61039 | 18 |
val (_, prop) = |
19 |
Logic.unconstrainT (Thm.shyps_of thm) |
|
20 |
(Logic.list_implies (Thm.hyps_of thm, Thm.prop_of thm)); |
|
| 52424 | 21 |
val prf = |
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
22 |
Proofterm.proof_of (Proofterm.strip_thm (Thm.proof_body_of thm)) |> |
| 62922 | 23 |
Reconstruct.reconstruct_proof ctxt prop |> |
24 |
Reconstruct.expand_proof ctxt [("", NONE)] |>
|
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
25 |
Proofterm.rew_proof thy |> |
|
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
26 |
Proofterm.no_thm_proofs; |
|
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
27 |
in Proofterm.encode prf end; |
| 52424 | 28 |
|
29 |
fun import_proof thy xml = |
|
30 |
let |
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
31 |
val prf = Proofterm.decode xml; |
|
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
32 |
val (prf', _) = Proofterm.freeze_thaw_prf prf; |
|
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
33 |
in Drule.export_without_context (Proof_Checker.thm_of_proof thy prf') end; |
| 61986 | 34 |
\<close> |
| 52424 | 35 |
|
36 |
||
| 61986 | 37 |
subsection \<open>Examples\<close> |
| 52424 | 38 |
|
| 61986 | 39 |
ML \<open>val thy1 = @{theory}\<close>
|
| 52424 | 40 |
|
41 |
lemma ex: "A \<longrightarrow> A" .. |
|
42 |
||
| 61986 | 43 |
ML_val \<open> |
| 62922 | 44 |
val xml = export_proof @{context} @{thm ex};
|
| 52424 | 45 |
val thm = import_proof thy1 xml; |
| 61986 | 46 |
\<close> |
| 52424 | 47 |
|
| 61986 | 48 |
ML_val \<open> |
| 62922 | 49 |
val xml = export_proof @{context} @{thm de_Morgan};
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
50 |
val thm = import_proof thy1 xml; |
| 61986 | 51 |
\<close> |
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
52 |
|
| 61986 | 53 |
ML_val \<open> |
| 62922 | 54 |
val xml = export_proof @{context} @{thm Drinker's_Principle};
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
55 |
val thm = import_proof thy1 xml; |
| 61986 | 56 |
\<close> |
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
57 |
|
| 61986 | 58 |
text \<open>Some fairly large proof:\<close> |
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
59 |
|
| 61986 | 60 |
ML_val \<open> |
| 62922 | 61 |
val xml = export_proof @{context} @{thm abs_less_iff};
|
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
62 |
val thm = import_proof thy1 xml; |
|
60157
ccf9241af217
use smaller example that fits into 64MB string limit of Poly/ML x86 platform;
wenzelm
parents:
58372
diff
changeset
|
63 |
@{assert} (size (YXML.string_of_body xml) > 1000000);
|
| 61986 | 64 |
\<close> |
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52424
diff
changeset
|
65 |
|
| 52424 | 66 |
end |