848 (mk_prodT (U1, U2) ->> mk_matchT (mk_prodT (V1, V2))); |
848 (mk_prodT (U1, U2) ->> mk_matchT (mk_prodT (V1, V2))); |
849 val pat_const = Const (@{const_name cpair_pat}, pat_typ); |
849 val pat_const = Const (@{const_name cpair_pat}, pat_typ); |
850 in |
850 in |
851 pat_const $ p1 $ p2 |
851 pat_const $ p1 $ p2 |
852 end; |
852 end; |
853 fun mk_tuple_pat [] = return_const HOLogic.unitT |
853 fun mk_tuple_pat [] = succeed_const HOLogic.unitT |
854 | mk_tuple_pat ps = foldr1 mk_pair_pat ps; |
854 | mk_tuple_pat ps = foldr1 mk_pair_pat ps; |
855 fun branch_const (T,U,V) = |
855 fun branch_const (T,U,V) = |
856 Const (@{const_name branch}, |
856 Const (@{const_name branch}, |
857 (T ->> mk_matchT U) --> (U ->> V) ->> T ->> mk_matchT V); |
857 (T ->> mk_matchT U) --> (U ->> V) ->> T ->> mk_matchT V); |
858 |
858 |
949 fun pat_strict (pat, (con, args)) = |
949 fun pat_strict (pat, (con, args)) = |
950 let |
950 let |
951 val (fun1, fun2, taken) = pat_lhs (pat, args); |
951 val (fun1, fun2, taken) = pat_lhs (pat, args); |
952 val defs = @{thm branch_def} :: pat_defs; |
952 val defs = @{thm branch_def} :: pat_defs; |
953 val goal = mk_trp (mk_strict fun1); |
953 val goal = mk_trp (mk_strict fun1); |
954 val rules = @{thms maybe_when_rews} @ case_rews; |
954 val rules = @{thms match_case_simps} @ case_rews; |
955 val tacs = [simp_tac (beta_ss addsimps rules) 1]; |
955 val tacs = [simp_tac (beta_ss addsimps rules) 1]; |
956 in prove thy defs goal (K tacs) end; |
956 in prove thy defs goal (K tacs) end; |
957 fun pat_apps (i, (pat, (con, args))) = |
957 fun pat_apps (i, (pat, (con, args))) = |
958 let |
958 let |
959 val (fun1, fun2, taken) = pat_lhs (pat, args); |
959 val (fun1, fun2, taken) = pat_lhs (pat, args); |
964 val assms = map (mk_trp o mk_defined) nonlazy; |
964 val assms = map (mk_trp o mk_defined) nonlazy; |
965 val rhs = if i = j then fun2 ` mk_tuple vs else mk_fail R; |
965 val rhs = if i = j then fun2 ` mk_tuple vs else mk_fail R; |
966 val concl = mk_trp (mk_eq (fun1 ` con_app, rhs)); |
966 val concl = mk_trp (mk_eq (fun1 ` con_app, rhs)); |
967 val goal = Logic.list_implies (assms, concl); |
967 val goal = Logic.list_implies (assms, concl); |
968 val defs = @{thm branch_def} :: pat_defs; |
968 val defs = @{thm branch_def} :: pat_defs; |
969 val rules = @{thms maybe_when_rews} @ case_rews; |
969 val rules = @{thms match_case_simps} @ case_rews; |
970 val tacs = [asm_simp_tac (beta_ss addsimps rules) 1]; |
970 val tacs = [asm_simp_tac (beta_ss addsimps rules) 1]; |
971 in prove thy defs goal (K tacs) end; |
971 in prove thy defs goal (K tacs) end; |
972 in map_index pat_app spec end; |
972 in map_index pat_app spec end; |
973 in |
973 in |
974 val pat_stricts = map pat_strict (pat_consts ~~ spec); |
974 val pat_stricts = map pat_strict (pat_consts ~~ spec); |