equal
deleted
inserted
replaced
80 fun possible_index_of_singleton_case cases = |
80 fun possible_index_of_singleton_case cases = |
81 let |
81 let |
82 fun check (i, case_t) s = |
82 fun check (i, case_t) s = |
83 (case strip_abs_body case_t of |
83 (case strip_abs_body case_t of |
84 (Const (@{const_name List.Nil}, _)) => s |
84 (Const (@{const_name List.Nil}, _)) => s |
85 | t => (case s of NONE => SOME i | SOME s => NONE)) |
85 | _ => (case s of NONE => SOME i | SOME _ => NONE)) |
86 in |
86 in |
87 fold_index check cases NONE |
87 fold_index check cases NONE |
88 end |
88 end |
89 (* returns (case_expr type index chosen_case) option *) |
89 (* returns (case_expr type index chosen_case) option *) |
90 fun dest_case case_term = |
90 fun dest_case case_term = |
130 let |
130 let |
131 val info = Datatype.the_info thy (fst (dest_Type T)) |
131 val info = Datatype.the_info thy (fst (dest_Type T)) |
132 in |
132 in |
133 (* do case distinction *) |
133 (* do case distinction *) |
134 Splitter.split_tac [#split info] 1 |
134 Splitter.split_tac [#split info] 1 |
135 THEN EVERY (map_index (fn (i', case_rewrite) => |
135 THEN EVERY (map_index (fn (i', _) => |
136 (if i' < length (#case_rewrites info) - 1 then rtac @{thm conjI} 1 else all_tac) |
136 (if i' < length (#case_rewrites info) - 1 then rtac @{thm conjI} 1 else all_tac) |
137 THEN REPEAT_DETERM (rtac @{thm allI} 1) |
137 THEN REPEAT_DETERM (rtac @{thm allI} 1) |
138 THEN rtac @{thm impI} 1 |
138 THEN rtac @{thm impI} 1 |
139 THEN (if i' = i then |
139 THEN (if i' = i then |
140 (* continue recursively *) |
140 (* continue recursively *) |
205 val reverse_bounds = curry subst_bounds |
205 val reverse_bounds = curry subst_bounds |
206 ((map Bound ((length bound_vs - 1) downto 0)) @ [Bound (length bound_vs)]) |
206 ((map Bound ((length bound_vs - 1) downto 0)) @ [Bound (length bound_vs)]) |
207 val eqs' = map reverse_bounds eqs |
207 val eqs' = map reverse_bounds eqs |
208 val pat_eq' = reverse_bounds pat_eq |
208 val pat_eq' = reverse_bounds pat_eq |
209 val inner_t = |
209 val inner_t = |
210 fold (fn (v, T) => fn t => HOLogic.exists_const T $ absdummy T t) |
210 fold (fn (_, T) => fn t => HOLogic.exists_const T $ absdummy T t) |
211 (rev bound_vs) (fold (curry HOLogic.mk_conj) eqs' pat_eq') |
211 (rev bound_vs) (fold (curry HOLogic.mk_conj) eqs' pat_eq') |
212 val lhs = term_of redex |
212 val lhs = term_of redex |
213 val rhs = HOLogic.mk_Collect ("x", rT, inner_t) |
213 val rhs = HOLogic.mk_Collect ("x", rT, inner_t) |
214 val rewrite_rule_t = HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs)) |
214 val rewrite_rule_t = HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs)) |
215 in |
215 in |