556 let |
556 let |
557 val (fun1, fun2, taken) = pat_lhs (pat, args); |
557 val (fun1, fun2, taken) = pat_lhs (pat, args); |
558 val defs = @{thm branch_def} :: pat_defs; |
558 val defs = @{thm branch_def} :: pat_defs; |
559 val goal = mk_trp (mk_strict fun1); |
559 val goal = mk_trp (mk_strict fun1); |
560 val rules = @{thms match_bind_simps} @ case_rews; |
560 val rules = @{thms match_bind_simps} @ case_rews; |
561 val tacs = [simp_tac (Simplifier.global_context thy beta_ss addsimps rules) 1]; |
561 fun tacs ctxt = [simp_tac (put_simpset beta_ss ctxt addsimps rules) 1]; |
562 in prove thy defs goal (K tacs) end; |
562 in prove thy defs goal (tacs o #context) end; |
563 fun pat_apps (i, (pat, (con, args))) = |
563 fun pat_apps (i, (pat, (con, args))) = |
564 let |
564 let |
565 val (fun1, fun2, taken) = pat_lhs (pat, args); |
565 val (fun1, fun2, taken) = pat_lhs (pat, args); |
566 fun pat_app (j, (con', args')) = |
566 fun pat_app (j, (con', args')) = |
567 let |
567 let |
571 val rhs = if i = j then fun2 ` mk_tuple vs else mk_fail R; |
571 val rhs = if i = j then fun2 ` mk_tuple vs else mk_fail R; |
572 val concl = mk_trp (mk_eq (fun1 ` con_app, rhs)); |
572 val concl = mk_trp (mk_eq (fun1 ` con_app, rhs)); |
573 val goal = Logic.list_implies (assms, concl); |
573 val goal = Logic.list_implies (assms, concl); |
574 val defs = @{thm branch_def} :: pat_defs; |
574 val defs = @{thm branch_def} :: pat_defs; |
575 val rules = @{thms match_bind_simps} @ case_rews; |
575 val rules = @{thms match_bind_simps} @ case_rews; |
576 val tacs = [asm_simp_tac (Simplifier.global_context thy beta_ss addsimps rules) 1]; |
576 fun tacs ctxt = [asm_simp_tac (put_simpset beta_ss ctxt addsimps rules) 1]; |
577 in prove thy defs goal (K tacs) end; |
577 in prove thy defs goal (tacs o #context) end; |
578 in map_index pat_app spec end; |
578 in map_index pat_app spec end; |
579 in |
579 in |
580 val pat_stricts = map pat_strict (pat_consts ~~ spec); |
580 val pat_stricts = map pat_strict (pat_consts ~~ spec); |
581 val pat_apps = flat (map_index pat_apps (pat_consts ~~ spec)); |
581 val pat_apps = flat (map_index pat_apps (pat_consts ~~ spec)); |
582 end; |
582 end; |