167 val (cnstr_head, cnstr_args) = strip_comb cnstr |
167 val (cnstr_head, cnstr_args) = strip_comb cnstr |
168 val rhs_elements = strip_bn_fun lthy cnstr_args rhs |
168 val rhs_elements = strip_bn_fun lthy cnstr_args rhs |
169 in |
169 in |
170 (dt_index, (bn_fun, (cnstr_head, rhs_elements))) |
170 (dt_index, (bn_fun, (cnstr_head, rhs_elements))) |
171 end |
171 end |
|
172 |
172 fun order dts i ts = |
173 fun order dts i ts = |
173 let |
174 let |
174 val dt = nth dts i |
175 val dt = nth dts i |
175 val cts = map (fn (x, _, _) => Binding.name_of x) ((fn (_, _, _, x) => x) dt) |
176 val cts = map (fn (x, _, _) => Binding.name_of x) ((fn (_, _, _, x) => x) dt) |
176 val ts' = map (fn (x, y) => (fst (dest_Const x), y)) ts |
177 val ts' = map (fn (x, y) => (fst (dest_Const x), y)) ts |
296 |> uncurry drop |
297 |> uncurry drop |
297 |
298 |
298 (* definitions of raw permutations by primitive recursion *) |
299 (* definitions of raw permutations by primitive recursion *) |
299 val _ = warning "Definition of raw permutations"; |
300 val _ = warning "Definition of raw permutations"; |
300 val ((raw_perm_funs, raw_perm_simps, raw_perm_laws), lthy2a) = |
301 val ((raw_perm_funs, raw_perm_simps, raw_perm_laws), lthy2a) = |
301 if get_STEPS lthy0 > 1 |
302 if get_STEPS lthy0 > 0 |
302 then define_raw_perms raw_full_ty_names raw_tys tvs raw_constrs raw_induct_thm lthy0 |
303 then define_raw_perms raw_full_ty_names raw_tys tvs raw_constrs raw_induct_thm lthy0 |
303 else raise TEST lthy0 |
304 else raise TEST lthy0 |
304 |
305 |
305 (* noting the raw permutations as eqvt theorems *) |
306 (* noting the raw permutations as eqvt theorems *) |
306 val (_, lthy3) = Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_perm_simps) lthy2a |
307 val (_, lthy3) = Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_perm_simps) lthy2a |
307 |
308 |
308 (* definition of raw fv_functions *) |
309 (* definition of raw fv and bn functions *) |
309 val _ = warning "Definition of raw fv-functions"; |
310 val _ = warning "Definition of raw fv- and bn-functions"; |
310 val (raw_bns, raw_bn_defs, raw_bn_info, raw_bn_induct, lthy3a) = |
311 val (raw_bns, raw_bn_defs, raw_bn_info, raw_bn_induct, lthy3a) = |
311 if get_STEPS lthy3 > 2 |
312 if get_STEPS lthy3 > 1 |
312 then define_raw_bns raw_full_ty_names raw_dts raw_bn_funs raw_bn_eqs |
313 then define_raw_bns raw_full_ty_names raw_dts raw_bn_funs raw_bn_eqs |
313 (raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3 |
314 (raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3 |
314 else raise TEST lthy3 |
315 else raise TEST lthy3 |
315 |
316 |
316 val (raw_fvs, raw_fv_bns, raw_fv_defs, raw_fv_bns_induct, lthy3b) = |
317 (* defining the permute_bn functions *) |
317 if get_STEPS lthy3a > 3 |
318 val (_, _, lthy3b) = |
318 then define_raw_fvs raw_full_ty_names raw_tys raw_cns_info raw_bn_info raw_bclauses |
319 if get_STEPS lthy3a > 2 |
|
320 then define_raw_bn_perms raw_tys raw_bn_info raw_cns_info |
319 (raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3a |
321 (raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3a |
320 else raise TEST lthy3a |
322 else raise TEST lthy3a |
|
323 |
|
324 val (raw_fvs, raw_fv_bns, raw_fv_defs, raw_fv_bns_induct, lthy3c) = |
|
325 if get_STEPS lthy3b > 3 |
|
326 then define_raw_fvs raw_full_ty_names raw_tys raw_cns_info raw_bn_info raw_bclauses |
|
327 (raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3b |
|
328 else raise TEST lthy3b |
321 |
329 |
322 (* definition of raw alphas *) |
330 (* definition of raw alphas *) |
323 val _ = warning "Definition of alphas"; |
331 val _ = warning "Definition of alphas"; |
324 val (alpha_trms, alpha_bn_trms, alpha_intros, alpha_cases, alpha_induct, lthy4) = |
332 val (alpha_trms, alpha_bn_trms, alpha_intros, alpha_cases, alpha_induct, lthy4) = |
325 if get_STEPS lthy3b > 4 |
333 if get_STEPS lthy3c > 4 |
326 then define_raw_alpha raw_full_ty_names raw_tys raw_cns_info raw_bn_info raw_bclauses raw_fvs lthy3b |
334 then define_raw_alpha raw_full_ty_names raw_tys raw_cns_info raw_bn_info raw_bclauses raw_fvs lthy3c |
327 else raise TEST lthy3b |
335 else raise TEST lthy3c |
328 val alpha_tys = map (domain_type o fastype_of) alpha_trms |
336 val alpha_tys = map (domain_type o fastype_of) alpha_trms |
329 |
337 |
330 (* definition of alpha-distinct lemmas *) |
338 (* definition of alpha-distinct lemmas *) |
331 val _ = warning "Distinct theorems"; |
339 val _ = warning "Distinct theorems"; |
332 val alpha_distincts = |
340 val alpha_distincts = |