162 val {sel_rews, ...} = result; |
162 val {sel_rews, ...} = result; |
163 val when_rews = #cases result; |
163 val when_rews = #cases result; |
164 val when_strict = hd when_rews; |
164 val when_strict = hd when_rews; |
165 val dis_rews = #dis_rews result; |
165 val dis_rews = #dis_rews result; |
166 val mat_rews = #match_rews result; |
166 val mat_rews = #match_rews result; |
167 val axs_pat_def = #pat_rews result; |
167 val pat_rews = #pat_rews result; |
168 |
168 |
169 (* ----- theorems concerning the isomorphism -------------------------------- *) |
169 (* ----- theorems concerning the isomorphism -------------------------------- *) |
170 |
170 |
171 val pg = pg' thy; |
171 val pg = pg' thy; |
172 |
172 |
173 val dc_copy = %%:(dname^"_copy"); |
173 val dc_copy = %%:(dname^"_copy"); |
174 |
174 |
175 val abs_strict = ax_rep_iso RS (allI RS retraction_strict); |
175 val abs_strict = ax_rep_iso RS (allI RS retraction_strict); |
176 val rep_strict = ax_abs_iso RS (allI RS retraction_strict); |
176 val rep_strict = ax_abs_iso RS (allI RS retraction_strict); |
177 val iso_rews = map Drule.export_without_context [ax_abs_iso, ax_rep_iso, abs_strict, rep_strict]; |
177 val iso_rews = map Drule.export_without_context [ax_abs_iso, ax_rep_iso, abs_strict, rep_strict]; |
178 |
|
179 (* ----- theorems concerning the constructors, discriminators and selectors - *) |
|
180 |
|
181 local |
|
182 fun ps args = mapn (fn n => fn _ => %:("pat" ^ string_of_int n)) 1 args; |
|
183 |
|
184 fun pat_lhs (con,_,args) = mk_branch (list_comb (%%:(pat_name con), ps args)); |
|
185 |
|
186 fun pat_rhs (con,_,[]) = mk_return ((%:"rhs") ` HOLogic.unit) |
|
187 | pat_rhs (con,_,args) = |
|
188 (mk_branch (mk_ctuple_pat (ps args))) |
|
189 `(%:"rhs")`(mk_ctuple (map %# args)); |
|
190 |
|
191 fun pat_strict c = |
|
192 let |
|
193 val axs = @{thm branch_def} :: axs_pat_def; |
|
194 val goal = mk_trp (strict (pat_lhs c ` (%:"rhs"))); |
|
195 val tacs = [simp_tac (HOLCF_ss addsimps [when_strict]) 1]; |
|
196 in pg axs goal (K tacs) end; |
|
197 |
|
198 fun pat_app c (con, _, args) = |
|
199 let |
|
200 val axs = @{thm branch_def} :: axs_pat_def; |
|
201 val lhs = (pat_lhs c)`(%:"rhs")`(con_app con args); |
|
202 val rhs = if con = first c then pat_rhs c else mk_fail; |
|
203 val goal = lift_defined %: (nonlazy args, mk_trp (lhs === rhs)); |
|
204 val tacs = [asm_simp_tac (HOLCF_ss addsimps when_rews) 1]; |
|
205 in pg axs goal (K tacs) end; |
|
206 |
|
207 val _ = trace " Proving pat_stricts..."; |
|
208 val pat_stricts = map pat_strict cons; |
|
209 val _ = trace " Proving pat_apps..."; |
|
210 val pat_apps = maps (fn c => map (pat_app c) cons) cons; |
|
211 in |
|
212 val pat_rews = pat_stricts @ pat_apps; |
|
213 end; |
|
214 |
178 |
215 (* ----- theorems concerning one induction step ----------------------------- *) |
179 (* ----- theorems concerning one induction step ----------------------------- *) |
216 |
180 |
217 val copy_strict = |
181 val copy_strict = |
218 let |
182 let |