23 apply(drule_tac x="- p \<bullet> xa" in bspec) |
23 apply(drule_tac x="- p \<bullet> xa" in bspec) |
24 apply(rule_tac ?p1="p" in in_permute_iff[THEN iffD1]) |
24 apply(rule_tac ?p1="p" in in_permute_iff[THEN iffD1]) |
25 apply(simp) |
25 apply(simp) |
26 apply(simp) |
26 apply(simp) |
27 done |
27 done |
28 |
|
29 lemma fresh_minus_perm: |
|
30 fixes p::perm |
|
31 shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p" |
|
32 apply(simp add: fresh_def) |
|
33 apply(simp only: supp_minus_perm) |
|
34 done |
|
35 |
28 |
36 lemma fresh_plus: |
29 lemma fresh_plus: |
37 fixes p q::perm |
30 fixes p q::perm |
38 shows "\<lbrakk>a \<sharp> p; a \<sharp> q\<rbrakk> \<Longrightarrow> a \<sharp> (p + q)" |
31 shows "\<lbrakk>a \<sharp> p; a \<sharp> q\<rbrakk> \<Longrightarrow> a \<sharp> (p + q)" |
39 unfolding fresh_def |
32 unfolding fresh_def |
151 inductive |
144 inductive |
152 alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100) |
145 alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100) |
153 where |
146 where |
154 a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)" |
147 a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)" |
155 | a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2" |
148 | a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2" |
156 | a3: "\<exists>pi. (rfv t - {atom a} = rfv s - {atom b} \<and> (rfv t - {atom a})\<sharp>* pi \<and> (pi \<bullet> t) \<approx> s) |
149 | a3: "\<exists>pi. (({atom a}, t) \<approx>gen alpha rfv pi ({atom b}, s)) \<Longrightarrow> rLam a t \<approx> rLam b s" |
157 \<Longrightarrow> rLam a t \<approx> rLam b s" |
150 |
|
151 thm alpha.induct |
158 |
152 |
159 lemma a3_inverse: |
153 lemma a3_inverse: |
160 assumes "rLam a t \<approx> rLam b s" |
154 assumes "rLam a t \<approx> rLam b s" |
161 shows "\<exists>pi. (rfv t - {atom a} = rfv s - {atom b} \<and> (rfv t - {atom a})\<sharp>* pi \<and> (pi \<bullet> t) \<approx> s)" |
155 shows "\<exists>pi. (({atom a}, t) \<approx>gen alpha rfv pi ({atom b}, s))" |
162 using assms |
156 using assms |
163 apply(erule_tac alpha.cases) |
157 apply(erule_tac alpha.cases) |
164 apply(auto) |
158 apply(auto) |
165 done |
159 done |
166 |
160 |
170 apply(induct rule: alpha.induct) |
164 apply(induct rule: alpha.induct) |
171 apply(simp add: a1) |
165 apply(simp add: a1) |
172 apply(simp add: a2) |
166 apply(simp add: a2) |
173 apply(simp) |
167 apply(simp) |
174 apply(rule a3) |
168 apply(rule a3) |
175 apply(erule conjE) |
|
176 apply(erule exE) |
169 apply(erule exE) |
177 apply(erule conjE) |
|
178 apply(rule_tac x="pi \<bullet> pia" in exI) |
170 apply(rule_tac x="pi \<bullet> pia" in exI) |
179 apply(rule conjI) |
171 apply(simp add: alpha_gen.simps) |
|
172 apply(erule conjE)+ |
|
173 apply(rule conjI)+ |
180 apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1]) |
174 apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1]) |
181 apply(simp add: eqvts atom_eqvt) |
175 apply(simp add: eqvts atom_eqvt) |
182 apply(rule conjI) |
176 apply(rule conjI) |
183 apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1]) |
177 apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1]) |
184 apply(simp add: eqvts atom_eqvt) |
178 apply(simp add: eqvts atom_eqvt) |
191 apply(induct t rule: rlam.induct) |
185 apply(induct t rule: rlam.induct) |
192 apply(simp add: a1) |
186 apply(simp add: a1) |
193 apply(simp add: a2) |
187 apply(simp add: a2) |
194 apply(rule a3) |
188 apply(rule a3) |
195 apply(rule_tac x="0" in exI) |
189 apply(rule_tac x="0" in exI) |
196 apply(simp_all add: fresh_star_def fresh_zero_perm) |
190 apply(rule alpha_gen_refl) |
197 done |
191 apply(assumption) |
|
192 done |
|
193 |
|
194 lemma fresh_minus_perm: |
|
195 fixes p::perm |
|
196 shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p" |
|
197 apply(simp add: fresh_def) |
|
198 apply(simp only: supp_minus_perm) |
|
199 done |
|
200 |
|
201 lemma alpha_gen_atom_sym: |
|
202 assumes a: "\<And>pi t s. (R t s \<Longrightarrow> R (pi \<bullet> t) (pi \<bullet> s))" |
|
203 shows "\<exists>pi. ({atom a}, t) \<approx>gen \<lambda>x1 x2. R x1 x2 \<and> R x2 x1 f pi ({atom b}, s) \<Longrightarrow> |
|
204 \<exists>pi. ({atom b}, s) \<approx>gen R f pi ({atom a}, t)" |
|
205 apply(erule exE) |
|
206 apply(rule_tac x="- pi" in exI) |
|
207 apply(simp add: alpha_gen.simps) |
|
208 apply(erule conjE)+ |
|
209 apply(rule conjI) |
|
210 apply(simp add: fresh_star_def fresh_minus_perm) |
|
211 apply(subgoal_tac "R (- pi \<bullet> s) ((- pi) \<bullet> (pi \<bullet> t))") |
|
212 apply simp |
|
213 apply(rule a) |
|
214 apply assumption |
|
215 done |
198 |
216 |
199 lemma alpha_sym: |
217 lemma alpha_sym: |
200 shows "t \<approx> s \<Longrightarrow> s \<approx> t" |
218 shows "t \<approx> s \<Longrightarrow> s \<approx> t" |
201 apply(induct rule: alpha.induct) |
219 apply(induct rule: alpha.induct) |
202 apply(simp add: a1) |
220 apply(simp add: a1) |
203 apply(simp add: a2) |
221 apply(simp add: a2) |
204 apply(rule a3) |
222 apply(rule a3) |
205 apply(erule exE) |
223 apply(rule alpha_gen_atom_sym) |
206 apply(rule_tac x="- pi" in exI) |
224 apply(rule alpha_eqvt) |
207 apply(simp) |
225 apply(assumption)+ |
208 apply(simp add: fresh_star_def fresh_minus_perm) |
226 done |
209 apply(erule conjE)+ |
|
210 apply(rotate_tac 3) |
|
211 apply(drule_tac pi="- pi" in alpha_eqvt) |
|
212 apply(simp) |
|
213 done |
|
214 |
227 |
215 lemma alpha_trans: |
228 lemma alpha_trans: |
216 shows "t1 \<approx> t2 \<Longrightarrow> t2 \<approx> t3 \<Longrightarrow> t1 \<approx> t3" |
229 shows "t1 \<approx> t2 \<Longrightarrow> t2 \<approx> t3 \<Longrightarrow> t1 \<approx> t3" |
217 apply(induct arbitrary: t3 rule: alpha.induct) |
230 apply(induct arbitrary: t3 rule: alpha.induct) |
218 apply(erule alpha.cases) |
231 apply(erule alpha.cases) |
223 apply(simp_all) |
236 apply(simp_all) |
224 apply(simp add: a2) |
237 apply(simp add: a2) |
225 apply(rotate_tac 1) |
238 apply(rotate_tac 1) |
226 apply(erule alpha.cases) |
239 apply(erule alpha.cases) |
227 apply(simp_all) |
240 apply(simp_all) |
|
241 apply(simp add: alpha_gen.simps) |
228 apply(erule conjE)+ |
242 apply(erule conjE)+ |
229 apply(erule exE)+ |
243 apply(erule exE)+ |
230 apply(erule conjE)+ |
244 apply(erule conjE)+ |
231 apply(rule a3) |
245 apply(rule a3) |
232 apply(rule_tac x="pia + pi" in exI) |
246 apply(rule_tac x="pia + pi" in exI) |
|
247 apply(simp add: alpha_gen.simps) |
233 apply(simp add: fresh_star_plus) |
248 apply(simp add: fresh_star_plus) |
234 apply(drule_tac x="- pia \<bullet> sa" in spec) |
249 apply(drule_tac x="- pia \<bullet> sa" in spec) |
235 apply(drule mp) |
250 apply(drule mp) |
236 apply(rotate_tac 7) |
251 apply(rotate_tac 7) |
237 apply(drule_tac pi="- pia" in alpha_eqvt) |
252 apply(drule_tac pi="- pia" in alpha_eqvt) |
249 done |
264 done |
250 |
265 |
251 lemma alpha_rfv: |
266 lemma alpha_rfv: |
252 shows "t \<approx> s \<Longrightarrow> rfv t = rfv s" |
267 shows "t \<approx> s \<Longrightarrow> rfv t = rfv s" |
253 apply(induct rule: alpha.induct) |
268 apply(induct rule: alpha.induct) |
254 apply(simp_all) |
269 apply(simp_all add: alpha_gen.simps) |
255 done |
270 done |
256 |
|
257 inductive |
|
258 alpha2 :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100) |
|
259 where |
|
260 a21: "a = b \<Longrightarrow> (rVar a) \<approx>2 (rVar b)" |
|
261 | a22: "\<lbrakk>t1 \<approx>2 t2; s1 \<approx>2 s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx>2 rApp t2 s2" |
|
262 | a23: "(a = b \<and> t \<approx>2 s) \<or> (a \<noteq> b \<and> ((a \<leftrightarrow> b) \<bullet> t) \<approx>2 s \<and> atom b \<notin> rfv t)\<Longrightarrow> rLam a t \<approx>2 rLam b s" |
|
263 |
|
264 lemma fv_vars: |
|
265 fixes a::name |
|
266 assumes a1: "\<forall>x \<in> rfv t - {atom a}. pi \<bullet> x = x" |
|
267 shows "(pi \<bullet> t) \<approx>2 ((a \<leftrightarrow> (pi \<bullet> a)) \<bullet> t)" |
|
268 using a1 |
|
269 apply(induct t) |
|
270 apply(auto) |
|
271 apply(rule a21) |
|
272 apply(case_tac "name = a") |
|
273 apply(simp) |
|
274 apply(simp) |
|
275 defer |
|
276 apply(rule a22) |
|
277 apply(simp) |
|
278 apply(simp) |
|
279 apply(rule a23) |
|
280 apply(case_tac "a = name") |
|
281 apply(simp) |
|
282 oops |
|
283 |
|
284 |
|
285 lemma |
|
286 assumes a1: "t \<approx>2 s" |
|
287 shows "t \<approx> s" |
|
288 using a1 |
|
289 apply(induct) |
|
290 apply(rule alpha.intros) |
|
291 apply(simp) |
|
292 apply(rule alpha.intros) |
|
293 apply(simp) |
|
294 apply(simp) |
|
295 apply(rule alpha.intros) |
|
296 apply(erule disjE) |
|
297 apply(rule_tac x="0" in exI) |
|
298 apply(simp add: fresh_star_def fresh_zero_perm) |
|
299 apply(erule conjE)+ |
|
300 apply(drule alpha_rfv) |
|
301 apply(simp) |
|
302 apply(rule_tac x="(a \<leftrightarrow> b)" in exI) |
|
303 apply(simp) |
|
304 apply(erule conjE)+ |
|
305 apply(rule conjI) |
|
306 apply(drule alpha_rfv) |
|
307 apply(drule sym) |
|
308 apply(simp) |
|
309 apply(simp add: rfv_eqvt[symmetric]) |
|
310 defer |
|
311 apply(subgoal_tac "atom a \<sharp> (rfv t - {atom a})") |
|
312 apply(subgoal_tac "atom b \<sharp> (rfv t - {atom a})") |
|
313 |
|
314 defer |
|
315 sorry |
|
316 |
|
317 lemma |
|
318 assumes a1: "t \<approx> s" |
|
319 shows "t \<approx>2 s" |
|
320 using a1 |
|
321 apply(induct) |
|
322 apply(rule alpha2.intros) |
|
323 apply(simp) |
|
324 apply(rule alpha2.intros) |
|
325 apply(simp) |
|
326 apply(simp) |
|
327 apply(clarify) |
|
328 apply(rule alpha2.intros) |
|
329 apply(frule alpha_rfv) |
|
330 apply(rotate_tac 4) |
|
331 apply(drule sym) |
|
332 apply(simp) |
|
333 apply(drule sym) |
|
334 apply(simp) |
|
335 oops |
|
336 |
271 |
337 quotient_type lam = rlam / alpha |
272 quotient_type lam = rlam / alpha |
338 by (rule alpha_equivp) |
273 by (rule alpha_equivp) |
339 |
274 |
340 quotient_definition |
275 quotient_definition |
376 "(op = ===> alpha ===> alpha) rLam rLam" |
311 "(op = ===> alpha ===> alpha) rLam rLam" |
377 apply(auto) |
312 apply(auto) |
378 apply(rule a3) |
313 apply(rule a3) |
379 apply(rule_tac x="0" in exI) |
314 apply(rule_tac x="0" in exI) |
380 unfolding fresh_star_def |
315 unfolding fresh_star_def |
381 apply(simp add: fresh_star_def fresh_zero_perm) |
316 apply(simp add: fresh_star_def fresh_zero_perm alpha_gen.simps) |
382 apply(simp add: alpha_rfv) |
317 apply(simp add: alpha_rfv) |
383 done |
318 done |
384 |
319 |
385 lemma rfv_rsp[quot_respect]: |
320 lemma rfv_rsp[quot_respect]: |
386 "(alpha ===> op =) rfv rfv" |
321 "(alpha ===> op =) rfv rfv" |
439 |
374 |
440 lemma a2: |
375 lemma a2: |
441 "\<lbrakk>x = xa; xb = xc\<rbrakk> \<Longrightarrow> App x xb = App xa xc" |
376 "\<lbrakk>x = xa; xb = xc\<rbrakk> \<Longrightarrow> App x xb = App xa xc" |
442 by (lifting a2) |
377 by (lifting a2) |
443 |
378 |
444 lemma a3: |
379 lemma alpha_gen_rsp_pre: |
445 "\<lbrakk>\<exists>pi. (fv t - {atom a} = fv s - {atom b} \<and> (fv t - {atom a})\<sharp>* pi \<and> (pi \<bullet> t) = s)\<rbrakk> |
380 assumes a5: "\<And>t s. R t s \<Longrightarrow> R (pi \<bullet> t) (pi \<bullet> s)" |
446 \<Longrightarrow> Lam a t = Lam b s" |
381 and a1: "R s1 t1" |
447 apply (lifting a3) |
382 and a2: "R s2 t2" |
|
383 and a3: "\<And>a b c d. R a b \<Longrightarrow> R c d \<Longrightarrow> R1 a c = R2 b d" |
|
384 and a4: "\<And>x y. R x y \<Longrightarrow> fv1 x = fv2 y" |
|
385 shows "(a, s1) \<approx>gen R1 fv1 pi (b, s2) = (a, t1) \<approx>gen R2 fv2 pi (b, t2)" |
|
386 apply (simp add: alpha_gen.simps) |
|
387 apply (simp only: a4[symmetric, OF a1] a4[symmetric, OF a2]) |
|
388 apply auto |
|
389 apply (subst a3[symmetric]) |
|
390 apply (rule a5) |
|
391 apply (rule a1) |
|
392 apply (rule a2) |
|
393 apply (assumption) |
|
394 apply (subst a3) |
|
395 apply (rule a5) |
|
396 apply (rule a1) |
|
397 apply (rule a2) |
|
398 apply (assumption) |
|
399 done |
|
400 |
|
401 lemma [quot_respect]: "(prod_rel op = alpha ===> |
|
402 (alpha ===> alpha ===> op =) ===> (alpha ===> op =) ===> op = ===> prod_rel op = alpha ===> op =) |
|
403 alpha_gen alpha_gen" |
|
404 apply simp |
|
405 apply clarify |
|
406 apply (rule alpha_gen_rsp_pre[of "alpha",OF alpha_eqvt]) |
|
407 apply auto |
|
408 done |
|
409 |
|
410 lemma pi_rep: "pi \<bullet> (rep_lam x) = rep_lam (pi \<bullet> x)" |
|
411 apply (unfold rep_lam_def) |
|
412 sorry |
|
413 |
|
414 lemma [quot_preserve]: "(prod_fun id rep_lam ---> |
|
415 (abs_lam ---> abs_lam ---> id) ---> (abs_lam ---> id) ---> id ---> (prod_fun id rep_lam) ---> id) |
|
416 alpha_gen = alpha_gen" |
|
417 apply (simp add: expand_fun_eq) |
|
418 apply (simp add: alpha_gen.simps) |
|
419 apply (simp add: pi_rep) |
|
420 apply (simp only: Quotient_abs_rep[OF Quotient_lam]) |
|
421 apply auto |
|
422 done |
|
423 |
|
424 lemma alpha_prs [quot_preserve]: "(rep_lam ---> rep_lam ---> id) alpha = (op =)" |
|
425 apply (simp add: expand_fun_eq) |
|
426 sledgehammer |
|
427 sorry |
|
428 |
|
429 |
|
430 lemma a3: |
|
431 "\<exists>pi. ({atom a}, t) \<approx>gen (op =) fv pi ({atom b}, s) \<Longrightarrow> Lam a t = Lam b s" |
|
432 apply (lifting a3) |
448 done |
433 done |
449 |
434 |
450 lemma a3_inv: |
435 lemma a3_inv: |
451 assumes "Lam a t = Lam b s" |
436 assumes "Lam a t = Lam b s" |
452 shows "\<exists>pi. (fv t - {atom a} = fv s - {atom b} \<and> (fv t - {atom a})\<sharp>* pi \<and> (pi \<bullet> t) = s)" |
437 shows "\<exists>pi. (fv t - {atom a} = fv s - {atom b} \<and> (fv t - {atom a})\<sharp>* pi \<and> (pi \<bullet> t) = s)" |