Quot/Nominal/Terms.thy
changeset 1180 3f36936f1280
parent 1179 789fbba5c23f
child 1181 788a59d2d7aa
equal deleted inserted replaced
1179:789fbba5c23f 1180:3f36936f1280
     1 theory Terms
     1 theory Terms
     2 imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm"
     2 imports "Nominal2_Atoms" "Nominal2_Eqvt" "Nominal2_Supp" "Abs" "Perm" "Fv"
     3 begin
     3 begin
     4 
     4 
     5 atom_decl name
     5 atom_decl name
     6 
     6 
     7 text {* primrec seems to be genarally faster than fun *}
     7 text {* primrec seems to be genarally faster than fun *}
    25 where
    25 where
    26   "bv1 (BUnit) = {}"
    26   "bv1 (BUnit) = {}"
    27 | "bv1 (BVr x) = {atom x}"
    27 | "bv1 (BVr x) = {atom x}"
    28 | "bv1 (BPr bp1 bp2) = (bv1 bp1) \<union> (bv1 bp1)"
    28 | "bv1 (BPr bp1 bp2) = (bv1 bp1) \<union> (bv1 bp1)"
    29 
    29 
    30 (* needs to be calculated by the package *)
    30 local_setup {* define_raw_fv "Terms.rtrm1"
    31 primrec 
    31   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(NONE, 0)], [], [(SOME @{term bv1}, 0)]]],
    32   rfv_trm1 and rfv_bp
    32    [[], [[]], [[], []]]] *}
    33 where
    33 print_theorems
    34   "rfv_trm1 (rVr1 x) = {atom x}"
       
    35 | "rfv_trm1 (rAp1 t1 t2) = (rfv_trm1 t1) \<union> (rfv_trm1 t2)"
       
    36 | "rfv_trm1 (rLm1 x t) = (rfv_trm1 t) - {atom x}"
       
    37 | "rfv_trm1 (rLt1 bp t1 t2) = (rfv_trm1 t1) \<union> (rfv_trm1 t2 - bv1 bp)"
       
    38 | "rfv_bp (BUnit) = {}"
       
    39 | "rfv_bp (BVr x) = {atom x}"
       
    40 | "rfv_bp (BPr b1 b2) = (rfv_bp b1) \<union> (rfv_bp b2)"
       
    41 
    34 
    42 setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Terms.rtrm1", "Terms.bp"] *}
    35 setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Terms.rtrm1", "Terms.bp"] *}
    43 
    36 
    44 inductive
    37 inductive
    45   alpha1 :: "rtrm1 \<Rightarrow> rtrm1 \<Rightarrow> bool" ("_ \<approx>1 _" [100, 100] 100)
    38   alpha1 :: "rtrm1 \<Rightarrow> rtrm1 \<Rightarrow> bool" ("_ \<approx>1 _" [100, 100] 100)
    46 where
    39 where
    47   a1: "a = b \<Longrightarrow> (rVr1 a) \<approx>1 (rVr1 b)"
    40   a1: "a = b \<Longrightarrow> (rVr1 a) \<approx>1 (rVr1 b)"
    48 | a2: "\<lbrakk>t1 \<approx>1 t2; s1 \<approx>1 s2\<rbrakk> \<Longrightarrow> rAp1 t1 s1 \<approx>1 rAp1 t2 s2"
    41 | a2: "\<lbrakk>t1 \<approx>1 t2; s1 \<approx>1 s2\<rbrakk> \<Longrightarrow> rAp1 t1 s1 \<approx>1 rAp1 t2 s2"
    49 | a3: "(\<exists>pi. (({atom aa}, t) \<approx>gen alpha1 rfv_trm1 pi ({atom ab}, s))) \<Longrightarrow> rLm1 aa t \<approx>1 rLm1 ab s"
    42 | a3: "(\<exists>pi. (({atom aa}, t) \<approx>gen alpha1 fv_rtrm1 pi ({atom ab}, s))) \<Longrightarrow> rLm1 aa t \<approx>1 rLm1 ab s"
    50 | a4: "t1 \<approx>1 t2 \<Longrightarrow> (\<exists>pi. (((bv1 b1), s1) \<approx>gen alpha1 rfv_trm1 pi ((bv1 b2), s2))) \<Longrightarrow> rLt1 b1 t1 s1 \<approx>1 rLt1 b2 t2 s2"
    43 | a4: "t1 \<approx>1 t2 \<Longrightarrow> (\<exists>pi. (((bv1 b1), s1) \<approx>gen alpha1 fv_rtrm1 pi ((bv1 b2), s2))) \<Longrightarrow> rLt1 b1 t1 s1 \<approx>1 rLt1 b2 t2 s2"
    51 
    44 
    52 lemma alpha1_inj:
    45 lemma alpha1_inj:
    53 "(rVr1 a \<approx>1 rVr1 b) = (a = b)"
    46 "(rVr1 a \<approx>1 rVr1 b) = (a = b)"
    54 "(rAp1 t1 s1 \<approx>1 rAp1 t2 s2) = (t1 \<approx>1 t2 \<and> s1 \<approx>1 s2)"
    47 "(rAp1 t1 s1 \<approx>1 rAp1 t2 s2) = (t1 \<approx>1 t2 \<and> s1 \<approx>1 s2)"
    55 "(rLm1 aa t \<approx>1 rLm1 ab s) = (\<exists>pi. (({atom aa}, t) \<approx>gen alpha1 rfv_trm1 pi ({atom ab}, s)))"
    48 "(rLm1 aa t \<approx>1 rLm1 ab s) = (\<exists>pi. (({atom aa}, t) \<approx>gen alpha1 fv_rtrm1 pi ({atom ab}, s)))"
    56 "(rLt1 b1 t1 s1 \<approx>1 rLt1 b2 t2 s2) = (t1 \<approx>1 t2 \<and> (\<exists>pi. (((bv1 b1), s1) \<approx>gen alpha1 rfv_trm1 pi ((bv1 b2), s2))))"
    49 "(rLt1 b1 t1 s1 \<approx>1 rLt1 b2 t2 s2) = (t1 \<approx>1 t2 \<and> (\<exists>pi. (((bv1 b1), s1) \<approx>gen alpha1 fv_rtrm1 pi ((bv1 b2), s2))))"
    57 apply -
    50 apply -
    58 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    51 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    59 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    52 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    60 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    53 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    61 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    54 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    66   shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
    59   shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
    67   apply (induct x)
    60   apply (induct x)
    68 apply (simp_all add: empty_eqvt insert_eqvt atom_eqvt)
    61 apply (simp_all add: empty_eqvt insert_eqvt atom_eqvt)
    69 done
    62 done
    70 
    63 
    71 lemma rfv_trm1_eqvt[eqvt]:
    64 lemma fv_rtrm1_eqvt[eqvt]:
    72   shows "(pi\<bullet>rfv_trm1 t) = rfv_trm1 (pi\<bullet>t)"
    65   shows "(pi\<bullet>fv_rtrm1 t) = fv_rtrm1 (pi\<bullet>t)"
    73   apply (induct t)
    66   apply (induct t)
    74   apply (simp_all add: insert_eqvt atom_eqvt empty_eqvt union_eqvt Diff_eqvt bv1_eqvt)
    67   apply (simp_all add: insert_eqvt atom_eqvt empty_eqvt union_eqvt Diff_eqvt bv1_eqvt)
    75   done
    68   done
    76 
    69 
    77 
    70 
    83   apply (rule_tac x="pi \<bullet> pia" in exI)
    76   apply (rule_tac x="pi \<bullet> pia" in exI)
    84   apply (simp add: alpha_gen)
    77   apply (simp add: alpha_gen)
    85   apply(erule conjE)+
    78   apply(erule conjE)+
    86   apply(rule conjI)
    79   apply(rule conjI)
    87   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
    80   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
    88   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt empty_eqvt rfv_trm1_eqvt)
    81   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt empty_eqvt fv_rtrm1_eqvt)
    89   apply(rule conjI)
    82   apply(rule conjI)
    90   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
    83   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
    91   apply(simp add: atom_eqvt Diff_eqvt rfv_trm1_eqvt insert_eqvt empty_eqvt)
    84   apply(simp add: atom_eqvt Diff_eqvt fv_rtrm1_eqvt insert_eqvt empty_eqvt)
    92   apply(simp add: permute_eqvt[symmetric])
    85   apply(simp add: permute_eqvt[symmetric])
    93   apply (erule exE)
    86   apply (erule exE)
    94   apply (rule_tac x="pi \<bullet> pia" in exI)
    87   apply (rule_tac x="pi \<bullet> pia" in exI)
    95   apply (simp add: alpha_gen)
    88   apply (simp add: alpha_gen)
    96   apply(erule conjE)+
    89   apply(erule conjE)+
    97   apply(rule conjI)
    90   apply(rule conjI)
    98   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
    91   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
    99   apply(simp add: rfv_trm1_eqvt Diff_eqvt bv1_eqvt)
    92   apply(simp add: fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
   100   apply(rule conjI)
    93   apply(rule conjI)
   101   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
    94   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
   102   apply(simp add: atom_eqvt rfv_trm1_eqvt Diff_eqvt bv1_eqvt)
    95   apply(simp add: atom_eqvt fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
   103   apply(simp add: permute_eqvt[symmetric])
    96   apply(simp add: permute_eqvt[symmetric])
   104   done
    97   done
   105 
    98 
   106 lemma alpha1_equivp: "equivp alpha1" 
    99 lemma alpha1_equivp: "equivp alpha1" 
   107   sorry
   100   sorry
   130   "rLt1"
   123   "rLt1"
   131 
   124 
   132 quotient_definition
   125 quotient_definition
   133   "fv_trm1 :: trm1 \<Rightarrow> atom set"
   126   "fv_trm1 :: trm1 \<Rightarrow> atom set"
   134 is
   127 is
   135   "rfv_trm1"
   128   "fv_rtrm1"
   136 
   129 
   137 lemma alpha_rfv1:
   130 lemma alpha_rfv1:
   138   shows "t \<approx>1 s \<Longrightarrow> rfv_trm1 t = rfv_trm1 s"
   131   shows "t \<approx>1 s \<Longrightarrow> fv_rtrm1 t = fv_rtrm1 s"
   139   apply(induct rule: alpha1.induct)
   132   apply(induct rule: alpha1.induct)
   140   apply(simp_all add: alpha_gen.simps)
   133   apply(simp_all add: alpha_gen.simps)
   141   done
   134   done
   142 
   135 
   143 lemma [quot_respect]:
   136 lemma [quot_respect]:
   158 apply (rule alpha1_eqvt)
   151 apply (rule alpha1_eqvt)
   159 apply simp
   152 apply simp
   160 done
   153 done
   161 
   154 
   162 lemma [quot_respect]:
   155 lemma [quot_respect]:
   163   "(alpha1 ===> op =) rfv_trm1 rfv_trm1"
   156   "(alpha1 ===> op =) fv_rtrm1 fv_rtrm1"
   164 apply (simp add: alpha_rfv1)
   157 apply (simp add: alpha_rfv1)
   165 done
   158 done
   166 
   159 
   167 lemmas trm1_bp_induct = rtrm1_bp.induct[quot_lifted]
   160 lemmas trm1_bp_induct = rtrm1_bp.induct[quot_lifted]
   168 lemmas trm1_bp_inducts = rtrm1_bp.inducts[quot_lifted]
   161 lemmas trm1_bp_inducts = rtrm1_bp.inducts[quot_lifted]
   183 apply(simp_all)
   176 apply(simp_all)
   184 done
   177 done
   185 
   178 
   186 end
   179 end
   187 
   180 
   188 lemmas fv_trm1 = rfv_trm1_rfv_bp.simps[quot_lifted]
   181 lemmas fv_trm1 = fv_rtrm1_fv_bp.simps[quot_lifted]
   189 
   182 
   190 lemmas fv_trm1_eqvt = rfv_trm1_eqvt[quot_lifted]
   183 lemmas fv_trm1_eqvt = fv_rtrm1_eqvt[quot_lifted]
   191 
   184 
   192 lemmas alpha1_INJ = alpha1_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
   185 lemmas alpha1_INJ = alpha1_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
   193 
   186 
   194 lemma lm1_supp_pre:
   187 lemma lm1_supp_pre:
   195   shows "(supp (atom x, t)) supports (Lm1 x t) "
   188   shows "(supp (atom x, t)) supports (Lm1 x t) "
   289 primrec 
   282 primrec 
   290   rbv2
   283   rbv2
   291 where
   284 where
   292   "rbv2 (rAs x t) = {atom x}"
   285   "rbv2 (rAs x t) = {atom x}"
   293 
   286 
   294 (* needs to be calculated by the package *)
   287 local_setup {* define_raw_fv "Terms.rtrm2"
   295 primrec
   288   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term rbv2}, 0)]]],
   296   fv_rtrm2 and fv_rassign
   289    [[[(NONE, 0)], []]]] *}
   297 where
   290 print_theorems
   298   "fv_rtrm2 (rVr2 x) = {atom x}"
       
   299 | "fv_rtrm2 (rAp2 t1 t2) = (fv_rtrm2 t1) \<union> (fv_rtrm2 t2)"
       
   300 | "fv_rtrm2 (rLm2 x t) = (fv_rtrm2 t) - {atom x}"
       
   301 | "fv_rtrm2 (rLt2 as t) = (fv_rtrm2 t - rbv2 as) \<union> (fv_rassign as)"
       
   302 | "fv_rassign (rAs x t) = fv_rtrm2 t"
       
   303 
   291 
   304 setup {* snd o define_raw_perms ["rtrm2", "rassign"] ["Terms.rtrm2", "Terms.rassign"] *}
   292 setup {* snd o define_raw_perms ["rtrm2", "rassign"] ["Terms.rtrm2", "Terms.rassign"] *}
   305 
   293 
   306 inductive
   294 inductive
   307   alpha2 :: "rtrm2 \<Rightarrow> rtrm2 \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100)
   295   alpha2 :: "rtrm2 \<Rightarrow> rtrm2 \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100)
   345   bv3
   333   bv3
   346 where
   334 where
   347   "bv3 ANil = {}"
   335   "bv3 ANil = {}"
   348 | "bv3 (ACons x t as) = {atom x} \<union> (bv3 as)"
   336 | "bv3 (ACons x t as) = {atom x} \<union> (bv3 as)"
   349 
   337 
   350 primrec
   338 local_setup {* define_raw_fv "Terms.trm3"
   351   fv_trm3 and fv_assigns
   339   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term bv3}, 0)]]],
   352 where
   340    [[], [[(NONE, 0)], [], []]]] *}
   353   "fv_trm3 (Vr3 x) = {atom x}"
   341 print_theorems
   354 | "fv_trm3 (Ap3 t1 t2) = (fv_trm3 t1) \<union> (fv_trm3 t2)"
       
   355 | "fv_trm3 (Lm3 x t) = (fv_trm3 t) - {atom x}"
       
   356 | "fv_trm3 (Lt3 as t) = (fv_trm3 t - bv3 as) \<union> (fv_assigns as)"
       
   357 | "fv_assigns (ANil) = {}"
       
   358 | "fv_assigns (ACons x t as) = (fv_trm3 t) \<union> (fv_assigns as)"
       
   359 
   342 
   360 setup {* snd o define_raw_perms ["rtrm3", "assigns"] ["Terms.trm3", "Terms.assigns"] *}
   343 setup {* snd o define_raw_perms ["rtrm3", "assigns"] ["Terms.trm3", "Terms.assigns"] *}
   361 
   344 
   362 inductive
   345 inductive
   363   alpha3 :: "trm3 \<Rightarrow> trm3 \<Rightarrow> bool" ("_ \<approx>3 _" [100, 100] 100)
   346   alpha3 :: "trm3 \<Rightarrow> trm3 \<Rightarrow> bool" ("_ \<approx>3 _" [100, 100] 100)
   389 
   372 
   390 datatype trm4 =
   373 datatype trm4 =
   391   Vr4 "name"
   374   Vr4 "name"
   392 | Ap4 "trm4" "trm4 list"
   375 | Ap4 "trm4" "trm4 list"
   393 | Lm4 "name" "trm4"  --"bind (name) in (trm)"
   376 | Lm4 "name" "trm4"  --"bind (name) in (trm)"
       
   377 print_theorems
   394 
   378 
   395 thm trm4.recs
   379 thm trm4.recs
   396 
   380 
   397 primrec
   381 local_setup {* define_raw_fv "Terms.trm4" [
   398   fv_trm4 and fv_trm4_list
   382   [[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]]], [[], [[], []]]  ] *}
   399 where
   383 print_theorems
   400   "fv_trm4 (Vr4 x) = {atom x}"
       
   401 | "fv_trm4 (Ap4 t ts) = (fv_trm4 t) \<union> (fv_trm4_list ts)"
       
   402 | "fv_trm4 (Lm4 x t) = (fv_trm4 t) - {atom x}"
       
   403 | "fv_trm4_list ([]) = {}"
       
   404 | "fv_trm4_list (t#ts) = (fv_trm4 t) \<union> (fv_trm4_list ts)"
       
   405 
   384 
   406 (* there cannot be a clause for lists, as *)
   385 (* there cannot be a clause for lists, as *)
   407 (* permutations are  already defined in Nominal (also functions, options, and so on) *)
   386 (* permutations are  already defined in Nominal (also functions, options, and so on) *)
   408 setup {* snd o define_raw_perms ["trm4"] ["Terms.trm4"] *}
   387 setup {* snd o define_raw_perms ["trm4"] ["Terms.trm4"] *}
   409 
   388 
   449   rbv5
   428   rbv5
   450 where
   429 where
   451   "rbv5 rLnil = {}"
   430   "rbv5 rLnil = {}"
   452 | "rbv5 (rLcons n t ltl) = {atom n} \<union> (rbv5 ltl)"
   431 | "rbv5 (rLcons n t ltl) = {atom n} \<union> (rbv5 ltl)"
   453 
   432 
   454 primrec
   433 local_setup {* define_raw_fv "Terms.rtrm5" [
   455   rfv_trm5 and rfv_lts
   434   [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[(NONE, 0)], [], []]]  ] *}
   456 where
   435 print_theorems
   457   "rfv_trm5 (rVr5 n) = {atom n}"
       
   458 | "rfv_trm5 (rAp5 t s) = (rfv_trm5 t) \<union> (rfv_trm5 s)"
       
   459 | "rfv_trm5 (rLt5 lts t) = (rfv_trm5 t - rbv5 lts) \<union> (rfv_lts lts - rbv5 lts)"
       
   460 | "rfv_lts (rLnil) = {}"
       
   461 | "rfv_lts (rLcons n t ltl) = (rfv_trm5 t) \<union> (rfv_lts ltl)"
       
   462 
   436 
   463 setup {* snd o define_raw_perms ["rtrm5", "rlts"] ["Terms.rtrm5", "Terms.rlts"] *}
   437 setup {* snd o define_raw_perms ["rtrm5", "rlts"] ["Terms.rtrm5", "Terms.rlts"] *}
   464 print_theorems
   438 print_theorems
   465 
   439 
   466 inductive
   440 inductive
   468 and
   442 and
   469   alphalts :: "rlts \<Rightarrow> rlts \<Rightarrow> bool" ("_ \<approx>l _" [100, 100] 100)
   443   alphalts :: "rlts \<Rightarrow> rlts \<Rightarrow> bool" ("_ \<approx>l _" [100, 100] 100)
   470 where
   444 where
   471   a1: "a = b \<Longrightarrow> (rVr5 a) \<approx>5 (rVr5 b)"
   445   a1: "a = b \<Longrightarrow> (rVr5 a) \<approx>5 (rVr5 b)"
   472 | a2: "\<lbrakk>t1 \<approx>5 t2; s1 \<approx>5 s2\<rbrakk> \<Longrightarrow> rAp5 t1 s1 \<approx>5 rAp5 t2 s2"
   446 | a2: "\<lbrakk>t1 \<approx>5 t2; s1 \<approx>5 s2\<rbrakk> \<Longrightarrow> rAp5 t1 s1 \<approx>5 rAp5 t2 s2"
   473 | a3: "\<lbrakk>\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha5 rfv_trm5 pi (rbv5 l2, t2)); 
   447 | a3: "\<lbrakk>\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha5 fv_rtrm5 pi (rbv5 l2, t2)); 
   474         \<exists>pi. ((rbv5 l1, l1) \<approx>gen alphalts rfv_lts pi (rbv5 l2, l2))\<rbrakk>
   448         \<exists>pi. ((rbv5 l1, l1) \<approx>gen alphalts fv_rlts pi (rbv5 l2, l2))\<rbrakk>
   475         \<Longrightarrow> rLt5 l1 t1 \<approx>5 rLt5 l2 t2"
   449         \<Longrightarrow> rLt5 l1 t1 \<approx>5 rLt5 l2 t2"
   476 | a4: "rLnil \<approx>l rLnil"
   450 | a4: "rLnil \<approx>l rLnil"
   477 | a5: "ls1 \<approx>l ls2 \<Longrightarrow> t1 \<approx>5 t2 \<Longrightarrow> n1 = n2 \<Longrightarrow> rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2"
   451 | a5: "ls1 \<approx>l ls2 \<Longrightarrow> t1 \<approx>5 t2 \<Longrightarrow> n1 = n2 \<Longrightarrow> rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2"
   478 
   452 
   479 print_theorems
   453 print_theorems
   480 
   454 
   481 lemma alpha5_inj:
   455 lemma alpha5_inj:
   482   "((rVr5 a) \<approx>5 (rVr5 b)) = (a = b)"
   456   "((rVr5 a) \<approx>5 (rVr5 b)) = (a = b)"
   483   "(rAp5 t1 s1 \<approx>5 rAp5 t2 s2) = (t1 \<approx>5 t2 \<and> s1 \<approx>5 s2)"
   457   "(rAp5 t1 s1 \<approx>5 rAp5 t2 s2) = (t1 \<approx>5 t2 \<and> s1 \<approx>5 s2)"
   484   "(rLt5 l1 t1 \<approx>5 rLt5 l2 t2) = ((\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha5 rfv_trm5 pi (rbv5 l2, t2))) \<and>
   458   "(rLt5 l1 t1 \<approx>5 rLt5 l2 t2) = ((\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha5 fv_rtrm5 pi (rbv5 l2, t2))) \<and>
   485          (\<exists>pi. ((rbv5 l1, l1) \<approx>gen alphalts rfv_lts pi (rbv5 l2, l2))))"
   459          (\<exists>pi. ((rbv5 l1, l1) \<approx>gen alphalts fv_rlts pi (rbv5 l2, l2))))"
   486   "rLnil \<approx>l rLnil"
   460   "rLnil \<approx>l rLnil"
   487   "(rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2) = (n1 = n2 \<and> ls1 \<approx>l ls2 \<and> t1 \<approx>5 t2)"
   461   "(rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2) = (n1 = n2 \<and> ls1 \<approx>l ls2 \<and> t1 \<approx>5 t2)"
   488 apply -
   462 apply -
   489 apply (simp_all add: alpha5_alphalts.intros)
   463 apply (simp_all add: alpha5_alphalts.intros)
   490 apply rule
   464 apply rule
   538   "rLcons"
   512   "rLcons"
   539 
   513 
   540 quotient_definition
   514 quotient_definition
   541    "fv_trm5 :: trm5 \<Rightarrow> atom set"
   515    "fv_trm5 :: trm5 \<Rightarrow> atom set"
   542 is
   516 is
   543   "rfv_trm5"
   517   "fv_rtrm5"
   544 
   518 
   545 quotient_definition
   519 quotient_definition
   546    "fv_lts :: lts \<Rightarrow> atom set"
   520    "fv_lts :: lts \<Rightarrow> atom set"
   547 is
   521 is
   548   "rfv_lts"
   522   "fv_rlts"
   549 
   523 
   550 quotient_definition
   524 quotient_definition
   551    "bv5 :: lts \<Rightarrow> atom set"
   525    "bv5 :: lts \<Rightarrow> atom set"
   552 is
   526 is
   553   "rbv5"
   527   "rbv5"
   554 
   528 
   555 lemma rbv5_eqvt:
   529 lemma rbv5_eqvt:
   556   "pi \<bullet> (rbv5 x) = rbv5 (pi \<bullet> x)"
   530   "pi \<bullet> (rbv5 x) = rbv5 (pi \<bullet> x)"
   557 sorry
   531 sorry
   558 
   532 
   559 lemma rfv_trm5_eqvt:
   533 lemma fv_rtrm5_eqvt:
   560   "pi \<bullet> (rfv_trm5 x) = rfv_trm5 (pi \<bullet> x)"
   534   "pi \<bullet> (fv_rtrm5 x) = fv_rtrm5 (pi \<bullet> x)"
   561 sorry
   535 sorry
   562 
   536 
   563 lemma rfv_lts_eqvt:
   537 lemma fv_rlts_eqvt:
   564   "pi \<bullet> (rfv_lts x) = rfv_lts (pi \<bullet> x)"
   538   "pi \<bullet> (fv_rlts x) = fv_rlts (pi \<bullet> x)"
   565 sorry
   539 sorry
   566 
   540 
   567 lemma alpha5_eqvt:
   541 lemma alpha5_eqvt:
   568   "xa \<approx>5 y \<Longrightarrow> (x \<bullet> xa) \<approx>5 (x \<bullet> y)"
   542   "xa \<approx>5 y \<Longrightarrow> (x \<bullet> xa) \<approx>5 (x \<bullet> y)"
   569   "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)"
   543   "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)"
   574   apply (erule conjE)+
   548   apply (erule conjE)+
   575   apply (rule conjI)
   549   apply (rule conjI)
   576   apply (rule_tac x="x \<bullet> pi" in exI)
   550   apply (rule_tac x="x \<bullet> pi" in exI)
   577   apply (rule conjI)
   551   apply (rule conjI)
   578   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   552   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   579   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_trm5_eqvt)
   553   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
   580   apply(rule conjI)
   554   apply(rule conjI)
   581   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   555   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   582   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_trm5_eqvt)
   556   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
   583   apply (subst permute_eqvt[symmetric])
   557   apply (subst permute_eqvt[symmetric])
   584   apply (simp)
   558   apply (simp)
   585   apply (rule_tac x="x \<bullet> pia" in exI)
   559   apply (rule_tac x="x \<bullet> pia" in exI)
   586   apply (rule conjI)
   560   apply (rule conjI)
   587   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   561   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   588   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_lts_eqvt)
   562   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rlts_eqvt)
   589   apply(rule conjI)
   563   apply(rule conjI)
   590   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   564   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   591   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt rfv_lts_eqvt)
   565   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rlts_eqvt)
   592   apply (subst permute_eqvt[symmetric])
   566   apply (subst permute_eqvt[symmetric])
   593   apply (simp)
   567   apply (simp)
   594   done
   568   done
   595 
   569 
   596 lemma alpha5_rfv:
   570 lemma alpha5_rfv:
   597   "(t \<approx>5 s \<Longrightarrow> rfv_trm5 t = rfv_trm5 s)"
   571   "(t \<approx>5 s \<Longrightarrow> fv_rtrm5 t = fv_rtrm5 s)"
   598   "(l \<approx>l m \<Longrightarrow> rfv_lts l = rfv_lts m)"
   572   "(l \<approx>l m \<Longrightarrow> fv_rlts l = fv_rlts m)"
   599   apply(induct rule: alpha5_alphalts.inducts)
   573   apply(induct rule: alpha5_alphalts.inducts)
   600   apply(simp_all add: alpha_gen)
   574   apply(simp_all add: alpha_gen)
   601   done
   575   done
   602 
   576 
   603 lemma bv_list_rsp:
   577 lemma bv_list_rsp:
   605   apply(induct rule: alpha5_alphalts.inducts(2))
   579   apply(induct rule: alpha5_alphalts.inducts(2))
   606   apply(simp_all)
   580   apply(simp_all)
   607   done
   581   done
   608 
   582 
   609 lemma [quot_respect]:
   583 lemma [quot_respect]:
   610   "(alphalts ===> op =) rfv_lts rfv_lts"
   584   "(alphalts ===> op =) fv_rlts fv_rlts"
   611   "(alpha5 ===> op =) rfv_trm5 rfv_trm5"
   585   "(alpha5 ===> op =) fv_rtrm5 fv_rtrm5"
   612   "(alphalts ===> op =) rbv5 rbv5"
   586   "(alphalts ===> op =) rbv5 rbv5"
   613   "(op = ===> alpha5) rVr5 rVr5"
   587   "(op = ===> alpha5) rVr5 rVr5"
   614   "(alpha5 ===> alpha5 ===> alpha5) rAp5 rAp5"
   588   "(alpha5 ===> alpha5 ===> alpha5) rAp5 rAp5"
   615   "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5"
   589   "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5"
   616   "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5"
   590   "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5"
   669 
   643 
   670 lemmas alpha5_INJ = alpha5_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
   644 lemmas alpha5_INJ = alpha5_inj[unfolded alpha_gen, quot_lifted, folded alpha_gen]
   671 
   645 
   672 lemmas bv5[simp] = rbv5.simps[quot_lifted]
   646 lemmas bv5[simp] = rbv5.simps[quot_lifted]
   673 
   647 
   674 lemmas fv_trm5_lts[simp] = rfv_trm5_rfv_lts.simps[quot_lifted]
   648 lemmas fv_trm5_lts[simp] = fv_rtrm5_fv_rlts.simps[quot_lifted]
   675 
   649 
   676 lemma lets_ok:
   650 lemma lets_ok:
   677   "(Lt5 (Lcons x (Vr5 x) Lnil) (Vr5 x)) = (Lt5 (Lcons y (Vr5 y) Lnil) (Vr5 y))"
   651   "(Lt5 (Lcons x (Vr5 x) Lnil) (Vr5 x)) = (Lt5 (Lcons y (Vr5 y) Lnil) (Vr5 y))"
   678 apply (subst alpha5_INJ)
   652 apply (subst alpha5_INJ)
   679 apply (rule conjI)
   653 apply (rule conjI)
   746 where
   720 where
   747   "rbv6 (rVr6 n) = {}"
   721   "rbv6 (rVr6 n) = {}"
   748 | "rbv6 (rLm6 n t) = {atom n} \<union> rbv6 t"
   722 | "rbv6 (rLm6 n t) = {atom n} \<union> rbv6 t"
   749 | "rbv6 (rLt6 l r) = rbv6 l \<union> rbv6 r"
   723 | "rbv6 (rLt6 l r) = rbv6 l \<union> rbv6 r"
   750 
   724 
   751 primrec
   725 local_setup {* define_raw_fv "Terms.rtrm6" [
   752   rfv_trm6
   726   [[[]], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term rbv6}, 0)]]]] *}
   753 where
   727 print_theorems 
   754   "rfv_trm6 (rVr6 n) = {atom n}"
       
   755 | "rfv_trm6 (rLm6 n t) = (rfv_trm6 t) - {atom n}"
       
   756 | "rfv_trm6 (rLt6 l r) = (rfv_trm6 r - rbv6 l) \<union> rfv_trm6 l"
       
   757 
   728 
   758 setup {* snd o define_raw_perms ["rtrm6"] ["Terms.rtrm6"] *}
   729 setup {* snd o define_raw_perms ["rtrm6"] ["Terms.rtrm6"] *}
   759 print_theorems
   730 print_theorems
   760 
   731 
   761 inductive
   732 inductive
   762   alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [100, 100] 100)
   733   alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [100, 100] 100)
   763 where
   734 where
   764   a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
   735   a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
   765 | a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha6 rfv_trm6 pi ({atom b}, s))) \<Longrightarrow> rLm6 a t \<approx>6 rLm6 b s"
   736 | a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha6 fv_rtrm6 pi ({atom b}, s))) \<Longrightarrow> rLm6 a t \<approx>6 rLm6 b s"
   766 | a3: "(\<exists>pi. (((rbv6 t1), s1) \<approx>gen alpha6 rfv_trm6 pi ((rbv6 t2), s2))) \<Longrightarrow> rLt6 t1 s1 \<approx>6 rLt6 t2 s2"
   737 | a3: "(\<exists>pi. (((rbv6 t1), s1) \<approx>gen alpha6 fv_rtrm6 pi ((rbv6 t2), s2))) \<Longrightarrow> rLt6 t1 s1 \<approx>6 rLt6 t2 s2"
   767 
   738 
   768 lemma alpha6_equivps:
   739 lemma alpha6_equivps:
   769   shows "equivp alpha6"
   740   shows "equivp alpha6"
   770 sorry
   741 sorry
   771 
   742 
   789   "rLt6"
   760   "rLt6"
   790 
   761 
   791 quotient_definition
   762 quotient_definition
   792    "fv_trm6 :: trm6 \<Rightarrow> atom set"
   763    "fv_trm6 :: trm6 \<Rightarrow> atom set"
   793 is
   764 is
   794   "rfv_trm6"
   765   "fv_rtrm6"
   795 
   766 
   796 quotient_definition
   767 quotient_definition
   797    "bv6 :: trm6 \<Rightarrow> atom set"
   768    "bv6 :: trm6 \<Rightarrow> atom set"
   798 is
   769 is
   799   "rbv6"
   770   "rbv6"
   820 apply (simp add: alpha_gen fresh_star_def)
   791 apply (simp add: alpha_gen fresh_star_def)
   821 apply (rule a1)
   792 apply (rule a1)
   822 apply (rule refl)
   793 apply (rule refl)
   823 done
   794 done
   824 
   795 
   825 lemma [quot_respect]:"(alpha6 ===> op =) rfv_trm6 rfv_trm6"
   796 lemma [quot_respect]:"(alpha6 ===> op =) fv_rtrm6 fv_rtrm6"
   826 apply simp apply clarify
   797 apply simp apply clarify
   827 apply (induct_tac x y rule: alpha6.induct)
   798 apply (induct_tac x y rule: alpha6.induct)
   828 apply simp_all
   799 apply simp_all
   829 apply (erule exE)
   800 apply (erule exE)
   830 apply (simp_all add: alpha_gen)
   801 apply (simp_all add: alpha_gen)
   905 where
   876 where
   906   "rbv7 (rVr7 n) = {atom n}"
   877   "rbv7 (rVr7 n) = {atom n}"
   907 | "rbv7 (rLm7 n t) = rbv7 t - {atom n}"
   878 | "rbv7 (rLm7 n t) = rbv7 t - {atom n}"
   908 | "rbv7 (rLt7 l r) = rbv7 l \<union> rbv7 r"
   879 | "rbv7 (rLt7 l r) = rbv7 l \<union> rbv7 r"
   909 
   880 
   910 primrec
   881 local_setup {* define_raw_fv "Terms.rtrm7" [
   911   rfv_trm7
   882   [[[]], [[(NONE, 0)], [(NONE, 0)]], [[], [(SOME @{term rbv7}, 0)]]]] *}
   912 where
   883 print_theorems 
   913   "rfv_trm7 (rVr7 n) = {atom n}"
       
   914 | "rfv_trm7 (rLm7 n t) = (rfv_trm7 t) - {atom n}"
       
   915 | "rfv_trm7 (rLt7 l r) = (rfv_trm7 l) \<union> (rfv_trm7 r - rbv7 l)"
       
   916 
   884 
   917 setup {* snd o define_raw_perms ["rtrm7"] ["Terms.rtrm7"] *}
   885 setup {* snd o define_raw_perms ["rtrm7"] ["Terms.rtrm7"] *}
   918 print_theorems
   886 print_theorems
   919 
   887 
   920 inductive
   888 inductive
   921   alpha7 :: "rtrm7 \<Rightarrow> rtrm7 \<Rightarrow> bool" ("_ \<approx>7 _" [100, 100] 100)
   889   alpha7 :: "rtrm7 \<Rightarrow> rtrm7 \<Rightarrow> bool" ("_ \<approx>7 _" [100, 100] 100)
   922 where
   890 where
   923   a1: "a = b \<Longrightarrow> (rVr7 a) \<approx>7 (rVr7 b)"
   891   a1: "a = b \<Longrightarrow> (rVr7 a) \<approx>7 (rVr7 b)"
   924 | a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha7 rfv_trm7 pi ({atom b}, s))) \<Longrightarrow> rLm7 a t \<approx>7 rLm7 b s"
   892 | a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha7 fv_rtrm7 pi ({atom b}, s))) \<Longrightarrow> rLm7 a t \<approx>7 rLm7 b s"
   925 | a3: "(\<exists>pi. (((rbv7 t1), s1) \<approx>gen alpha7 rfv_trm7 pi ((rbv7 t2), s2))) \<Longrightarrow> rLt7 t1 s1 \<approx>7 rLt7 t2 s2"
   893 | a3: "(\<exists>pi. (((rbv7 t1), s1) \<approx>gen alpha7 fv_rtrm7 pi ((rbv7 t2), s2))) \<Longrightarrow> rLt7 t1 s1 \<approx>7 rLt7 t2 s2"
   926 
   894 
   927 lemma bvfv7: "rbv7 x = rfv_trm7 x"
   895 lemma bvfv7: "rbv7 x = fv_rtrm7 x"
   928   apply induct
   896   apply induct
   929   apply simp_all
   897   apply simp_all
   930 done
   898 done
   931 
   899 
   932 lemma "(x::name) \<noteq> y \<Longrightarrow> \<not> (alpha7 ===> op =) rbv7 rbv7"
   900 lemma "(x::name) \<noteq> y \<Longrightarrow> \<not> (alpha7 ===> op =) rbv7 rbv7"
   956   rbv8
   924   rbv8
   957 where
   925 where
   958   "rbv8 (Bar0 x) = {}"
   926   "rbv8 (Bar0 x) = {}"
   959 | "rbv8 (Bar1 v x b) = {atom v}"
   927 | "rbv8 (Bar1 v x b) = {atom v}"
   960 
   928 
   961 primrec 
   929 local_setup {* define_raw_fv "Terms.rfoo8" [
   962   rfv_foo8 and rfv_bar8
   930   [[[]], [[], [(SOME @{term rbv8}, 0)]]], [[[]], [[], [(NONE, 1)], [(NONE, 1)]]]] *}
   963 where
   931 print_theorems 
   964   "rfv_foo8 (Foo0 x) = {atom x}"
       
   965 | "rfv_foo8 (Foo1 b t) = (rfv_foo8 t - rbv8 b) \<union> (rfv_bar8 b)"
       
   966 | "rfv_bar8 (Bar0 x) = {atom x}"
       
   967 | "rfv_bar8 (Bar1 v x t) = {atom v} \<union> (rfv_bar8 t - {atom x})"
       
   968 print_theorems
       
   969 
   932 
   970 setup {* snd o define_raw_perms ["rfoo8", "rbar8"] ["Terms.rfoo8", "Terms.rbar8"] *}
   933 setup {* snd o define_raw_perms ["rfoo8", "rbar8"] ["Terms.rfoo8", "Terms.rbar8"] *}
   971 print_theorems
   934 print_theorems
   972 
   935 
   973 inductive
   936 inductive
   975 and
   938 and
   976   alpha8b :: "rbar8 \<Rightarrow> rbar8 \<Rightarrow> bool" ("_ \<approx>b _" [100, 100] 100)
   939   alpha8b :: "rbar8 \<Rightarrow> rbar8 \<Rightarrow> bool" ("_ \<approx>b _" [100, 100] 100)
   977 where
   940 where
   978   a1: "a = b \<Longrightarrow> (Foo0 a) \<approx>f (Foo0 b)"
   941   a1: "a = b \<Longrightarrow> (Foo0 a) \<approx>f (Foo0 b)"
   979 | a2: "a = b \<Longrightarrow> (Bar0 a) \<approx>b (Bar0 b)"
   942 | a2: "a = b \<Longrightarrow> (Bar0 a) \<approx>b (Bar0 b)"
   980 | a3: "b1 \<approx>b b2 \<Longrightarrow> (\<exists>pi. (((rbv8 b1), t1) \<approx>gen alpha8f rfv_foo8 pi ((rbv8 b2), t2))) \<Longrightarrow> Foo1 b1 t1 \<approx>f Foo1 b2 t2"
   943 | a3: "b1 \<approx>b b2 \<Longrightarrow> (\<exists>pi. (((rbv8 b1), t1) \<approx>gen alpha8f fv_rfoo8 pi ((rbv8 b2), t2))) \<Longrightarrow> Foo1 b1 t1 \<approx>f Foo1 b2 t2"
   981 | a4: "v1 = v2 \<Longrightarrow> (\<exists>pi. (({atom x1}, t1) \<approx>gen alpha8b rfv_bar8 pi ({atom x2}, t2))) \<Longrightarrow> Bar1 v1 x1 t1 \<approx>b Bar1 v2 x2 t2"
   944 | a4: "v1 = v2 \<Longrightarrow> (\<exists>pi. (({atom x1}, t1) \<approx>gen alpha8b fv_rbar8 pi ({atom x2}, t2))) \<Longrightarrow> Bar1 v1 x1 t1 \<approx>b Bar1 v2 x2 t2"
   982 
   945 
   983 lemma "(alpha8b ===> op =) rbv8 rbv8"
   946 lemma "(alpha8b ===> op =) rbv8 rbv8"
   984   apply simp apply clarify
   947   apply simp apply clarify
   985   apply (erule alpha8f_alpha8b.inducts(2))
   948   apply (erule alpha8f_alpha8b.inducts(2))
   986   apply (simp_all)
   949   apply (simp_all)
   987 done
   950 done
   988 
   951 
   989 lemma rfv_bar8_rsp_hlp: "x \<approx>b y \<Longrightarrow> rfv_bar8 x = rfv_bar8 y"
   952 lemma fv_rbar8_rsp_hlp: "x \<approx>b y \<Longrightarrow> fv_rbar8 x = fv_rbar8 y"
   990   apply (erule alpha8f_alpha8b.inducts(2))
   953   apply (erule alpha8f_alpha8b.inducts(2))
   991   apply (simp_all add: alpha_gen)
   954   apply (simp_all add: alpha_gen)
   992 done
   955 done
   993 lemma "(alpha8b ===> op =) rfv_bar8 rfv_bar8"
   956 lemma "(alpha8b ===> op =) fv_rbar8 fv_rbar8"
   994   apply simp apply clarify apply (simp add: rfv_bar8_rsp_hlp)
   957   apply simp apply clarify apply (simp add: fv_rbar8_rsp_hlp)
   995 done
   958 done
   996 
   959 
   997 lemma "(alpha8f ===> op =) rfv_foo8 rfv_foo8"
   960 lemma "(alpha8f ===> op =) fv_rfoo8 fv_rfoo8"
   998   apply simp apply clarify
   961   apply simp apply clarify
   999   apply (erule alpha8f_alpha8b.inducts(1))
   962   apply (erule alpha8f_alpha8b.inducts(1))
  1000   apply (simp_all add: alpha_gen rfv_bar8_rsp_hlp)
   963   apply (simp_all add: alpha_gen fv_rbar8_rsp_hlp)
  1001 done
   964 done
  1002 
   965 
  1003 
   966 
  1004 
   967 
  1005 
   968 
  1015   rbv9
   978   rbv9
  1016 where
   979 where
  1017   "rbv9 (Var9 x) = {}"
   980   "rbv9 (Var9 x) = {}"
  1018 | "rbv9 (Lam9 x b) = {atom x}"
   981 | "rbv9 (Lam9 x b) = {atom x}"
  1019 
   982 
  1020 primrec 
   983 local_setup {* define_raw_fv "Terms.rlam9" [
  1021   rfv_lam9 and rfv_bla9
   984   [[[]], [[(NONE, 0)], [(NONE, 0)]]], [[[], [(SOME @{term rbv9}, 0)]]]] *}
  1022 where
   985 print_theorems
  1023   "rfv_lam9 (Var9 x) = {atom x}"
       
  1024 | "rfv_lam9 (Lam9 b t) = (rfv_lam9 t - {atom b})"
       
  1025 | "rfv_bla9 (Bla9 l r) = (rfv_lam9 r - rbv9 l) \<union> rfv_lam9 l"
       
  1026 
   986 
  1027 setup {* snd o define_raw_perms ["rlam9", "rbla9"] ["Terms.rlam9", "Terms.rbla9"] *}
   987 setup {* snd o define_raw_perms ["rlam9", "rbla9"] ["Terms.rlam9", "Terms.rbla9"] *}
  1028 print_theorems
   988 print_theorems
  1029 
   989 
  1030 inductive
   990 inductive
  1031   alpha9l :: "rlam9 \<Rightarrow> rlam9 \<Rightarrow> bool" ("_ \<approx>9l _" [100, 100] 100)
   991   alpha9l :: "rlam9 \<Rightarrow> rlam9 \<Rightarrow> bool" ("_ \<approx>9l _" [100, 100] 100)
  1032 and
   992 and
  1033   alpha9b :: "rbla9 \<Rightarrow> rbla9 \<Rightarrow> bool" ("_ \<approx>9b _" [100, 100] 100)
   993   alpha9b :: "rbla9 \<Rightarrow> rbla9 \<Rightarrow> bool" ("_ \<approx>9b _" [100, 100] 100)
  1034 where
   994 where
  1035   a1: "a = b \<Longrightarrow> (Var9 a) \<approx>9l (Var9 b)"
   995   a1: "a = b \<Longrightarrow> (Var9 a) \<approx>9l (Var9 b)"
  1036 | a4: "(\<exists>pi. (({atom x1}, t1) \<approx>gen alpha9l rfv_lam9 pi ({atom x2}, t2))) \<Longrightarrow> Lam9 x1 t1 \<approx>9l Lam9 x2 t2"
   996 | a4: "(\<exists>pi. (({atom x1}, t1) \<approx>gen alpha9l fv_rlam9 pi ({atom x2}, t2))) \<Longrightarrow> Lam9 x1 t1 \<approx>9l Lam9 x2 t2"
  1037 | a3: "b1 \<approx>9l b2 \<Longrightarrow> (\<exists>pi. (((rbv9 b1), t1) \<approx>gen alpha9l rfv_lam9 pi ((rbv9 b2), t2))) \<Longrightarrow> Bla9 b1 t1 \<approx>9b Bla9 b2 t2"
   997 | a3: "b1 \<approx>9l b2 \<Longrightarrow> (\<exists>pi. (((rbv9 b1), t1) \<approx>gen alpha9l fv_rlam9 pi ((rbv9 b2), t2))) \<Longrightarrow> Bla9 b1 t1 \<approx>9b Bla9 b2 t2"
  1038 
   998 
  1039 quotient_type
   999 quotient_type
  1040   lam9 = rlam9 / alpha9l and bla9 = rbla9 / alpha9b
  1000   lam9 = rlam9 / alpha9l and bla9 = rbla9 / alpha9b
  1041 sorry
  1001 sorry
  1042 
  1002 
  1056   "Bla9"
  1016   "Bla9"
  1057 
  1017 
  1058 quotient_definition
  1018 quotient_definition
  1059   "fv_lam9 :: lam9 \<Rightarrow> atom set"
  1019   "fv_lam9 :: lam9 \<Rightarrow> atom set"
  1060 is
  1020 is
  1061   "rfv_lam9"
  1021   "fv_rlam9"
  1062 
  1022 
  1063 quotient_definition
  1023 quotient_definition
  1064   "fv_bla9 :: bla9 \<Rightarrow> atom set"
  1024   "fv_bla9 :: bla9 \<Rightarrow> atom set"
  1065 is
  1025 is
  1066   "rfv_bla9"
  1026   "fv_rbla9"
  1067 
  1027 
  1068 quotient_definition
  1028 quotient_definition
  1069   "bv9 :: lam9 \<Rightarrow> atom set"
  1029   "bv9 :: lam9 \<Rightarrow> atom set"
  1070 is
  1030 is
  1071   "rbv9"
  1031   "rbv9"
  1116 print_theorems
  1076 print_theorems
  1117 
  1077 
  1118 abbreviation
  1078 abbreviation
  1119   "atoms xs \<equiv> {atom x| x. x \<in> xs}"
  1079   "atoms xs \<equiv> {atom x| x. x \<in> xs}"
  1120 
  1080 
       
  1081 local_setup {* define_raw_fv "Terms.ty" [[[[]], [[], []]]] *}
       
  1082 print_theorems 
       
  1083 
       
  1084 (*
       
  1085 doesn't work yet
       
  1086 local_setup {* define_raw_fv "Terms.tyS" [[[[], []]]] *}
       
  1087 print_theorems
       
  1088 *)
       
  1089 
  1121 primrec
  1090 primrec
  1122   rfv_ty
  1091   fv_tyS
  1123 where
       
  1124   "rfv_ty (Var n) = {atom n}"
       
  1125 | "rfv_ty (Fun T1 T2) = (rfv_ty T1) \<union> (rfv_ty T2)"
       
  1126 
       
  1127 primrec
       
  1128   rfv_tyS
       
  1129 where 
  1092 where 
  1130   "rfv_tyS (All xs T) = (rfv_ty T - atoms xs)"
  1093   "fv_tyS (All xs T) = (fv_ty T - atoms xs)"
  1131 
  1094 
  1132 inductive
  1095 inductive
  1133   alpha_tyS :: "tyS \<Rightarrow> tyS \<Rightarrow> bool" ("_ \<approx>tyS _" [100, 100] 100)
  1096   alpha_tyS :: "tyS \<Rightarrow> tyS \<Rightarrow> bool" ("_ \<approx>tyS _" [100, 100] 100)
  1134 where
  1097 where
  1135   a1: "\<exists>pi. ((atoms xs1, T1) \<approx>gen (op =) rfv_ty pi (atoms xs2, T2)) 
  1098   a1: "\<exists>pi. ((atoms xs1, T1) \<approx>gen (op =) fv_ty pi (atoms xs2, T2)) 
  1136         \<Longrightarrow> All xs1 T1 \<approx>tyS All xs2 T2"
  1099         \<Longrightarrow> All xs1 T1 \<approx>tyS All xs2 T2"
  1137 
  1100 
  1138 lemma
  1101 lemma
  1139   shows "All {a, b} (Fun (Var a) (Var b)) \<approx>tyS All {b, a} (Fun (Var a) (Var b))"
  1102   shows "All {a, b} (Fun (Var a) (Var b)) \<approx>tyS All {b, a} (Fun (Var a) (Var b))"
  1140   apply(rule a1)
  1103   apply(rule a1)