43 val induct_pred: string -> attribute |
43 val induct_pred: string -> attribute |
44 val induct_del: attribute |
44 val induct_del: attribute |
45 val coinduct_type: string -> attribute |
45 val coinduct_type: string -> attribute |
46 val coinduct_pred: string -> attribute |
46 val coinduct_pred: string -> attribute |
47 val coinduct_del: attribute |
47 val coinduct_del: attribute |
48 val map_simpset: (simpset -> simpset) -> Context.generic -> Context.generic |
48 val map_simpset: (Proof.context -> Proof.context) -> Context.generic -> Context.generic |
49 val induct_simp_add: attribute |
49 val induct_simp_add: attribute |
50 val induct_simp_del: attribute |
50 val induct_simp_del: attribute |
51 val no_simpN: string |
51 val no_simpN: string |
52 val casesN: string |
52 val casesN: string |
53 val inductN: string |
53 val inductN: string |
162 | SOME (i, k, j) => SOME (swap_params_conv ctxt k j (K (swap_prems_conv i)) ct)); |
162 | SOME (i, k, j) => SOME (swap_params_conv ctxt k j (K (swap_prems_conv i)) ct)); |
163 |
163 |
164 val rearrange_eqs_simproc = |
164 val rearrange_eqs_simproc = |
165 Simplifier.simproc_global |
165 Simplifier.simproc_global |
166 (Thm.theory_of_thm Drule.swap_prems_eq) "rearrange_eqs" ["all t"] |
166 (Thm.theory_of_thm Drule.swap_prems_eq) "rearrange_eqs" ["all t"] |
167 (fn thy => fn ss => fn t => |
167 (fn ctxt => fn t => mk_swap_rrule ctxt (cterm_of (Proof_Context.theory_of ctxt) t)); |
168 mk_swap_rrule (Simplifier.the_context ss) (cterm_of thy t)); |
|
169 |
168 |
170 |
169 |
171 (* rotate k premises to the left by j, skipping over first j premises *) |
170 (* rotate k premises to the left by j, skipping over first j premises *) |
172 |
171 |
173 fun rotate_conv 0 j 0 = Conv.all_conv |
172 fun rotate_conv 0 j 0 = Conv.all_conv |
223 type T = (rules * rules) * (rules * rules) * (rules * rules) * simpset; |
222 type T = (rules * rules) * (rules * rules) * (rules * rules) * simpset; |
224 val empty = |
223 val empty = |
225 ((init_rules (left_var_prem o #2), init_rules (Thm.major_prem_of o #2)), |
224 ((init_rules (left_var_prem o #2), init_rules (Thm.major_prem_of o #2)), |
226 (init_rules (right_var_concl o #2), init_rules (Thm.major_prem_of o #2)), |
225 (init_rules (right_var_concl o #2), init_rules (Thm.major_prem_of o #2)), |
227 (init_rules (left_var_concl o #2), init_rules (Thm.concl_of o #2)), |
226 (init_rules (left_var_concl o #2), init_rules (Thm.concl_of o #2)), |
228 empty_ss addsimprocs [rearrange_eqs_simproc] addsimps [Drule.norm_hhf_eq]); |
227 simpset_of (empty_simpset @{context} |
|
228 addsimprocs [rearrange_eqs_simproc] addsimps [Drule.norm_hhf_eq])); |
229 val extend = I; |
229 val extend = I; |
230 fun merge (((casesT1, casesP1), (inductT1, inductP1), (coinductT1, coinductP1), simpset1), |
230 fun merge (((casesT1, casesP1), (inductT1, inductP1), (coinductT1, coinductP1), simpset1), |
231 ((casesT2, casesP2), (inductT2, inductP2), (coinductT2, coinductP2), simpset2)) = |
231 ((casesT2, casesP2), (inductT2, inductP2), (coinductT2, coinductP2), simpset2)) = |
232 ((Item_Net.merge (casesT1, casesT2), Item_Net.merge (casesP1, casesP2)), |
232 ((Item_Net.merge (casesT1, casesT2), Item_Net.merge (casesP1, casesP2)), |
233 (Item_Net.merge (inductT1, inductT2), Item_Net.merge (inductP1, inductP2)), |
233 (Item_Net.merge (inductT1, inductT2), Item_Net.merge (inductP1, inductP2)), |
329 |
329 |
330 val coinduct_type = mk_att add_coinductT consumes0; |
330 val coinduct_type = mk_att add_coinductT consumes0; |
331 val coinduct_pred = mk_att add_coinductP consumes1; |
331 val coinduct_pred = mk_att add_coinductP consumes1; |
332 val coinduct_del = del_att map3; |
332 val coinduct_del = del_att map3; |
333 |
333 |
334 fun map_simpset f = Data.map (map4 f); |
334 fun map_simpset f context = |
|
335 context |> (Data.map o map4 o Simplifier.simpset_map (Context.proof_of context)) f; |
335 |
336 |
336 fun induct_simp f = |
337 fun induct_simp f = |
337 Thm.declaration_attribute (fn thm => fn context => |
338 Thm.declaration_attribute (fn thm => map_simpset (fn ctxt => f (ctxt, [thm]))); |
338 map_simpset |
|
339 (Simplifier.with_context (Context.proof_of context) (fn ss => f (ss, [thm]))) context); |
|
340 |
339 |
341 val induct_simp_add = induct_simp (op addsimps); |
340 val induct_simp_add = induct_simp (op addsimps); |
342 val induct_simp_del = induct_simp (op delsimps); |
341 val induct_simp_del = induct_simp (op delsimps); |
343 |
342 |
344 end; |
343 end; |
442 |
441 |
443 |
442 |
444 (* simplify *) |
443 (* simplify *) |
445 |
444 |
446 fun simplify_conv' ctxt = |
445 fun simplify_conv' ctxt = |
447 Simplifier.full_rewrite (Simplifier.context ctxt (#4 (get_local ctxt))); |
446 Simplifier.full_rewrite (put_simpset (#4 (get_local ctxt)) ctxt); |
448 |
447 |
449 fun simplify_conv ctxt ct = |
448 fun simplify_conv ctxt ct = |
450 if exists_subterm (is_some o Induct_Args.dest_def) (term_of ct) then |
449 if exists_subterm (is_some o Induct_Args.dest_def) (term_of ct) then |
451 (Conv.try_conv (rulify_defs_conv ctxt) then_conv simplify_conv' ctxt) ct |
450 (Conv.try_conv (rulify_defs_conv ctxt) then_conv simplify_conv' ctxt) ct |
452 else Conv.all_conv ct; |
451 else Conv.all_conv ct; |