|     72 apply(simp only: alpha_gen) |     72 apply(simp only: alpha_gen) | 
|     73 apply(simp only: supp_eqvt[symmetric]) |     73 apply(simp only: supp_eqvt[symmetric]) | 
|     74 apply(simp only: eqvts) |     74 apply(simp only: eqvts) | 
|     75 apply(simp only: supp_Abs) |     75 apply(simp only: supp_Abs) | 
|     76 (* LET case *) |     76 (* LET case *) | 
|     77 defer |         | 
|     78 (* BP case *) |         | 
|     79 apply(simp only: supp_def) |         | 
|     80 apply(simp only: lam_bp_perm) |         | 
|     81 apply(simp only: lam_bp_inject) |         | 
|     82 apply(simp only: de_Morgan_conj) |         | 
|     83 apply(simp only: Collect_disj_eq) |         | 
|     84 apply(simp only: infinite_Un) |         | 
|     85 apply(simp only: Collect_disj_eq) |         | 
|     86 apply(simp only: supp_def[symmetric]) |         | 
|     87 apply(simp only: supp_at_base) |         | 
|     88 apply(simp) |         | 
|     89 (* LET case *) |         | 
|     90 apply(rule_tac t="supp (LET bp_raw lam_raw)" and s="supp (Abs (bi bp_raw) lam_raw) \<union> fv_bi bp_raw" in subst) |     77 apply(rule_tac t="supp (LET bp_raw lam_raw)" and s="supp (Abs (bi bp_raw) lam_raw) \<union> fv_bi bp_raw" in subst) | 
|     91 apply(simp (no_asm) only: supp_def) |     78 apply(simp (no_asm) only: supp_def) | 
|     92 apply(simp only: lam_bp_perm) |     79 apply(simp only: lam_bp_perm) | 
|     93 apply(simp only: permute_ABS) |     80 apply(simp only: permute_ABS) | 
|     94 apply(simp only: lam_bp_inject) |     81 apply(simp only: lam_bp_inject) | 
|    103 apply(simp only: supp_eqvt[symmetric]) |     90 apply(simp only: supp_eqvt[symmetric]) | 
|    104 apply(simp only: eqvts) |     91 apply(simp only: eqvts) | 
|    105 apply(blast) |     92 apply(blast) | 
|    106 apply(simp add: supp_Abs) |     93 apply(simp add: supp_Abs) | 
|    107 apply(blast) |     94 apply(blast) | 
|         |     95 (* BP case *) | 
|         |     96 apply(simp only: supp_def) | 
|         |     97 apply(simp only: lam_bp_perm) | 
|         |     98 apply(simp only: lam_bp_inject) | 
|         |     99 apply(simp only: de_Morgan_conj) | 
|         |    100 apply(simp only: Collect_disj_eq) | 
|         |    101 apply(simp only: infinite_Un) | 
|         |    102 apply(simp only: Collect_disj_eq) | 
|         |    103 apply(simp only: supp_def[symmetric]) | 
|         |    104 apply(simp only: supp_at_base) | 
|         |    105 apply(simp) | 
|    108 done |    106 done | 
|    109  |    107  | 
|    110 thm lam_bp_fv[simplified supp_fv(1)[symmetric] supp_fv(2)[THEN conjunct1, symmetric]] |    108 thm lam_bp_fv[simplified supp_fv(1)[symmetric] supp_fv(2)[THEN conjunct1, symmetric]] | 
|    111  |    109  | 
|    112 ML {* val _ = recursive := true *} |    110 ML {* val _ = recursive := true *} | 
|    541 thm exp6_pat6_distinct |    539 thm exp6_pat6_distinct | 
|    542  |    540  | 
|    543 (* THE REST ARE NOT SUPPOSED TO WORK YET *) |    541 (* THE REST ARE NOT SUPPOSED TO WORK YET *) | 
|    544  |    542  | 
|    545 (* example 7 from Peter Sewell's bestiary *) |    543 (* example 7 from Peter Sewell's bestiary *) | 
|         |    544 (* dest_Const raised | 
|    546 nominal_datatype exp7 = |    545 nominal_datatype exp7 = | 
|    547   EVar name |    546   EVar' name | 
|    548 | EUnit |    547 | EUnit' | 
|    549 | EPair exp7 exp7 |    548 | EPair' exp7 exp7 | 
|    550 | ELetRec l::lrbs e::exp7 bind "b7s l" in e, bind "b7s l" in l |    549 | ELetRec' l::lrbs e::exp7 bind "b7s l" in e, bind "b7s l" in l | 
|    551 and lrb = |    550 and lrb = | 
|    552   Assign name exp7 |    551   Assign' name exp7 | 
|    553 and lrbs = |    552 and lrbs = | 
|    554   Single lrb |    553   Single' lrb | 
|    555 | More lrb lrbs |    554 | More' lrb lrbs | 
|    556 binder |    555 binder | 
|    557   b7 :: "lrb \<Rightarrow> atom set" and |    556   b7 :: "lrb \<Rightarrow> atom set" and | 
|    558   b7s :: "lrbs \<Rightarrow> atom set" |    557   b7s :: "lrbs \<Rightarrow> atom set" | 
|    559 where |    558 where | 
|    560   "b7 (Assign x e) = {atom x}" |    559   "b7 (Assign x e) = {atom x}" | 
|    561 | "b7s (Single a) = b7 a" |    560 | "b7s (Single a) = b7 a" | 
|    562 | "b7s (More a as) = (b7 a) \<union> (b7s as)" |    561 | "b7s (More a as) = (b7 a) \<union> (b7s as)" | 
|    563 thm alpha_exp7_raw_alpha_lrb_raw_alpha_lrbs_raw.intros |    562 thm alpha_exp7_raw_alpha_lrb_raw_alpha_lrbs_raw.intros | 
|         |    563 *) | 
|    564  |    564  | 
|    565 (* example 8 from Peter Sewell's bestiary *) |    565 (* example 8 from Peter Sewell's bestiary *) | 
|         |    566 (* | 
|         |    567 *** fv_bn: recursive argument, but wrong datatype. | 
|         |    568 *** At command "nominal_datatype". | 
|    566 nominal_datatype exp8 = |    569 nominal_datatype exp8 = | 
|    567   EVar name |    570   EVar' name | 
|    568 | EUnit |    571 | EUnit' | 
|    569 | EPair exp8 exp8 |    572 | EPair' exp8 exp8 | 
|    570 | ELetRec l::lrbs8 e::exp8 bind "b_lrbs8 l" in e, bind "b_lrbs8 l" in l |    573 | ELetRec' l::lrbs8 e::exp8 bind "b_lrbs8 l" in e, bind "b_lrbs8 l" in l | 
|    571 and fnclause = |    574 and fnclause = | 
|    572   K x::name p::pat8 e::exp8 bind "b_pat p" in e |    575   K' x::name p::pat8 e::exp8 bind "b_pat p" in e | 
|    573 and fnclauses = |    576 and fnclauses = | 
|    574   S fnclause |    577   S' fnclause | 
|    575 | ORs fnclause fnclauses |    578 | ORs' fnclause fnclauses | 
|    576 and lrb8 = |    579 and lrb8 = | 
|    577   Clause fnclauses |    580   Clause' fnclauses | 
|    578 and lrbs8 = |    581 and lrbs8 = | 
|    579   Single lrb8 |    582   Single' lrb8 | 
|    580 | More lrb8 lrbs8 |    583 | More' lrb8 lrbs8 | 
|    581 and pat8 = |    584 and pat8 = | 
|    582   PVar name |    585   PVar'' name | 
|    583 | PUnit |    586 | PUnit'' | 
|    584 | PPair pat8 pat8 |    587 | PPair'' pat8 pat8 | 
|    585 binder |    588 binder | 
|    586   b_lrbs8 :: "lrbs8 \<Rightarrow> atom set" and |    589   b_lrbs8 :: "lrbs8 \<Rightarrow> atom set" and | 
|    587   b_pat :: "pat8 \<Rightarrow> atom set" and |    590   b_pat :: "pat8 \<Rightarrow> atom set" and | 
|    588   b_fnclauses :: "fnclauses \<Rightarrow> atom set" and |    591   b_fnclauses :: "fnclauses \<Rightarrow> atom set" and | 
|    589   b_fnclause :: "fnclause \<Rightarrow> atom set" and |    592   b_fnclause :: "fnclause \<Rightarrow> atom set" and | 
|    590   b_lrb8 :: "lrb8 \<Rightarrow> atom set" |    593   b_lrb8 :: "lrb8 \<Rightarrow> atom set" | 
|    591 where |    594 where | 
|    592   "b_lrbs8 (Single l) = b_lrb8 l" |    595   "b_lrbs8 (Single' l) = b_lrb8 l" | 
|    593 | "b_lrbs8 (More l ls) = b_lrb8 l \<union> b_lrbs8 ls" |    596 | "b_lrbs8 (More' l ls) = b_lrb8 l \<union> b_lrbs8 ls" | 
|    594 | "b_pat (PVar x) = {atom x}" |    597 | "b_pat (PVar'' x) = {atom x}" | 
|    595 | "b_pat (PUnit) = {}" |    598 | "b_pat (PUnit'') = {}" | 
|    596 | "b_pat (PPair p1 p2) = b_pat p1 \<union> b_pat p2" |    599 | "b_pat (PPair'' p1 p2) = b_pat p1 \<union> b_pat p2" | 
|    597 | "b_fnclauses (S fc) = (b_fnclause fc)" |    600 | "b_fnclauses (S' fc) = (b_fnclause fc)" | 
|    598 | "b_fnclauses (ORs fc fcs) = (b_fnclause fc) \<union> (b_fnclauses fcs)" |    601 | "b_fnclauses (ORs' fc fcs) = (b_fnclause fc) \<union> (b_fnclauses fcs)" | 
|    599 | "b_lrb8 (Clause fcs) = (b_fnclauses fcs)" |    602 | "b_lrb8 (Clause' fcs) = (b_fnclauses fcs)" | 
|    600 | "b_fnclause (K x pat exp8) = {atom x}" |    603 | "b_fnclause (K' x pat exp8) = {atom x}" | 
|    601 thm alpha_exp8_raw_alpha_fnclause_raw_alpha_fnclauses_raw_alpha_lrb8_raw_alpha_lrbs8_raw_alpha_pat8_raw.intros |    604 thm alpha_exp8_raw_alpha_fnclause_raw_alpha_fnclauses_raw_alpha_lrb8_raw_alpha_lrbs8_raw_alpha_pat8_raw.intros | 
|    602  |    605 *) | 
|    603 (* example 4 from Terms.thy *) |    606 (* example 4 from Terms.thy *) | 
|    604 (* fv_eqvt does not work, we need to repaire defined permute functions |    607 (* fv_eqvt does not work, we need to repaire defined permute functions | 
|    605    defined fv and defined alpha... *) |    608    defined fv and defined alpha... *) | 
|         |    609 (* lists-datastructure does not work yet | 
|    606 nominal_datatype trm4 = |    610 nominal_datatype trm4 = | 
|    607   Vr4 "name" |    611   Vr4 "name" | 
|    608 | Ap4 "trm4" "trm4 list" |    612 | Ap4 "trm4" "trm4 list" | 
|    609 | Lm4 x::"name" t::"trm4"  bind x in t |    613 | Lm4 x::"name" t::"trm4"  bind x in t | 
|    610  |    614  | 
|    611 thm alpha_trm4_raw_alpha_trm4_raw_list.intros[no_vars] |    615 thm alpha_trm4_raw_alpha_trm4_raw_list.intros[no_vars] | 
|    612 thm fv_trm4_raw_fv_trm4_raw_list.simps[no_vars] |    616 thm fv_trm4_raw_fv_trm4_raw_list.simps[no_vars] | 
|    613  |    617 *) | 
|    614 (* core haskell *) |    618 (* core haskell *) | 
|    615 atom_decl var |    619 atom_decl var | 
|    616 atom_decl tvar |    620 atom_decl tvar | 
|    617  |    621  | 
|    618 (* there are types, coercion types and regular types *) |    622 (* there are types, coercion types and regular types *) | 
|         |    623 (* list-data-structure | 
|    619 nominal_datatype tkind = |    624 nominal_datatype tkind = | 
|    620   KStar |    625   KStar | 
|    621 | KFun "tkind" "tkind" |    626 | KFun "tkind" "tkind" | 
|    622 and ckind = |    627 and ckind = | 
|    623   CKEq "ty" "ty" |    628   CKEq "ty" "ty" | 
|    693 thm fv_weird_raw.simps[no_vars] |    684 thm fv_weird_raw.simps[no_vars] | 
|    694  |    685  | 
|    695 (* example 6 from Terms.thy *) |    686 (* example 6 from Terms.thy *) | 
|    696  |    687  | 
|    697 (* BV is not respectful, needs to fail*) |    688 (* BV is not respectful, needs to fail*) | 
|         |    689 (* | 
|    698 nominal_datatype trm6 = |    690 nominal_datatype trm6 = | 
|    699   Vr6 "name" |    691   Vr6 "name" | 
|    700 | Lm6 x::"name" t::"trm6"         bind x in t |    692 | Lm6 x::"name" t::"trm6"         bind x in t | 
|    701 | Lt6 left::"trm6" right::"trm6"  bind "bv6 left" in right |    693 | Lt6 left::"trm6" right::"trm6"  bind "bv6 left" in right | 
|    702 binder |    694 binder | 
|    703   bv6 |    695   bv6 | 
|    704 where |    696 where | 
|    705   "bv6 (Vr6 n) = {}" |    697   "bv6 (Vr6 n) = {}" | 
|    706 | "bv6 (Lm6 n t) = {atom n} \<union> bv6 t" |    698 | "bv6 (Lm6 n t) = {atom n} \<union> bv6 t" | 
|    707 | "bv6 (Lt6 l r) = bv6 l \<union> bv6 r" |    699 | "bv6 (Lt6 l r) = bv6 l \<union> bv6 r" | 
|         |    700 *) | 
|         |    701  | 
|    708 (* example 7 from Terms.thy *) |    702 (* example 7 from Terms.thy *) | 
|    709  |         | 
|    710 (* BV is not respectful, needs to fail*) |    703 (* BV is not respectful, needs to fail*) | 
|         |    704 (* | 
|    711 nominal_datatype trm7 = |    705 nominal_datatype trm7 = | 
|    712   Vr7 "name" |    706   Vr7 "name" | 
|    713 | Lm7 l::"name" r::"trm7"   bind l in r |    707 | Lm7 l::"name" r::"trm7"   bind l in r | 
|    714 | Lt7 l::"trm7" r::"trm7"   bind "bv7 l" in r |    708 | Lt7 l::"trm7" r::"trm7"   bind "bv7 l" in r | 
|    715 binder |    709 binder | 
|    716   bv7 |    710   bv7 | 
|    717 where |    711 where | 
|    718   "bv7 (Vr7 n) = {atom n}" |    712   "bv7 (Vr7 n) = {atom n}" | 
|    719 | "bv7 (Lm7 n t) = bv7 t - {atom n}" |    713 | "bv7 (Lm7 n t) = bv7 t - {atom n}" | 
|    720 | "bv7 (Lt7 l r) = bv7 l \<union> bv7 r" |    714 | "bv7 (Lt7 l r) = bv7 l \<union> bv7 r" | 
|         |    715 *) | 
|    721  |    716  | 
|    722 (* example 8 from Terms.thy *) |    717 (* example 8 from Terms.thy *) | 
|    723  |    718  | 
|    724 (* Binding in a term under a bn, needs to fail *) |    719 (* Binding in a term under a bn, needs to fail *) | 
|         |    720 (* | 
|    725 nominal_datatype foo8 = |    721 nominal_datatype foo8 = | 
|    726   Foo0 "name" |    722   Foo0 "name" | 
|    727 | Foo1 b::"bar8" f::"foo8" bind "bv8 b" in f --"check fo error if this is called foo" |    723 | Foo1 b::"bar8" f::"foo8" bind "bv8 b" in f --"check fo error if this is called foo" | 
|    728 and bar8 = |    724 and bar8 = | 
|    729   Bar0 "name" |    725   Bar0 "name" | 
|    731 binder |    727 binder | 
|    732   bv8 |    728   bv8 | 
|    733 where |    729 where | 
|    734   "bv8 (Bar0 x) = {}" |    730   "bv8 (Bar0 x) = {}" | 
|    735 | "bv8 (Bar1 v x b) = {atom v}" |    731 | "bv8 (Bar1 v x b) = {atom v}" | 
|    736  |    732 *) | 
|    737 (* example 9 from Terms.thy *) |    733 (* example 9 from Terms.thy *) | 
|    738  |    734  | 
|    739 (* BV is not respectful, needs to fail*) |    735 (* BV is not respectful, needs to fail*) | 
|         |    736 (* | 
|    740 nominal_datatype lam9 = |    737 nominal_datatype lam9 = | 
|    741   Var9 "name" |    738   Var9 "name" | 
|    742 | Lam9 n::"name" l::"lam9" bind n in l |    739 | Lam9 n::"name" l::"lam9" bind n in l | 
|    743 and bla9 = |    740 and bla9 = | 
|    744   Bla9 f::"lam9" s::"lam9" bind "bv9 f" in s |    741   Bla9 f::"lam9" s::"lam9" bind "bv9 f" in s | 
|    745 binder |    742 binder | 
|    746   bv9 |    743   bv9 | 
|    747 where |    744 where | 
|    748   "bv9 (Var9 x) = {}" |    745   "bv9 (Var9 x) = {}" | 
|    749 | "bv9 (Lam9 x b) = {atom x}" |    746 | "bv9 (Lam9 x b) = {atom x}" | 
|    750  |    747 *) | 
|    751  |    748  | 
|    752 (* Type schemes with separate datatypes *) |    749 (* Type schemes with separate datatypes *) | 
|    753 nominal_datatype t = |    750 nominal_datatype T = | 
|    754   Var "name" |    751   TVar "name" | 
|    755 | Fun "t" "t" |    752 | TFun "T" "T" | 
|    756  |    753  | 
|    757 nominal_datatype tyS = |    754 (* PROBLEM:  | 
|    758   All xs::"name list" ty::"t_raw" bind xs in ty |    755 *** exception Datatype raised  | 
|    759  |    756 *** (line 218 of "/usr/local/src/Isabelle_16-Mar-2010/src/HOL/Tools/Datatype/datatype_aux.ML") | 
|    760  |    757 *** At command "nominal_datatype". | 
|    761  |    758 nominal_datatype TyS = | 
|         |    759   TAll xs::"name list" ty::"T" bind xs in ty | 
|         |    760 *) | 
|    762  |    761  | 
|    763 (* example 9 from Peter Sewell's bestiary *) |    762 (* example 9 from Peter Sewell's bestiary *) | 
|    764 (* run out of steam at the moment *) |    763 (* run out of steam at the moment *) | 
|    765  |    764  | 
|    766 end |    765 end |