equal
deleted
inserted
replaced
11 val add_fixrec_cmd: bool -> (binding * string option * mixfix) list |
11 val add_fixrec_cmd: bool -> (binding * string option * mixfix) list |
12 -> (Attrib.binding * string) list -> local_theory -> local_theory |
12 -> (Attrib.binding * string) list -> local_theory -> local_theory |
13 val add_fixpat: Thm.binding * term list -> theory -> theory |
13 val add_fixpat: Thm.binding * term list -> theory -> theory |
14 val add_fixpat_cmd: Attrib.binding * string list -> theory -> theory |
14 val add_fixpat_cmd: Attrib.binding * string list -> theory -> theory |
15 val add_matchers: (string * string) list -> theory -> theory |
15 val add_matchers: (string * string) list -> theory -> theory |
16 val fixrec_simp_add: Thm.attribute |
16 val fixrec_simp_add: attribute |
17 val fixrec_simp_del: Thm.attribute |
17 val fixrec_simp_del: attribute |
18 val fixrec_simp_tac: Proof.context -> int -> tactic |
18 val fixrec_simp_tac: Proof.context -> int -> tactic |
19 val setup: theory -> theory |
19 val setup: theory -> theory |
20 end; |
20 end; |
21 |
21 |
22 structure Fixrec :> FIXREC = |
22 structure Fixrec :> FIXREC = |
163 structure FixrecUnfoldData = GenericDataFun ( |
163 structure FixrecUnfoldData = GenericDataFun ( |
164 type T = thm Symtab.table; |
164 type T = thm Symtab.table; |
165 val empty = Symtab.empty; |
165 val empty = Symtab.empty; |
166 val copy = I; |
166 val copy = I; |
167 val extend = I; |
167 val extend = I; |
168 val merge = K (Symtab.merge (K true)); |
168 fun merge _ = Symtab.merge (K true); |
169 ); |
169 ); |
170 |
170 |
171 local |
171 local |
172 |
172 |
173 fun name_of (Const (n, T)) = n |
173 fun name_of (Const (n, T)) = n |
177 val lhs_name = |
177 val lhs_name = |
178 name_of o fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of; |
178 name_of o fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of; |
179 |
179 |
180 in |
180 in |
181 |
181 |
182 val add_unfold : Thm.attribute = |
182 val add_unfold : attribute = |
183 Thm.declaration_attribute |
183 Thm.declaration_attribute |
184 (fn th => FixrecUnfoldData.map (Symtab.insert (K true) (lhs_name th, th))); |
184 (fn th => FixrecUnfoldData.map (Symtab.insert (K true) (lhs_name th, th))); |
185 |
185 |
186 end |
186 end |
187 |
187 |
255 structure FixrecMatchData = TheoryDataFun ( |
255 structure FixrecMatchData = TheoryDataFun ( |
256 type T = string Symtab.table; |
256 type T = string Symtab.table; |
257 val empty = Symtab.empty; |
257 val empty = Symtab.empty; |
258 val copy = I; |
258 val copy = I; |
259 val extend = I; |
259 val extend = I; |
260 val merge = K (Symtab.merge (K true)); |
260 fun merge _ = Symtab.merge (K true); |
261 ); |
261 ); |
262 |
262 |
263 (* associate match functions with pattern constants *) |
263 (* associate match functions with pattern constants *) |
264 fun add_matchers ms = FixrecMatchData.map (fold Symtab.update ms); |
264 fun add_matchers ms = FixrecMatchData.map (fold Symtab.update ms); |
265 |
265 |
370 addsimps simp_thms |
370 addsimps simp_thms |
371 addsimps [@{thm beta_cfun}] |
371 addsimps [@{thm beta_cfun}] |
372 addsimprocs [@{simproc cont_proc}]; |
372 addsimprocs [@{simproc cont_proc}]; |
373 val copy = I; |
373 val copy = I; |
374 val extend = I; |
374 val extend = I; |
375 val merge = K merge_ss; |
375 fun merge _ = merge_ss; |
376 ); |
376 ); |
377 |
377 |
378 fun fixrec_simp_tac ctxt = |
378 fun fixrec_simp_tac ctxt = |
379 let |
379 let |
380 val tab = FixrecUnfoldData.get (Context.Proof ctxt); |
380 val tab = FixrecUnfoldData.get (Context.Proof ctxt); |
389 val rule = unfold_thm RS @{thm ssubst_lhs}; |
389 val rule = unfold_thm RS @{thm ssubst_lhs}; |
390 in |
390 in |
391 CHANGED (rtac rule i THEN asm_simp_tac ss i) |
391 CHANGED (rtac rule i THEN asm_simp_tac ss i) |
392 end |
392 end |
393 in |
393 in |
394 SUBGOAL (fn ti => tac ti handle _ => no_tac) |
394 SUBGOAL (fn ti => tac ti handle _ => no_tac) (* FIXME avoid handle _ *) |
395 end; |
395 end; |
396 |
396 |
397 val fixrec_simp_add : Thm.attribute = |
397 val fixrec_simp_add : attribute = |
398 Thm.declaration_attribute |
398 Thm.declaration_attribute |
399 (fn th => FixrecSimpData.map (fn ss => ss addsimps [th])); |
399 (fn th => FixrecSimpData.map (fn ss => ss addsimps [th])); |
400 |
400 |
401 val fixrec_simp_del : Thm.attribute = |
401 val fixrec_simp_del : attribute = |
402 Thm.declaration_attribute |
402 Thm.declaration_attribute |
403 (fn th => FixrecSimpData.map (fn ss => ss delsimps [th])); |
403 (fn th => FixrecSimpData.map (fn ss => ss delsimps [th])); |
404 |
404 |
405 (* proves a block of pattern matching equations as theorems, using unfold *) |
405 (* proves a block of pattern matching equations as theorems, using unfold *) |
406 fun make_simps ctxt (unfold_thm, eqns : (Attrib.binding * term) list) = |
406 fun make_simps ctxt (unfold_thm, eqns : (Attrib.binding * term) list) = |