src/HOL/Codatatype/Tools/bnf_def.ML
changeset 49395 323414474c1f
parent 49386 ac2e29fc57a5
child 49425 f27f83f71e94
equal deleted inserted replaced
49394:52e636ace94e 49395:323414474c1f
   602         [] => ()
   602         [] => ()
   603       | frees => Proof_Display.print_consts true lthy (K false) frees;
   603       | frees => Proof_Display.print_consts true lthy (K false) frees;
   604 
   604 
   605     val bnf_map = Morphism.term phi bnf_map_term;
   605     val bnf_map = Morphism.term phi bnf_map_term;
   606 
   606 
   607     fun iter_split ((Ts, T1), T2) = if length Ts < live then error "Bad map function"
       
   608       else if length Ts = live then ((Ts, T1), T2)
       
   609       else iter_split (split_last Ts, T1 --> T2);
       
   610 
       
   611     (*TODO: handle errors*)
   607     (*TODO: handle errors*)
   612     (*simple shape analysis of a map function*)
   608     (*simple shape analysis of a map function*)
   613     val (((alphas, betas), CA), _) =
   609     val ((alphas, betas), (CA, _)) =
   614       apfst (apfst (map_split dest_funT))
   610       fastype_of bnf_map
   615         (iter_split (apfst split_last (strip_type (fastype_of bnf_map))));
   611       |> strip_typeN live
       
   612       |>> map_split dest_funT
       
   613       ||> dest_funT
       
   614       handle TYPE _ => error "Bad map function";
   616 
   615 
   617     val CA_params = map TVar (Term.add_tvarsT CA []);
   616     val CA_params = map TVar (Term.add_tvarsT CA []);
   618 
   617 
   619     val bnf_sets = map2 (normalize_set CA_params) alphas (map (Morphism.term phi) bnf_set_terms);
   618     val bnf_sets = map2 (normalize_set CA_params) alphas (map (Morphism.term phi) bnf_set_terms);
   620     val bdT = Morphism.typ phi bd_rhsT;
   619     val bdT = Morphism.typ phi bd_rhsT;