314 shows "P a rtrma" |
314 shows "P a rtrma" |
315 sorry |
315 sorry |
316 |
316 |
317 section {*** lets with single assignments ***} |
317 section {*** lets with single assignments ***} |
318 |
318 |
319 datatype trm2 = |
319 datatype rtrm2 = |
320 Vr2 "name" |
320 rVr2 "name" |
321 | Ap2 "trm2" "trm2" |
321 | rAp2 "rtrm2" "rtrm2" |
322 | Lm2 "name" "trm2" |
322 | rLm2 "name" "rtrm2" --"bind (name) in (rtrm2)" |
323 | Lt2 "assign" "trm2" |
323 | rLt2 "rassign" "rtrm2" --"bind (bv2 rassign) in (rtrm2)" |
324 and assign = |
324 and rassign = |
325 As "name" "trm2" |
325 rAs "name" "rtrm2" |
326 |
326 |
327 (* to be given by the user *) |
327 (* to be given by the user *) |
328 primrec |
328 primrec |
329 bv2 |
329 rbv2 |
330 where |
330 where |
331 "bv2 (As x t) = {atom x}" |
331 "rbv2 (rAs x t) = {atom x}" |
332 |
332 |
333 (* needs to be calculated by the package *) |
333 (* needs to be calculated by the package *) |
334 primrec |
334 primrec |
335 fv_trm2 and fv_assign |
335 fv_rtrm2 and fv_rassign |
336 where |
336 where |
337 "fv_trm2 (Vr2 x) = {atom x}" |
337 "fv_rtrm2 (rVr2 x) = {atom x}" |
338 | "fv_trm2 (Ap2 t1 t2) = (fv_trm2 t1) \<union> (fv_trm2 t2)" |
338 | "fv_rtrm2 (rAp2 t1 t2) = (fv_rtrm2 t1) \<union> (fv_rtrm2 t2)" |
339 | "fv_trm2 (Lm2 x t) = (fv_trm2 t) - {atom x}" |
339 | "fv_rtrm2 (rLm2 x t) = (fv_rtrm2 t) - {atom x}" |
340 | "fv_trm2 (Lt2 as t) = (fv_trm2 t - bv2 as) \<union> (fv_assign as)" |
340 | "fv_rtrm2 (rLt2 as t) = (fv_rtrm2 t - rbv2 as) \<union> (fv_rassign as)" |
341 | "fv_assign (As x t) = (fv_trm2 t)" |
341 | "fv_rassign (rAs x t) = fv_rtrm2 t" |
342 |
342 |
343 (* needs to be stated by the package *) |
343 (* needs to be stated by the package *) |
344 instantiation |
344 instantiation |
345 trm2 and assign :: pt |
345 rtrm2 and rassign :: pt |
346 begin |
346 begin |
347 |
347 |
348 primrec |
348 primrec |
349 permute_trm2 and permute_assign |
349 permute_rtrm2 and permute_rassign |
350 where |
350 where |
351 "permute_trm2 pi (Vr2 a) = Vr2 (pi \<bullet> a)" |
351 "permute_rtrm2 pi (rVr2 a) = rVr2 (pi \<bullet> a)" |
352 | "permute_trm2 pi (Ap2 t1 t2) = Ap2 (permute_trm2 pi t1) (permute_trm2 pi t2)" |
352 | "permute_rtrm2 pi (rAp2 t1 t2) = rAp2 (permute_rtrm2 pi t1) (permute_rtrm2 pi t2)" |
353 | "permute_trm2 pi (Lm2 a t) = Lm2 (pi \<bullet> a) (permute_trm2 pi t)" |
353 | "permute_rtrm2 pi (rLm2 a t) = rLm2 (pi \<bullet> a) (permute_rtrm2 pi t)" |
354 | "permute_trm2 pi (Lt2 as t) = Lt2 (permute_assign pi as) (permute_trm2 pi t)" |
354 | "permute_rtrm2 pi (rLt2 as t) = rLt2 (permute_rassign pi as) (permute_rtrm2 pi t)" |
355 | "permute_assign pi (As a t) = As (pi \<bullet> a) (permute_trm2 pi t)" |
355 | "permute_rassign pi (rAs a t) = rAs (pi \<bullet> a) (permute_rtrm2 pi t)" |
356 |
356 |
357 lemma pt_trm2_assign_zero: |
357 lemma pt_rtrm2_rassign_zero: |
358 fixes t::trm2 |
358 fixes t::rtrm2 |
359 and b::assign |
359 and b::rassign |
360 shows "0 \<bullet> t = t" |
360 shows "0 \<bullet> t = t" |
361 and "0 \<bullet> b = b" |
361 and "0 \<bullet> b = b" |
362 apply(induct t and b rule: trm2_assign.inducts) |
362 apply(induct t and b rule: rtrm2_rassign.inducts) |
363 apply(simp_all) |
363 apply(simp_all) |
364 done |
364 done |
365 |
365 |
366 lemma pt_trm2_assign_plus: |
366 lemma pt_rtrm2_rassign_plus: |
367 fixes t::trm2 |
367 fixes t::rtrm2 |
368 and b::assign |
368 and b::rassign |
369 shows "((p + q) \<bullet> t) = p \<bullet> (q \<bullet> t)" |
369 shows "((p + q) \<bullet> t) = p \<bullet> (q \<bullet> t)" |
370 and "((p + q) \<bullet> b) = p \<bullet> (q \<bullet> b)" |
370 and "((p + q) \<bullet> b) = p \<bullet> (q \<bullet> b)" |
371 apply(induct t and b rule: trm2_assign.inducts) |
371 apply(induct t and b rule: rtrm2_rassign.inducts) |
372 apply(simp_all) |
372 apply(simp_all) |
373 done |
373 done |
374 |
374 |
375 instance |
375 instance |
376 apply default |
376 apply default |
377 apply(simp_all add: pt_trm2_assign_zero pt_trm2_assign_plus) |
377 apply(simp_all add: pt_rtrm2_rassign_zero pt_rtrm2_rassign_plus) |
378 done |
378 done |
379 |
379 |
380 |
380 |
381 end |
381 end |
382 |
382 |
383 inductive |
383 inductive |
384 alpha2 :: "trm2 \<Rightarrow> trm2 \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100) |
384 alpha2 :: "rtrm2 \<Rightarrow> rtrm2 \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100) |
385 where |
385 and |
386 a1: "a = b \<Longrightarrow> (Vr2 a) \<approx>2 (Vr2 b)" |
386 alpha2a :: "rassign \<Rightarrow> rassign \<Rightarrow> bool" ("_ \<approx>2a _" [100, 100] 100) |
387 | a2: "\<lbrakk>t1 \<approx>2 t2; s1 \<approx>2 s2\<rbrakk> \<Longrightarrow> Ap2 t1 s1 \<approx>2 Ap2 t2 s2" |
387 where |
388 | a3: "\<exists>pi. (fv_trm2 t - {atom a} = fv_trm2 s - {atom b} \<and> |
388 a1: "a = b \<Longrightarrow> (rVr2 a) \<approx>2 (rVr2 b)" |
389 (fv_trm2 t - {atom a})\<sharp>* pi \<and> |
389 | a2: "\<lbrakk>t1 \<approx>2 t2; s1 \<approx>2 s2\<rbrakk> \<Longrightarrow> rAp2 t1 s1 \<approx>2 rAp2 t2 s2" |
390 (pi \<bullet> t) \<approx>2 s \<and> |
390 | a3: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha2 fv_rtrm2 pi ({atom b}, s))) \<Longrightarrow> rLm2 a t \<approx>2 rLm2 b s" |
391 (pi \<bullet> a) = b) |
391 | a4: "\<lbrakk>\<exists>pi. ((rbv2 bt, t) \<approx>gen alpha2 fv_rtrm2 pi ((rbv2 bs), s)); |
392 \<Longrightarrow> Lm2 a t \<approx>2 Lm2 b s" |
392 \<exists>pi. ((rbv2 bt, bt) \<approx>gen alpha2a fv_rassign pi (rbv2 bs, bs))\<rbrakk> |
393 | a4: "\<exists>pi. ( |
393 \<Longrightarrow> rLt2 bt t \<approx>2 rLt2 bs s" |
394 fv_trm2 t1 - fv_assign b1 = fv_trm2 t2 - fv_assign b2 \<and> |
394 | a5: "\<lbrakk>a = b; t \<approx>2 s\<rbrakk> \<Longrightarrow> rAs a t \<approx>2a rAs b s" (* This way rbv2 can be lifted *) |
395 (fv_trm2 t1 - fv_assign b1) \<sharp>* pi \<and> |
395 |
396 pi \<bullet> t1 = t2 (* \<and> (pi \<bullet> b1 = b2) *) |
396 lemma alpha2_equivp: |
397 ) \<Longrightarrow> Lt2 b1 t1 \<approx>2 Lt2 b2 t2" |
397 "equivp alpha2" |
398 |
398 "equivp alpha2a" |
399 lemma alpha2_equivp: "equivp alpha2" |
|
400 sorry |
399 sorry |
401 |
400 |
402 quotient_type qtrm2 = trm2 / alpha2 |
401 quotient_type |
403 by (rule alpha2_equivp) |
402 trm2 = rtrm2 / alpha2 |
|
403 and |
|
404 assign = rassign / alpha2a |
|
405 by (auto intro: alpha2_equivp) |
|
406 |
|
407 |
404 |
408 |
405 section {*** lets with many assignments ***} |
409 section {*** lets with many assignments ***} |
406 |
410 |
407 datatype trm3 = |
411 datatype trm3 = |
408 Vr3 "name" |
412 Vr3 "name" |
409 | Ap3 "trm3" "trm3" |
413 | Ap3 "trm3" "trm3" |
410 | Lm3 "name" "trm3" |
414 | Lm3 "name" "trm3" --"bind (name) in (trm3)" |
411 | Lt3 "assigns" "trm3" |
415 | Lt3 "assigns" "trm3" --"bind (bv3 assigns) in (trm3)" |
412 and assigns = |
416 and assigns = |
413 ANil |
417 ANil |
414 | ACons "name" "trm3" "assigns" |
418 | ACons "name" "trm3" "assigns" |
415 |
419 |
416 (* to be given by the user *) |
420 (* to be given by the user *) |
471 |
475 |
472 end |
476 end |
473 |
477 |
474 inductive |
478 inductive |
475 alpha3 :: "trm3 \<Rightarrow> trm3 \<Rightarrow> bool" ("_ \<approx>3 _" [100, 100] 100) |
479 alpha3 :: "trm3 \<Rightarrow> trm3 \<Rightarrow> bool" ("_ \<approx>3 _" [100, 100] 100) |
|
480 and |
|
481 alpha3a :: "assigns \<Rightarrow> assigns \<Rightarrow> bool" ("_ \<approx>3a _" [100, 100] 100) |
476 where |
482 where |
477 a1: "a = b \<Longrightarrow> (Vr3 a) \<approx>3 (Vr3 b)" |
483 a1: "a = b \<Longrightarrow> (Vr3 a) \<approx>3 (Vr3 b)" |
478 | a2: "\<lbrakk>t1 \<approx>3 t2; s1 \<approx>3 s2\<rbrakk> \<Longrightarrow> Ap3 t1 s1 \<approx>3 Ap3 t2 s2" |
484 | a2: "\<lbrakk>t1 \<approx>3 t2; s1 \<approx>3 s2\<rbrakk> \<Longrightarrow> Ap3 t1 s1 \<approx>3 Ap3 t2 s2" |
479 | a3: "\<exists>pi. (fv_trm3 t - {atom a} = fv_trm3 s - {atom b} \<and> |
485 | a3: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha3 fv_rtrm3 pi ({atom b}, s))) \<Longrightarrow> Lm3 a t \<approx>3 Lm3 b s" |
480 (fv_trm3 t - {atom a})\<sharp>* pi \<and> |
486 | a4: "\<lbrakk>\<exists>pi. ((bv3 bt, t) \<approx>gen alpha3 fv_trm3 pi ((bv3 bs), s)); |
481 (pi \<bullet> t) \<approx>3 s \<and> |
487 \<exists>pi. ((bv3 bt, bt) \<approx>gen alpha3a fv_assign pi (bv3 bs, bs))\<rbrakk> |
482 (pi \<bullet> a) = b) |
488 \<Longrightarrow> Lt3 bt t \<approx>3 Lt3 bs s" |
483 \<Longrightarrow> Lm3 a t \<approx>3 Lm3 b s" |
489 | a5: "ANil \<approx>3a ANil" |
484 | a4: "\<exists>pi. ( |
490 | a6: "\<lbrakk>a = b; t \<approx>3 s; tt \<approx>3a st\<rbrakk> \<Longrightarrow> ACons a t tt \<approx>3a ACons b s st" |
485 fv_trm3 t1 - fv_assigns b1 = fv_trm3 t2 - fv_assigns b2 \<and> |
491 |
486 (fv_trm3 t1 - fv_assigns b1) \<sharp>* pi \<and> |
492 lemma alpha3_equivp: |
487 pi \<bullet> t1 = t2 (* \<and> (pi \<bullet> b1 = b2) *) |
493 "equivp alpha3" |
488 ) \<Longrightarrow> Lt3 b1 t1 \<approx>3 Lt3 b2 t2" |
494 "equivp alpha3a" |
489 |
|
490 lemma alpha3_equivp: "equivp alpha3" |
|
491 sorry |
495 sorry |
492 |
496 |
493 quotient_type qtrm3 = trm3 / alpha3 |
497 quotient_type |
494 by (rule alpha3_equivp) |
498 qtrm3 = trm3 / alpha3 |
|
499 and |
|
500 qassigns = assigns / alpha3a |
|
501 by (auto intro: alpha3_equivp) |
495 |
502 |
496 |
503 |
497 section {*** lam with indirect list recursion ***} |
504 section {*** lam with indirect list recursion ***} |
498 |
505 |
499 datatype trm4 = |
506 datatype trm4 = |
500 Vr4 "name" |
507 Vr4 "name" |
501 | Ap4 "trm4" "trm4 list" |
508 | Ap4 "trm4" "trm4 list" |
502 | Lm4 "name" "trm4" |
509 | Lm4 "name" "trm4" --"bind (name) in (trm)" |
503 |
510 |
504 thm trm4.recs |
511 thm trm4.recs |
505 |
512 |
506 primrec |
513 primrec |
507 fv_trm4 and fv_trm4_list |
514 fv_trm4 and fv_trm4_list |
571 alpha4 :: "trm4 \<Rightarrow> trm4 \<Rightarrow> bool" ("_ \<approx>4 _" [100, 100] 100) |
578 alpha4 :: "trm4 \<Rightarrow> trm4 \<Rightarrow> bool" ("_ \<approx>4 _" [100, 100] 100) |
572 and alpha4list :: "trm4 list \<Rightarrow> trm4 list \<Rightarrow> bool" ("_ \<approx>4list _" [100, 100] 100) |
579 and alpha4list :: "trm4 list \<Rightarrow> trm4 list \<Rightarrow> bool" ("_ \<approx>4list _" [100, 100] 100) |
573 where |
580 where |
574 a1: "a = b \<Longrightarrow> (Vr4 a) \<approx>4 (Vr4 b)" |
581 a1: "a = b \<Longrightarrow> (Vr4 a) \<approx>4 (Vr4 b)" |
575 | a2: "\<lbrakk>t1 \<approx>4 t2; s1 \<approx>4list s2\<rbrakk> \<Longrightarrow> Ap4 t1 s1 \<approx>4 Ap4 t2 s2" |
582 | a2: "\<lbrakk>t1 \<approx>4 t2; s1 \<approx>4list s2\<rbrakk> \<Longrightarrow> Ap4 t1 s1 \<approx>4 Ap4 t2 s2" |
576 | a4: "\<exists>pi. (fv_trm4 t - {atom a} = fv_trm4 s - {atom b} \<and> |
583 | a3: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha4 fv_rtrm4 pi ({atom b}, s))) \<Longrightarrow> Lm4 a t \<approx>4 Lm4 b s" |
577 (fv_trm4 t - {atom a})\<sharp>* pi \<and> |
|
578 (pi \<bullet> t) \<approx>4 s \<and> |
|
579 (pi \<bullet> a) = b) |
|
580 \<Longrightarrow> Lm4 a t \<approx>4 Lm4 b s" |
|
581 | a5: "[] \<approx>4list []" |
584 | a5: "[] \<approx>4list []" |
582 | a6: "\<lbrakk>t \<approx>4 s; ts \<approx>4list ss\<rbrakk> \<Longrightarrow> (t#ts) \<approx>4list (s#ss)" |
585 | a6: "\<lbrakk>t \<approx>4 s; ts \<approx>4list ss\<rbrakk> \<Longrightarrow> (t#ts) \<approx>4list (s#ss)" |
583 |
586 |
584 lemma alpha4_equivp: "equivp alpha4" sorry |
587 lemma alpha4_equivp: "equivp alpha4" sorry |
585 lemma alpha4list_equivp: "equivp alpha4list" sorry |
588 lemma alpha4list_equivp: "equivp alpha4list" sorry |
738 quotient_definition |
741 quotient_definition |
739 "bv5 :: lts \<Rightarrow> atom set" |
742 "bv5 :: lts \<Rightarrow> atom set" |
740 as |
743 as |
741 "rbv5" |
744 "rbv5" |
742 |
745 |
|
746 lemma rbv5_eqvt: |
|
747 "pi \<bullet> (rbv5 x) = rbv5 (pi \<bullet> x)" |
|
748 sorry |
|
749 |
|
750 lemma rfv_trm5_eqvt: |
|
751 "pi \<bullet> (rfv_trm5 x) = rfv_trm5 (pi \<bullet> x)" |
|
752 sorry |
|
753 |
|
754 lemma rfv_lts_eqvt: |
|
755 "pi \<bullet> (rfv_lts x) = rfv_lts (pi \<bullet> x)" |
|
756 sorry |
|
757 |
|
758 lemma alpha5_eqvt: |
|
759 "xa \<approx>5 y \<Longrightarrow> (x \<bullet> xa) \<approx>5 (x \<bullet> y)" |
|
760 "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)" |
|
761 apply(induct rule: alpha5_alphalts.inducts) |
|
762 apply (simp_all add: alpha5_inj) |
|
763 apply (erule exE)+ |
|
764 apply(unfold alpha_gen) |
|
765 apply (erule conjE)+ |
|
766 apply (rule conjI) |
|
767 apply (rule_tac x="x \<bullet> pi" in exI) |
|
768 apply (rule conjI) |
|
769 apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1]) |
|
770 apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_trm5_eqvt) |
|
771 apply(rule conjI) |
|
772 apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1]) |
|
773 apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_trm5_eqvt) |
|
774 apply (subst permute_eqvt[symmetric]) |
|
775 apply (simp) |
|
776 apply (rule_tac x="x \<bullet> pia" in exI) |
|
777 apply (rule conjI) |
|
778 apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1]) |
|
779 apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_lts_eqvt) |
|
780 apply(rule conjI) |
|
781 apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1]) |
|
782 apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_lts_eqvt) |
|
783 apply (subst permute_eqvt[symmetric]) |
|
784 apply (simp) |
|
785 done |
|
786 |
743 lemma alpha5_rfv: |
787 lemma alpha5_rfv: |
744 "(t \<approx>5 s \<Longrightarrow> rfv_trm5 t = rfv_trm5 s)" |
788 "(t \<approx>5 s \<Longrightarrow> rfv_trm5 t = rfv_trm5 s)" |
745 "(l \<approx>l m \<Longrightarrow> rfv_lts l = rfv_lts m)" |
789 "(l \<approx>l m \<Longrightarrow> rfv_lts l = rfv_lts m)" |
746 apply(induct rule: alpha5_alphalts.inducts) |
790 apply(induct rule: alpha5_alphalts.inducts) |
747 apply(simp_all add: alpha_gen) |
791 apply(simp_all add: alpha_gen) |
748 done |
792 done |
749 |
793 |
750 lemma [quot_respect]: |
|
751 "(op = ===> alpha5 ===> alpha5) permute permute" |
|
752 "(op = ===> alphalts ===> alphalts) permute permute" |
|
753 "(op = ===> alpha5) rVr5 rVr5" |
|
754 "(alpha5 ===> alpha5 ===> alpha5) rAp5 rAp5" |
|
755 "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5" |
|
756 "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5" |
|
757 "(op = ===> alpha5 ===> alphalts ===> alphalts) rLcons rLcons" |
|
758 "(alpha5 ===> op =) rfv_trm5 rfv_trm5" |
|
759 "(alphalts ===> op =) rfv_lts rfv_lts" |
|
760 "(alphalts ===> op =) rbv5 rbv5" |
|
761 sorry |
|
762 |
|
763 lemma bv_list_rsp: |
794 lemma bv_list_rsp: |
764 shows "x \<approx>l y \<Longrightarrow> rbv5 x = rbv5 y" |
795 shows "x \<approx>l y \<Longrightarrow> rbv5 x = rbv5 y" |
765 apply(induct rule: alpha5_alphalts.inducts(2)) |
796 apply(induct rule: alpha5_alphalts.inducts(2)) |
766 apply(simp_all) |
797 apply(simp_all) |
767 done |
798 done |
768 |
799 |
769 |
800 lemma [quot_respect]: |
770 lemma |
801 "(alphalts ===> op =) rfv_lts rfv_lts" |
|
802 "(alpha5 ===> op =) rfv_trm5 rfv_trm5" |
|
803 "(alphalts ===> op =) rbv5 rbv5" |
|
804 "(op = ===> alpha5) rVr5 rVr5" |
|
805 "(alpha5 ===> alpha5 ===> alpha5) rAp5 rAp5" |
|
806 "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5" |
|
807 "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5" |
|
808 "(op = ===> alpha5 ===> alphalts ===> alphalts) rLcons rLcons" |
|
809 "(op = ===> alpha5 ===> alpha5) permute permute" |
|
810 "(op = ===> alphalts ===> alphalts) permute permute" |
|
811 apply (simp_all add: alpha5_inj alpha5_rfv alpha5_eqvt bv_list_rsp) |
|
812 apply (auto) |
|
813 apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv) |
|
814 apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv) |
|
815 apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv) |
|
816 apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv) |
|
817 done |
|
818 |
|
819 lemma |
771 shows "(alphalts ===> op =) rbv5 rbv5" |
820 shows "(alphalts ===> op =) rbv5 rbv5" |
772 by (simp add: bv_list_rsp) |
821 by (simp add: bv_list_rsp) |
773 |
822 |
774 lemmas trm5_lts_inducts = rtrm5_rlts.inducts[quot_lifted] |
823 lemmas trm5_lts_inducts = rtrm5_rlts.inducts[quot_lifted] |
775 |
824 |