Quot/Nominal/Terms.thy
changeset 1193 a228acf2907e
parent 1190 d900d19931fa
child 1195 6f3b75135638
child 1196 4efbaba9d754
equal deleted inserted replaced
1192:6fd072d3acd2 1193:a228acf2907e
    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 bp2)"
    28 | "bv1 (BPr bp1 bp2) = (bv1 bp1) \<union> (bv1 bp2)"
    29 
    29 
    30 local_setup {* define_raw_fv "Terms.rtrm1"
    30 setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Terms.rtrm1", "Terms.bp"] *}
       
    31 
       
    32 local_setup {* snd o define_fv_alpha "Terms.rtrm1"
    31   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv1}, 0)], [], [(SOME @{term bv1}, 0)]]],
    33   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv1}, 0)], [], [(SOME @{term bv1}, 0)]]],
    32    [[], [[]], [[], []]]] *}
    34    [[], [[]], [[], []]]] *}
    33 print_theorems
    35 print_theorems
    34 
    36 notation
    35 setup {* snd o define_raw_perms ["rtrm1", "bp"] ["Terms.rtrm1", "Terms.bp"] *}
    37   alpha_rtrm1 ("_ \<approx>1 _" [100, 100] 100) and
    36 
    38   alpha_bp ("_ \<approx>1b _" [100, 100] 100)
    37 inductive
    39 thm alpha_rtrm1_alpha_bp.intros
    38   alpha1 :: "rtrm1 \<Rightarrow> rtrm1 \<Rightarrow> bool" ("_ \<approx>1 _" [100, 100] 100)
       
    39 where
       
    40   a1: "a = b \<Longrightarrow> (rVr1 a) \<approx>1 (rVr1 b)"
       
    41 | a2: "\<lbrakk>t1 \<approx>1 t2; s1 \<approx>1 s2\<rbrakk> \<Longrightarrow> rAp1 t1 s1 \<approx>1 rAp1 t2 s2"
       
    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"
       
    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"
       
    44 
    40 
    45 lemma alpha1_inj:
    41 lemma alpha1_inj:
    46 "(rVr1 a \<approx>1 rVr1 b) = (a = b)"
    42 "(rVr1 a \<approx>1 rVr1 b) = (a = b)"
    47 "(rAp1 t1 s1 \<approx>1 rAp1 t2 s2) = (t1 \<approx>1 t2 \<and> s1 \<approx>1 s2)"
    43 "(rAp1 t1 s1 \<approx>1 rAp1 t2 s2) = (t1 \<approx>1 t2 \<and> s1 \<approx>1 s2)"
    48 "(rLm1 aa t \<approx>1 rLm1 ab s) = (\<exists>pi. (({atom aa}, t) \<approx>gen alpha1 fv_rtrm1 pi ({atom ab}, s)))"
    44 "(rLm1 aa t \<approx>1 rLm1 ab s) = (\<exists>pi. (({atom aa}, t) \<approx>gen alpha_rtrm1 fv_rtrm1 pi ({atom ab}, s)))"
    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))))"
    45 "(rLt1 bp rtrm11 rtrm12 \<approx>1 rLt1 bpa rtrm11a rtrm12a) =
       
    46    ((\<exists>pi. (bv1 bp, bp) \<approx>gen alpha_bp fv_bp pi (bv1 bpa, bpa)) \<and> rtrm11 \<approx>1 rtrm11a \<and>
       
    47    (\<exists>pi. (bv1 bp, rtrm12) \<approx>gen alpha_rtrm1 fv_rtrm1 pi (bv1 bpa, rtrm12a)))"
       
    48 "alpha_bp BUnit BUnit"
       
    49 "(alpha_bp (BVr name) (BVr namea)) = (name = namea)"
       
    50 "(alpha_bp (BPr bp1 bp2) (BPr bp1a bp2a)) = (alpha_bp bp1 bp1a \<and> alpha_bp bp2 bp2a)"
    50 apply -
    51 apply -
    51 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    52 apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
    52 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    53 apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
    53 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    54 apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
    54 apply rule apply (erule alpha1.cases) apply (simp_all add: alpha1.intros)
    55 apply rule apply (erule alpha_rtrm1.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
    55 done
    56 apply rule apply (erule alpha_bp.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
    56 
    57 apply rule apply (erule alpha_bp.cases) apply (simp_all add: alpha_rtrm1_alpha_bp.intros)
    57 (* Shouyld we derive it? But bv is given by the user? *)
    58 done
       
    59 
       
    60 lemma alpha_bp_refl: "alpha_bp a a"
       
    61 apply induct
       
    62 apply (simp_all  add: alpha1_inj)
       
    63 done
       
    64 
       
    65 lemma alpha_bp_eq_eq: "alpha_bp a b = (a = b)"
       
    66 apply rule
       
    67 apply (induct a b rule: alpha_rtrm1_alpha_bp.inducts(2))
       
    68 apply (simp_all add: alpha_bp_refl)
       
    69 done
       
    70 
       
    71 lemma alpha_bp_eq: "alpha_bp = (op =)"
       
    72 apply (rule ext)+
       
    73 apply (rule alpha_bp_eq_eq)
       
    74 done
       
    75 
    58 lemma bv1_eqvt[eqvt]:
    76 lemma bv1_eqvt[eqvt]:
    59   shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
    77   shows "(pi \<bullet> bv1 x) = bv1 (pi \<bullet> x)"
    60   apply (induct x)
    78   apply (induct x)
    61 apply (simp_all add: empty_eqvt insert_eqvt atom_eqvt eqvts)
    79 apply (simp_all add: empty_eqvt insert_eqvt atom_eqvt eqvts)
    62 done
    80 done
    66     "(pi\<bullet>fv_bp b) = fv_bp (pi\<bullet>b)"
    84     "(pi\<bullet>fv_bp b) = fv_bp (pi\<bullet>b)"
    67   apply (induct t and b)
    85   apply (induct t and b)
    68   apply (simp_all add: insert_eqvt atom_eqvt empty_eqvt union_eqvt Diff_eqvt bv1_eqvt)
    86   apply (simp_all add: insert_eqvt atom_eqvt empty_eqvt union_eqvt Diff_eqvt bv1_eqvt)
    69   done
    87   done
    70 
    88 
    71 
       
    72 lemma alpha1_eqvt:
    89 lemma alpha1_eqvt:
    73   shows "t \<approx>1 s \<Longrightarrow> (pi \<bullet> t) \<approx>1 (pi \<bullet> s)"
    90   "t \<approx>1 s \<Longrightarrow> (pi \<bullet> t) \<approx>1 (pi \<bullet> s)"
    74   apply (induct t s rule: alpha1.inducts)
    91   "alpha_bp a b \<Longrightarrow> alpha_bp (pi \<bullet> a) (pi \<bullet> b)"
       
    92   apply (induct t s and a b rule: alpha_rtrm1_alpha_bp.inducts)
    75   apply (simp_all add:eqvts alpha1_inj)
    93   apply (simp_all add:eqvts alpha1_inj)
    76   apply (erule exE)
    94   apply (erule exE)
    77   apply (rule_tac x="pi \<bullet> pia" in exI)
    95   apply (rule_tac x="pi \<bullet> pia" in exI)
    78   apply (simp add: alpha_gen)
    96   apply (simp add: alpha_gen)
    79   apply(erule conjE)+
    97   apply(erule conjE)+
    83   apply(rule conjI)
   101   apply(rule conjI)
    84   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
   102   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
    85   apply(simp add: atom_eqvt Diff_eqvt fv_rtrm1_eqvt insert_eqvt empty_eqvt)
   103   apply(simp add: atom_eqvt Diff_eqvt fv_rtrm1_eqvt insert_eqvt empty_eqvt)
    86   apply(simp add: permute_eqvt[symmetric])
   104   apply(simp add: permute_eqvt[symmetric])
    87   apply (erule exE)
   105   apply (erule exE)
       
   106   apply (erule exE)
       
   107   apply (rule conjI)
    88   apply (rule_tac x="pi \<bullet> pia" in exI)
   108   apply (rule_tac x="pi \<bullet> pia" in exI)
    89   apply (simp add: alpha_gen)
   109   apply (simp add: alpha_gen)
    90   apply(erule conjE)+
   110   apply(erule conjE)+
    91   apply(rule conjI)
   111   apply(rule conjI)
    92   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
   112   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
    93   apply(simp add: fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
   113   apply(simp add: fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
    94   apply(rule conjI)
   114   apply(rule conjI)
    95   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
   115   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
    96   apply(simp add: atom_eqvt fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
   116   apply(simp add: atom_eqvt fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
    97   apply(simp add: permute_eqvt[symmetric])
   117   apply(simp add: permute_eqvt[symmetric])
    98   done
   118   apply (rule_tac x="pi \<bullet> piaa" in exI)
    99 
   119   apply (simp add: alpha_gen)
   100 lemma alpha1_equivp: "equivp alpha1" 
   120   apply(erule conjE)+
       
   121   apply(rule conjI)
       
   122   apply(rule_tac ?p1="- pi" in permute_eq_iff[THEN iffD1])
       
   123   apply(simp add: fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
       
   124   apply(rule conjI)
       
   125   apply(rule_tac ?p1="- pi" in fresh_star_permute_iff[THEN iffD1])
       
   126   apply(simp add: atom_eqvt fv_rtrm1_eqvt Diff_eqvt bv1_eqvt)
       
   127   apply(simp add: permute_eqvt[symmetric])
       
   128   done
       
   129 
       
   130 lemma alpha1_equivp: "equivp alpha_rtrm1" 
   101   sorry
   131   sorry
   102 
   132 
   103 quotient_type trm1 = rtrm1 / alpha1
   133 quotient_type trm1 = rtrm1 / alpha_rtrm1
   104   by (rule alpha1_equivp)
   134   by (rule alpha1_equivp)
   105 
   135 
   106 local_setup {*
   136 local_setup {*
   107 (fn ctxt => ctxt
   137 (fn ctxt => ctxt
   108  |> snd o (Quotient_Def.quotient_lift_const ("Vr1", @{term rVr1}))
   138  |> snd o (Quotient_Def.quotient_lift_const ("Vr1", @{term rVr1}))
   113 *}
   143 *}
   114 print_theorems
   144 print_theorems
   115 
   145 
   116 lemma alpha_rfv1:
   146 lemma alpha_rfv1:
   117   shows "t \<approx>1 s \<Longrightarrow> fv_rtrm1 t = fv_rtrm1 s"
   147   shows "t \<approx>1 s \<Longrightarrow> fv_rtrm1 t = fv_rtrm1 s"
   118   apply(induct rule: alpha1.induct)
   148   apply(induct rule: alpha_rtrm1_alpha_bp.inducts(1))
   119   apply(simp_all add: alpha_gen.simps)
   149   apply(simp_all add: alpha_gen.simps)
   120   sorry
   150   done
   121 
   151 
   122 lemma [quot_respect]:
   152 lemma [quot_respect]:
   123  "(op = ===> alpha1) rVr1 rVr1"
   153  "(op = ===> alpha_rtrm1) rVr1 rVr1"
   124  "(alpha1 ===> alpha1 ===> alpha1) rAp1 rAp1"
   154  "(alpha_rtrm1 ===> alpha_rtrm1 ===> alpha_rtrm1) rAp1 rAp1"
   125  "(op = ===> alpha1 ===> alpha1) rLm1 rLm1"
   155  "(op = ===> alpha_rtrm1 ===> alpha_rtrm1) rLm1 rLm1"
   126  "(op = ===> alpha1 ===> alpha1 ===> alpha1) rLt1 rLt1"
   156  "(op = ===> alpha_rtrm1 ===> alpha_rtrm1 ===> alpha_rtrm1) rLt1 rLt1"
   127 apply (auto simp add: alpha1_inj)
   157 apply (auto simp add: alpha1_inj)
   128 apply (rule_tac x="0" in exI)
   158 apply (rule_tac x="0" in exI)
   129 apply (simp add: fresh_star_def fresh_zero_perm alpha_rfv1 alpha_gen)
   159 apply (simp add: fresh_star_def fresh_zero_perm alpha_rfv1 alpha_gen)
   130 apply (rule_tac x="0" in exI)
   160 apply (rule_tac x="0" in exI)
       
   161 apply (simp add: alpha_gen fresh_star_def fresh_zero_perm alpha_rfv1 alpha_bp_eq)
       
   162 apply (rule_tac x="0" in exI)
   131 apply (simp add: alpha_gen fresh_star_def fresh_zero_perm alpha_rfv1)
   163 apply (simp add: alpha_gen fresh_star_def fresh_zero_perm alpha_rfv1)
   132 done
   164 done
   133 
   165 
   134 lemma [quot_respect]:
   166 lemma [quot_respect]:
   135   "(op = ===> alpha1 ===> alpha1) permute permute"
   167   "(op = ===> alpha_rtrm1 ===> alpha_rtrm1) permute permute"
   136   by (simp add: alpha1_eqvt)
   168   by (simp add: alpha1_eqvt)
   137 
   169 
   138 lemma [quot_respect]:
   170 lemma [quot_respect]:
   139   "(alpha1 ===> op =) fv_rtrm1 fv_rtrm1"
   171   "(alpha_rtrm1 ===> op =) fv_rtrm1 fv_rtrm1"
   140   by (simp add: alpha_rfv1)
   172   by (simp add: alpha_rfv1)
   141 
   173 
   142 lemmas trm1_bp_induct = rtrm1_bp.induct[quot_lifted]
   174 lemmas trm1_bp_induct = rtrm1_bp.induct[quot_lifted]
   143 lemmas trm1_bp_inducts = rtrm1_bp.inducts[quot_lifted]
   175 lemmas trm1_bp_inducts = rtrm1_bp.inducts[quot_lifted]
   144 
   176 
   211 done
   243 done
   212 
   244 
   213 lemma fv_eq_bv: "fv_bp bp = bv1 bp"
   245 lemma fv_eq_bv: "fv_bp bp = bv1 bp"
   214 apply(induct bp rule: trm1_bp_inducts(2))
   246 apply(induct bp rule: trm1_bp_inducts(2))
   215 apply(simp_all)
   247 apply(simp_all)
       
   248 done
       
   249 
       
   250 lemma helper: "{b. \<forall>pi. pi \<bullet> (a \<rightleftharpoons> b) \<bullet> bp \<noteq> bp} = {}"
       
   251 apply auto
       
   252 apply (rule_tac x="(x \<rightleftharpoons> a)" in exI)
       
   253 apply auto
   216 done
   254 done
   217 
   255 
   218 lemma supp_fv:
   256 lemma supp_fv:
   219   shows "supp t = fv_trm1 t"
   257   shows "supp t = fv_trm1 t"
   220 apply(induct t rule: trm1_bp_inducts(1))
   258 apply(induct t rule: trm1_bp_inducts(1))
   231 apply(simp add: alpha_gen.simps)
   269 apply(simp add: alpha_gen.simps)
   232 apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric])
   270 apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric])
   233 apply(subgoal_tac "supp (Lt1 bp rtrm11 rtrm12) = supp(rtrm11) \<union> supp (Abs (bv1 bp) rtrm12)")
   271 apply(subgoal_tac "supp (Lt1 bp rtrm11 rtrm12) = supp(rtrm11) \<union> supp (Abs (bv1 bp) rtrm12)")
   234 apply(simp add: supp_Abs fv_trm1 fv_eq_bv)
   272 apply(simp add: supp_Abs fv_trm1 fv_eq_bv)
   235 apply(simp (no_asm) add: supp_def)
   273 apply(simp (no_asm) add: supp_def)
   236 apply(simp add: alpha1_INJ)
   274 apply(simp add: alpha1_INJ alpha_bp_eq)
   237 apply(simp add: Abs_eq_iff)
   275 apply(simp add: Abs_eq_iff)
   238 apply(simp add: alpha_gen)
   276 apply(simp add: alpha_gen)
   239 apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt)
   277 apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt fv_eq_bv)
   240 apply(simp add: Collect_imp_eq Collect_neg_eq)
   278 apply(simp add: Collect_imp_eq Collect_neg_eq fresh_star_def helper)
   241 done
   279 done
   242 
   280 
   243 lemma trm1_supp:
   281 lemma trm1_supp:
   244   "supp (Vr1 x) = {atom x}"
   282   "supp (Vr1 x) = {atom x}"
   245   "supp (Ap1 t1 t2) = supp t1 \<union> supp t2"
   283   "supp (Ap1 t1 t2) = supp t1 \<union> supp t2"
   269 primrec 
   307 primrec 
   270   rbv2
   308   rbv2
   271 where
   309 where
   272   "rbv2 (rAs x t) = {atom x}"
   310   "rbv2 (rAs x t) = {atom x}"
   273 
   311 
   274 local_setup {* define_raw_fv "Terms.rtrm2"
   312 setup {* snd o define_raw_perms ["rtrm2", "rassign"] ["Terms.rtrm2", "Terms.rassign"] *}
       
   313 
       
   314 local_setup {* snd o define_fv_alpha "Terms.rtrm2"
   275   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv2}, 0)], [(SOME @{term rbv2}, 0)]]],
   315   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv2}, 0)], [(SOME @{term rbv2}, 0)]]],
   276    [[[], []]]] *}
   316    [[[], []]]] *}
   277 print_theorems
   317 print_theorems
   278 
   318 
   279 setup {* snd o define_raw_perms ["rtrm2", "rassign"] ["Terms.rtrm2", "Terms.rassign"] *}
   319 notation
   280 
   320   alpha_rtrm2 ("_ \<approx>2 _" [100, 100] 100) and
   281 inductive
   321   alpha_rassign ("_ \<approx>2b _" [100, 100] 100)
   282   alpha2 :: "rtrm2 \<Rightarrow> rtrm2 \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100)
   322 thm alpha_rtrm2_alpha_rassign.intros
       
   323 
       
   324 lemma alpha2_equivp:
       
   325   "equivp alpha_rtrm2"
       
   326   "equivp alpha_rassign"
       
   327   sorry
       
   328 
       
   329 quotient_type
       
   330   trm2 = rtrm2 / alpha_rtrm2
   283 and
   331 and
   284   alpha2a :: "rassign \<Rightarrow> rassign \<Rightarrow> bool" ("_ \<approx>2a _" [100, 100] 100)
   332   assign = rassign / alpha_rassign
   285 where
       
   286   a1: "a = b \<Longrightarrow> (rVr2 a) \<approx>2 (rVr2 b)"
       
   287 | a2: "\<lbrakk>t1 \<approx>2 t2; s1 \<approx>2 s2\<rbrakk> \<Longrightarrow> rAp2 t1 s1 \<approx>2 rAp2 t2 s2"
       
   288 | a3: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha2 fv_rtrm2 pi ({atom b}, s))) \<Longrightarrow> rLm2 a t \<approx>2 rLm2 b s"
       
   289 | a4: "\<lbrakk>\<exists>pi. ((rbv2 bt, t) \<approx>gen alpha2 fv_rtrm2 pi ((rbv2 bs), s));
       
   290         \<exists>pi. ((rbv2 bt, bt) \<approx>gen alpha2a fv_rassign pi (rbv2 bs, bs))\<rbrakk>
       
   291         \<Longrightarrow> rLt2 bt t \<approx>2 rLt2 bs s"
       
   292 | a5: "\<lbrakk>a = b; t \<approx>2 s\<rbrakk> \<Longrightarrow> rAs a t \<approx>2a rAs b s" (* This way rbv2 can be lifted *)
       
   293 
       
   294 lemma alpha2_equivp:
       
   295   "equivp alpha2"
       
   296   "equivp alpha2a"
       
   297   sorry
       
   298 
       
   299 quotient_type
       
   300   trm2 = rtrm2 / alpha2
       
   301 and
       
   302   assign = rassign / alpha2a
       
   303   by (auto intro: alpha2_equivp)
   333   by (auto intro: alpha2_equivp)
   304 
   334 
   305 local_setup {*
   335 local_setup {*
   306 (fn ctxt => ctxt
   336 (fn ctxt => ctxt
   307  |> snd o (Quotient_Def.quotient_lift_const ("Vr2", @{term rVr2}))
   337  |> snd o (Quotient_Def.quotient_lift_const ("Vr2", @{term rVr2}))
   331   bv3
   361   bv3
   332 where
   362 where
   333   "bv3 ANil = {}"
   363   "bv3 ANil = {}"
   334 | "bv3 (ACons x t as) = {atom x} \<union> (bv3 as)"
   364 | "bv3 (ACons x t as) = {atom x} \<union> (bv3 as)"
   335 
   365 
   336 local_setup {* define_raw_fv "Terms.trm3"
   366 setup {* snd o define_raw_perms ["rtrm3", "assigns"] ["Terms.trm3", "Terms.assigns"] *}
       
   367 
       
   368 local_setup {* snd o define_fv_alpha "Terms.trm3"
   337   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv3}, 0)], [(SOME @{term bv3}, 0)]]],
   369   [[[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term bv3}, 0)], [(SOME @{term bv3}, 0)]]],
   338    [[], [[], [], []]]] *}
   370    [[], [[], [], []]]] *}
   339 print_theorems
   371 print_theorems
   340 
   372 
   341 setup {* snd o define_raw_perms ["rtrm3", "assigns"] ["Terms.trm3", "Terms.assigns"] *}
   373 notation
   342 
   374   alpha_trm3 ("_ \<approx>3 _" [100, 100] 100) and
   343 inductive
   375   alpha_assigns ("_ \<approx>3a _" [100, 100] 100)
   344   alpha3 :: "trm3 \<Rightarrow> trm3 \<Rightarrow> bool" ("_ \<approx>3 _" [100, 100] 100)
   376 thm alpha_trm3_alpha_assigns.intros
       
   377 
       
   378 lemma alpha3_equivp:
       
   379   "equivp alpha_trm3"
       
   380   "equivp alpha_assigns"
       
   381   sorry
       
   382 
       
   383 quotient_type
       
   384   qtrm3 = trm3 / alpha_trm3
   345 and
   385 and
   346   alpha3a :: "assigns \<Rightarrow> assigns \<Rightarrow> bool" ("_ \<approx>3a _" [100, 100] 100)
   386   qassigns = assigns / alpha_assigns
   347 where
       
   348   a1: "a = b \<Longrightarrow> (Vr3 a) \<approx>3 (Vr3 b)"
       
   349 | a2: "\<lbrakk>t1 \<approx>3 t2; s1 \<approx>3 s2\<rbrakk> \<Longrightarrow> Ap3 t1 s1 \<approx>3 Ap3 t2 s2"
       
   350 | a3: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha3 fv_rtrm3 pi ({atom b}, s))) \<Longrightarrow> Lm3 a t \<approx>3 Lm3 b s"
       
   351 | a4: "\<lbrakk>\<exists>pi. ((bv3 bt, t) \<approx>gen alpha3 fv_trm3 pi ((bv3 bs), s));
       
   352         \<exists>pi. ((bv3 bt, bt) \<approx>gen alpha3a fv_assign pi (bv3 bs, bs))\<rbrakk>
       
   353         \<Longrightarrow> Lt3 bt t \<approx>3 Lt3 bs s"
       
   354 | a5: "ANil \<approx>3a ANil"
       
   355 | a6: "\<lbrakk>a = b; t \<approx>3 s; tt \<approx>3a st\<rbrakk> \<Longrightarrow> ACons a t tt \<approx>3a ACons b s st"
       
   356 
       
   357 lemma alpha3_equivp:
       
   358   "equivp alpha3"
       
   359   "equivp alpha3a"
       
   360   sorry
       
   361 
       
   362 quotient_type
       
   363   qtrm3 = trm3 / alpha3
       
   364 and
       
   365   qassigns = assigns / alpha3a
       
   366   by (auto intro: alpha3_equivp)
   387   by (auto intro: alpha3_equivp)
   367 
   388 
   368 
   389 
   369 section {*** lam with indirect list recursion ***}
   390 section {*** lam with indirect list recursion ***}
   370 
   391 
   373 | Ap4 "trm4" "trm4 list"
   394 | Ap4 "trm4" "trm4 list"
   374 | Lm4 "name" "trm4"  --"bind (name) in (trm)"
   395 | Lm4 "name" "trm4"  --"bind (name) in (trm)"
   375 print_theorems
   396 print_theorems
   376 
   397 
   377 thm trm4.recs
   398 thm trm4.recs
   378 
       
   379 local_setup {* define_raw_fv "Terms.trm4" [
       
   380   [[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]]], [[], [[], []]]  ] *}
       
   381 print_theorems
       
   382 
   399 
   383 (* there cannot be a clause for lists, as *)
   400 (* there cannot be a clause for lists, as *)
   384 (* permutations are  already defined in Nominal (also functions, options, and so on) *)
   401 (* permutations are  already defined in Nominal (also functions, options, and so on) *)
   385 setup {* snd o define_raw_perms ["trm4"] ["Terms.trm4"] *}
   402 setup {* snd o define_raw_perms ["trm4"] ["Terms.trm4"] *}
   386 
   403 
   393   done
   410   done
   394 
   411 
   395 thm permute_trm4_permute_trm4_list.simps
   412 thm permute_trm4_permute_trm4_list.simps
   396 thm permute_trm4_permute_trm4_list.simps[simplified repaired]
   413 thm permute_trm4_permute_trm4_list.simps[simplified repaired]
   397 
   414 
   398 inductive
   415 local_setup {* snd o define_fv_alpha "Terms.trm4" [
   399     alpha4 :: "trm4 \<Rightarrow> trm4 \<Rightarrow> bool" ("_ \<approx>4 _" [100, 100] 100)
   416   [[[]], [[], []], [[(NONE, 0)], [(NONE, 0)]]], [[], [[], []]]  ] *}
   400 and alpha4list :: "trm4 list \<Rightarrow> trm4 list \<Rightarrow> bool" ("_ \<approx>4list _" [100, 100] 100) 
   417 print_theorems
   401 where
   418 
   402   a1: "a = b \<Longrightarrow> (Vr4 a) \<approx>4 (Vr4 b)"
   419 notation
   403 | a2: "\<lbrakk>t1 \<approx>4 t2; s1 \<approx>4list s2\<rbrakk> \<Longrightarrow> Ap4 t1 s1 \<approx>4 Ap4 t2 s2"
   420   alpha_trm4 ("_ \<approx>4 _" [100, 100] 100) and
   404 | a3: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha4 fv_rtrm4 pi ({atom b}, s))) \<Longrightarrow> Lm4 a t \<approx>4 Lm4 b s"
   421   alpha_trm4_list ("_ \<approx>4l _" [100, 100] 100)
   405 | a5: "[] \<approx>4list []"
   422 thm alpha_trm4_alpha_trm4_list.intros
   406 | a6: "\<lbrakk>t \<approx>4 s; ts \<approx>4list ss\<rbrakk> \<Longrightarrow> (t#ts) \<approx>4list (s#ss)"
   423 
   407 
   424 lemma alpha4_equivp: "equivp alpha_trm4" sorry
   408 lemma alpha4_equivp: "equivp alpha4" sorry
   425 lemma alpha4list_equivp: "equivp alpha_trm4_list" sorry
   409 lemma alpha4list_equivp: "equivp alpha4list" sorry
       
   410 
   426 
   411 quotient_type 
   427 quotient_type 
   412   qtrm4 = trm4 / alpha4 and
   428   qtrm4 = trm4 / alpha_trm4 and
   413   qtrm4list = "trm4 list" / alpha4list
   429   qtrm4list = "trm4 list" / alpha_trm4_list
   414   by (simp_all add: alpha4_equivp alpha4list_equivp)
   430   by (simp_all add: alpha4_equivp alpha4list_equivp)
   415 
   431 
   416 
   432 
   417 datatype rtrm5 =
   433 datatype rtrm5 =
   418   rVr5 "name"
   434   rVr5 "name"
   427 where
   443 where
   428   "rbv5 rLnil = {}"
   444   "rbv5 rLnil = {}"
   429 | "rbv5 (rLcons n t ltl) = {atom n} \<union> (rbv5 ltl)"
   445 | "rbv5 (rLcons n t ltl) = {atom n} \<union> (rbv5 ltl)"
   430 
   446 
   431 
   447 
   432 local_setup {* define_raw_fv "Terms.rtrm5" [
   448 setup {* snd o define_raw_perms ["rtrm5", "rlts"] ["Terms.rtrm5", "Terms.rlts"] *}
       
   449 print_theorems
       
   450 
       
   451 local_setup {* snd o define_fv_alpha "Terms.rtrm5" [
   433   [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[], [], []]]  ] *}
   452   [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[], [], []]]  ] *}
   434 print_theorems
   453 print_theorems
   435 
   454 
   436 (* Alternate version with additional binding of name in rlts in rLcons *)
   455 (* Alternate version with additional binding of name in rlts in rLcons *)
   437 (*local_setup {* define_raw_fv "Terms.rtrm5" [
   456 (*local_setup {* snd o define_fv_alpha "Terms.rtrm5" [
   438   [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[(NONE,0)], [], [(NONE,0)]]]  ] *}
   457   [[[]], [[], []], [[(SOME @{term rbv5}, 0)], [(SOME @{term rbv5}, 0)]]], [[], [[(NONE,0)], [], [(NONE,0)]]]  ] *}
   439 print_theorems*)
   458 print_theorems*)
   440 
   459 
   441 
   460 notation
   442 setup {* snd o define_raw_perms ["rtrm5", "rlts"] ["Terms.rtrm5", "Terms.rlts"] *}
   461   alpha_rtrm5 ("_ \<approx>5 _" [100, 100] 100) and
   443 print_theorems
   462   alpha_rlts ("_ \<approx>l _" [100, 100] 100)
   444 
   463 thm alpha_rtrm5_alpha_rlts.intros
   445 inductive
       
   446   alpha5 :: "rtrm5 \<Rightarrow> rtrm5 \<Rightarrow> bool" ("_ \<approx>5 _" [100, 100] 100)
       
   447 and
       
   448   alphalts :: "rlts \<Rightarrow> rlts \<Rightarrow> bool" ("_ \<approx>l _" [100, 100] 100)
       
   449 where
       
   450   a1: "a = b \<Longrightarrow> (rVr5 a) \<approx>5 (rVr5 b)"
       
   451 | a2: "\<lbrakk>t1 \<approx>5 t2; s1 \<approx>5 s2\<rbrakk> \<Longrightarrow> rAp5 t1 s1 \<approx>5 rAp5 t2 s2"
       
   452 | a3: "\<lbrakk>\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha5 fv_rtrm5 pi (rbv5 l2, t2)); 
       
   453         \<exists>pi. ((rbv5 l1, l1) \<approx>gen alphalts fv_rlts pi (rbv5 l2, l2))\<rbrakk>
       
   454         \<Longrightarrow> rLt5 l1 t1 \<approx>5 rLt5 l2 t2"
       
   455 | a4: "rLnil \<approx>l rLnil"
       
   456 | a5: "ls1 \<approx>l ls2 \<Longrightarrow> t1 \<approx>5 t2 \<Longrightarrow> n1 = n2 \<Longrightarrow> rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2"
       
   457 
       
   458 print_theorems
       
   459 
   464 
   460 lemma alpha5_inj:
   465 lemma alpha5_inj:
   461   "((rVr5 a) \<approx>5 (rVr5 b)) = (a = b)"
   466   "((rVr5 a) \<approx>5 (rVr5 b)) = (a = b)"
   462   "(rAp5 t1 s1 \<approx>5 rAp5 t2 s2) = (t1 \<approx>5 t2 \<and> s1 \<approx>5 s2)"
   467   "(rAp5 t1 s1 \<approx>5 rAp5 t2 s2) = (t1 \<approx>5 t2 \<and> s1 \<approx>5 s2)"
   463   "(rLt5 l1 t1 \<approx>5 rLt5 l2 t2) = ((\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha5 fv_rtrm5 pi (rbv5 l2, t2))) \<and>
   468   "(rLt5 l1 t1 \<approx>5 rLt5 l2 t2) = ((\<exists>pi. ((rbv5 l1, t1) \<approx>gen alpha_rtrm5 fv_rtrm5 pi (rbv5 l2, t2))) \<and>
   464          (\<exists>pi. ((rbv5 l1, l1) \<approx>gen alphalts fv_rlts pi (rbv5 l2, l2))))"
   469          (\<exists>pi. ((rbv5 l1, l1) \<approx>gen alpha_rlts fv_rlts pi (rbv5 l2, l2))))"
   465   "rLnil \<approx>l rLnil"
   470   "rLnil \<approx>l rLnil"
   466   "(rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2) = (n1 = n2 \<and> ls1 \<approx>l ls2 \<and> t1 \<approx>5 t2)"
   471   "(rLcons n1 t1 ls1 \<approx>l rLcons n2 t2 ls2) = (n1 = n2 \<and> ls1 \<approx>l ls2 \<and> t1 \<approx>5 t2)"
   467 apply -
   472 apply -
   468 apply (simp_all add: alpha5_alphalts.intros)
   473 apply (simp_all add: alpha_rtrm5_alpha_rlts.intros)
   469 apply rule
   474 apply rule
   470 apply (erule alpha5.cases)
   475 apply (erule alpha_rtrm5.cases)
   471 apply (simp_all add: alpha5_alphalts.intros)
   476 apply (simp_all add: alpha_rtrm5_alpha_rlts.intros)
   472 apply rule
   477 apply rule
   473 apply (erule alpha5.cases)
   478 apply (erule alpha_rtrm5.cases)
   474 apply (simp_all add: alpha5_alphalts.intros)
   479 apply (simp_all add: alpha_rtrm5_alpha_rlts.intros)
   475 apply rule
   480 apply rule
   476 apply (erule alpha5.cases)
   481 apply (erule alpha_rtrm5.cases)
   477 apply (simp_all add: alpha5_alphalts.intros)
   482 apply (simp_all add: alpha_rtrm5_alpha_rlts.intros)
   478 apply rule
   483 apply rule
   479 apply (erule alphalts.cases)
   484 apply (erule alpha_rlts.cases)
   480 apply (simp_all add: alpha5_alphalts.intros)
   485 apply (simp_all add: alpha_rtrm5_alpha_rlts.intros)
   481 done
   486 done
   482 
   487 
   483 lemma alpha5_equivps:
   488 lemma alpha5_equivps:
   484   shows "equivp alpha5"
   489   shows "equivp alpha_rtrm5"
   485   and   "equivp alphalts"
   490   and   "equivp alpha_rlts"
   486 sorry
   491 sorry
   487 
   492 
   488 quotient_type
   493 quotient_type
   489   trm5 = rtrm5 / alpha5
   494   trm5 = rtrm5 / alpha_rtrm5
   490 and
   495 and
   491   lts = rlts / alphalts
   496   lts = rlts / alpha_rlts
   492   by (auto intro: alpha5_equivps)
   497   by (auto intro: alpha5_equivps)
   493 
   498 
   494 local_setup {*
   499 local_setup {*
   495 (fn ctxt => ctxt
   500 (fn ctxt => ctxt
   496  |> snd o (Quotient_Def.quotient_lift_const ("Vr5", @{term rVr5}))
   501  |> snd o (Quotient_Def.quotient_lift_const ("Vr5", @{term rVr5}))
   517 sorry
   522 sorry
   518 
   523 
   519 lemma alpha5_eqvt:
   524 lemma alpha5_eqvt:
   520   "xa \<approx>5 y \<Longrightarrow> (x \<bullet> xa) \<approx>5 (x \<bullet> y)"
   525   "xa \<approx>5 y \<Longrightarrow> (x \<bullet> xa) \<approx>5 (x \<bullet> y)"
   521   "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)"
   526   "xb \<approx>l ya \<Longrightarrow> (x \<bullet> xb) \<approx>l (x \<bullet> ya)"
   522   apply(induct rule: alpha5_alphalts.inducts)
   527   apply(induct rule: alpha_rtrm5_alpha_rlts.inducts)
   523   apply (simp_all add: alpha5_inj)
   528   apply (simp_all add: alpha5_inj)
   524   apply (erule exE)+
   529   apply (erule exE)+
   525   apply(unfold alpha_gen)
   530   apply(unfold alpha_gen)
   526   apply (erule conjE)+
   531   apply (erule conjE)+
   527   apply (rule conjI)
   532   apply (rule conjI)
   528   apply (rule_tac x="x \<bullet> pi" in exI)
   533   apply (rule_tac x="x \<bullet> pia" in exI)
   529   apply (rule conjI)
   534   apply (rule conjI)
   530   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   535   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   531   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
   536   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
   532   apply(rule conjI)
   537   apply(rule conjI)
   533   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   538   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   534   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
   539   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rtrm5_eqvt)
   535   apply (subst permute_eqvt[symmetric])
   540   apply (subst permute_eqvt[symmetric])
   536   apply (simp)
   541   apply (simp)
   537   apply (rule_tac x="x \<bullet> pia" in exI)
   542   apply (rule_tac x="x \<bullet> pi" in exI)
   538   apply (rule conjI)
   543   apply (rule conjI)
   539   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   544   apply(rule_tac ?p1="- x" in permute_eq_iff[THEN iffD1])
   540   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rlts_eqvt)
   545   apply(simp add: atom_eqvt Diff_eqvt insert_eqvt set_eqvt empty_eqvt rbv5_eqvt fv_rlts_eqvt)
   541   apply(rule conjI)
   546   apply(rule conjI)
   542   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   547   apply(rule_tac ?p1="- x" in fresh_star_permute_iff[THEN iffD1])
   546   done
   551   done
   547 
   552 
   548 lemma alpha5_rfv:
   553 lemma alpha5_rfv:
   549   "(t \<approx>5 s \<Longrightarrow> fv_rtrm5 t = fv_rtrm5 s)"
   554   "(t \<approx>5 s \<Longrightarrow> fv_rtrm5 t = fv_rtrm5 s)"
   550   "(l \<approx>l m \<Longrightarrow> fv_rlts l = fv_rlts m)"
   555   "(l \<approx>l m \<Longrightarrow> fv_rlts l = fv_rlts m)"
   551   apply(induct rule: alpha5_alphalts.inducts)
   556   apply(induct rule: alpha_rtrm5_alpha_rlts.inducts)
   552   apply(simp_all add: alpha_gen)
   557   apply(simp_all add: alpha_gen)
   553   done
   558   done
   554 
   559 
   555 lemma bv_list_rsp:
   560 lemma bv_list_rsp:
   556   shows "x \<approx>l y \<Longrightarrow> rbv5 x = rbv5 y"
   561   shows "x \<approx>l y \<Longrightarrow> rbv5 x = rbv5 y"
   557   apply(induct rule: alpha5_alphalts.inducts(2))
   562   apply(induct rule: alpha_rtrm5_alpha_rlts.inducts(2))
   558   apply(simp_all)
   563   apply(simp_all)
   559   done
   564   done
   560 
   565 
   561 lemma [quot_respect]:
   566 lemma [quot_respect]:
   562   "(alphalts ===> op =) fv_rlts fv_rlts"
   567   "(alpha_rlts ===> op =) fv_rlts fv_rlts"
   563   "(alpha5 ===> op =) fv_rtrm5 fv_rtrm5"
   568   "(alpha_rtrm5 ===> op =) fv_rtrm5 fv_rtrm5"
   564   "(alphalts ===> op =) rbv5 rbv5"
   569   "(alpha_rlts ===> op =) rbv5 rbv5"
   565   "(op = ===> alpha5) rVr5 rVr5"
   570   "(op = ===> alpha_rtrm5) rVr5 rVr5"
   566   "(alpha5 ===> alpha5 ===> alpha5) rAp5 rAp5"
   571   "(alpha_rtrm5 ===> alpha_rtrm5 ===> alpha_rtrm5) rAp5 rAp5"
   567   "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5"
   572   "(alpha_rlts ===> alpha_rtrm5 ===> alpha_rtrm5) rLt5 rLt5"
   568   "(alphalts ===> alpha5 ===> alpha5) rLt5 rLt5"
   573   "(alpha_rlts ===> alpha_rtrm5 ===> alpha_rtrm5) rLt5 rLt5"
   569   "(op = ===> alpha5 ===> alphalts ===> alphalts) rLcons rLcons"
   574   "(op = ===> alpha_rtrm5 ===> alpha_rlts ===> alpha_rlts) rLcons rLcons"
   570   "(op = ===> alpha5 ===> alpha5) permute permute"
   575   "(op = ===> alpha_rtrm5 ===> alpha_rtrm5) permute permute"
   571   "(op = ===> alphalts ===> alphalts) permute permute"
   576   "(op = ===> alpha_rlts ===> alpha_rlts) permute permute"
   572   apply (simp_all add: alpha5_inj alpha5_rfv alpha5_eqvt bv_list_rsp)
   577   apply (simp_all add: alpha5_inj alpha5_rfv alpha5_eqvt bv_list_rsp)
   573   apply (clarify) apply (rule conjI)
   578   apply (clarify) apply (rule conjI)
   574   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   579   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   575   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   580   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   576   apply (clarify) apply (rule conjI)
   581   apply (clarify) apply (rule conjI)
   577   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   582   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   578   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   583   apply (rule_tac x="0" in exI) apply (simp add: fresh_star_def fresh_zero_perm alpha_gen alpha5_rfv)
   579   done
   584   done
   580 
   585 
   581 lemma
   586 lemma
   582   shows "(alphalts ===> op =) rbv5 rbv5"
   587   shows "(alpha_rlts ===> op =) rbv5 rbv5"
   583   by (simp add: bv_list_rsp)
   588   by (simp add: bv_list_rsp)
   584 
   589 
   585 lemmas trm5_lts_inducts = rtrm5_rlts.inducts[quot_lifted]
   590 lemmas trm5_lts_inducts = rtrm5_rlts.inducts[quot_lifted]
   586 
   591 
   587 instantiation trm5 and lts :: pt
   592 instantiation trm5 and lts :: pt
   666 done
   671 done
   667 
   672 
   668 lemma distinct_helper:
   673 lemma distinct_helper:
   669   shows "\<not>(rVr5 x \<approx>5 rAp5 y z)"
   674   shows "\<not>(rVr5 x \<approx>5 rAp5 y z)"
   670   apply auto
   675   apply auto
   671   apply (erule alpha5.cases)
   676   apply (erule alpha_rtrm5.cases)
   672   apply (simp_all only: rtrm5.distinct)
   677   apply (simp_all only: rtrm5.distinct)
   673   done
   678   done
   674 
   679 
   675 lemma distinct_helper2:
   680 lemma distinct_helper2:
   676   shows "(Vr5 x) \<noteq> (Ap5 y z)"
   681   shows "(Vr5 x) \<noteq> (Ap5 y z)"
   699 where
   704 where
   700   "rbv6 (rVr6 n) = {}"
   705   "rbv6 (rVr6 n) = {}"
   701 | "rbv6 (rLm6 n t) = {atom n} \<union> rbv6 t"
   706 | "rbv6 (rLm6 n t) = {atom n} \<union> rbv6 t"
   702 | "rbv6 (rLt6 l r) = rbv6 l \<union> rbv6 r"
   707 | "rbv6 (rLt6 l r) = rbv6 l \<union> rbv6 r"
   703 
   708 
   704 local_setup {* define_raw_fv "Terms.rtrm6" [
   709 setup {* snd o define_raw_perms ["rtrm6"] ["Terms.rtrm6"] *}
       
   710 print_theorems
       
   711 
       
   712 local_setup {* snd o define_fv_alpha "Terms.rtrm6" [
   705   [[[]], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv6}, 0)], [(SOME @{term rbv6}, 0)]]]] *}
   713   [[[]], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv6}, 0)], [(SOME @{term rbv6}, 0)]]]] *}
   706 print_theorems 
   714 notation alpha_rtrm6 ("_ \<approx>6a _" [100, 100] 100)
   707 
   715 (* HERE THE RULES DIFFER *)
   708 setup {* snd o define_raw_perms ["rtrm6"] ["Terms.rtrm6"] *}
   716 thm alpha_rtrm6.intros
   709 print_theorems
       
   710 
   717 
   711 inductive
   718 inductive
   712   alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [100, 100] 100)
   719   alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [100, 100] 100)
   713 where
   720 where
   714   a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
   721   a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
   839 where
   846 where
   840   "rbv7 (rVr7 n) = {atom n}"
   847   "rbv7 (rVr7 n) = {atom n}"
   841 | "rbv7 (rLm7 n t) = rbv7 t - {atom n}"
   848 | "rbv7 (rLm7 n t) = rbv7 t - {atom n}"
   842 | "rbv7 (rLt7 l r) = rbv7 l \<union> rbv7 r"
   849 | "rbv7 (rLt7 l r) = rbv7 l \<union> rbv7 r"
   843 
   850 
   844 local_setup {* define_raw_fv "Terms.rtrm7" [
   851 setup {* snd o define_raw_perms ["rtrm7"] ["Terms.rtrm7"] *}
       
   852 print_theorems
       
   853 
       
   854 local_setup {* snd o define_fv_alpha "Terms.rtrm7" [
   845   [[[]], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv7}, 0)], [(SOME @{term rbv7}, 0)]]]] *}
   855   [[[]], [[(NONE, 0)], [(NONE, 0)]], [[(SOME @{term rbv7}, 0)], [(SOME @{term rbv7}, 0)]]]] *}
   846 print_theorems 
   856 notation
   847 
   857   alpha_rtrm7 ("_ \<approx>7a _" [100, 100] 100)
   848 setup {* snd o define_raw_perms ["rtrm7"] ["Terms.rtrm7"] *}
   858 (* HERE THE RULES DIFFER *)
   849 print_theorems
   859 thm alpha_rtrm7.intros
   850 
   860 
   851 inductive
   861 inductive
   852   alpha7 :: "rtrm7 \<Rightarrow> rtrm7 \<Rightarrow> bool" ("_ \<approx>7 _" [100, 100] 100)
   862   alpha7 :: "rtrm7 \<Rightarrow> rtrm7 \<Rightarrow> bool" ("_ \<approx>7 _" [100, 100] 100)
   853 where
   863 where
   854   a1: "a = b \<Longrightarrow> (rVr7 a) \<approx>7 (rVr7 b)"
   864   a1: "a = b \<Longrightarrow> (rVr7 a) \<approx>7 (rVr7 b)"
   882   rbv8
   892   rbv8
   883 where
   893 where
   884   "rbv8 (Bar0 x) = {}"
   894   "rbv8 (Bar0 x) = {}"
   885 | "rbv8 (Bar1 v x b) = {atom v}"
   895 | "rbv8 (Bar1 v x b) = {atom v}"
   886 
   896 
   887 local_setup {* define_raw_fv "Terms.rfoo8" [
   897 setup {* snd o define_raw_perms ["rfoo8", "rbar8"] ["Terms.rfoo8", "Terms.rbar8"] *}
       
   898 print_theorems
       
   899 
       
   900 local_setup {* snd o define_fv_alpha "Terms.rfoo8" [
   888   [[[]], [[(SOME @{term rbv8}, 0)], [(SOME @{term rbv8}, 0)]]], [[[]], [[], [(NONE, 1)], [(NONE, 1)]]]] *}
   901   [[[]], [[(SOME @{term rbv8}, 0)], [(SOME @{term rbv8}, 0)]]], [[[]], [[], [(NONE, 1)], [(NONE, 1)]]]] *}
   889 print_theorems 
   902 notation
   890 
   903   alpha_rfoo8 ("_ \<approx>f' _" [100, 100] 100) and
   891 setup {* snd o define_raw_perms ["rfoo8", "rbar8"] ["Terms.rfoo8", "Terms.rbar8"] *}
   904   alpha_rbar8 ("_ \<approx>b' _" [100, 100] 100)
   892 print_theorems
   905 (* HERE THE RULE DIFFERS *)
       
   906 thm alpha_rfoo8_alpha_rbar8.intros
       
   907 
   893 
   908 
   894 inductive
   909 inductive
   895   alpha8f :: "rfoo8 \<Rightarrow> rfoo8 \<Rightarrow> bool" ("_ \<approx>f _" [100, 100] 100)
   910   alpha8f :: "rfoo8 \<Rightarrow> rfoo8 \<Rightarrow> bool" ("_ \<approx>f _" [100, 100] 100)
   896 and
   911 and
   897   alpha8b :: "rbar8 \<Rightarrow> rbar8 \<Rightarrow> bool" ("_ \<approx>b _" [100, 100] 100)
   912   alpha8b :: "rbar8 \<Rightarrow> rbar8 \<Rightarrow> bool" ("_ \<approx>b _" [100, 100] 100)
   939   rbv9
   954   rbv9
   940 where
   955 where
   941   "rbv9 (Var9 x) = {}"
   956   "rbv9 (Var9 x) = {}"
   942 | "rbv9 (Lam9 x b) = {atom x}"
   957 | "rbv9 (Lam9 x b) = {atom x}"
   943 
   958 
   944 local_setup {* define_raw_fv "Terms.rlam9" [
   959 setup {* snd o define_raw_perms ["rlam9", "rbla9"] ["Terms.rlam9", "Terms.rbla9"] *}
       
   960 print_theorems
       
   961 
       
   962 local_setup {* snd o define_fv_alpha "Terms.rlam9" [
   945   [[[]], [[(NONE, 0)], [(NONE, 0)]]], [[[(SOME @{term rbv9}, 0)], [(SOME @{term rbv9}, 0)]]]] *}
   963   [[[]], [[(NONE, 0)], [(NONE, 0)]]], [[[(SOME @{term rbv9}, 0)], [(SOME @{term rbv9}, 0)]]]] *}
   946 print_theorems
   964 notation
   947 
   965   alpha_rlam9 ("_ \<approx>9l' _" [100, 100] 100) and
   948 setup {* snd o define_raw_perms ["rlam9", "rbla9"] ["Terms.rlam9", "Terms.rbla9"] *}
   966   alpha_rbla9 ("_ \<approx>9b' _" [100, 100] 100)
   949 print_theorems
   967 (* HERE THE RULES DIFFER *)
       
   968 thm alpha_rlam9_alpha_rbla9.intros
       
   969 
   950 
   970 
   951 inductive
   971 inductive
   952   alpha9l :: "rlam9 \<Rightarrow> rlam9 \<Rightarrow> bool" ("_ \<approx>9l _" [100, 100] 100)
   972   alpha9l :: "rlam9 \<Rightarrow> rlam9 \<Rightarrow> bool" ("_ \<approx>9l _" [100, 100] 100)
   953 and
   973 and
   954   alpha9b :: "rbla9 \<Rightarrow> rbla9 \<Rightarrow> bool" ("_ \<approx>9b _" [100, 100] 100)
   974   alpha9b :: "rbla9 \<Rightarrow> rbla9 \<Rightarrow> bool" ("_ \<approx>9b _" [100, 100] 100)