src/HOL/Tools/datatype_aux.ML
changeset 26823 f426b9c2a90d
parent 26532 3fc9730403c1
child 26939 1035c89b4c02
equal deleted inserted replaced
26822:67c24cfa8def 26823:f426b9c2a90d
   260   Type (s, map (typ_of_dtyp descr sorts) ds)) descr;
   260   Type (s, map (typ_of_dtyp descr sorts) ds)) descr;
   261 
   261 
   262 (* get all branching types *)
   262 (* get all branching types *)
   263 
   263 
   264 fun get_branching_types descr sorts =
   264 fun get_branching_types descr sorts =
   265   map (typ_of_dtyp descr sorts) (Library.foldl (fn (Ts, (_, (_, _, constrs))) =>
   265   map (typ_of_dtyp descr sorts) (fold (fn (_, (_, _, constrs)) =>
   266     Library.foldl (fn (Ts', (_, cargs)) => foldr op union Ts' (map (fst o strip_dtyp)
   266     fold (fn (_, cargs) => fold (strip_dtyp #> fst #> fold (insert op =)) cargs)
   267       cargs)) (Ts, constrs)) ([], descr));
   267       constrs) descr []);
   268 
   268 
   269 fun get_arities descr = Library.foldl (fn (is, (_, (_, _, constrs))) =>
   269 fun get_arities descr = fold (fn (_, (_, _, constrs)) =>
   270   Library.foldl (fn (is', (_, cargs)) => map (length o fst o strip_dtyp)
   270   fold (fn (_, cargs) => fold (insert op =) (map (length o fst o strip_dtyp)
   271     (List.filter is_rec_type cargs) union is') (is, constrs)) ([], descr);
   271     (List.filter is_rec_type cargs))) constrs) descr [];
   272 
   272 
   273 (* nonemptiness check for datatypes *)
   273 (* nonemptiness check for datatypes *)
   274 
   274 
   275 fun check_nonempty descr =
   275 fun check_nonempty descr =
   276   let
   276   let