153 val (_, Type (tname, _)) = hd (rev params); |
153 val (_, Type (tname, _)) = hd (rev params); |
154 val exhaustion = lift_rule (state, i) (exh_thm_of tname); |
154 val exhaustion = lift_rule (state, i) (exh_thm_of tname); |
155 val prem' = hd (prems_of exhaustion); |
155 val prem' = hd (prems_of exhaustion); |
156 val _ $ (_ $ lhs $ _) = hd (rev (Logic.strip_assums_hyp prem')); |
156 val _ $ (_ $ lhs $ _) = hd (rev (Logic.strip_assums_hyp prem')); |
157 val exhaustion' = cterm_instantiate [(cterm_of sg (head_of lhs), |
157 val exhaustion' = cterm_instantiate [(cterm_of sg (head_of lhs), |
158 cterm_of sg (Library.foldr (fn ((_, T), t) => Abs ("z", T, t)) |
158 cterm_of sg (foldr (fn ((_, T), t) => Abs ("z", T, t)) |
159 (params, Bound 0)))] exhaustion |
159 (Bound 0) params))] exhaustion |
160 in compose_tac (false, exhaustion', nprems_of exhaustion) i state |
160 in compose_tac (false, exhaustion', nprems_of exhaustion) i state |
161 end; |
161 end; |
162 |
162 |
163 (* handling of distinctness theorems *) |
163 (* handling of distinctness theorems *) |
164 |
164 |
263 |
263 |
264 (* get all branching types *) |
264 (* get all branching types *) |
265 |
265 |
266 fun get_branching_types descr sorts = |
266 fun get_branching_types descr sorts = |
267 map (typ_of_dtyp descr sorts) (Library.foldl (fn (Ts, (_, (_, _, constrs))) => |
267 map (typ_of_dtyp descr sorts) (Library.foldl (fn (Ts, (_, (_, _, constrs))) => |
268 Library.foldl (fn (Ts', (_, cargs)) => Library.foldr op union (map (fst o strip_dtyp) |
268 Library.foldl (fn (Ts', (_, cargs)) => foldr op union Ts' (map (fst o strip_dtyp) |
269 cargs, Ts')) (Ts, constrs)) ([], descr)); |
269 cargs)) (Ts, constrs)) ([], descr)); |
270 |
270 |
271 fun get_arities descr = Library.foldl (fn (is, (_, (_, _, constrs))) => |
271 fun get_arities descr = Library.foldl (fn (is, (_, (_, _, constrs))) => |
272 Library.foldl (fn (is', (_, cargs)) => map (length o fst o strip_dtyp) |
272 Library.foldl (fn (is', (_, cargs)) => map (length o fst o strip_dtyp) |
273 (List.filter is_rec_type cargs) union is') (is, constrs)) ([], descr); |
273 (List.filter is_rec_type cargs) union is') (is, constrs)) ([], descr); |
274 |
274 |