author | wenzelm |
Thu, 27 Mar 2008 14:41:10 +0100 | |
changeset 26425 | 6561665c5cb1 |
parent 26415 | 1b624d6e9163 |
child 26435 | bdce320cd426 |
permissions | -rw-r--r-- |
5831 | 1 |
(* Title: Pure/Isar/isar_cmd.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
21350 | 5 |
Derived Isar commands. |
5831 | 6 |
*) |
7 |
||
8 |
signature ISAR_CMD = |
|
9 |
sig |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
10 |
val generic_setup: (string * Position.T) option -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
11 |
val parse_ast_translation: bool * (string * Position.T) -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
12 |
val parse_translation: bool * (string * Position.T) -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
13 |
val print_translation: bool * (string * Position.T) -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
14 |
val typed_print_translation: bool * (string * Position.T) -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
15 |
val print_ast_translation: bool * (string * Position.T) -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
16 |
val token_translation: string * Position.T -> theory -> theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
17 |
val oracle: bstring -> string -> string * Position.T -> theory -> theory |
21350 | 18 |
val add_axioms: ((bstring * string) * Attrib.src list) list -> theory -> theory |
19 |
val add_defs: (bool * bool) * ((bstring * string) * Attrib.src list) list -> theory -> theory |
|
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
26186
diff
changeset
|
20 |
val apply_theorems: (Facts.ref * Attrib.src list) list -> theory -> thm list * theory |
21350 | 21 |
val apply_theorems_i: (thm list * attribute list) list -> theory -> thm list * theory |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
22 |
val declaration: string * Position.T -> local_theory -> local_theory |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
23 |
val simproc_setup: string -> string list -> string * Position.T -> string list -> |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
24 |
local_theory -> local_theory |
21350 | 25 |
val have: ((string * Attrib.src list) * (string * string list) list) list -> |
26 |
bool -> Proof.state -> Proof.state |
|
27 |
val hence: ((string * Attrib.src list) * (string * string list) list) list -> |
|
28 |
bool -> Proof.state -> Proof.state |
|
29 |
val show: ((string * Attrib.src list) * (string * string list) list) list -> |
|
30 |
bool -> Proof.state -> Proof.state |
|
31 |
val thus: ((string * Attrib.src list) * (string * string list) list) list -> |
|
32 |
bool -> Proof.state -> Proof.state |
|
33 |
val qed: Method.text option -> Toplevel.transition -> Toplevel.transition |
|
34 |
val terminal_proof: Method.text * Method.text option -> |
|
35 |
Toplevel.transition -> Toplevel.transition |
|
36 |
val default_proof: Toplevel.transition -> Toplevel.transition |
|
37 |
val immediate_proof: Toplevel.transition -> Toplevel.transition |
|
38 |
val done_proof: Toplevel.transition -> Toplevel.transition |
|
39 |
val skip_proof: Toplevel.transition -> Toplevel.transition |
|
40 |
val begin_theory: string -> string list -> (string * bool) list -> bool -> theory |
|
41 |
val end_theory: theory -> theory |
|
42 |
val kill_theory: string -> unit |
|
43 |
val theory: string * string list * (string * bool) list |
|
44 |
-> Toplevel.transition -> Toplevel.transition |
|
7462 | 45 |
val welcome: Toplevel.transition -> Toplevel.transition |
46 |
val init_toplevel: Toplevel.transition -> Toplevel.transition |
|
5831 | 47 |
val exit: Toplevel.transition -> Toplevel.transition |
48 |
val quit: Toplevel.transition -> Toplevel.transition |
|
7908 | 49 |
val touch_child_thys: string -> Toplevel.transition -> Toplevel.transition |
7101 | 50 |
val touch_thy: string -> Toplevel.transition -> Toplevel.transition |
51 |
val remove_thy: string -> Toplevel.transition -> Toplevel.transition |
|
7931 | 52 |
val kill_thy: string -> Toplevel.transition -> Toplevel.transition |
9731 | 53 |
val pr: string list * (int option * int option) -> Toplevel.transition -> Toplevel.transition |
8453 | 54 |
val disable_pr: Toplevel.transition -> Toplevel.transition |
55 |
val enable_pr: Toplevel.transition -> Toplevel.transition |
|
6742 | 56 |
val redo: Toplevel.transition -> Toplevel.transition |
57 |
val undos_proof: int -> Toplevel.transition -> Toplevel.transition |
|
7936 | 58 |
val kill_proof_notify: (unit -> unit) -> Toplevel.transition -> Toplevel.transition |
6742 | 59 |
val kill_proof: Toplevel.transition -> Toplevel.transition |
60 |
val undo_theory: Toplevel.transition -> Toplevel.transition |
|
6686 | 61 |
val undo: Toplevel.transition -> Toplevel.transition |
21955 | 62 |
val cannot_undo: string -> Toplevel.transition -> Toplevel.transition |
8498 | 63 |
val kill: Toplevel.transition -> Toplevel.transition |
17066 | 64 |
val back: Toplevel.transition -> Toplevel.transition |
14950 | 65 |
val use: Path.T -> Toplevel.transition -> Toplevel.transition |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
66 |
val use_mltext_theory: string * Position.T -> Toplevel.transition -> Toplevel.transition |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
67 |
val use_mltext: bool -> string * Position.T -> Toplevel.transition -> Toplevel.transition |
5831 | 68 |
val use_commit: Toplevel.transition -> Toplevel.transition |
25793
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
69 |
val nested_command: Markup.property list -> string * Position.T -> Toplevel.transition |
14950 | 70 |
val cd: Path.T -> Toplevel.transition -> Toplevel.transition |
5831 | 71 |
val pwd: Toplevel.transition -> Toplevel.transition |
14950 | 72 |
val display_drafts: Path.T list -> Toplevel.transition -> Toplevel.transition |
73 |
val print_drafts: Path.T list -> Toplevel.transition -> Toplevel.transition |
|
7124 | 74 |
val pretty_setmargin: int -> Toplevel.transition -> Toplevel.transition |
7308 | 75 |
val print_context: Toplevel.transition -> Toplevel.transition |
20621 | 76 |
val print_theory: bool -> Toplevel.transition -> Toplevel.transition |
5831 | 77 |
val print_syntax: Toplevel.transition -> Toplevel.transition |
21725 | 78 |
val print_abbrevs: Toplevel.transition -> Toplevel.transition |
21003
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
79 |
val print_facts: Toplevel.transition -> Toplevel.transition |
24115 | 80 |
val print_configs: Toplevel.transition -> Toplevel.transition |
5880 | 81 |
val print_theorems: Toplevel.transition -> Toplevel.transition |
12060 | 82 |
val print_locales: Toplevel.transition -> Toplevel.transition |
18135 | 83 |
val print_locale: bool * (Locale.expr * Element.context list) |
12758 | 84 |
-> Toplevel.transition -> Toplevel.transition |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17066
diff
changeset
|
85 |
val print_registrations: bool -> string -> Toplevel.transition -> Toplevel.transition |
5831 | 86 |
val print_attributes: Toplevel.transition -> Toplevel.transition |
16026 | 87 |
val print_simpset: Toplevel.transition -> Toplevel.transition |
12382 | 88 |
val print_rules: Toplevel.transition -> Toplevel.transition |
9219 | 89 |
val print_trans_rules: Toplevel.transition -> Toplevel.transition |
5831 | 90 |
val print_methods: Toplevel.transition -> Toplevel.transition |
9219 | 91 |
val print_antiquotations: Toplevel.transition -> Toplevel.transition |
20574 | 92 |
val class_deps: Toplevel.transition -> Toplevel.transition |
22485 | 93 |
val thy_deps: Toplevel.transition -> Toplevel.transition |
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
26186
diff
changeset
|
94 |
val thm_deps: (Facts.ref * Attrib.src list) list -> Toplevel.transition -> Toplevel.transition |
22340
275802767bf3
Remove duplicates from printed theorems in find_theorems
kleing
parents:
22239
diff
changeset
|
95 |
val find_theorems: (int option * bool) * (bool * string FindTheorems.criterion) list |
13284 | 96 |
-> Toplevel.transition -> Toplevel.transition |
26184 | 97 |
val unused_thms: (string list * string list option) option -> |
98 |
Toplevel.transition -> Toplevel.transition |
|
5831 | 99 |
val print_binds: Toplevel.transition -> Toplevel.transition |
8369 | 100 |
val print_cases: Toplevel.transition -> Toplevel.transition |
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
26186
diff
changeset
|
101 |
val print_stmts: string list * (Facts.ref * Attrib.src list) list |
19268 | 102 |
-> Toplevel.transition -> Toplevel.transition |
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
26186
diff
changeset
|
103 |
val print_thms: string list * (Facts.ref * Attrib.src list) list |
10581 | 104 |
-> Toplevel.transition -> Toplevel.transition |
26336
a0e2b706ce73
renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents:
26186
diff
changeset
|
105 |
val print_prfs: bool -> string list * (Facts.ref * Attrib.src list) list option |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11017
diff
changeset
|
106 |
-> Toplevel.transition -> Toplevel.transition |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
107 |
val print_prop: (string list * string) -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
108 |
val print_term: (string list * string) -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
109 |
val print_type: (string list * string) -> Toplevel.transition -> Toplevel.transition |
12938
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
110 |
val add_header: string * Position.T -> Toplevel.transition -> Toplevel.transition |
17262
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
111 |
val add_chapter: xstring option * (string * Position.T) -> |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
112 |
Toplevel.transition -> Toplevel.transition |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
113 |
val add_section: xstring option * (string * Position.T) -> |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
114 |
Toplevel.transition -> Toplevel.transition |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
115 |
val add_subsection: xstring option * (string * Position.T) -> |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
116 |
Toplevel.transition -> Toplevel.transition |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
117 |
val add_subsubsection: xstring option * (string * Position.T) -> |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
118 |
Toplevel.transition -> Toplevel.transition |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
119 |
val add_text: xstring option * (string * Position.T) -> |
63cf42df2723
add_chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
120 |
Toplevel.transition -> Toplevel.transition |
12938
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
121 |
val add_text_raw: string * Position.T -> Toplevel.transition -> Toplevel.transition |
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
122 |
val add_sect: string * Position.T -> Toplevel.transition -> Toplevel.transition |
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
123 |
val add_subsect: string * Position.T -> Toplevel.transition -> Toplevel.transition |
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
124 |
val add_subsubsect: string * Position.T -> Toplevel.transition -> Toplevel.transition |
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
125 |
val add_txt: string * Position.T -> Toplevel.transition -> Toplevel.transition |
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
126 |
val add_txt_raw: string * Position.T -> Toplevel.transition -> Toplevel.transition |
5831 | 127 |
end; |
128 |
||
129 |
structure IsarCmd: ISAR_CMD = |
|
130 |
struct |
|
131 |
||
132 |
||
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
133 |
(** theory declarations **) |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
134 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
135 |
(* generic_setup *) |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
136 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
137 |
fun generic_setup NONE = (fn thy => thy |> Context.setup ()) |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
138 |
| generic_setup (SOME (txt, pos)) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
139 |
ML_Context.use_let pos "val setup: theory -> theory" "Context.map_theory setup" txt |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
140 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
141 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
142 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
143 |
(* translation functions *) |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
144 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
145 |
local |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
146 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
147 |
fun advancedT false = "" |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
148 |
| advancedT true = "Proof.context -> "; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
149 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
150 |
fun advancedN false = "" |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
151 |
| advancedN true = "advanced_"; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
152 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
153 |
in |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
154 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
155 |
fun parse_ast_translation (a, (txt, pos)) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
156 |
txt |> ML_Context.use_let pos ("val parse_ast_translation: (string * (" ^ advancedT a ^ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
157 |
"Syntax.ast list -> Syntax.ast)) list") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
158 |
("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns (parse_ast_translation, [], [], []))") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
159 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
160 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
161 |
fun parse_translation (a, (txt, pos)) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
162 |
txt |> ML_Context.use_let pos ("val parse_translation: (string * (" ^ advancedT a ^ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
163 |
"term list -> term)) list") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
164 |
("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], parse_translation, [], []))") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
165 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
166 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
167 |
fun print_translation (a, (txt, pos)) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
168 |
txt |> ML_Context.use_let pos ("val print_translation: (string * (" ^ advancedT a ^ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
169 |
"term list -> term)) list") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
170 |
("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], [], print_translation, []))") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
171 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
172 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
173 |
fun print_ast_translation (a, (txt, pos)) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
174 |
txt |> ML_Context.use_let pos ("val print_ast_translation: (string * (" ^ advancedT a ^ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
175 |
"Syntax.ast list -> Syntax.ast)) list") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
176 |
("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], [], [], print_ast_translation))") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
177 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
178 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
179 |
fun typed_print_translation (a, (txt, pos)) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
180 |
txt |> ML_Context.use_let pos ("val typed_print_translation: (string * (" ^ advancedT a ^ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
181 |
"bool -> typ -> term list -> term)) list") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
182 |
("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfunsT typed_print_translation)") |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
183 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
184 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
185 |
fun token_translation (txt, pos) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
186 |
txt |> ML_Context.use_let pos |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
187 |
"val token_translation: (string * string * (string -> output * int)) list" |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
188 |
"Context.map_theory (Sign.add_tokentrfuns token_translation)" |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
189 |
|> Context.theory_map; |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
190 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
191 |
end; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
192 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
193 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
194 |
(* oracles *) |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
195 |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
196 |
fun oracle name typ (oracle, pos) = |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
197 |
let val txt = |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
198 |
"local\ |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
199 |
\ type T = " ^ typ ^ ";\ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
200 |
\ val oracle: theory -> T -> term = " ^ oracle ^ ";\n\ |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
201 |
\ val name = " ^ quote name ^ ";\n\ |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
202 |
\ exception Arg of T;\n\ |
26415 | 203 |
\ val _ = Context.>> (Theory.add_oracle (name, fn (thy, Arg x) => oracle thy x));\n\ |
26425
6561665c5cb1
renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents:
26415
diff
changeset
|
204 |
\ val thy = ML_Context.the_global_context ();\n\ |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
205 |
\ val invoke_" ^ name ^ " = Thm.invoke_oracle_i thy (Sign.full_name thy name);\n\ |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
206 |
\in\n\ |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
207 |
\ fun " ^ name ^ " thy x = invoke_" ^ name ^ " (thy, Arg x);\n\ |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
208 |
\end;\n"; |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
209 |
in ML_Context.use_mltext_update false pos txt end |
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
210 |
|> Context.theory_map; |
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
211 |
|
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
212 |
|
21350 | 213 |
(* axioms *) |
214 |
||
215 |
fun add_axms f args thy = |
|
216 |
f (map (fn (x, srcs) => (x, map (Attrib.attribute thy) srcs)) args) thy; |
|
217 |
||
218 |
val add_axioms = add_axms (snd oo PureThy.add_axioms); |
|
219 |
||
220 |
fun add_defs ((unchecked, overloaded), args) = |
|
221 |
add_axms |
|
222 |
(snd oo (if unchecked then PureThy.add_defs_unchecked else PureThy.add_defs) overloaded) args; |
|
223 |
||
224 |
||
225 |
(* facts *) |
|
226 |
||
227 |
fun apply_theorems args thy = |
|
228 |
let val facts = Attrib.map_facts (Attrib.attribute thy) [(("", []), args)] |
|
229 |
in apfst (maps snd) (PureThy.note_thmss "" facts thy) end; |
|
230 |
||
231 |
fun apply_theorems_i args = apfst (maps snd) o PureThy.note_thmss_i "" [(("", []), args)]; |
|
232 |
||
233 |
||
22087 | 234 |
(* declarations *) |
235 |
||
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
236 |
fun declaration (txt, pos) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
237 |
txt |> ML_Context.use_let pos "val declaration: Morphism.declaration" |
24020 | 238 |
"Context.map_proof (LocalTheory.declaration declaration)" |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
239 |
|> Context.proof_map; |
22087 | 240 |
|
241 |
||
22202 | 242 |
(* simprocs *) |
243 |
||
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
244 |
fun simproc_setup name lhss (proc, pos) identifier = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
245 |
ML_Context.use_let pos |
22239 | 246 |
"val proc: Morphism.morphism -> Simplifier.simpset -> cterm -> thm option" |
247 |
("Context.map_proof (Simplifier.def_simproc {name = " ^ ML_Syntax.print_string name ^ ", \ |
|
248 |
\lhss = " ^ ML_Syntax.print_strings lhss ^ ", proc = proc, \ |
|
249 |
\identifier = Library.maps ML_Context.thms " ^ ML_Syntax.print_strings identifier ^ "})") proc |
|
22202 | 250 |
|> Context.proof_map; |
251 |
||
252 |
||
21350 | 253 |
(* goals *) |
254 |
||
255 |
fun goal opt_chain goal stmt int = |
|
256 |
opt_chain #> goal NONE (K Seq.single) stmt int; |
|
257 |
||
258 |
val have = goal I Proof.have; |
|
259 |
val hence = goal Proof.chain Proof.have; |
|
260 |
val show = goal I Proof.show; |
|
261 |
val thus = goal Proof.chain Proof.show; |
|
262 |
||
263 |
||
264 |
(* local endings *) |
|
265 |
||
266 |
fun local_qed m = Toplevel.proofs (Proof.local_qed (m, true)); |
|
267 |
val local_terminal_proof = Toplevel.proofs o Proof.local_terminal_proof; |
|
268 |
val local_default_proof = Toplevel.proofs Proof.local_default_proof; |
|
269 |
val local_immediate_proof = Toplevel.proofs Proof.local_immediate_proof; |
|
270 |
val local_done_proof = Toplevel.proofs Proof.local_done_proof; |
|
271 |
val local_skip_proof = Toplevel.proofs' Proof.local_skip_proof; |
|
272 |
||
273 |
val skip_local_qed = |
|
274 |
Toplevel.skip_proof (History.apply (fn i => if i > 1 then i - 1 else raise Toplevel.UNDEF)); |
|
275 |
||
276 |
||
277 |
(* global endings *) |
|
278 |
||
279 |
fun global_qed m = Toplevel.end_proof (K (Proof.global_qed (m, true))); |
|
280 |
val global_terminal_proof = Toplevel.end_proof o K o Proof.global_terminal_proof; |
|
281 |
val global_default_proof = Toplevel.end_proof (K Proof.global_default_proof); |
|
282 |
val global_immediate_proof = Toplevel.end_proof (K Proof.global_immediate_proof); |
|
283 |
val global_skip_proof = Toplevel.end_proof Proof.global_skip_proof; |
|
284 |
val global_done_proof = Toplevel.end_proof (K Proof.global_done_proof); |
|
285 |
||
286 |
val skip_global_qed = Toplevel.skip_proof_to_theory (equal 1); |
|
287 |
||
288 |
||
289 |
(* common endings *) |
|
290 |
||
291 |
fun qed m = local_qed m o global_qed m o skip_local_qed o skip_global_qed; |
|
292 |
fun terminal_proof m = local_terminal_proof m o global_terminal_proof m; |
|
293 |
val default_proof = local_default_proof o global_default_proof; |
|
294 |
val immediate_proof = local_immediate_proof o global_immediate_proof; |
|
295 |
val done_proof = local_done_proof o global_done_proof; |
|
296 |
val skip_proof = local_skip_proof o global_skip_proof; |
|
297 |
||
298 |
||
299 |
(* init and exit *) |
|
300 |
||
301 |
fun begin_theory name imports uses = |
|
23897 | 302 |
ThyInfo.begin_theory name imports (map (apfst Path.explode) uses); |
21350 | 303 |
|
21566 | 304 |
fun end_theory thy = |
305 |
if ThyInfo.check_known_thy (Context.theory_name thy) then ThyInfo.end_theory thy else thy; |
|
21350 | 306 |
|
307 |
val kill_theory = ThyInfo.if_known_thy ThyInfo.remove_thy; |
|
308 |
||
309 |
fun theory (name, imports, uses) = |
|
310 |
Toplevel.init_theory (begin_theory name imports uses) |
|
311 |
(fn thy => (end_theory thy; ())) |
|
312 |
(kill_theory o Context.theory_name); |
|
313 |
||
7462 | 314 |
val init_toplevel = Toplevel.imperative (fn () => raise Toplevel.RESTART); |
21350 | 315 |
|
7462 | 316 |
val welcome = Toplevel.imperative (writeln o Session.welcome); |
5831 | 317 |
|
318 |
val exit = Toplevel.keep (fn state => |
|
26415 | 319 |
(CRITICAL (fn () => Context.set_thread_data (try Toplevel.generic_theory_of state)); |
24071 | 320 |
raise Toplevel.TERMINATE)); |
5831 | 321 |
|
322 |
val quit = Toplevel.imperative quit; |
|
323 |
||
7101 | 324 |
|
325 |
(* touch theories *) |
|
326 |
||
7908 | 327 |
fun touch_child_thys name = Toplevel.imperative (fn () => ThyInfo.touch_child_thys name); |
7101 | 328 |
fun touch_thy name = Toplevel.imperative (fn () => ThyInfo.touch_thy name); |
329 |
fun remove_thy name = Toplevel.imperative (fn () => ThyInfo.remove_thy name); |
|
21350 | 330 |
fun kill_thy name = Toplevel.imperative (fn () => kill_theory name); |
7101 | 331 |
|
5831 | 332 |
|
8453 | 333 |
(* print state *) |
334 |
||
15531 | 335 |
fun set_limit _ NONE = () |
336 |
| set_limit r (SOME n) = r := n; |
|
9731 | 337 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
338 |
fun pr (modes, (lim1, lim2)) = Toplevel.keep (fn state => |
9731 | 339 |
(set_limit goals_limit lim1; set_limit ProofContext.prems_limit lim2; Toplevel.quiet := false; |
23935 | 340 |
PrintMode.with_modes modes (Toplevel.print_state true) state)); |
8453 | 341 |
|
342 |
val disable_pr = Toplevel.imperative (fn () => Toplevel.quiet := true); |
|
343 |
val enable_pr = Toplevel.imperative (fn () => Toplevel.quiet := false); |
|
344 |
||
345 |
||
6686 | 346 |
(* history commands *) |
347 |
||
16812 | 348 |
val redo = |
349 |
Toplevel.history History.redo o |
|
350 |
Toplevel.actual_proof ProofHistory.redo o |
|
15237
250e9be7a09d
Some changes to allow skipping of proof scripts.
berghofe
parents:
15222
diff
changeset
|
351 |
Toplevel.skip_proof History.redo; |
6686 | 352 |
|
16812 | 353 |
fun undos_proof n = |
354 |
Toplevel.actual_proof (fn prf => |
|
15237
250e9be7a09d
Some changes to allow skipping of proof scripts.
berghofe
parents:
15222
diff
changeset
|
355 |
if ProofHistory.is_initial prf then raise Toplevel.UNDEF else funpow n ProofHistory.undo prf) o |
250e9be7a09d
Some changes to allow skipping of proof scripts.
berghofe
parents:
15222
diff
changeset
|
356 |
Toplevel.skip_proof (fn h => |
250e9be7a09d
Some changes to allow skipping of proof scripts.
berghofe
parents:
15222
diff
changeset
|
357 |
if History.is_initial h then raise Toplevel.UNDEF else funpow n History.undo h); |
6686 | 358 |
|
7936 | 359 |
fun kill_proof_notify (f: unit -> unit) = Toplevel.history (fn hist => |
18588 | 360 |
if is_some (Toplevel.theory_node (History.current hist)) then raise Toplevel.UNDEF |
361 |
else (f (); History.undo hist)); |
|
7936 | 362 |
|
363 |
val kill_proof = kill_proof_notify (K ()); |
|
6686 | 364 |
|
6742 | 365 |
val undo_theory = Toplevel.history (fn hist => |
366 |
if History.is_initial hist then raise Toplevel.UNDEF else History.undo hist); |
|
6686 | 367 |
|
23500 | 368 |
val undo = Toplevel.kill o undo_theory o Toplevel.undo_exit o undos_proof 1; |
21955 | 369 |
|
370 |
fun cannot_undo "end" = undo (*ProofGeneral legacy*) |
|
371 |
| cannot_undo txt = Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt)); |
|
372 |
||
21003
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
373 |
val kill = Toplevel.kill o kill_proof; |
17899 | 374 |
|
375 |
val back = |
|
376 |
Toplevel.actual_proof ProofHistory.back o |
|
377 |
Toplevel.skip_proof (History.apply I); |
|
9273 | 378 |
|
6686 | 379 |
|
5831 | 380 |
(* use ML text *) |
381 |
||
16045 | 382 |
fun use path = Toplevel.keep (fn state => |
26415 | 383 |
Context.setmp_thread_data (try Toplevel.generic_theory_of state) (ThyInfo.load_file false) path); |
5831 | 384 |
|
385 |
(*passes changes of theory context*) |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
386 |
fun use_mltext_theory (txt, pos) = |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
387 |
Toplevel.theory' (fn int => Context.theory_map (ML_Context.use_mltext_update int pos txt)); |
5831 | 388 |
|
389 |
(*ignore result theory context*) |
|
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
390 |
fun use_mltext verbose (txt, pos) = Toplevel.keep' (fn int => fn state => |
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26336
diff
changeset
|
391 |
(ML_Context.use_mltext (verbose andalso int) pos txt (try Toplevel.generic_theory_of state))); |
5831 | 392 |
|
20927 | 393 |
val use_commit = Toplevel.imperative Secure.commit; |
5831 | 394 |
|
395 |
||
25793
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
396 |
(* nested commands *) |
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
397 |
|
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
398 |
fun nested_command props (str, pos) = |
26053 | 399 |
let val pos' = Position.of_properties (props |> Position.default_properties pos) in |
25793
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
400 |
(case OuterSyntax.parse pos' str of |
25956 | 401 |
[transition] => transition |
25793
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
402 |
| _ => error "exactly one command expected") |
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
403 |
end; |
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
404 |
|
6c2adbf41c7c
added nested_command (with explicit position argument via properties);
wenzelm
parents:
25331
diff
changeset
|
405 |
|
5831 | 406 |
(* current working directory *) |
407 |
||
14950 | 408 |
fun cd path = Toplevel.imperative (fn () => (File.cd path)); |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
21725
diff
changeset
|
409 |
val pwd = Toplevel.imperative (fn () => writeln (Path.implode (File.pwd ()))); |
5831 | 410 |
|
411 |
||
14934 | 412 |
(* present draft files *) |
413 |
||
414 |
fun display_drafts files = Toplevel.imperative (fn () => |
|
16258 | 415 |
let val outfile = File.shell_path (Present.drafts (getenv "ISABELLE_DOC_FORMAT") files) |
416 |
in File.isatool ("display -c " ^ outfile ^ " &"); () end); |
|
14934 | 417 |
|
418 |
fun print_drafts files = Toplevel.imperative (fn () => |
|
16258 | 419 |
let val outfile = File.shell_path (Present.drafts "ps" files) |
420 |
in File.isatool ("print -c " ^ outfile); () end); |
|
14934 | 421 |
|
422 |
||
7124 | 423 |
(* pretty_setmargin *) |
424 |
||
425 |
fun pretty_setmargin n = Toplevel.imperative (fn () => Pretty.setmargin n); |
|
5831 | 426 |
|
427 |
||
9513 | 428 |
(* print parts of theory and proof context *) |
5831 | 429 |
|
7308 | 430 |
val print_context = Toplevel.keep Toplevel.print_state_context; |
9513 | 431 |
|
20621 | 432 |
fun print_theory verbose = Toplevel.unknown_theory o |
22872 | 433 |
Toplevel.keep (Pretty.writeln o ProofDisplay.pretty_full_theory verbose o Toplevel.theory_of); |
9513 | 434 |
|
21663 | 435 |
val print_syntax = Toplevel.unknown_context o |
436 |
Toplevel.keep (ProofContext.print_syntax o Toplevel.context_of); |
|
9513 | 437 |
|
21725 | 438 |
val print_abbrevs = Toplevel.unknown_context o |
439 |
Toplevel.keep (ProofContext.print_abbrevs o Toplevel.context_of); |
|
440 |
||
21003
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
441 |
val print_facts = Toplevel.unknown_context o Toplevel.keep (fn state => |
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
442 |
ProofContext.setmp_verbose |
21506 | 443 |
ProofContext.print_lthms (Toplevel.context_of state)); |
21003
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
444 |
|
24115 | 445 |
val print_configs = Toplevel.unknown_context o Toplevel.keep (fn state => |
446 |
Attrib.print_configs (Toplevel.context_of state)); |
|
23989 | 447 |
|
17066 | 448 |
val print_theorems_proof = Toplevel.keep (fn state => |
449 |
ProofContext.setmp_verbose |
|
450 |
ProofContext.print_lthms (Proof.context_of (Toplevel.proof_of state))); |
|
451 |
||
18588 | 452 |
val print_theorems_theory = Toplevel.keep (fn state => |
453 |
Toplevel.theory_of state |> |
|
454 |
(case Option.map Toplevel.theory_node (History.previous (Toplevel.node_history_of state)) of |
|
20957 | 455 |
SOME (SOME prev_thy) => ProofDisplay.print_theorems_diff (Context.theory_of prev_thy) |
19430 | 456 |
| _ => ProofDisplay.print_theorems)); |
18588 | 457 |
|
21663 | 458 |
val print_theorems = Toplevel.unknown_context o print_theorems_theory o print_theorems_proof; |
9513 | 459 |
|
12060 | 460 |
val print_locales = Toplevel.unknown_theory o |
461 |
Toplevel.keep (Locale.print_locales o Toplevel.theory_of); |
|
462 |
||
22573 | 463 |
fun print_locale (show_facts, (imports, body)) = Toplevel.unknown_theory o |
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
464 |
Toplevel.keep (fn state => |
22573 | 465 |
Locale.print_locale (Toplevel.theory_of state) show_facts imports body); |
15596 | 466 |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17066
diff
changeset
|
467 |
fun print_registrations show_wits name = Toplevel.unknown_context o |
20957 | 468 |
Toplevel.keep (Toplevel.node_case |
24789
33b7fbc07361
Simplified interface for printing of interpretations.
ballarin
parents:
24560
diff
changeset
|
469 |
(Context.cases (Locale.print_registrations show_wits name o ProofContext.init) |
33b7fbc07361
Simplified interface for printing of interpretations.
ballarin
parents:
24560
diff
changeset
|
470 |
(Locale.print_registrations show_wits name)) |
33b7fbc07361
Simplified interface for printing of interpretations.
ballarin
parents:
24560
diff
changeset
|
471 |
(Locale.print_registrations show_wits name o Proof.context_of)); |
12060 | 472 |
|
9513 | 473 |
val print_attributes = Toplevel.unknown_theory o |
474 |
Toplevel.keep (Attrib.print_attributes o Toplevel.theory_of); |
|
475 |
||
16026 | 476 |
val print_simpset = Toplevel.unknown_context o |
20957 | 477 |
Toplevel.keep (Toplevel.node_case |
478 |
(Context.cases Simplifier.print_simpset Simplifier.print_local_simpset) |
|
16026 | 479 |
(Simplifier.print_local_simpset o Proof.context_of)); |
480 |
||
12382 | 481 |
val print_rules = Toplevel.unknown_context o |
18639 | 482 |
Toplevel.keep (ContextRules.print_rules o Toplevel.context_of); |
12382 | 483 |
|
9513 | 484 |
val print_trans_rules = Toplevel.unknown_context o |
18639 | 485 |
Toplevel.keep (Calculation.print_rules o Toplevel.context_of); |
9513 | 486 |
|
487 |
val print_methods = Toplevel.unknown_theory o |
|
488 |
Toplevel.keep (Method.print_methods o Toplevel.theory_of); |
|
489 |
||
22116
6917be2e647d
added various ML setup functions (from sign.ML, pure_thy.ML);
wenzelm
parents:
22087
diff
changeset
|
490 |
val print_antiquotations = Toplevel.imperative ThyOutput.print_antiquotations; |
5831 | 491 |
|
22485 | 492 |
val thy_deps = Toplevel.unknown_theory o Toplevel.keep (fn state => |
493 |
let |
|
494 |
val thy = Toplevel.theory_of state; |
|
24560
2693220bd77f
thy_deps: ThyInfo.thy_ord, improved dir/unfold entry;
wenzelm
parents:
24508
diff
changeset
|
495 |
val all_thys = sort ThyInfo.thy_ord (thy :: Theory.ancestors_of thy); |
22604 | 496 |
val gr = all_thys |> map (fn node => |
22602
a165d9ed08b8
simplified thy_deps using Theory.ancestors_of (in order of creation);
wenzelm
parents:
22573
diff
changeset
|
497 |
let |
a165d9ed08b8
simplified thy_deps using Theory.ancestors_of (in order of creation);
wenzelm
parents:
22573
diff
changeset
|
498 |
val name = Context.theory_name node; |
a165d9ed08b8
simplified thy_deps using Theory.ancestors_of (in order of creation);
wenzelm
parents:
22573
diff
changeset
|
499 |
val parents = map Context.theory_name (Theory.parents_of node); |
24560
2693220bd77f
thy_deps: ThyInfo.thy_ord, improved dir/unfold entry;
wenzelm
parents:
24508
diff
changeset
|
500 |
val dir = Present.session_name node; |
2693220bd77f
thy_deps: ThyInfo.thy_ord, improved dir/unfold entry;
wenzelm
parents:
24508
diff
changeset
|
501 |
val unfold = not (ThyInfo.known_thy name andalso ThyInfo.is_finished name); |
2693220bd77f
thy_deps: ThyInfo.thy_ord, improved dir/unfold entry;
wenzelm
parents:
24508
diff
changeset
|
502 |
in {name = name, ID = name, parents = parents, dir = dir, unfold = unfold, path = ""} end); |
22602
a165d9ed08b8
simplified thy_deps using Theory.ancestors_of (in order of creation);
wenzelm
parents:
22573
diff
changeset
|
503 |
in Present.display_graph gr end); |
22485 | 504 |
|
20574 | 505 |
val class_deps = Toplevel.unknown_theory o Toplevel.keep (fn state => |
506 |
let |
|
507 |
val thy = Toplevel.theory_of state; |
|
508 |
val {classes = (space, algebra), ...} = Type.rep_tsig (Sign.tsig_of thy); |
|
509 |
val {classes, ...} = Sorts.rep_algebra algebra; |
|
510 |
fun entry (c, (i, (_, cs))) = |
|
511 |
(i, {name = NameSpace.extern space c, ID = c, parents = cs, |
|
512 |
dir = "", unfold = true, path = ""}); |
|
513 |
val gr = |
|
514 |
Graph.fold (cons o entry) classes [] |
|
515 |
|> sort (int_ord o pairself #1) |> map #2; |
|
516 |
in Present.display_graph gr end); |
|
517 |
||
15964
f2074e12d1d4
searching for thms by combination of criteria (intro, elim, dest, name, term pattern)
kleing
parents:
15799
diff
changeset
|
518 |
|
16026 | 519 |
(* retrieve theorems *) |
7615 | 520 |
|
9513 | 521 |
fun thm_deps args = Toplevel.unknown_theory o Toplevel.keep (fn state => |
21003
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
522 |
ThmDeps.thm_deps (Proof.get_thmss (Toplevel.enter_proof_body state) args)); |
9454 | 523 |
|
24560
2693220bd77f
thy_deps: ThyInfo.thy_ord, improved dir/unfold entry;
wenzelm
parents:
24508
diff
changeset
|
524 |
fun find_theorems ((opt_lim, rem_dups), spec) = |
22340
275802767bf3
Remove duplicates from printed theorems in find_theorems
kleing
parents:
22239
diff
changeset
|
525 |
Toplevel.unknown_theory o Toplevel.keep (fn state => |
16026 | 526 |
let |
21003
37492b0062c6
renamed print_lthms to print_facts, do not insist on proof state;
wenzelm
parents:
20978
diff
changeset
|
527 |
val proof_state = Toplevel.enter_proof_body state; |
16026 | 528 |
val ctxt = Proof.context_of proof_state; |
529 |
val opt_goal = try Proof.get_goal proof_state |> Option.map (Thm.prop_of o #2 o #2); |
|
22340
275802767bf3
Remove duplicates from printed theorems in find_theorems
kleing
parents:
22239
diff
changeset
|
530 |
in FindTheorems.print_theorems ctxt opt_goal opt_lim rem_dups spec end); |
16026 | 531 |
|
5831 | 532 |
|
26184 | 533 |
(* find unused theorems *) |
534 |
||
26186
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
535 |
fun unused_thms opt_range = Toplevel.keep (fn state => |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
536 |
let |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
537 |
val thy = Toplevel.theory_of state; |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
538 |
val ctxt = Toplevel.context_of state; |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
539 |
fun pretty_thm (a, th) = ProofContext.pretty_fact ctxt (a, [th]); |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
540 |
in |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
541 |
ThmDeps.unused_thms |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
542 |
(case opt_range of |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
543 |
NONE => (NONE, [thy]) |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
544 |
| SOME (xs, NONE) => (SOME (map ThyInfo.get_theory xs), [thy]) |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
545 |
| SOME (xs, SOME ys) => (SOME (map ThyInfo.get_theory xs), map ThyInfo.get_theory ys)) |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
546 |
|> map pretty_thm |> Pretty.chunks |> Pretty.writeln |
9af968b694d9
unused_thms: print via official context (ProofContext.pretty_fact),
wenzelm
parents:
26184
diff
changeset
|
547 |
end); |
26184 | 548 |
|
549 |
||
5831 | 550 |
(* print proof context contents *) |
551 |
||
21663 | 552 |
val print_binds = Toplevel.unknown_context o Toplevel.keep (fn state => |
553 |
ProofContext.setmp_verbose ProofContext.print_binds (Toplevel.context_of state)); |
|
9513 | 554 |
|
21663 | 555 |
val print_cases = Toplevel.unknown_context o Toplevel.keep (fn state => |
556 |
ProofContext.setmp_verbose ProofContext.print_cases (Toplevel.context_of state)); |
|
5831 | 557 |
|
558 |
||
19268 | 559 |
(* print theorems, terms, types etc. *) |
560 |
||
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
561 |
local |
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
562 |
|
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
563 |
fun string_of_stmts state args = |
19268 | 564 |
Proof.get_thmss state args |
21437 | 565 |
|> map (Element.pretty_statement (Proof.context_of state) Thm.theoremK) |
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
566 |
|> Pretty.chunks2 |> Pretty.string_of; |
5880 | 567 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
568 |
fun string_of_thms state args = |
12055 | 569 |
Pretty.string_of (ProofContext.pretty_thms (Proof.context_of state) |
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
570 |
(Proof.get_thmss state args)); |
5895 | 571 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
572 |
fun string_of_prfs full state arg = |
17066 | 573 |
Pretty.string_of (case arg of |
15531 | 574 |
NONE => |
12125
316d11f760f7
Commands prf and full_prf can now also be used to display proof term
berghofe
parents:
12069
diff
changeset
|
575 |
let |
17066 | 576 |
val (ctxt, (_, thm)) = Proof.get_goal state; |
577 |
val {thy, der = (_, prf), ...} = Thm.rep_thm thm; |
|
578 |
val prop = Thm.full_prop_of thm; |
|
12125
316d11f760f7
Commands prf and full_prf can now also be used to display proof term
berghofe
parents:
12069
diff
changeset
|
579 |
val prf' = Proofterm.rewrite_proof_notypes ([], []) prf |
316d11f760f7
Commands prf and full_prf can now also be used to display proof term
berghofe
parents:
12069
diff
changeset
|
580 |
in |
17066 | 581 |
ProofContext.pretty_proof ctxt |
582 |
(if full then Reconstruct.reconstruct_proof thy prop prf' else prf') |
|
12125
316d11f760f7
Commands prf and full_prf can now also be used to display proof term
berghofe
parents:
12069
diff
changeset
|
583 |
end |
15531 | 584 |
| SOME args => Pretty.chunks |
17066 | 585 |
(map (ProofContext.pretty_proof_of (Proof.context_of state) full) |
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
586 |
(Proof.get_thmss state args))); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11017
diff
changeset
|
587 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
588 |
fun string_of_prop state s = |
5831 | 589 |
let |
12055 | 590 |
val ctxt = Proof.context_of state; |
24508
c8b82fec6447
replaced ProofContext.read_term/prop by general Syntax.read_term/prop;
wenzelm
parents:
24314
diff
changeset
|
591 |
val prop = Syntax.read_prop ctxt s; |
24920 | 592 |
in Pretty.string_of (Pretty.quote (Syntax.pretty_term ctxt prop)) end; |
5831 | 593 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
594 |
fun string_of_term state s = |
5831 | 595 |
let |
12055 | 596 |
val ctxt = Proof.context_of state; |
24508
c8b82fec6447
replaced ProofContext.read_term/prop by general Syntax.read_term/prop;
wenzelm
parents:
24314
diff
changeset
|
597 |
val t = Syntax.read_term ctxt s; |
5831 | 598 |
val T = Term.type_of t; |
599 |
in |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
600 |
Pretty.string_of |
24920 | 601 |
(Pretty.block [Pretty.quote (Syntax.pretty_term ctxt t), Pretty.fbrk, |
602 |
Pretty.str "::", Pretty.brk 1, Pretty.quote (Syntax.pretty_typ ctxt T)]) |
|
9128 | 603 |
end; |
5831 | 604 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
605 |
fun string_of_type state s = |
5831 | 606 |
let |
12055 | 607 |
val ctxt = Proof.context_of state; |
25331 | 608 |
val T = Syntax.read_typ ctxt s; |
24920 | 609 |
in Pretty.string_of (Pretty.quote (Syntax.pretty_typ ctxt T)) end; |
9128 | 610 |
|
23935 | 611 |
fun print_item string_of (modes, arg) = Toplevel.keep (fn state => |
612 |
PrintMode.with_modes modes (fn () => |
|
613 |
writeln (string_of (Toplevel.enter_proof_body state) arg)) ()); |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
614 |
|
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
615 |
in |
9128 | 616 |
|
19268 | 617 |
val print_stmts = print_item string_of_stmts; |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
618 |
val print_thms = print_item string_of_thms; |
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
619 |
val print_prfs = print_item o string_of_prfs; |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
620 |
val print_prop = print_item string_of_prop; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
621 |
val print_term = print_item string_of_term; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12758
diff
changeset
|
622 |
val print_type = print_item string_of_type; |
5831 | 623 |
|
19385
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
624 |
end; |
c0f2f8224ea8
print_term etc.: actually observe print mode in final output;
wenzelm
parents:
19268
diff
changeset
|
625 |
|
12938
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
626 |
|
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
627 |
(* markup commands *) |
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
628 |
|
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
629 |
fun add_header s = Toplevel.keep' (fn int => fn state => |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
21725
diff
changeset
|
630 |
(if Toplevel.is_toplevel state then () else raise Toplevel.UNDEF; |
19057 | 631 |
if int then OuterSyntax.check_text s NONE else ())); |
12938
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
632 |
|
12953
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
633 |
local |
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
634 |
|
19057 | 635 |
fun present _ txt true node = OuterSyntax.check_text txt (SOME node) |
26415 | 636 |
| present f (s, _) false node = Context.setmp_thread_data |
637 |
(try (Toplevel.cases_node I (Context.Proof o Proof.context_of)) node) f s; |
|
12953
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
638 |
|
19057 | 639 |
fun present_local_theory f (loc, txt) = Toplevel.present_local_theory loc (present f txt); |
640 |
fun present_proof f txt = Toplevel.print o Toplevel.present_proof (present f txt); |
|
12938
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
641 |
|
12953
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
642 |
in |
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
643 |
|
19057 | 644 |
val add_chapter = present_local_theory Present.section; |
645 |
val add_section = present_local_theory Present.section; |
|
646 |
val add_subsection = present_local_theory Present.subsection; |
|
647 |
val add_subsubsection = present_local_theory Present.subsubsection; |
|
648 |
val add_text = present_local_theory (K ()); |
|
649 |
fun add_text_raw txt = present_local_theory (K ()) (NONE, txt); |
|
650 |
val add_txt = present_proof (K ()); |
|
651 |
val add_txt_raw = add_txt; |
|
652 |
val add_sect = add_txt; |
|
653 |
val add_subsect = add_txt; |
|
654 |
val add_subsubsect = add_txt; |
|
12938
a646d0467d81
markup commands (from isar_thy.ML) with proper check of antiquotations;
wenzelm
parents:
12876
diff
changeset
|
655 |
|
5831 | 656 |
end; |
12953
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
657 |
|
7d5bd53555d8
markup commands: proper theory/proof transactions!
wenzelm
parents:
12938
diff
changeset
|
658 |
end; |