1 theory IntEx |
1 theory IntEx |
2 imports QuotMain |
2 imports QuotMain |
3 begin |
3 begin |
4 |
4 |
5 fun |
5 fun |
6 intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" |
6 intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" (infix "\<approx>" 50) |
7 where |
7 where |
8 "intrel (x, y) (u, v) = (x + v = u + y)" |
8 "intrel (x, y) (u, v) = (x + v = u + y)" |
9 |
9 |
10 quotient my_int = "nat \<times> nat" / intrel |
10 quotient my_int = "nat \<times> nat" / intrel |
11 apply(unfold EQUIV_def) |
11 apply(unfold EQUIV_def) |
146 |
145 |
147 |
146 |
148 |
147 |
149 |
148 |
150 |
149 |
151 |
150 lemma ho_tst: "foldl my_plus x [] = x" |
|
151 apply simp |
|
152 done |
152 |
153 |
153 text {* Below is the construction site code used if things do not work *} |
154 text {* Below is the construction site code used if things do not work *} |
154 ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *} |
155 ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *} |
155 ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int" *} |
156 ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int" *} |
156 ML {* val abs = findabs rty (prop_of (atomize_thm @{thm plus_sym_pre})) *} |
|
157 ML {* val simp_lam_prs_thms = map (make_simp_prs_thm @{context} quot @{thm LAMBDA_PRS}) abs *} |
|
158 ML {* val defs_sym = add_lower_defs @{context} defs *} |
|
159 (* ML {* val consts = [@{const_name my_plus}] *}*) |
157 (* ML {* val consts = [@{const_name my_plus}] *}*) |
160 ML {* val consts = lookup_quot_consts defs *} |
158 ML {* val consts = lookup_quot_consts defs *} |
161 ML {* val t_a = atomize_thm @{thm ho_tst} *} |
159 ML {* val t_a = atomize_thm @{thm ho_tst} *} |
162 prove t_r: {* build_regularize_goal t_a rty rel @{context} *} |
160 |
|
161 (*prove t_r: {* build_regularize_goal t_a rty rel @{context} *} |
163 ML_prf {* fun tac ctxt = |
162 ML_prf {* fun tac ctxt = |
164 (ObjectLogic.full_atomize_tac) THEN' |
163 (ObjectLogic.full_atomize_tac) THEN' |
165 REPEAT_ALL_NEW (FIRST' [ |
164 REPEAT_ALL_NEW (FIRST' [ |
166 rtac rel_refl, |
165 rtac rel_refl, |
167 atac, |
166 atac, |
175 (rtac @{thm RIGHT_RES_FORALL_REGULAR}) |
174 (rtac @{thm RIGHT_RES_FORALL_REGULAR}) |
176 ]);*} |
175 ]);*} |
177 apply (atomize(full)) |
176 apply (atomize(full)) |
178 apply (tactic {* tac @{context} 1 *}) |
177 apply (tactic {* tac @{context} 1 *}) |
179 apply (auto) |
178 apply (auto) |
180 sorry |
179 done |
181 (*ML {* val t_r = regularize t_a rty rel rel_eqv rel_refl @{context} *}*) |
180 ML {* val t_r = @{thm t_r} OF [t_a] *}*) |
182 ML {* val t_t = Toplevel.program (fn () => repabs @{context} @{thm t_r} consts rty qty quot rel_refl trans2 rsp_thms) *} |
181 ML {* val t_r = regularize t_a rty rel rel_eqv rel_refl @{context} *} |
|
182 ML {* |
|
183 val rt = build_repabs_term @{context} t_r consts rty qty |
|
184 val rg = Logic.mk_equals ((Thm.prop_of t_r), rt); |
|
185 *} |
|
186 |
|
187 lemma foldl_rsp: |
|
188 "((IntEx.intrel ===> IntEx.intrel ===> IntEx.intrel) ===> |
|
189 IntEx.intrel ===> op = ===> IntEx.intrel) |
|
190 foldl foldl" |
|
191 apply (simp only:FUN_REL.simps) |
|
192 apply (rule allI) |
|
193 apply (rule allI) |
|
194 apply (rule impI) |
|
195 apply (rule allI) |
|
196 apply (rule allI) |
|
197 apply (rule impI) |
|
198 apply (rule allI) |
|
199 apply (rule allI) |
|
200 apply (rule impI) |
|
201 apply (simp only:) |
|
202 apply (rule list.induct) |
|
203 apply (simp) |
|
204 apply (simp only: foldl.simps) |
|
205 sorry |
|
206 |
|
207 ML {* val rsp_thms = @{thm foldl_rsp} :: rsp_thms *} |
|
208 prove t_t: rg |
|
209 apply(atomize(full)) |
|
210 ML_prf {* fun r_mk_comb_tac_int lthy = r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms *} |
|
211 apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_int @{context}) 1 *}) |
|
212 done |
|
213 ML {* val t_t = @{thm Pure.equal_elim_rule1} OF [@{thm t_t},t_r] *} |
|
214 ML {* val abs = findabs rty (prop_of t_a) *} |
|
215 ML {* val aps = findaps rty (prop_of t_a); *} |
|
216 ML {* val simp_lam_prs_thms = map (make_simp_prs_thm @{context} quot @{thm LAMBDA_PRS}) abs *} |
|
217 |
|
218 (*ML {* val t_t = Toplevel.program (fn () => repabs @{context} @{thm t_r} consts rty qty quot rel_refl trans2 rsp_thms) *}*) |
183 ML {* val (alls, exs) = findallex rty qty (prop_of t_a) *} |
219 ML {* val (alls, exs) = findallex rty qty (prop_of t_a) *} |
184 ML {* val allthms = map (make_allex_prs_thm @{context} quot @{thm FORALL_PRS}) alls *} |
220 ML {* val allthms = map (make_allex_prs_thm @{context} quot @{thm FORALL_PRS}) alls *} |
185 ML {* val t_a = MetaSimplifier.rewrite_rule (allthms) t_t *} |
221 ML {* val t_a = MetaSimplifier.rewrite_rule (allthms) t_t *} |
186 ML {* val t_l = repeat_eqsubst_thm @{context} simp_lam_prs_thms t_a *} |
222 ML {* val t_l = repeat_eqsubst_thm @{context} simp_lam_prs_thms t_a *} |
|
223 ML {* val defs_sym = add_lower_defs @{context} defs *} |
187 ML {* val t_d = repeat_eqsubst_thm @{context} defs_sym t_l *} |
224 ML {* val t_d = repeat_eqsubst_thm @{context} defs_sym t_l *} |
188 ML {* val t_r = MetaSimplifier.rewrite_rule [reps_same] t_d *} |
225 ML {* val t_r = MetaSimplifier.rewrite_rule [reps_same] t_d *} |
189 ML {* ObjectLogic.rulify t_r *} |
226 ML {* ObjectLogic.rulify t_r *} |
190 |
|
191 thm FORALL_PRS |
|
192 |
|