equal
deleted
inserted
replaced
96 val (names, pre_fixdefs) = ListPair.unzip (defs lhss fixpoint); |
96 val (names, pre_fixdefs) = ListPair.unzip (defs lhss fixpoint); |
97 |
97 |
98 val fixdefs = map (apsnd (legacy_infer_prop thy)) pre_fixdefs; |
98 val fixdefs = map (apsnd (legacy_infer_prop thy)) pre_fixdefs; |
99 val (fixdef_thms, thy') = |
99 val (fixdef_thms, thy') = |
100 PureThy.add_defs_i false (map Thm.no_attributes fixdefs) thy; |
100 PureThy.add_defs_i false (map Thm.no_attributes fixdefs) thy; |
101 val ctuple_fixdef_thm = foldr1 (fn (x,y) => cpair_equalI OF [x,y]) fixdef_thms; |
101 val ctuple_fixdef_thm = foldr1 (fn (x,y) => @{thm cpair_equalI} OF [x,y]) fixdef_thms; |
102 |
102 |
103 val ctuple_unfold = legacy_infer_term thy' (mk_trp (mk_ctuple lhss === mk_ctuple rhss)); |
103 val ctuple_unfold = legacy_infer_term thy' (mk_trp (mk_ctuple lhss === mk_ctuple rhss)); |
104 val ctuple_unfold_thm = Goal.prove_global thy' [] [] ctuple_unfold |
104 val ctuple_unfold_thm = Goal.prove_global thy' [] [] ctuple_unfold |
105 (fn _ => EVERY [rtac (ctuple_fixdef_thm RS fix_eq2 RS trans) 1, |
105 (fn _ => EVERY [rtac (ctuple_fixdef_thm RS fix_eq2 RS trans) 1, |
106 simp_tac (simpset_of thy') 1]); |
106 simp_tac (simpset_of thy') 1]); |
108 (space_implode "_" names ^ "_induct", ctuple_fixdef_thm RS def_fix_ind); |
108 (space_implode "_" names ^ "_induct", ctuple_fixdef_thm RS def_fix_ind); |
109 |
109 |
110 fun unfolds [] thm = [] |
110 fun unfolds [] thm = [] |
111 | unfolds (n::[]) thm = [(n^"_unfold", thm)] |
111 | unfolds (n::[]) thm = [(n^"_unfold", thm)] |
112 | unfolds (n::ns) thm = let |
112 | unfolds (n::ns) thm = let |
113 val thmL = thm RS cpair_eqD1; |
113 val thmL = thm RS @{thm cpair_eqD1}; |
114 val thmR = thm RS cpair_eqD2; |
114 val thmR = thm RS @{thm cpair_eqD2}; |
115 in (n^"_unfold", thmL) :: unfolds ns thmR end; |
115 in (n^"_unfold", thmL) :: unfolds ns thmR end; |
116 val unfold_thms = unfolds names ctuple_unfold_thm; |
116 val unfold_thms = unfolds names ctuple_unfold_thm; |
117 val thms = ctuple_induct_thm :: unfold_thms; |
117 val thms = ctuple_induct_thm :: unfold_thms; |
118 val (_, thy'') = PureThy.add_thms (map Thm.no_attributes thms) thy'; |
118 val (_, thy'') = PureThy.add_thms (map Thm.no_attributes thms) thy'; |
119 in |
119 in |
208 (*************************************************************************) |
208 (*************************************************************************) |
209 |
209 |
210 (* proves a block of pattern matching equations as theorems, using unfold *) |
210 (* proves a block of pattern matching equations as theorems, using unfold *) |
211 fun make_simps thy (unfold_thm, eqns) = |
211 fun make_simps thy (unfold_thm, eqns) = |
212 let |
212 let |
213 val tacs = [rtac (unfold_thm RS ssubst_lhs) 1, asm_simp_tac (simpset_of thy) 1]; |
213 val tacs = [rtac (unfold_thm RS @{thm ssubst_lhs}) 1, asm_simp_tac (simpset_of thy) 1]; |
214 fun prove_term t = Goal.prove_global thy [] [] t (K (EVERY tacs)); |
214 fun prove_term t = Goal.prove_global thy [] [] t (K (EVERY tacs)); |
215 fun prove_eqn ((name, eqn_t), atts) = ((name, prove_term eqn_t), atts); |
215 fun prove_eqn ((name, eqn_t), atts) = ((name, prove_term eqn_t), atts); |
216 in |
216 in |
217 map prove_eqn eqns |
217 map prove_eqn eqns |
218 end; |
218 end; |