157 let |
157 let |
158 val thy = Proof_Context.theory_of ctxt |
158 val thy = Proof_Context.theory_of ctxt |
159 val eval_if_P = |
159 val eval_if_P = |
160 @{lemma "P ==> Predicate.eval x z ==> Predicate.eval (if P then x else y) z" by simp} |
160 @{lemma "P ==> Predicate.eval x z ==> Predicate.eval (if P then x else y) z" by simp} |
161 fun get_case_rewrite t = |
161 fun get_case_rewrite t = |
162 if (is_constructor thy t) then let |
162 if (is_constructor thy t) then |
163 val case_rewrites = (#case_rewrites (Datatype.the_info thy |
163 let |
164 ((fst o dest_Type o fastype_of) t))) |
164 val {case_rewrites, ...} = Datatype.the_info thy (fst (dest_Type (fastype_of t))) |
165 in fold (union Thm.eq_thm) (case_rewrites :: map get_case_rewrite (snd (strip_comb t))) [] end |
165 in |
|
166 fold (union Thm.eq_thm) (case_rewrites :: map get_case_rewrite (snd (strip_comb t))) [] |
|
167 end |
166 else [] |
168 else [] |
167 val simprules = insert Thm.eq_thm @{thm "unit.cases"} (insert Thm.eq_thm @{thm "prod.cases"} |
169 val simprules = insert Thm.eq_thm @{thm "unit.cases"} (insert Thm.eq_thm @{thm "prod.cases"} |
168 (fold (union Thm.eq_thm) (map get_case_rewrite out_ts) [])) |
170 (fold (union Thm.eq_thm) (map get_case_rewrite out_ts) [])) |
169 (* replace TRY by determining if it necessary - are there equations when calling compile match? *) |
171 (* replace TRY by determining if it necessary - are there equations when calling compile match? *) |
170 in |
172 in |
325 val thy = Proof_Context.theory_of ctxt |
327 val thy = Proof_Context.theory_of ctxt |
326 fun split_term_tac (Free _) = all_tac |
328 fun split_term_tac (Free _) = all_tac |
327 | split_term_tac t = |
329 | split_term_tac t = |
328 if (is_constructor thy t) then |
330 if (is_constructor thy t) then |
329 let |
331 let |
330 val info = Datatype.the_info thy ((fst o dest_Type o fastype_of) t) |
332 val {case_rewrites, split_asm, ...} = |
331 val num_of_constrs = length (#case_rewrites info) |
333 Datatype.the_info thy (fst (dest_Type (fastype_of t))) |
|
334 val num_of_constrs = length case_rewrites |
332 val (_, ts) = strip_comb t |
335 val (_, ts) = strip_comb t |
333 in |
336 in |
334 print_tac options ("Term " ^ (Syntax.string_of_term ctxt t) ^ |
337 print_tac options ("Term " ^ (Syntax.string_of_term ctxt t) ^ |
335 "splitting with rules \n" ^ Display.string_of_thm ctxt (#split_asm info)) |
338 "splitting with rules \n" ^ Display.string_of_thm ctxt split_asm) |
336 THEN TRY ((Splitter.split_asm_tac [#split_asm info] 1) |
339 THEN TRY (Splitter.split_asm_tac [split_asm] 1 |
337 THEN (print_tac options "after splitting with split_asm rules") |
340 THEN (print_tac options "after splitting with split_asm rules") |
338 (* THEN (Simplifier.asm_full_simp_tac HOL_basic_ss 1) |
341 (* THEN (Simplifier.asm_full_simp_tac HOL_basic_ss 1) |
339 THEN (DETERM (TRY (etac @{thm Pair_inject} 1)))*) |
342 THEN (DETERM (TRY (etac @{thm Pair_inject} 1)))*) |
340 THEN (REPEAT_DETERM_N (num_of_constrs - 1) |
343 THEN (REPEAT_DETERM_N (num_of_constrs - 1) |
341 (etac @{thm botE} 1 ORELSE etac @{thm botE} 2))) |
344 (etac @{thm botE} 1 ORELSE etac @{thm botE} 2))) |