77 val branchTs = get_branching_types descr' sorts; |
77 val branchTs = get_branching_types descr' sorts; |
78 val branchT = if null branchTs then HOLogic.unitT |
78 val branchT = if null branchTs then HOLogic.unitT |
79 else fold_bal (fn (T, U) => Type ("+", [T, U])) branchTs; |
79 else fold_bal (fn (T, U) => Type ("+", [T, U])) branchTs; |
80 val arities = get_arities descr' \ 0; |
80 val arities = get_arities descr' \ 0; |
81 val unneeded_vars = hd tyvars \\ foldr add_typ_tfree_names [] (leafTs' @ branchTs); |
81 val unneeded_vars = hd tyvars \\ foldr add_typ_tfree_names [] (leafTs' @ branchTs); |
82 val leafTs = leafTs' @ (map (fn n => TFree (n, valOf (assoc (sorts, n)))) unneeded_vars); |
82 val leafTs = leafTs' @ (map (fn n => TFree (n, (the o AList.lookup (op =) sorts) n)) unneeded_vars); |
83 val recTs = get_rec_types descr' sorts; |
83 val recTs = get_rec_types descr' sorts; |
84 val newTs = Library.take (length (hd descr), recTs); |
84 val newTs = Library.take (length (hd descr), recTs); |
85 val oldTs = Library.drop (length (hd descr), recTs); |
85 val oldTs = Library.drop (length (hd descr), recTs); |
86 val sumT = if null leafTs then HOLogic.unitT |
86 val sumT = if null leafTs then HOLogic.unitT |
87 else fold_bal (fn (T, U) => Type ("+", [T, U])) leafTs; |
87 else fold_bal (fn (T, U) => Type ("+", [T, U])) leafTs; |