equal
deleted
inserted
replaced
63 * (typ list list * typ list list list list * term list list |
63 * (typ list list * typ list list list list * term list list |
64 * term list list list list) list option |
64 * term list list list list) list option |
65 * (string * term list * term list list |
65 * (string * term list * term list list |
66 * ((term list list * term list list list) * typ list) list) option) |
66 * ((term list list * term list list list) * typ list) list) option) |
67 * Proof.context |
67 * Proof.context |
68 val mk_iter_fun_arg_types: typ list list list -> int list -> int list list -> term -> |
68 val mk_iter_fun_arg_types: typ list list list -> int list -> int list list -> typ -> |
69 typ list list list list |
69 typ list list list list |
70 val mk_coiter_fun_arg_types: typ list list list -> typ list -> int list -> term -> |
70 val mk_coiter_fun_arg_types: typ list list list -> typ list -> int list -> term -> |
71 typ list list |
71 typ list list |
72 * (typ list list list list * typ list list list * typ list list list list * typ list) |
72 * (typ list list list list * typ list list list * typ list list list list * typ list) |
73 val define_iters: string list -> |
73 val define_iters: string list -> |
281 val rho = tvar_subst thy (fpTs0 @ Cs0) (fpTs @ Cs); |
281 val rho = tvar_subst thy (fpTs0 @ Cs0) (fpTs @ Cs); |
282 in |
282 in |
283 map (Term.subst_TVars rho) ts0 |
283 map (Term.subst_TVars rho) ts0 |
284 end; |
284 end; |
285 |
285 |
286 val mk_fp_iter_fun_types = binder_fun_types o fastype_of; |
|
287 |
|
288 fun unzip_recT (Type (@{type_name prod}, _)) T = [T] |
286 fun unzip_recT (Type (@{type_name prod}, _)) T = [T] |
289 | unzip_recT _ (Type (@{type_name prod}, Ts)) = Ts |
287 | unzip_recT _ (Type (@{type_name prod}, Ts)) = Ts |
290 | unzip_recT _ T = [T]; |
288 | unzip_recT _ T = [T]; |
291 |
289 |
292 fun unzip_corecT (Type (@{type_name sum}, _)) T = [T] |
290 fun unzip_corecT (Type (@{type_name sum}, _)) T = [T] |
371 morph_gfp_sugar_thms o Morphism.transfer_morphism o Proof_Context.theory_of; |
369 morph_gfp_sugar_thms o Morphism.transfer_morphism o Proof_Context.theory_of; |
372 |
370 |
373 fun mk_iter_fun_arg_types0 n ms = map2 dest_tupleT ms o dest_sumTN_balanced n o domain_type; |
371 fun mk_iter_fun_arg_types0 n ms = map2 dest_tupleT ms o dest_sumTN_balanced n o domain_type; |
374 |
372 |
375 fun mk_iter_fun_arg_types ctr_Tsss ns mss = |
373 fun mk_iter_fun_arg_types ctr_Tsss ns mss = |
376 mk_fp_iter_fun_types |
374 binder_fun_types |
377 #> map3 mk_iter_fun_arg_types0 ns mss |
375 #> map3 mk_iter_fun_arg_types0 ns mss |
378 #> map2 (map2 (map2 unzip_recT)) ctr_Tsss; |
376 #> map2 (map2 (map2 unzip_recT)) ctr_Tsss; |
379 |
377 |
380 fun mk_iters_args_types ctr_Tsss Cs ns mss ctor_iter_fun_Tss lthy = |
378 fun mk_iters_args_types ctr_Tsss Cs ns mss ctor_iter_fun_Tss lthy = |
381 let |
379 let |
430 |
428 |
431 fun mk_coiter_p_pred_types Cs ns = map2 (fn n => replicate (Int.max (0, n - 1)) o mk_pred1T) ns Cs; |
429 fun mk_coiter_p_pred_types Cs ns = map2 (fn n => replicate (Int.max (0, n - 1)) o mk_pred1T) ns Cs; |
432 |
430 |
433 fun mk_coiter_fun_arg_types ctr_Tsss Cs ns dtor_coiter = |
431 fun mk_coiter_fun_arg_types ctr_Tsss Cs ns dtor_coiter = |
434 (mk_coiter_p_pred_types Cs ns, |
432 (mk_coiter_p_pred_types Cs ns, |
435 mk_fp_iter_fun_types dtor_coiter |> mk_coiter_fun_arg_types0 ctr_Tsss Cs ns); |
433 mk_coiter_fun_arg_types0 ctr_Tsss Cs ns (binder_fun_types (fastype_of dtor_coiter))); |
436 |
434 |
437 fun mk_coiters_args_types ctr_Tsss Cs ns dtor_coiter_fun_Tss lthy = |
435 fun mk_coiters_args_types ctr_Tsss Cs ns dtor_coiter_fun_Tss lthy = |
438 let |
436 let |
439 val p_Tss = mk_coiter_p_pred_types Cs ns; |
437 val p_Tss = mk_coiter_p_pred_types Cs ns; |
440 |
438 |
490 fun mk_co_iters_prelims fp ctr_Tsss fpTs Cs ns mss xtor_co_iterss0 lthy = |
488 fun mk_co_iters_prelims fp ctr_Tsss fpTs Cs ns mss xtor_co_iterss0 lthy = |
491 let |
489 let |
492 val thy = Proof_Context.theory_of lthy; |
490 val thy = Proof_Context.theory_of lthy; |
493 |
491 |
494 val (xtor_co_iter_fun_Tss, xtor_co_iterss) = |
492 val (xtor_co_iter_fun_Tss, xtor_co_iterss) = |
495 map (mk_co_iters thy fp fpTs Cs #> `(mk_fp_iter_fun_types o hd)) (transpose xtor_co_iterss0) |
493 map (mk_co_iters thy fp fpTs Cs #> `(binder_fun_types o fastype_of o hd)) |
|
494 (transpose xtor_co_iterss0) |
496 |> apsnd transpose o apfst transpose o split_list; |
495 |> apsnd transpose o apfst transpose o split_list; |
497 |
496 |
498 val ((iters_args_types, coiters_args_types), lthy') = |
497 val ((iters_args_types, coiters_args_types), lthy') = |
499 if fp = Least_FP then |
498 if fp = Least_FP then |
500 mk_iters_args_types ctr_Tsss Cs ns mss xtor_co_iter_fun_Tss lthy |>> (rpair NONE o SOME) |
499 mk_iters_args_types ctr_Tsss Cs ns mss xtor_co_iter_fun_Tss lthy |>> (rpair NONE o SOME) |