134 |
134 |
135 lemma plus_rsp[quotient_rsp]: |
135 lemma plus_rsp[quotient_rsp]: |
136 shows "(intrel ===> intrel ===> intrel) my_plus my_plus" |
136 shows "(intrel ===> intrel ===> intrel) my_plus my_plus" |
137 by (simp) |
137 by (simp) |
138 |
138 |
139 ML {* val qty = @{typ "my_int"} *} |
|
140 ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *} |
|
141 ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int"; *} |
|
142 |
|
143 ML {* fun lift_tac_intex lthy t = lift_tac lthy t *} |
|
144 |
|
145 ML {* fun inj_repabs_tac_intex lthy = inj_repabs_tac lthy [rel_refl] [trans2] *} |
|
146 ML {* fun all_inj_repabs_tac_intex lthy = all_inj_repabs_tac lthy [rel_refl] [trans2] *} |
|
147 |
|
148 lemma test1: "my_plus a b = my_plus a b" |
139 lemma test1: "my_plus a b = my_plus a b" |
149 apply(rule refl) |
140 apply(rule refl) |
150 done |
141 done |
151 |
142 |
152 lemma "PLUS a b = PLUS a b" |
143 lemma "PLUS a b = PLUS a b" |
153 apply(tactic {* procedure_tac @{context} @{thm test1} 1 *}) |
144 apply(tactic {* procedure_tac @{context} @{thm test1} 1 *}) |
154 apply(tactic {* regularize_tac @{context} 1 *}) |
145 apply(tactic {* regularize_tac @{context} 1 *}) |
155 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
146 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
156 apply(tactic {* clean_tac @{context} 1 *}) |
147 apply(tactic {* clean_tac @{context} 1 *}) |
157 done |
148 done |
158 |
149 |
159 thm lambda_prs |
150 thm lambda_prs |
160 |
151 |
166 apply(tactic {* procedure_tac @{context} @{thm test2} 1 *}) |
157 apply(tactic {* procedure_tac @{context} @{thm test2} 1 *}) |
167 apply(rule impI) |
158 apply(rule impI) |
168 apply(rule ballI) |
159 apply(rule ballI) |
169 apply(rule apply_rsp[OF Quotient_my_int plus_rsp]) |
160 apply(rule apply_rsp[OF Quotient_my_int plus_rsp]) |
170 apply(simp only: in_respects) |
161 apply(simp only: in_respects) |
171 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
162 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
172 apply(tactic {* clean_tac @{context} 1 *}) |
163 apply(tactic {* clean_tac @{context} 1 *}) |
173 done |
164 done |
174 |
165 |
175 lemma test3: "my_plus = my_plus" |
166 lemma test3: "my_plus = my_plus" |
176 apply(rule refl) |
167 apply(rule refl) |
178 |
169 |
179 lemma "PLUS = PLUS" |
170 lemma "PLUS = PLUS" |
180 apply(tactic {* procedure_tac @{context} @{thm test3} 1 *}) |
171 apply(tactic {* procedure_tac @{context} @{thm test3} 1 *}) |
181 apply(rule impI) |
172 apply(rule impI) |
182 apply(rule plus_rsp) |
173 apply(rule plus_rsp) |
183 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
174 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
184 apply(tactic {* clean_tac @{context} 1 *}) |
175 apply(tactic {* clean_tac @{context} 1 *}) |
185 done |
176 done |
186 |
177 |
187 |
178 |
188 lemma "PLUS a b = PLUS b a" |
179 lemma "PLUS a b = PLUS b a" |
189 apply(tactic {* procedure_tac @{context} @{thm plus_sym_pre} 1 *}) |
180 apply(tactic {* procedure_tac @{context} @{thm plus_sym_pre} 1 *}) |
190 apply(tactic {* regularize_tac @{context} 1 *}) |
181 apply(tactic {* regularize_tac @{context} 1 *}) |
191 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
182 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
192 apply(tactic {* clean_tac @{context} 1 *}) |
183 apply(tactic {* clean_tac @{context} 1 *}) |
193 done |
184 done |
194 |
185 |
195 lemma plus_assoc_pre: |
186 lemma plus_assoc_pre: |
196 shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)" |
187 shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)" |
201 done |
192 done |
202 |
193 |
203 lemma plus_assoc: "PLUS (PLUS x xa) xb = PLUS x (PLUS xa xb)" |
194 lemma plus_assoc: "PLUS (PLUS x xa) xb = PLUS x (PLUS xa xb)" |
204 apply(tactic {* procedure_tac @{context} @{thm plus_assoc_pre} 1 *}) |
195 apply(tactic {* procedure_tac @{context} @{thm plus_assoc_pre} 1 *}) |
205 apply(tactic {* regularize_tac @{context} 1 *}) |
196 apply(tactic {* regularize_tac @{context} 1 *}) |
206 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
197 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
207 apply(tactic {* clean_tac @{context} 1 *}) |
198 apply(tactic {* clean_tac @{context} 1 *}) |
208 done |
199 done |
209 |
200 |
210 lemma ho_tst: "foldl my_plus x [] = x" |
201 lemma ho_tst: "foldl my_plus x [] = x" |
211 apply simp |
202 apply simp |
212 done |
203 done |
213 |
204 |
214 lemma "foldl PLUS x [] = x" |
205 lemma "foldl PLUS x [] = x" |
215 apply(tactic {* procedure_tac @{context} @{thm ho_tst} 1 *}) |
206 apply(tactic {* procedure_tac @{context} @{thm ho_tst} 1 *}) |
216 apply(tactic {* regularize_tac @{context} 1 *}) |
207 apply(tactic {* regularize_tac @{context} 1 *}) |
217 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
208 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
218 apply(tactic {* clean_tac @{context} 1 *}) |
209 apply(tactic {* clean_tac @{context} 1 *}) |
219 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int]) |
210 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int]) |
220 done |
211 done |
221 |
212 |
222 lemma ho_tst2: "foldl my_plus x (h # t) \<approx> my_plus h (foldl my_plus x t)" |
213 lemma ho_tst2: "foldl my_plus x (h # t) \<approx> my_plus h (foldl my_plus x t)" |
223 sorry |
214 sorry |
224 |
215 |
225 lemma "foldl PLUS x (h # t) = PLUS h (foldl PLUS x t)" |
216 lemma "foldl PLUS x (h # t) = PLUS h (foldl PLUS x t)" |
226 apply(tactic {* procedure_tac @{context} @{thm ho_tst2} 1 *}) |
217 apply(tactic {* procedure_tac @{context} @{thm ho_tst2} 1 *}) |
227 apply(tactic {* regularize_tac @{context} 1 *}) |
218 apply(tactic {* regularize_tac @{context} 1 *}) |
228 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
219 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
229 apply(tactic {* clean_tac @{context} 1 *}) |
220 apply(tactic {* clean_tac @{context} 1 *}) |
230 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] cons_prs[OF Quotient_my_int]) |
221 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] cons_prs[OF Quotient_my_int]) |
231 done |
222 done |
232 |
223 |
233 lemma ho_tst3: "foldl f (s::nat \<times> nat) ([]::(nat \<times> nat) list) = s" |
224 lemma ho_tst3: "foldl f (s::nat \<times> nat) ([]::(nat \<times> nat) list) = s" |
234 by simp |
225 by simp |
235 |
226 |
236 lemma "foldl f (x::my_int) ([]::my_int list) = x" |
227 lemma "foldl f (x::my_int) ([]::my_int list) = x" |
237 apply(tactic {* procedure_tac @{context} @{thm ho_tst3} 1 *}) |
228 apply(tactic {* procedure_tac @{context} @{thm ho_tst3} 1 *}) |
238 apply(tactic {* regularize_tac @{context} 1 *}) |
229 apply(tactic {* regularize_tac @{context} 1 *}) |
239 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
230 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
240 (* TODO: does not work when this is added *) |
231 (* TODO: does not work when this is added *) |
241 (* apply(tactic {* lambda_prs_tac @{context} 1 *})*) |
232 (* apply(tactic {* lambda_prs_tac @{context} 1 *})*) |
242 apply(tactic {* clean_tac @{context} 1 *}) |
233 apply(tactic {* clean_tac @{context} 1 *}) |
243 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int]) |
234 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int]) |
244 done |
235 done |
247 by simp |
238 by simp |
248 |
239 |
249 lemma "(\<lambda>x. (x, x)) (y::my_int) = (y, y)" |
240 lemma "(\<lambda>x. (x, x)) (y::my_int) = (y, y)" |
250 apply(tactic {* procedure_tac @{context} @{thm lam_tst} 1 *}) |
241 apply(tactic {* procedure_tac @{context} @{thm lam_tst} 1 *}) |
251 apply(tactic {* regularize_tac @{context} 1 *}) |
242 apply(tactic {* regularize_tac @{context} 1 *}) |
252 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
243 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
253 apply(tactic {* clean_tac @{context} 1 *}) |
244 apply(tactic {* clean_tac @{context} 1 *}) |
254 apply(simp add: pair_prs) |
245 apply(simp add: pair_prs) |
255 done |
246 done |
256 |
247 |
257 lemma lam_tst2: "(\<lambda>(y :: nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat). x)" |
248 lemma lam_tst2: "(\<lambda>(y :: nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat). x)" |
323 done |
314 done |
324 |
315 |
325 lemma "(\<lambda>(y :: my_int). y) = (\<lambda>(x :: my_int). x)" |
316 lemma "(\<lambda>(y :: my_int). y) = (\<lambda>(x :: my_int). x)" |
326 apply(tactic {* procedure_tac @{context} @{thm lam_tst3a} 1 *}) |
317 apply(tactic {* procedure_tac @{context} @{thm lam_tst3a} 1 *}) |
327 defer |
318 defer |
328 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
319 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
329 apply(tactic {* clean_tac @{context} 1 *}) |
320 apply(tactic {* clean_tac @{context} 1 *}) |
330 apply(subst babs_rsp) |
321 apply(subst babs_rsp) |
331 apply(tactic {* clean_tac @{context} 1 *}) |
322 apply(tactic {* clean_tac @{context} 1 *}) |
332 apply(simp) |
323 apply(simp) |
333 apply(tactic {* regularize_tac @{context} 1*})? |
324 apply(tactic {* regularize_tac @{context} 1*})? |
341 by auto |
332 by auto |
342 |
333 |
343 lemma "(\<lambda>(y :: my_int => my_int). y) = (\<lambda>(x :: my_int => my_int). x)" |
334 lemma "(\<lambda>(y :: my_int => my_int). y) = (\<lambda>(x :: my_int => my_int). x)" |
344 apply(tactic {* procedure_tac @{context} @{thm lam_tst3b} 1 *}) |
335 apply(tactic {* procedure_tac @{context} @{thm lam_tst3b} 1 *}) |
345 defer |
336 defer |
346 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*}) |
337 apply(tactic {* all_inj_repabs_tac @{context} 1*}) |
347 apply(tactic {* clean_tac @{context} 1 *}) |
338 apply(tactic {* clean_tac @{context} 1 *}) |
348 apply(subst babs_rsp) |
339 apply(subst babs_rsp) |
349 apply(tactic {* clean_tac @{context} 1 *}) |
340 apply(tactic {* clean_tac @{context} 1 *}) |
350 apply(simp) |
341 apply(simp) |
351 apply(tactic {* regularize_tac @{context} 1*})? |
342 apply(tactic {* regularize_tac @{context} 1*})? |