author | wenzelm |
Fri, 21 May 2004 21:20:14 +0200 | |
changeset 14778 | 69cafc301399 |
parent 14649 | 8ad41d25c152 |
child 14836 | ba0fc27a6c7e |
permissions | -rw-r--r-- |
5830 | 1 |
(* Title: Pure/Isar/isar_thy.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
8804 | 4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
5830 | 5 |
|
6371 | 6 |
Pure/Isar derived theory operations. |
5830 | 7 |
*) |
8 |
||
9 |
signature ISAR_THY = |
|
10 |
sig |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
11 |
val hide_space: string * xstring list -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
12 |
val hide_space_i: string * string list -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
13 |
val add_axioms: ((bstring * string) * Args.src list) list -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
14 |
val add_axioms_i: ((bstring * term) * theory attribute list) list -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
15 |
val add_defs: bool * ((bstring * string) * Args.src list) list -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
16 |
val add_defs_i: bool * ((bstring * term) * theory attribute list) list -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
17 |
val theorems: string -> ((bstring * Args.src list) * (xstring * Args.src list) list) list |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
18 |
-> theory -> theory * (string * thm list) list |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
19 |
val theorems_i: string -> |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
20 |
((bstring * theory attribute list) * (thm list * theory attribute list) list) list |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
21 |
-> theory -> theory * (string * thm list) list |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
22 |
val locale_theorems: string -> xstring -> |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
23 |
((bstring * Args.src list) * (xstring * Args.src list) list) list |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
24 |
-> theory -> theory * (bstring * thm list) list |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
25 |
val locale_theorems_i: string -> string -> |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
26 |
((bstring * Proof.context attribute list) |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
27 |
* (thm list * Proof.context attribute list) list) list |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
28 |
-> theory -> theory * (string * thm list) list |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
29 |
val smart_theorems: string -> xstring option -> |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
30 |
((bstring * Args.src list) * (xstring * Args.src list) list) list |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
31 |
-> theory -> theory * (string * thm list) list |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
32 |
val declare_theorems: xstring option -> (xstring * Args.src list) list -> theory -> theory |
6371 | 33 |
val apply_theorems: (xstring * Args.src list) list -> theory -> theory * thm list |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
34 |
val apply_theorems_i: (thm list * theory attribute list) list -> theory -> theory * thm list |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
35 |
val have_facts: ((string * Args.src list) * (string * Args.src list) list) list |
10464 | 36 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
37 |
val have_facts_i: ((string * Proof.context attribute list) * |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
38 |
(thm * Proof.context attribute list) list) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
39 |
val from_facts: (string * Args.src list) list list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
40 |
val from_facts_i: (thm * Proof.context attribute list) list list |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
41 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
42 |
val with_facts: (string * Args.src list) list list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
43 |
val with_facts_i: (thm * Proof.context attribute list) list list |
6879 | 44 |
-> ProofHistory.T -> ProofHistory.T |
12929 | 45 |
val using_facts: (string * Args.src list) list list -> ProofHistory.T -> ProofHistory.T |
46 |
val using_facts_i: (thm * Proof.context attribute list) list list |
|
47 |
-> ProofHistory.T -> ProofHistory.T |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
48 |
val chain: ProofHistory.T -> ProofHistory.T |
14528
1457584110ac
Locale instantiation: label parameter optional, new attribute paramter.
ballarin
parents:
14508
diff
changeset
|
49 |
val instantiate_locale: (string * Args.src list) * string -> ProofHistory.T |
1457584110ac
Locale instantiation: label parameter optional, new attribute paramter.
ballarin
parents:
14508
diff
changeset
|
50 |
-> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
51 |
val fix: (string list * string option) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
52 |
val fix_i: (string list * typ option) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
53 |
val let_bind: (string list * string) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
54 |
val let_bind_i: (term list * term) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
55 |
val invoke_case: string * string option list * Args.src list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
56 |
val invoke_case_i: string * string option list * Proof.context attribute list |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11764
diff
changeset
|
57 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
58 |
val theorem: string -> (bstring * Args.src list) * (string * (string list * string list)) |
12141 | 59 |
-> bool -> theory -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
60 |
val theorem_i: string -> (bstring * theory attribute list) * |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
61 |
(term * (term list * term list)) -> bool -> theory -> ProofHistory.T |
12957 | 62 |
val multi_theorem: string -> bstring * Args.src list |
63 |
-> Args.src Locale.element list |
|
64 |
-> ((bstring * Args.src list) * (string * (string list * string list)) list) list |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
65 |
-> bool -> theory -> ProofHistory.T |
12957 | 66 |
val multi_theorem_i: string -> bstring * theory attribute list |
67 |
-> Proof.context attribute Locale.element_i list |
|
68 |
-> ((bstring * theory attribute list) * (term * (term list * term list)) list) list |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
69 |
-> bool -> theory -> ProofHistory.T |
12957 | 70 |
val locale_multi_theorem: string -> xstring |
71 |
-> bstring * Args.src list -> Args.src Locale.element list |
|
72 |
-> ((bstring * Args.src list) * (string * (string list * string list)) list) list |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
73 |
-> bool -> theory -> ProofHistory.T |
12957 | 74 |
val locale_multi_theorem_i: string -> string -> bstring * Proof.context attribute list |
75 |
-> Proof.context attribute Locale.element_i list |
|
76 |
-> ((bstring * Proof.context attribute list) * (term * (term list * term list)) list) list |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
77 |
-> bool -> theory -> ProofHistory.T |
12957 | 78 |
val smart_multi_theorem: string -> xstring Library.option |
79 |
-> bstring * Args.src list -> Args.src Locale.element list |
|
80 |
-> ((bstring * Args.src list) * (string * (string list * string list)) list) list |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
81 |
-> bool -> theory -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
82 |
val assume: ((string * Args.src list) * (string * (string list * string list)) list) list |
12141 | 83 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
84 |
val assume_i: |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
85 |
((string * Proof.context attribute list) * (term * (term list * term list)) list) list |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
86 |
-> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
87 |
val presume: ((string * Args.src list) * (string * (string list * string list)) list) list |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
88 |
-> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
89 |
val presume_i: |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
90 |
((string * Proof.context attribute list) * (term * (term list * term list)) list) list |
12141 | 91 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
92 |
val have: ((string * Args.src list) * (string * (string list * string list)) list) list |
12141 | 93 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
94 |
val have_i: ((string * Proof.context attribute list) * |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
95 |
(term * (term list * term list)) list) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
96 |
val hence: ((string * Args.src list) * (string * (string list * string list)) list) list |
12141 | 97 |
-> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
98 |
val hence_i: ((string * Proof.context attribute list) * |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
99 |
(term * (term list * term list)) list) list -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
100 |
val show: ((string * Args.src list) * (string * (string list * string list)) list) list |
12141 | 101 |
-> bool -> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
102 |
val show_i: ((string * Proof.context attribute list) * |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
103 |
(term * (term list * term list)) list) list -> bool -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
104 |
val thus: ((string * Args.src list) * (string * (string list * string list)) list) list |
12141 | 105 |
-> bool -> ProofHistory.T -> ProofHistory.T |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
106 |
val thus_i: ((string * Proof.context attribute list) |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
107 |
* (term * (term list * term list)) list) list -> bool -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
108 |
val local_def: (string * Args.src list) * (string * (string * string list)) |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
109 |
-> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
110 |
val local_def_i: (string * Args.src list) * (string * (term * term list)) |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
111 |
-> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
112 |
val obtain: (string list * string option) list |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
113 |
* ((string * Args.src list) * (string * (string list * string list)) list) list |
12969 | 114 |
-> Toplevel.transition -> Toplevel.transition |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
115 |
val obtain_i: (string list * typ option) list |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
116 |
* ((string * Proof.context attribute list) * (term * (term list * term list)) list) list |
12969 | 117 |
-> Toplevel.transition -> Toplevel.transition |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
118 |
val begin_block: ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
119 |
val next_block: ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
120 |
val end_block: ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
121 |
val defer: int option -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
122 |
val prefer: int -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
123 |
val apply: Method.text -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
124 |
val apply_end: Method.text -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
125 |
val proof: Method.text option -> ProofHistory.T -> ProofHistory.T |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
126 |
val qed: Method.text option -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
127 |
val terminal_proof: Method.text * Method.text option |
6937 | 128 |
-> Toplevel.transition -> Toplevel.transition |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
129 |
val default_proof: Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
130 |
val immediate_proof: Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
131 |
val done_proof: Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
132 |
val skip_proof: Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
133 |
val forget_proof: Toplevel.transition -> Toplevel.transition |
7012 | 134 |
val get_thmss: (string * Args.src list) list -> Proof.state -> thm list |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
135 |
val also: (string * Args.src list) list option -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
136 |
val also_i: thm list option -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
137 |
val finally: (string * Args.src list) list option -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
138 |
val finally_i: thm list option -> Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
139 |
val moreover: Toplevel.transition -> Toplevel.transition |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
140 |
val ultimately: Toplevel.transition -> Toplevel.transition |
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
141 |
val parse_ast_translation: bool * string -> theory -> theory |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
142 |
val parse_translation: bool * string -> theory -> theory |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
143 |
val print_translation: bool * string -> theory -> theory |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
144 |
val typed_print_translation: bool * string -> theory -> theory |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
145 |
val print_ast_translation: bool * string -> theory -> theory |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
146 |
val token_translation: string -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
147 |
val method_setup: bstring * string * string -> theory -> theory |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
148 |
val add_oracle: bstring * string -> theory -> theory |
13393 | 149 |
val add_locale: bool * bstring * Locale.expr * Args.src Locale.element list -> theory -> theory |
6331 | 150 |
val begin_theory: string -> string list -> (string * bool) list -> theory |
151 |
val end_theory: theory -> theory |
|
7932 | 152 |
val kill_theory: string -> unit |
6246 | 153 |
val theory: string * string list * (string * bool) list |
154 |
-> Toplevel.transition -> Toplevel.transition |
|
7960 | 155 |
val init_context: ('a -> unit) -> 'a -> Toplevel.transition -> Toplevel.transition |
6246 | 156 |
val context: string -> Toplevel.transition -> Toplevel.transition |
5830 | 157 |
end; |
158 |
||
159 |
structure IsarThy: ISAR_THY = |
|
160 |
struct |
|
161 |
||
162 |
||
163 |
(** derived theory and proof operations **) |
|
164 |
||
8724 | 165 |
(* name spaces *) |
166 |
||
8885 | 167 |
local |
168 |
||
169 |
val kinds = |
|
10449
088aa7bd3154
hide_space(_i): use Sign.certify_tycon, Sign.certify_tyabbr, Sign.certify_const;
wenzelm
parents:
9903
diff
changeset
|
170 |
[(Sign.classK, can o Sign.certify_class), |
14778 | 171 |
(Sign.typeK, can o Sign.certify_tyname), |
10449
088aa7bd3154
hide_space(_i): use Sign.certify_tycon, Sign.certify_tyabbr, Sign.certify_const;
wenzelm
parents:
9903
diff
changeset
|
172 |
(Sign.constK, can o Sign.certify_const)]; |
8724 | 173 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
174 |
fun gen_hide intern (kind, xnames) thy = |
8885 | 175 |
(case assoc (kinds, kind) of |
176 |
Some check => |
|
177 |
let |
|
178 |
val sg = Theory.sign_of thy; |
|
179 |
val names = map (intern sg kind) xnames; |
|
180 |
val bads = filter_out (check sg) names; |
|
181 |
in |
|
12589 | 182 |
if null bads then Theory.hide_space_i true (kind, names) thy |
8885 | 183 |
else error ("Attempt to hide undeclared item(s): " ^ commas_quote bads) |
184 |
end |
|
185 |
| None => error ("Bad name space specification: " ^ quote kind)); |
|
186 |
||
187 |
in |
|
188 |
||
189 |
fun hide_space x = gen_hide Sign.intern x; |
|
190 |
fun hide_space_i x = gen_hide (K (K I)) x; |
|
191 |
||
192 |
end; |
|
8724 | 193 |
|
194 |
||
5830 | 195 |
(* axioms and defs *) |
196 |
||
5915 | 197 |
fun add_axms f args thy = |
198 |
f (map (fn (x, srcs) => (x, map (Attrib.global_attribute thy) srcs)) args) thy; |
|
199 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
200 |
val add_axioms = add_axms (#1 oo PureThy.add_axioms); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
201 |
val add_axioms_i = #1 oo PureThy.add_axioms_i; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
202 |
fun add_defs (x, args) = add_axms (#1 oo PureThy.add_defs x) args; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
203 |
fun add_defs_i (x, args) = (#1 oo PureThy.add_defs_i x) args; |
6371 | 204 |
|
205 |
||
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
206 |
(* attributes *) |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
207 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
208 |
local |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
209 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
210 |
fun prep_attribs f = map (fn ((name, more_srcs), th_srcs) => |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
211 |
((name, map f more_srcs), map (apsnd (map f)) th_srcs)); |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
212 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
213 |
in |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
214 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
215 |
fun global_attribs thy = prep_attribs (Attrib.global_attribute thy); |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
216 |
fun local_attribs thy = prep_attribs (Attrib.local_attribute thy); |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
217 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
218 |
end; |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
219 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
220 |
|
5915 | 221 |
(* theorems *) |
222 |
||
12705 | 223 |
local |
224 |
||
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
225 |
fun present_thmss kind (thy, named_thmss) = |
13529 | 226 |
(conditional (kind <> "" andalso kind <> Drule.internalK) (fn () => |
227 |
Context.setmp (Some thy) (Present.results (kind ^ "s")) named_thmss); |
|
228 |
(thy, named_thmss)); |
|
5915 | 229 |
|
12705 | 230 |
in |
231 |
||
14564 | 232 |
fun theorems_i k = present_thmss k oo PureThy.note_thmss_i (Drule.kind k); |
233 |
fun locale_theorems_i k loc = present_thmss k oo Locale.note_thmss_i k loc; |
|
5915 | 234 |
|
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
235 |
fun theorems k args thy = thy |
14564 | 236 |
|> PureThy.note_thmss (Drule.kind k) (global_attribs thy args) |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
237 |
|> present_thmss k; |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
238 |
|
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
239 |
fun locale_theorems k loc args thy = thy |
14564 | 240 |
|> Locale.note_thmss k loc (local_attribs thy args) |
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
241 |
|> present_thmss k; |
6371 | 242 |
|
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
243 |
fun smart_theorems k opt_loc args thy = thy |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
244 |
|> (case opt_loc of |
14564 | 245 |
None => PureThy.note_thmss (Drule.kind k) (global_attribs thy args) |
246 |
| Some loc => Locale.note_thmss k loc (local_attribs thy args)) |
|
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
247 |
|> present_thmss k; |
9590 | 248 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
249 |
fun declare_theorems opt_loc args = #1 o smart_theorems "" opt_loc [(("", []), args)]; |
9590 | 250 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
251 |
fun apply_theorems args = apsnd (flat o map snd) o theorems "" [(("", []), args)]; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
252 |
fun apply_theorems_i args = apsnd (flat o map snd) o theorems_i "" [(("", []), args)]; |
6371 | 253 |
|
12705 | 254 |
end; |
255 |
||
5915 | 256 |
|
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
257 |
(* facts and forward chaining *) |
6371 | 258 |
|
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
259 |
fun local_thmss f args state = f (local_attribs (Proof.theory_of state) args) state; |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
260 |
fun local_thmss_i f args = f (map (fn ((name, more_atts), th_atts) => |
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
261 |
((name, more_atts), map (apfst single) th_atts)) args); |
6371 | 262 |
|
12713
c9e3e34dbc45
clarified/added theorems(_i) vs. locale_theorems(_i);
wenzelm
parents:
12705
diff
changeset
|
263 |
fun chain_thmss f args = ProofHistory.apply (Proof.chain o f (map (pair ("", [])) args)); |
6879 | 264 |
|
14564 | 265 |
val have_facts = ProofHistory.apply o local_thmss Proof.note_thmss; |
266 |
val have_facts_i = ProofHistory.apply o local_thmss_i Proof.note_thmss_i; |
|
267 |
val from_facts = chain_thmss (local_thmss Proof.note_thmss); |
|
268 |
val from_facts_i = chain_thmss (local_thmss_i Proof.note_thmss_i); |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
269 |
val with_facts = chain_thmss (local_thmss Proof.with_thmss); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
270 |
val with_facts_i = chain_thmss (local_thmss_i Proof.with_thmss_i); |
12929 | 271 |
|
272 |
fun using_facts args = ProofHistory.apply (fn state => |
|
273 |
Proof.using_thmss (map (map (apsnd (map |
|
274 |
(Attrib.local_attribute (Proof.theory_of state))))) args) state); |
|
275 |
||
276 |
val using_facts_i = ProofHistory.apply o Proof.using_thmss_i o map (map (apfst single)); |
|
277 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
278 |
val chain = ProofHistory.apply Proof.chain; |
5830 | 279 |
|
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
280 |
|
14508
859b11514537
Experimental command for instantiation of locales in proof contexts:
ballarin
parents:
14503
diff
changeset
|
281 |
(* locale instantiation *) |
859b11514537
Experimental command for instantiation of locales in proof contexts:
ballarin
parents:
14503
diff
changeset
|
282 |
|
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
283 |
fun instantiate_locale ((name, atts), loc) = |
14528
1457584110ac
Locale instantiation: label parameter optional, new attribute paramter.
ballarin
parents:
14508
diff
changeset
|
284 |
ProofHistory.apply (fn state => |
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
285 |
Proof.instantiate_locale (loc, |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
286 |
(name, map (Attrib.local_attribute (Proof.theory_of state)) atts)) state); |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
287 |
|
5830 | 288 |
|
289 |
(* context *) |
|
290 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
291 |
val fix = ProofHistory.apply o Proof.fix; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
292 |
val fix_i = ProofHistory.apply o Proof.fix_i; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
293 |
val let_bind = ProofHistory.apply o Proof.let_bind; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
294 |
val let_bind_i = ProofHistory.apply o Proof.let_bind_i; |
8450 | 295 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
296 |
fun invoke_case (name, xs, src) = ProofHistory.apply (fn state => |
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
297 |
Proof.invoke_case (name, xs, |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
298 |
map (Attrib.local_attribute (Proof.theory_of state)) src) state); |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
299 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
300 |
val invoke_case_i = ProofHistory.apply o Proof.invoke_case; |
5830 | 301 |
|
302 |
||
10935 | 303 |
(* local results *) |
304 |
||
305 |
local |
|
306 |
||
12244 | 307 |
fun prt_facts ctxt = |
13276 | 308 |
flat o (separate [Pretty.fbrk, Pretty.str "and "]) o |
309 |
map (single o ProofContext.pretty_fact ctxt); |
|
12244 | 310 |
|
311 |
fun pretty_results ctxt ((kind, ""), facts) = |
|
312 |
Pretty.block (Pretty.str kind :: Pretty.brk 1 :: prt_facts ctxt facts) |
|
313 |
| pretty_results ctxt ((kind, name), facts) = Pretty.blk (1, |
|
314 |
[Pretty.str (kind ^ " " ^ name ^ ":"), Pretty.fbrk, |
|
315 |
Pretty.blk (1, Pretty.str "(" :: prt_facts ctxt facts @ [Pretty.str ")"])]); |
|
10935 | 316 |
|
12055 | 317 |
fun pretty_rule s ctxt thm = |
10935 | 318 |
Pretty.block [Pretty.str (s ^ " to solve goal by exported rule:"), |
12055 | 319 |
Pretty.fbrk, ProofContext.pretty_thm ctxt thm]; |
10935 | 320 |
|
321 |
in |
|
322 |
||
12244 | 323 |
val print_result = Pretty.writeln oo pretty_results; |
324 |
fun print_result' ctxt (k, res) = print_result ctxt ((k, ""), res); |
|
10935 | 325 |
|
13686 | 326 |
fun cond_print_result_rule int = if int |
327 |
then (print_result', |
|
328 |
priority oo (Pretty.string_of oo pretty_rule "Successful attempt")) |
|
12055 | 329 |
else (K (K ()), K (K ())); |
10935 | 330 |
|
331 |
fun proof'' f = Toplevel.proof' (f o cond_print_result_rule); |
|
332 |
||
333 |
fun check_goal false state = state |
|
334 |
| check_goal true state = |
|
335 |
let |
|
336 |
val rule = ref (None: thm option); |
|
13529 | 337 |
fun fail exn = |
10935 | 338 |
(["Problem! Local statement will fail to solve any pending goal"] @ |
339 |
(case exn of None => [] | Some e => [Toplevel.exn_message e]) @ |
|
340 |
(case ! rule of None => [] | Some thm => |
|
12055 | 341 |
[Pretty.string_of (pretty_rule "Failed attempt" (Proof.context_of state) thm)])) |
13529 | 342 |
|> cat_lines |> error; |
10935 | 343 |
val check = |
12055 | 344 |
(fn () => Seq.pull (SkipProof.local_skip_proof (K (K ()), |
12318
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
345 |
fn _ => fn thm => rule := Some thm) true state)) |
11932 | 346 |
|> Library.setmp proofs 0 |
10935 | 347 |
|> Library.transform_error; |
348 |
val result = (check (), None) handle Interrupt => raise Interrupt | e => (None, Some e); |
|
13529 | 349 |
in (case result of (Some _, None) => () | (_, exn) => fail exn); state end; |
12244 | 350 |
|
10935 | 351 |
end; |
352 |
||
353 |
||
5830 | 354 |
(* statements *) |
355 |
||
7271 | 356 |
local |
357 |
||
12141 | 358 |
fun global_attributes thy ((name, src), s) = ((name, map (Attrib.global_attribute thy) src), s); |
12697 | 359 |
fun local_attributes thy ((name, src), s) = ((name, map (Attrib.local_attribute thy) src), s); |
360 |
fun local_attributes' state = local_attributes (Proof.theory_of state); |
|
6371 | 361 |
|
12141 | 362 |
fun global_statement f args int thy = |
363 |
ProofHistory.init (Toplevel.undo_limit int) (f (map (global_attributes thy) args) thy); |
|
364 |
fun global_statement_i f args int thy = ProofHistory.init (Toplevel.undo_limit int) (f args thy); |
|
10935 | 365 |
|
12141 | 366 |
fun local_statement' f g args int = ProofHistory.apply (fn state => |
12697 | 367 |
f (map (local_attributes' state) args) int (g state)); |
12141 | 368 |
fun local_statement_i' f g args int = ProofHistory.apply (f args int o g); |
369 |
fun local_statement f g args = local_statement' (K o f) g args (); |
|
370 |
fun local_statement_i f g args = local_statement_i' (K o f) g args (); |
|
7271 | 371 |
|
12701
77ac6d8451ea
export multi_theorem(_i), locale_multi_theorem(_i);
wenzelm
parents:
12697
diff
changeset
|
372 |
in |
77ac6d8451ea
export multi_theorem(_i), locale_multi_theorem(_i);
wenzelm
parents:
12697
diff
changeset
|
373 |
|
12957 | 374 |
fun multi_theorem k a elems concl int thy = |
375 |
global_statement (Proof.multi_theorem k None (apsnd (map (Attrib.global_attribute thy)) a) |
|
376 |
(map (Locale.attribute (Attrib.local_attribute thy)) elems)) concl int thy; |
|
12697 | 377 |
|
12957 | 378 |
fun multi_theorem_i k a = global_statement_i o Proof.multi_theorem_i k None a; |
12697 | 379 |
|
12957 | 380 |
fun locale_multi_theorem k locale (name, atts) elems concl int thy = |
381 |
global_statement (Proof.multi_theorem k |
|
382 |
(Some (locale, (map (Attrib.local_attribute thy) atts, |
|
383 |
map (map (Attrib.local_attribute thy) o snd o fst) concl))) |
|
384 |
(name, []) (map (Locale.attribute (Attrib.local_attribute thy)) elems)) |
|
385 |
(map (apfst (apsnd (K []))) concl) int thy; |
|
12697 | 386 |
|
12957 | 387 |
fun locale_multi_theorem_i k locale (name, atts) elems concl = |
388 |
global_statement_i (Proof.multi_theorem_i k (Some (locale, (atts, map (snd o fst) concl))) |
|
389 |
(name, []) elems) (map (apfst (apsnd (K []))) concl); |
|
12697 | 390 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
391 |
fun theorem k (a, t) = multi_theorem k a [] [(("", []), [t])]; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
392 |
fun theorem_i k (a, t) = multi_theorem_i k a [] [(("", []), [t])]; |
11742 | 393 |
|
12957 | 394 |
fun smart_multi_theorem k None a elems = multi_theorem k a elems |
395 |
| smart_multi_theorem k (Some locale) a elems = locale_multi_theorem k locale a elems; |
|
11742 | 396 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
397 |
val assume = local_statement Proof.assume I; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
398 |
val assume_i = local_statement_i Proof.assume_i I; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
399 |
val presume = local_statement Proof.presume I; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
400 |
val presume_i = local_statement_i Proof.presume_i I; |
12969 | 401 |
val have = local_statement (Proof.have Seq.single true) I; |
402 |
val have_i = local_statement_i (Proof.have_i Seq.single true) I; |
|
403 |
val hence = local_statement (Proof.have Seq.single true) Proof.chain; |
|
404 |
val hence_i = local_statement_i (Proof.have_i Seq.single true) Proof.chain; |
|
405 |
val show = local_statement' (Proof.show check_goal Seq.single true) I; |
|
406 |
val show_i = local_statement_i' (Proof.show_i check_goal Seq.single true) I; |
|
407 |
val thus = local_statement' (Proof.show check_goal Seq.single true) Proof.chain; |
|
408 |
val thus_i = local_statement_i' (Proof.show_i check_goal Seq.single true) Proof.chain; |
|
12141 | 409 |
|
410 |
fun gen_def f ((name, srcs), def) = ProofHistory.apply (fn state => |
|
411 |
f name (map (Attrib.local_attribute (Proof.theory_of state)) srcs) def state); |
|
412 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
413 |
val local_def = gen_def Proof.def; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
414 |
val local_def_i = gen_def Proof.def_i; |
5830 | 415 |
|
12969 | 416 |
fun obtain (xs, asms) = proof'' (ProofHistory.applys o (fn print => fn state => |
417 |
Obtain.obtain xs (map (local_attributes' state) asms) print state)); |
|
11890 | 418 |
|
12969 | 419 |
fun obtain_i (xs, asms) = proof'' (ProofHistory.applys o Obtain.obtain_i xs asms); |
11890 | 420 |
|
7271 | 421 |
end; |
422 |
||
5830 | 423 |
|
424 |
(* blocks *) |
|
425 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
426 |
val begin_block = ProofHistory.apply Proof.begin_block; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
427 |
val next_block = ProofHistory.apply Proof.next_block; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
428 |
val end_block = ProofHistory.applys Proof.end_block; |
5830 | 429 |
|
430 |
||
8165 | 431 |
(* shuffle state *) |
432 |
||
8236 | 433 |
fun shuffle meth i = Method.refine (Method.Basic (K (meth i))) o Proof.assert_no_chain; |
8204 | 434 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
435 |
fun defer i = ProofHistory.applys (shuffle Method.defer i); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
436 |
fun prefer i = ProofHistory.applys (shuffle Method.prefer i); |
8165 | 437 |
|
438 |
||
5830 | 439 |
(* backward steps *) |
440 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
441 |
fun apply m = ProofHistory.applys |
8881 | 442 |
(Seq.map (Proof.goal_facts (K [])) o Method.refine m o Proof.assert_backward); |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
443 |
fun apply_end m = ProofHistory.applys (Method.refine_end m o Proof.assert_forward); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
444 |
val proof = ProofHistory.applys o Method.proof; |
6404 | 445 |
|
446 |
||
447 |
(* local endings *) |
|
448 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
449 |
val local_qed = proof'' o (ProofHistory.applys oo Method.local_qed true); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
450 |
val local_terminal_proof = proof'' o (ProofHistory.applys oo Method.local_terminal_proof); |
8966 | 451 |
val local_default_proof = proof'' (ProofHistory.applys o Method.local_default_proof); |
6904
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
452 |
val local_immediate_proof = proof'' (ProofHistory.applys o Method.local_immediate_proof); |
8966 | 453 |
val local_done_proof = proof'' (ProofHistory.applys o Method.local_done_proof); |
12318
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
454 |
val local_skip_proof = Toplevel.proof' (fn int => |
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
455 |
ProofHistory.applys (SkipProof.local_skip_proof (cond_print_result_rule int) int)); |
6404 | 456 |
|
457 |
||
458 |
(* global endings *) |
|
459 |
||
12318
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
460 |
fun global_result finish = Toplevel.proof_to_theory' (fn int => fn prf => |
6404 | 461 |
let |
462 |
val state = ProofHistory.current prf; |
|
463 |
val _ = if Proof.at_bottom state then () else raise Toplevel.UNDEF; |
|
12318
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
464 |
val (thy, ((kind, name), res)) = finish int state; |
11742 | 465 |
in |
466 |
if kind = "" orelse kind = Drule.internalK then () |
|
12244 | 467 |
else (print_result (Proof.context_of state) ((kind, name), res); |
13529 | 468 |
Context.setmp (Some thy) (Present.results kind) res); |
11742 | 469 |
thy |
470 |
end); |
|
6404 | 471 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
472 |
fun global_qed m = global_result (K (Method.global_qed true m)); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
473 |
fun global_terminal_proof m = global_result (K (Method.global_terminal_proof m)); |
12318
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
474 |
val global_default_proof = global_result (K Method.global_default_proof); |
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
475 |
val global_immediate_proof = global_result (K Method.global_immediate_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6885
diff
changeset
|
476 |
val global_skip_proof = global_result SkipProof.global_skip_proof; |
12318
72348ff7d4a0
skip_proof: do not require quick_and_dirty in interactive mode;
wenzelm
parents:
12271
diff
changeset
|
477 |
val global_done_proof = global_result (K Method.global_done_proof); |
6404 | 478 |
|
479 |
||
480 |
(* common endings *) |
|
481 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
482 |
fun qed meth = local_qed meth o global_qed meth; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
483 |
fun terminal_proof meths = local_terminal_proof meths o global_terminal_proof meths; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
484 |
val default_proof = local_default_proof o global_default_proof; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
485 |
val immediate_proof = local_immediate_proof o global_immediate_proof; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
486 |
val done_proof = local_done_proof o global_done_proof; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
487 |
val skip_proof = local_skip_proof o global_skip_proof; |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
488 |
val forget_proof = Toplevel.proof_to_theory (Proof.theory_of o ProofHistory.current); |
8210 | 489 |
|
5830 | 490 |
|
6774 | 491 |
(* calculational proof commands *) |
492 |
||
6879 | 493 |
local |
494 |
||
12055 | 495 |
fun cond_print_calc int ctxt thms = |
496 |
if int then |
|
497 |
Pretty.writeln (Pretty.big_list "calculation:" (map (ProofContext.pretty_thm ctxt) thms)) |
|
6774 | 498 |
else (); |
499 |
||
500 |
fun proof''' f = Toplevel.proof' (f o cond_print_calc); |
|
501 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
502 |
fun gen_calc get f args prt state = |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
503 |
f (apsome (fn srcs => get srcs state) args) prt state; |
6879 | 504 |
|
505 |
in |
|
506 |
||
14564 | 507 |
fun get_thmss srcs = Proof.the_facts o local_thmss Proof.note_thmss [(("", []), srcs)]; |
7012 | 508 |
fun get_thmss_i thms _ = thms; |
509 |
||
6879 | 510 |
fun also x = proof''' (ProofHistory.applys o gen_calc get_thmss Calculation.also x); |
511 |
fun also_i x = proof''' (ProofHistory.applys o gen_calc get_thmss_i Calculation.also x); |
|
512 |
fun finally x = proof''' (ProofHistory.applys o gen_calc get_thmss Calculation.finally x); |
|
513 |
fun finally_i x = proof''' (ProofHistory.applys o gen_calc get_thmss_i Calculation.finally x); |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
514 |
val moreover = proof''' (ProofHistory.apply o Calculation.moreover); |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
515 |
val ultimately = proof''' (ProofHistory.apply o Calculation.ultimately); |
6879 | 516 |
|
517 |
end; |
|
6774 | 518 |
|
519 |
||
5830 | 520 |
(* translation functions *) |
521 |
||
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
522 |
fun advancedT false = "" |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
523 |
| advancedT true = "Sign.sg -> "; |
5830 | 524 |
|
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
525 |
fun advancedN false = "" |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
526 |
| advancedN true = "advanced_"; |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
527 |
|
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
528 |
fun parse_ast_translation (a, txt) = |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
529 |
txt |> Context.use_let ("val parse_ast_translation: (string * (" ^ advancedT a ^ |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
530 |
"Syntax.ast list -> Syntax.ast)) list") |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
531 |
("Theory.add_" ^ advancedN a ^ "trfuns (parse_ast_translation, [], [], [])"); |
5830 | 532 |
|
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
533 |
fun parse_translation (a, txt) = |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
534 |
txt |> Context.use_let ("val parse_translation: (string * (" ^ advancedT a ^ |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
535 |
"term list -> term)) list") |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
536 |
("Theory.add_" ^ advancedN a ^ "trfuns ([], parse_translation, [], [])"); |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
537 |
|
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
538 |
fun print_translation (a, txt) = |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
539 |
txt |> Context.use_let ("val print_translation: (string * (" ^ advancedT a ^ |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
540 |
"term list -> term)) list") |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
541 |
("Theory.add_" ^ advancedN a ^ "trfuns ([], [], print_translation, [])"); |
5830 | 542 |
|
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
543 |
fun print_ast_translation (a, txt) = |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
544 |
txt |> Context.use_let ("val print_ast_translation: (string * (" ^ advancedT a ^ |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
545 |
"Syntax.ast list -> Syntax.ast)) list") |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
546 |
("Theory.add_" ^ advancedN a ^ "trfuns ([], [], [], print_ast_translation)"); |
5830 | 547 |
|
14649
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
548 |
fun typed_print_translation (a, txt) = |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
549 |
txt |> Context.use_let ("val typed_print_translation: (string * (" ^ advancedT a ^ |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
550 |
"bool -> typ -> term list -> term)) list") |
8ad41d25c152
removed add_constdefs(_i), see constdefs.ML for improved version; advanced translation functions;
wenzelm
parents:
14598
diff
changeset
|
551 |
("Theory.add_" ^ advancedN a ^ "trfunsT typed_print_translation"); |
5830 | 552 |
|
553 |
val token_translation = |
|
11717
d808005e6e08
Fixed erroneous type constraint in token_translation function.
berghofe
parents:
11048
diff
changeset
|
554 |
Context.use_let "val token_translation: (string * string * (string -> string * real)) list" |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
555 |
"Theory.add_tokentrfuns token_translation"; |
5830 | 556 |
|
557 |
||
9193
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
wenzelm
parents:
9032
diff
changeset
|
558 |
(* add method *) |
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
wenzelm
parents:
9032
diff
changeset
|
559 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
560 |
fun method_setup (name, txt, cmt) = |
9193
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
wenzelm
parents:
9032
diff
changeset
|
561 |
Context.use_let |
9810 | 562 |
"val thm = PureThy.get_thm_closure (Context.the_context ());\n\ |
563 |
\val thms = PureThy.get_thms_closure (Context.the_context ());\n\ |
|
564 |
\val method: bstring * (Args.src -> Proof.context -> Proof.method) * string" |
|
9193
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
wenzelm
parents:
9032
diff
changeset
|
565 |
"PureIsar.Method.add_method method" |
14598
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents:
14564
diff
changeset
|
566 |
("(" ^ Library.quote name ^ ", " ^ txt ^ ", " ^ Library.quote cmt ^ ")"); |
9193
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
wenzelm
parents:
9032
diff
changeset
|
567 |
|
4f4936582889
have_theorems etc.: handle multiple lists of arguments;
wenzelm
parents:
9032
diff
changeset
|
568 |
|
5830 | 569 |
(* add_oracle *) |
570 |
||
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12848
diff
changeset
|
571 |
fun add_oracle (name, txt) = |
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
572 |
Context.use_let |
9590 | 573 |
"val oracle: bstring * (Sign.sg * Object.T -> term)" |
5830 | 574 |
"Theory.add_oracle oracle" |
14598
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents:
14564
diff
changeset
|
575 |
("(" ^ Library.quote name ^ ", " ^ txt ^ ")"); |
5830 | 576 |
|
577 |
||
12062 | 578 |
(* add_locale *) |
579 |
||
13393 | 580 |
fun add_locale (do_pred, name, import, body) thy = |
581 |
Locale.add_locale do_pred name import |
|
13374 | 582 |
(map (Locale.attribute (Attrib.local_attribute thy)) body) thy; |
12062 | 583 |
|
584 |
||
6688 | 585 |
(* theory init and exit *) |
5830 | 586 |
|
8804 | 587 |
fun gen_begin_theory upd name parents files = |
14503
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
skalberg
parents:
13686
diff
changeset
|
588 |
let val ml_filename = Path.pack (ThyLoad.ml_path name); |
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
skalberg
parents:
13686
diff
changeset
|
589 |
val () = if exists (equal ml_filename o #1) files |
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
skalberg
parents:
13686
diff
changeset
|
590 |
then error ((quote ml_filename) ^ " not allowed in files section for theory " ^ name) |
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
skalberg
parents:
13686
diff
changeset
|
591 |
else () |
255ad604e08e
Added check that Theory.ML does not occur in the files section of the theory
skalberg
parents:
13686
diff
changeset
|
592 |
in ThyInfo.begin_theory Present.begin_theory upd name parents (map (apfst Path.unpack) files) end; |
5830 | 593 |
|
8804 | 594 |
val begin_theory = gen_begin_theory false; |
7909 | 595 |
|
596 |
fun end_theory thy = |
|
7932 | 597 |
if ThyInfo.check_known_thy (PureThy.get_name thy) then ThyInfo.end_theory thy |
7909 | 598 |
else thy; |
599 |
||
7932 | 600 |
val kill_theory = ThyInfo.if_known_thy ThyInfo.remove_thy; |
6688 | 601 |
|
7103 | 602 |
|
8804 | 603 |
fun bg_theory (name, parents, files) int = gen_begin_theory int name parents files; |
6331 | 604 |
fun en_theory thy = (end_theory thy; ()); |
605 |
||
7932 | 606 |
fun theory spec = Toplevel.init_theory (bg_theory spec) en_theory (kill_theory o PureThy.get_name); |
6246 | 607 |
|
608 |
||
609 |
(* context switch *) |
|
610 |
||
7960 | 611 |
fun fetch_context f x = |
612 |
(case Context.pass None f x of |
|
613 |
((), None) => raise Toplevel.UNDEF |
|
614 |
| ((), Some thy) => thy); |
|
615 |
||
616 |
fun init_context f x = Toplevel.init_theory (fn _ => fetch_context f x) (K ()) (K ()); |
|
7953 | 617 |
|
618 |
val context = init_context (ThyInfo.quiet_update_thy true); |
|
6246 | 619 |
|
5830 | 620 |
|
621 |
end; |