author | Christian Urban <urbanc@in.tum.de> |
Thu, 20 Aug 2009 22:30:20 +0200 | |
changeset 316 | 74f0a06f751f |
parent 315 | de49d5780f57 |
child 317 | d69214e47ef9 |
permissions | -rw-r--r-- |
106
bdd82350cf22
renamed in the pdf all instances of cookbook to tutorial (in order to sound more serious)
Christian Urban <urbanc@in.tum.de>
parents:
103
diff
changeset
|
1 |
(* Auxiliary antiquotations for the tutorial. *) |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
|
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
3 |
structure AntiquoteSetup = |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
struct |
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
|
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
6 |
open OutputTutorial |
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
7 |
|
112 | 8 |
(* functions for generating appropriate expressions *) |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
9 |
fun translate_string f str = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
10 |
implode (map f (Symbol.explode str)) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
11 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
12 |
fun prefix_lines prfx txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
13 |
map (fn s => prfx ^ s) (split_lines txt) |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
15 |
fun ml_with_vars ys txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
16 |
implode ["fn ", (case ys of [] => "_" | _ => enclose "(" ")" (commas ys)), " => (", txt, ")"] |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
17 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
18 |
fun ml_with_struct (NONE) txt = txt |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
19 |
| ml_with_struct (SOME st) txt = implode ["let open ", st, " in ", txt, " end"] |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
20 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
21 |
fun ml_val vs stru txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
22 |
txt |> ml_with_struct stru |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
23 |
|> ml_with_vars vs |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
|
112 | 25 |
fun ml_pat (lhs, pat) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
26 |
implode ["val ", translate_string (fn "\<dots>" => "_" | s => s) pat, " = ", lhs] |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
28 |
fun ml_struct txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
29 |
implode ["functor DUMMY_FUNCTOR() = struct structure DUMMY = ", txt, " end"] |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
30 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
31 |
fun ml_type txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
32 |
implode ["val _ = NONE : (", txt, ") option"]; |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
|
112 | 34 |
(* eval function *) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
35 |
fun eval_fn ctxt exp = |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
36 |
ML_Context.eval_in (SOME ctxt) false Position.none exp |
57
065f472c09ab
Repaired output of marginal comments in ML antiquotation.
berghofe
parents:
54
diff
changeset
|
37 |
|
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
38 |
(* checks and prints a possibly open expressions, no index *) |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
39 |
fun output_ml {context = ctxt, ...} (txt, (vs, stru)) = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
40 |
(eval_fn ctxt (ml_val vs stru txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
41 |
output (split_lines txt)) |
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
42 |
|
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
43 |
val parser_ml = Scan.lift (Args.name -- |
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
44 |
(Scan.optional (Args.$$$ "for" |-- OuterParse.!!! (Scan.repeat1 Args.name)) [] -- |
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
45 |
Scan.option (Args.$$$ "in" |-- OuterParse.!!! Args.name))) |
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
46 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
47 |
(* checks and prints a single ML-item and produces an index entry *) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
48 |
fun output_ml_ind {context = ctxt, ...} (txt, stru) = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
49 |
(eval_fn ctxt (ml_val [] stru txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
50 |
case (stru, Long_Name.base_name txt, Long_Name.qualifier txt) of |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
51 |
(NONE, bn, "") => output_indexed {main = Code txt, minor = NoString} (split_lines txt) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
52 |
| (NONE, bn, qn) => output_indexed {main = Code bn, minor = Struct qn} (split_lines txt) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
53 |
| (SOME st, _, _) => output_indexed {main = Code txt, minor = Struct st} (split_lines txt)) |
112 | 54 |
|
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
55 |
val parser_ml_ind = Scan.lift (Args.name -- |
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
56 |
Scan.option (Args.$$$ "in" |-- OuterParse.!!! Args.name)) |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
58 |
(* checks and prints structures *) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
59 |
fun gen_output_struct outfn {context = ctxt, ...} txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
60 |
(eval_fn ctxt (ml_struct txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
61 |
outfn {main = Code txt, minor = Plain "structure"} (split_lines txt)) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
62 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
63 |
val output_struct = gen_output_struct (K output) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
64 |
val output_struct_ind = gen_output_struct output_indexed |
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
65 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
66 |
(* checks and prints types *) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
67 |
fun gen_output_type outfn {context = ctxt, ...} txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
68 |
(eval_fn ctxt (ml_type txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
69 |
outfn {main = Code txt, minor = Plain "type"} (split_lines txt)) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
70 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
71 |
val output_type = gen_output_type (K output) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
72 |
val output_type_ind = gen_output_type output_indexed |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
|
112 | 74 |
(* checks and expression agains a result pattern *) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
75 |
fun output_response {context = ctxt, ...} (lhs, pat) = |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
76 |
(eval_fn ctxt (ml_pat (lhs, pat)); |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
77 |
output ((prefix_lines "" lhs) @ (prefix_lines "> " pat))) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
78 |
|
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
79 |
(* checks the expressions, but does not check it against a result pattern *) |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
80 |
fun output_response_fake {context = ctxt, ...} (lhs, pat) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
81 |
(eval_fn ctxt (ml_val [] NONE lhs); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
82 |
output ((split_lines lhs) @ (prefix_lines "> " pat))) |
112 | 83 |
|
84 |
(* checks the expressions, but does not check it against a result pattern *) |
|
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
85 |
fun ouput_response_fake_both _ (lhs, pat) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
86 |
output ((split_lines lhs) @ (prefix_lines "> " pat)) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
87 |
|
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
88 |
val single_arg = Scan.lift (Args.name) |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
89 |
val two_args = Scan.lift (Args.name -- Args.name) |
112 | 90 |
|
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
91 |
val _ = ThyOutput.antiquotation "ML" parser_ml output_ml |
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
92 |
val _ = ThyOutput.antiquotation "ML_ind" parser_ml_ind output_ml_ind |
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
93 |
val _ = ThyOutput.antiquotation "ML_type" single_arg output_type |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
94 |
val _ = ThyOutput.antiquotation "ML_type_ind" single_arg output_type_ind |
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
95 |
val _ = ThyOutput.antiquotation "ML_struct" single_arg output_struct |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
96 |
val _ = ThyOutput.antiquotation "ML_struct_ind" single_arg output_struct_ind |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
97 |
val _ = ThyOutput.antiquotation "ML_response" two_args output_response |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
98 |
val _ = ThyOutput.antiquotation "ML_response_fake" two_args output_response_fake |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
99 |
val _ = ThyOutput.antiquotation "ML_response_fake_both" two_args ouput_response_fake_both |
54
1783211b3494
tuned; added document antiquotation ML_response_fake_both
Christian Urban <urbanc@in.tum.de>
parents:
53
diff
changeset
|
100 |
|
182
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
101 |
fun href_link txt = |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
102 |
let |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
103 |
val raw = Symbol.encode_raw |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
104 |
val path = "http://isabelle.in.tum.de/repos/isabelle/raw-file/tip/src/" |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
105 |
in |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
106 |
implode [raw "\\href{", raw path, raw txt, raw "}{", txt, raw "}"] |
182
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
107 |
end |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
108 |
|
112 | 109 |
(* checks whether a file exists in the Isabelle distribution *) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
110 |
fun check_file_exists _ txt = |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
111 |
(if File.exists (Path.append (Path.explode ("~~/src")) (Path.explode txt)) |
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
112 |
then output [href_link txt] |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
113 |
else error (implode ["Source file ", quote txt, " does not exist."])) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
114 |
|
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
115 |
|
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
116 |
val _ = ThyOutput.antiquotation "ML_file" single_arg check_file_exists |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
117 |
|
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
98
diff
changeset
|
119 |
(* replaces the official subgoal antiquotation with one *) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
98
diff
changeset
|
120 |
(* that is closer to the actual output *) |
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
121 |
fun proof_state state = |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
122 |
(case try Toplevel.proof_of state of |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
123 |
SOME prf => prf |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
124 |
| _ => error "No proof state") |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
125 |
|
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
126 |
fun output_goals {state = node, ...} _ = |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
127 |
let |
98
0a5c95f4d70c
calculated the exact number of goals in the subgoal antiquotation
Christian Urban <urbanc@in.tum.de>
parents:
96
diff
changeset
|
128 |
fun subgoals 0 = "" |
96
018bfa718982
(re)defined the document antiquotation @subgoal in order to be closer to what is actually printed
Christian Urban <urbanc@in.tum.de>
parents:
90
diff
changeset
|
129 |
| subgoals 1 = "goal (1 subgoal):" |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
130 |
| subgoals n = "goal (" ^ string_of_int n ^ " subgoals):" |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
131 |
|
98
0a5c95f4d70c
calculated the exact number of goals in the subgoal antiquotation
Christian Urban <urbanc@in.tum.de>
parents:
96
diff
changeset
|
132 |
val state = proof_state node; |
209 | 133 |
val goals = Pretty.chunks (Proof.pretty_goals false state); |
98
0a5c95f4d70c
calculated the exact number of goals in the subgoal antiquotation
Christian Urban <urbanc@in.tum.de>
parents:
96
diff
changeset
|
134 |
|
0a5c95f4d70c
calculated the exact number of goals in the subgoal antiquotation
Christian Urban <urbanc@in.tum.de>
parents:
96
diff
changeset
|
135 |
val {prop, ...} = rep_thm (Proof.get_goal state |> snd |> snd); |
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
136 |
val (As, _) = Logic.strip_horn prop; |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
137 |
val output = (case (length As) of |
209 | 138 |
0 => [goals] |
139 |
| n => [Pretty.str (subgoals n), goals]) |
|
96
018bfa718982
(re)defined the document antiquotation @subgoal in order to be closer to what is actually printed
Christian Urban <urbanc@in.tum.de>
parents:
90
diff
changeset
|
140 |
in |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
141 |
ThyOutput.output output |
96
018bfa718982
(re)defined the document antiquotation @subgoal in order to be closer to what is actually printed
Christian Urban <urbanc@in.tum.de>
parents:
90
diff
changeset
|
142 |
end |
165
890fbfef6d6b
partially adapted to new antiquotation infrastructure
Christian Urban <urbanc@in.tum.de>
parents:
112
diff
changeset
|
143 |
|
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
144 |
fun output_raw_goal_state {state = node, context = ctxt, ...} _ = |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
145 |
let |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
146 |
val state = proof_state node; |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
147 |
val goals = (Proof.get_goal state |> snd |> snd) |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
148 |
|
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
149 |
val output = [Pretty.str (Syntax.string_of_term ctxt (prop_of goals))] |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
150 |
val _ = tracing (Syntax.string_of_term ctxt (prop_of goals)) |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
151 |
val _ = tracing (Pretty.string_of (Pretty.str (Syntax.string_of_term ctxt (prop_of goals)))) |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
152 |
in |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
153 |
ThyOutput.output output |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
154 |
end |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
155 |
|
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
156 |
val _ = ThyOutput.antiquotation "subgoals" (Scan.succeed ()) output_goals |
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
157 |
val _ = ThyOutput.antiquotation "raw_goal_state" (Scan.succeed ()) output_raw_goal_state |
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
158 |
|
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
end; |