author | kleing |
Mon, 21 Jun 2004 10:25:57 +0200 | |
changeset 14981 | e73f8140af78 |
parent 14718 | f52f2cf2d137 |
child 15117 | b860e444c1db |
permissions | -rw-r--r-- |
5823 | 1 |
(* Title: Pure/Isar/attrib.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
5 |
Symbolic theorem attributes. |
|
6 |
*) |
|
7 |
||
8 |
signature BASIC_ATTRIB = |
|
9 |
sig |
|
10 |
val print_attributes: theory -> unit |
|
5879 | 11 |
val Attribute: bstring -> (Args.src -> theory attribute) * (Args.src -> Proof.context attribute) |
12 |
-> string -> unit |
|
5823 | 13 |
end; |
14 |
||
15 |
signature ATTRIB = |
|
16 |
sig |
|
17 |
include BASIC_ATTRIB |
|
5912 | 18 |
exception ATTRIB_FAIL of (string * Position.T) * exn |
5823 | 19 |
val global_attribute: theory -> Args.src -> theory attribute |
20 |
val local_attribute: theory -> Args.src -> Proof.context attribute |
|
5912 | 21 |
val local_attribute': Proof.context -> Args.src -> Proof.context attribute |
7673
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
22 |
val undef_global_attribute: theory attribute |
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
23 |
val undef_local_attribute: Proof.context attribute |
5823 | 24 |
val add_attributes: (bstring * ((Args.src -> theory attribute) * |
25 |
(Args.src -> Proof.context attribute)) * string) list -> theory -> theory |
|
6091 | 26 |
val global_thm: theory * Args.T list -> thm * (theory * Args.T list) |
27 |
val global_thms: theory * Args.T list -> thm list * (theory * Args.T list) |
|
28 |
val global_thmss: theory * Args.T list -> thm list * (theory * Args.T list) |
|
29 |
val local_thm: Proof.context * Args.T list -> thm * (Proof.context * Args.T list) |
|
30 |
val local_thms: Proof.context * Args.T list -> thm list * (Proof.context * Args.T list) |
|
31 |
val local_thmss: Proof.context * Args.T list -> thm list * (Proof.context * Args.T list) |
|
5879 | 32 |
val syntax: ('a * Args.T list -> 'a attribute * ('a * Args.T list)) -> Args.src -> 'a attribute |
5823 | 33 |
val no_args: 'a attribute -> Args.src -> 'a attribute |
8633 | 34 |
val add_del_args: 'a attribute -> 'a attribute -> Args.src -> 'a attribute |
5823 | 35 |
val setup: (theory -> theory) list |
36 |
end; |
|
37 |
||
38 |
structure Attrib: ATTRIB = |
|
39 |
struct |
|
40 |
||
41 |
||
42 |
(** attributes theory data **) |
|
43 |
||
44 |
(* data kind 'Isar/attributes' *) |
|
45 |
||
46 |
structure AttributesDataArgs = |
|
47 |
struct |
|
48 |
val name = "Isar/attributes"; |
|
49 |
type T = |
|
50 |
{space: NameSpace.T, |
|
51 |
attrs: |
|
52 |
((((Args.src -> theory attribute) * (Args.src -> Proof.context attribute)) |
|
53 |
* string) * stamp) Symtab.table}; |
|
54 |
||
55 |
val empty = {space = NameSpace.empty, attrs = Symtab.empty}; |
|
6546 | 56 |
val copy = I; |
5823 | 57 |
val prep_ext = I; |
58 |
||
59 |
fun merge ({space = space1, attrs = attrs1}, {space = space2, attrs = attrs2}) = |
|
60 |
{space = NameSpace.merge (space1, space2), |
|
61 |
attrs = Symtab.merge eq_snd (attrs1, attrs2) handle Symtab.DUPS dups => |
|
62 |
error ("Attempt to merge different versions of attributes " ^ commas_quote dups)}; |
|
63 |
||
9216 | 64 |
fun print _ {space, attrs} = |
5823 | 65 |
let |
66 |
fun prt_attr (name, ((_, comment), _)) = Pretty.block |
|
6846 | 67 |
[Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment]; |
5823 | 68 |
in |
8720 | 69 |
[Pretty.big_list "attributes:" (map prt_attr (NameSpace.cond_extern_table space attrs))] |
9216 | 70 |
|> Pretty.chunks |> Pretty.writeln |
5823 | 71 |
end; |
72 |
end; |
|
73 |
||
74 |
structure AttributesData = TheoryDataFun(AttributesDataArgs); |
|
75 |
val print_attributes = AttributesData.print; |
|
7611 | 76 |
|
5823 | 77 |
|
78 |
(* get global / local attributes *) |
|
79 |
||
5912 | 80 |
exception ATTRIB_FAIL of (string * Position.T) * exn; |
81 |
||
5823 | 82 |
fun gen_attribute which thy = |
83 |
let |
|
84 |
val {space, attrs} = AttributesData.get thy; |
|
85 |
||
5879 | 86 |
fun attr src = |
87 |
let |
|
88 |
val ((raw_name, _), pos) = Args.dest_src src; |
|
89 |
val name = NameSpace.intern space raw_name; |
|
90 |
in |
|
5823 | 91 |
(case Symtab.lookup (attrs, name) of |
92 |
None => error ("Unknown attribute: " ^ quote name ^ Position.str_of pos) |
|
5912 | 93 |
| Some ((p, _), _) => transform_failure (curry ATTRIB_FAIL (name, pos)) (which p src)) |
5823 | 94 |
end; |
95 |
in attr end; |
|
96 |
||
97 |
val global_attribute = gen_attribute fst; |
|
98 |
val local_attribute = gen_attribute snd; |
|
5879 | 99 |
val local_attribute' = local_attribute o ProofContext.theory_of; |
5823 | 100 |
|
7673
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
101 |
val undef_global_attribute: theory attribute = |
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
102 |
fn _ => error "attribute undefined in theory context"; |
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
103 |
|
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
104 |
val undef_local_attribute: Proof.context attribute = |
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
105 |
fn _ => error "attribute undefined in proof context"; |
b8e7fa177d62
added undef_global_attribute, undef_local_attribute;
wenzelm
parents:
7668
diff
changeset
|
106 |
|
5823 | 107 |
|
108 |
(* add_attributes *) |
|
109 |
||
110 |
fun add_attributes raw_attrs thy = |
|
111 |
let |
|
112 |
val full = Sign.full_name (Theory.sign_of thy); |
|
113 |
val new_attrs = |
|
114 |
map (fn (name, (f, g), comment) => (full name, (((f, g), comment), stamp ()))) raw_attrs; |
|
115 |
||
116 |
val {space, attrs} = AttributesData.get thy; |
|
117 |
val space' = NameSpace.extend (space, map fst new_attrs); |
|
118 |
val attrs' = Symtab.extend (attrs, new_attrs) handle Symtab.DUPS dups => |
|
119 |
error ("Duplicate declaration of attributes(s) " ^ commas_quote dups); |
|
120 |
in thy |> AttributesData.put {space = space', attrs = attrs'} end; |
|
121 |
||
5879 | 122 |
(*implicit version*) |
123 |
fun Attribute name att cmt = Context.>> (add_attributes [(name, att, cmt)]); |
|
5823 | 124 |
|
5879 | 125 |
|
126 |
||
127 |
(** attribute parsers **) |
|
128 |
||
129 |
(* tags *) |
|
5823 | 130 |
|
5879 | 131 |
fun tag x = Scan.lift (Args.name -- Scan.repeat Args.name) x; |
132 |
||
133 |
||
134 |
(* theorems *) |
|
135 |
||
136 |
fun gen_thm get attrib app = |
|
137 |
Scan.depend (fn st => Args.name -- Args.opt_attribs >> |
|
138 |
(fn (name, srcs) => app ((st, get st name), map (attrib st) srcs))); |
|
5823 | 139 |
|
6091 | 140 |
val global_thm = gen_thm PureThy.get_thm global_attribute Thm.apply_attributes; |
141 |
val global_thms = gen_thm PureThy.get_thms global_attribute Thm.applys_attributes; |
|
5879 | 142 |
val global_thmss = Scan.repeat global_thms >> flat; |
143 |
||
6091 | 144 |
val local_thm = gen_thm ProofContext.get_thm local_attribute' Thm.apply_attributes; |
145 |
val local_thms = gen_thm ProofContext.get_thms local_attribute' Thm.applys_attributes; |
|
5879 | 146 |
val local_thmss = Scan.repeat local_thms >> flat; |
147 |
||
5823 | 148 |
|
5879 | 149 |
|
150 |
(** attribute syntax **) |
|
5823 | 151 |
|
5879 | 152 |
fun syntax scan src (st, th) = |
8282 | 153 |
let val (st', f) = Args.syntax "attribute" scan src st |
5879 | 154 |
in f (st', th) end; |
155 |
||
156 |
fun no_args x = syntax (Scan.succeed x); |
|
5823 | 157 |
|
10034 | 158 |
fun add_del_args add del x = syntax |
159 |
(Scan.lift (Args.add >> K add || Args.del >> K del || Scan.succeed add)) x; |
|
8633 | 160 |
|
5823 | 161 |
|
162 |
||
163 |
(** Pure attributes **) |
|
164 |
||
165 |
(* tags *) |
|
166 |
||
9902 | 167 |
fun gen_tagged x = syntax (tag >> Drule.tag) x; |
168 |
fun gen_untagged x = syntax (Scan.lift Args.name >> Drule.untag) x; |
|
5823 | 169 |
|
170 |
||
6772 | 171 |
(* COMP *) |
172 |
||
6948 | 173 |
fun comp (i, B) (x, A) = (x, Drule.compose_single (A, i, B)); |
6772 | 174 |
|
10151 | 175 |
fun gen_COMP thm = syntax (Scan.lift (Scan.optional (Args.bracks Args.nat) 1) -- thm >> comp); |
9902 | 176 |
val COMP_global = gen_COMP global_thm; |
177 |
val COMP_local = gen_COMP local_thm; |
|
6772 | 178 |
|
179 |
||
5879 | 180 |
(* RS *) |
181 |
||
6091 | 182 |
fun resolve (i, B) (x, A) = (x, A RSN (i, B)); |
5879 | 183 |
|
10151 | 184 |
fun gen_RS thm = syntax (Scan.lift (Scan.optional (Args.bracks Args.nat) 1) -- thm >> resolve); |
9902 | 185 |
val RS_global = gen_RS global_thm; |
186 |
val RS_local = gen_RS local_thm; |
|
5879 | 187 |
|
188 |
||
9902 | 189 |
(* OF *) |
5879 | 190 |
|
6091 | 191 |
fun apply Bs (x, A) = (x, Bs MRS A); |
5879 | 192 |
|
9902 | 193 |
val OF_global = syntax (global_thmss >> apply); |
194 |
val OF_local = syntax (local_thmss >> apply); |
|
5879 | 195 |
|
196 |
||
14718 | 197 |
(* where *) |
198 |
||
199 |
(*named instantiations; permits instantiation of type and term variables*) |
|
5879 | 200 |
|
10807 | 201 |
fun read_instantiate _ [] _ thm = thm |
202 |
| read_instantiate context_of insts x thm = |
|
203 |
let |
|
204 |
val ctxt = context_of x; |
|
205 |
val sign = ProofContext.sign_of ctxt; |
|
206 |
||
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
207 |
(* Separate type and term insts, |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
208 |
type insts must occur strictly before term insts *) |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
209 |
fun has_type_var ((x, _), _) = (case Symbol.explode x of |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
210 |
"'"::cs => true | cs => false); |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
211 |
val (Tinst, tinsts) = take_prefix has_type_var insts; |
14718 | 212 |
val _ = if exists has_type_var tinsts |
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
213 |
then error |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
214 |
"Type instantiations must occur before term instantiations." |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
215 |
else (); |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
216 |
|
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
217 |
val Tinsts = filter has_type_var insts; |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
218 |
val tinsts = filter_out has_type_var insts; |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
219 |
|
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
220 |
(* Type instantiations first *) |
14718 | 221 |
(* Process type insts: Tinsts_env *) |
222 |
fun absent xi = error |
|
223 |
("No such type variable in theorem: " ^ |
|
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
224 |
Syntax.string_of_vname xi); |
14718 | 225 |
val (rtypes, rsorts) = types_sorts thm; |
226 |
fun readT (xi, s) = |
|
227 |
let val S = case rsorts xi of Some S => S | None => absent xi; |
|
228 |
val T = ProofContext.read_typ ctxt s; |
|
229 |
in if Sign.typ_instance sign (T, TVar (xi, S)) then (xi, T) |
|
230 |
else error |
|
231 |
("Instantiation of " ^ Syntax.string_of_vname xi ^ " fails") |
|
232 |
end; |
|
233 |
val Tinsts_env = map readT Tinsts; |
|
234 |
val cenvT = map (apsnd (Thm.ctyp_of sign)) (Tinsts_env); |
|
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
235 |
val thm' = Thm.instantiate (cenvT, []) thm; |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
236 |
(* Instantiate, but don't normalise: *) |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
237 |
(* this happens after term insts anyway. *) |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
238 |
|
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
239 |
(* Term instantiations *) |
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
240 |
val vars = Drule.vars_of thm'; |
10807 | 241 |
fun get_typ xi = |
242 |
(case assoc (vars, xi) of |
|
243 |
Some T => T |
|
244 |
| None => error ("No such variable in theorem: " ^ Syntax.string_of_vname xi)); |
|
5879 | 245 |
|
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
246 |
val (xs, ss) = Library.split_list tinsts; |
10807 | 247 |
val Ts = map get_typ xs; |
5879 | 248 |
|
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
249 |
val used = add_term_tvarnames (prop_of thm',[]) |
14718 | 250 |
(* Names of TVars occuring in thm'. read_def_termTs ensures |
14257
a7ef3f7588c5
Type inference bug in Isar attributes "where" and "of" fixed.
ballarin
parents:
14082
diff
changeset
|
251 |
that new TVars introduced when reading the instantiation string |
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
252 |
are distinct from those occuring in the theorem. *) |
14257
a7ef3f7588c5
Type inference bug in Isar attributes "where" and "of" fixed.
ballarin
parents:
14082
diff
changeset
|
253 |
|
14718 | 254 |
val (ts, envT) = |
255 |
ProofContext.read_termTs ctxt (K false) (K None) (K None) used (ss ~~ Ts); |
|
256 |
||
10807 | 257 |
val cenvT = map (apsnd (Thm.ctyp_of sign)) envT; |
258 |
val cenv = |
|
259 |
map (fn (xi, t) => pairself (Thm.cterm_of sign) (Var (xi, fastype_of t), t)) |
|
260 |
(gen_distinct (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2) (xs ~~ ts)); |
|
261 |
in |
|
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
262 |
thm' |
10807 | 263 |
|> Drule.instantiate (cenvT, cenv) |
264 |
|> RuleCases.save thm |
|
265 |
end; |
|
5879 | 266 |
|
6448 | 267 |
fun insts x = Args.and_list (Scan.lift (Args.var --| Args.$$$ "=" -- Args.name)) x; |
5879 | 268 |
|
6091 | 269 |
fun gen_where context_of = syntax (insts >> (Drule.rule_attribute o read_instantiate context_of)); |
5823 | 270 |
|
9902 | 271 |
val where_global = gen_where ProofContext.init; |
272 |
val where_local = gen_where I; |
|
5879 | 273 |
|
274 |
||
9902 | 275 |
(* of: positional instantiations *) |
14287
f630017ed01c
Isar: where attribute supports instantiation of type variables.
ballarin
parents:
14257
diff
changeset
|
276 |
(* permits instantiation of term variables only *) |
5912 | 277 |
|
10807 | 278 |
fun read_instantiate' _ ([], []) _ thm = thm |
279 |
| read_instantiate' context_of (args, concl_args) x thm = |
|
280 |
let |
|
281 |
fun zip_vars _ [] = [] |
|
282 |
| zip_vars (_ :: xs) (None :: opt_ts) = zip_vars xs opt_ts |
|
283 |
| zip_vars ((x, _) :: xs) (Some t :: opt_ts) = (x, t) :: zip_vars xs opt_ts |
|
284 |
| zip_vars [] _ = error "More instantiations than variables in theorem"; |
|
285 |
val insts = |
|
12804 | 286 |
zip_vars (Drule.vars_of_terms [Thm.prop_of thm]) args @ |
10807 | 287 |
zip_vars (Drule.vars_of_terms [Thm.concl_of thm]) concl_args; |
288 |
in |
|
289 |
thm |
|
290 |
|> read_instantiate context_of insts x |
|
291 |
|> RuleCases.save thm |
|
292 |
end; |
|
5912 | 293 |
|
10807 | 294 |
val concl = Args.$$$ "concl" -- Args.colon; |
8687 | 295 |
val inst_arg = Scan.unless concl Args.name_dummy; |
5912 | 296 |
val inst_args = Scan.repeat inst_arg; |
10807 | 297 |
fun insts' x = (inst_args -- Scan.optional (concl |-- Args.!!! inst_args) []) x; |
5912 | 298 |
|
10807 | 299 |
fun gen_of context_of = |
300 |
syntax (Scan.lift insts' >> (Drule.rule_attribute o read_instantiate' context_of)); |
|
5912 | 301 |
|
9902 | 302 |
val of_global = gen_of ProofContext.init; |
303 |
val of_local = gen_of I; |
|
5912 | 304 |
|
305 |
||
13782
44de406a7273
Added rename_abs attribute for renaming bound variables.
berghofe
parents:
13414
diff
changeset
|
306 |
(* rename_abs *) |
44de406a7273
Added rename_abs attribute for renaming bound variables.
berghofe
parents:
13414
diff
changeset
|
307 |
|
44de406a7273
Added rename_abs attribute for renaming bound variables.
berghofe
parents:
13414
diff
changeset
|
308 |
fun rename_abs src = syntax |
14082
c69d5bf3047d
Moved function for renaming bound variables to Pure/drule.ML
berghofe
parents:
13782
diff
changeset
|
309 |
(Scan.lift (Scan.repeat Args.name_dummy >> (apsnd o Drule.rename_bvars'))) src; |
13782
44de406a7273
Added rename_abs attribute for renaming bound variables.
berghofe
parents:
13414
diff
changeset
|
310 |
|
44de406a7273
Added rename_abs attribute for renaming bound variables.
berghofe
parents:
13414
diff
changeset
|
311 |
|
7598 | 312 |
(* unfold / fold definitions *) |
313 |
||
314 |
fun gen_rewrite rew defs (x, thm) = (x, rew defs thm); |
|
315 |
||
9902 | 316 |
val unfolded_global = syntax (global_thmss >> gen_rewrite Tactic.rewrite_rule); |
317 |
val unfolded_local = syntax (local_thmss >> gen_rewrite Tactic.rewrite_rule); |
|
318 |
val folded_global = syntax (global_thmss >> gen_rewrite Tactic.fold_rule); |
|
319 |
val folded_local = syntax (local_thmss >> gen_rewrite Tactic.fold_rule); |
|
7598 | 320 |
|
321 |
||
8368 | 322 |
(* rule cases *) |
323 |
||
10528 | 324 |
fun consumes x = syntax (Scan.lift (Scan.optional Args.nat 1) >> RuleCases.consumes) x; |
8368 | 325 |
fun case_names x = syntax (Scan.lift (Scan.repeat1 Args.name) >> RuleCases.case_names) x; |
326 |
fun params x = syntax (Args.and_list1 (Scan.lift (Scan.repeat Args.name)) >> RuleCases.params) x; |
|
327 |
||
328 |
||
11770 | 329 |
(* rule_format *) |
330 |
||
331 |
fun rule_format_att x = syntax |
|
332 |
(Scan.lift (Args.parens (Args.$$$ "no_asm") |
|
333 |
>> K ObjectLogic.rule_format_no_asm || Scan.succeed ObjectLogic.rule_format)) x; |
|
334 |
||
335 |
||
5879 | 336 |
(* misc rules *) |
337 |
||
6091 | 338 |
fun standard x = no_args (Drule.rule_attribute (K Drule.standard)) x; |
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9902
diff
changeset
|
339 |
fun elim_format x = no_args (Drule.rule_attribute (K Tactic.make_elim)) x; |
9216 | 340 |
fun no_vars x = no_args (Drule.rule_attribute (K (#1 o Drule.freeze_thaw))) x; |
5879 | 341 |
|
342 |
||
13370 | 343 |
(* rule declarations *) |
344 |
||
345 |
local |
|
346 |
||
347 |
fun add_args a b c x = syntax |
|
348 |
(Scan.lift ((Args.bang >> K a || Args.query >> K c || Scan.succeed b) -- (Scan.option Args.nat)) |
|
349 |
>> (fn (f, n) => f n)) x; |
|
350 |
||
351 |
fun del_args att = syntax (Scan.lift Args.del >> K att); |
|
352 |
||
353 |
open ContextRules; |
|
354 |
||
355 |
in |
|
356 |
||
357 |
val rule_atts = |
|
358 |
[("intro", |
|
359 |
(add_args intro_bang_global intro_global intro_query_global, |
|
360 |
add_args intro_bang_local intro_local intro_query_local), |
|
361 |
"declaration of introduction rule"), |
|
362 |
("elim", |
|
363 |
(add_args elim_bang_global elim_global elim_query_global, |
|
364 |
add_args elim_bang_local elim_local elim_query_local), |
|
365 |
"declaration of elimination rule"), |
|
366 |
("dest", |
|
367 |
(add_args dest_bang_global dest_global dest_query_global, |
|
368 |
add_args dest_bang_local dest_local dest_query_local), |
|
369 |
"declaration of destruction rule"), |
|
370 |
("rule", (del_args rule_del_global, del_args rule_del_local), |
|
371 |
"remove declaration of intro/elim/dest rule")]; |
|
372 |
||
373 |
end; |
|
374 |
||
375 |
||
11770 | 376 |
|
5879 | 377 |
(** theory setup **) |
5823 | 378 |
|
379 |
(* pure_attributes *) |
|
380 |
||
381 |
val pure_attributes = |
|
9902 | 382 |
[("tagged", (gen_tagged, gen_tagged), "tagged theorem"), |
383 |
("untagged", (gen_untagged, gen_untagged), "untagged theorem"), |
|
384 |
("COMP", (COMP_global, COMP_local), "direct composition with rules (no lifting)"), |
|
385 |
("THEN", (RS_global, RS_local), "resolution with rule"), |
|
386 |
("OF", (OF_global, OF_local), "rule applied to facts"), |
|
387 |
("where", (where_global, where_local), "named instantiation of theorem"), |
|
388 |
("of", (of_global, of_local), "rule applied to terms"), |
|
13782
44de406a7273
Added rename_abs attribute for renaming bound variables.
berghofe
parents:
13414
diff
changeset
|
389 |
("rename_abs", (rename_abs, rename_abs), "rename bound variables in abstractions"), |
9902 | 390 |
("unfolded", (unfolded_global, unfolded_local), "unfolded definitions"), |
391 |
("folded", (folded_global, folded_local), "folded definitions"), |
|
392 |
("standard", (standard, standard), "result put into standard form"), |
|
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9902
diff
changeset
|
393 |
("elim_format", (elim_format, elim_format), "destruct rule turned into elimination rule format"), |
9902 | 394 |
("no_vars", (no_vars, no_vars), "frozen schematic vars"), |
10528 | 395 |
("consumes", (consumes, consumes), "number of consumed facts"), |
9902 | 396 |
("case_names", (case_names, case_names), "named rule cases"), |
397 |
("params", (params, params), "named rule parameters"), |
|
11770 | 398 |
("atomize", (no_args ObjectLogic.declare_atomize, no_args undef_local_attribute), |
399 |
"declaration of atomize rule"), |
|
400 |
("rulify", (no_args ObjectLogic.declare_rulify, no_args undef_local_attribute), |
|
401 |
"declaration of rulify rule"), |
|
13370 | 402 |
("rule_format", (rule_format_att, rule_format_att), "result put into standard rule format")] @ |
403 |
rule_atts; |
|
5823 | 404 |
|
405 |
||
5879 | 406 |
(* setup *) |
5823 | 407 |
|
408 |
val setup = [AttributesData.init, add_attributes pure_attributes]; |
|
409 |
||
410 |
end; |
|
411 |
||
412 |
structure BasicAttrib: BASIC_ATTRIB = Attrib; |
|
413 |
open BasicAttrib; |