Nominal/Ex/AuxNoFCB.thy
author Cezary Kaliszyk <cezarykaliszyk@gmail.com>
Thu, 29 Mar 2012 10:37:09 +0200
changeset 3141 319964ecf1f6
parent 3140 5179ff4806c5
child 3142 4d01d1056e22
permissions -rw-r--r--
Change definition of Aux to include alpha-convertibility for non-closed terms.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     1
theory Lambda imports "../Nominal2" begin
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     2
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     3
atom_decl name
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     4
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     5
nominal_datatype lam =
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     6
  Var "name"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     7
| App "lam" "lam"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     8
| Lam x::"name" l::"lam"  binds x in l ("Lam [_]. _" [100, 100] 100)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
     9
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    10
nominal_primrec lam2_rec where
3141
319964ecf1f6 Change definition of Aux to include alpha-convertibility for non-closed terms.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3140
diff changeset
    11
  "lam2_rec faa fll xs (Var n) (Var m) = (n = m \<or> (n, m) \<in> set xs)"
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    12
| "lam2_rec faa fll xs (Var n) (App l r) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    13
| "lam2_rec faa fll xs (Var n) (Lam [x]. t) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    14
| "lam2_rec faa fll xs (App l r) (Var n) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    15
| "lam2_rec faa fll xs (App l1 r1) (App l2 r2) = faa l1 r1 l2 r2"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    16
| "lam2_rec faa fll xs (App l r) (Lam [x]. t) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    17
| "lam2_rec faa fll xs (Lam [x]. t) (Var n) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    18
| "lam2_rec faa fll xs (Lam [x]. t) (App l1 r1) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    19
| "(atom x \<sharp> (xs, Lam [y]. s) \<and> atom y \<sharp> (x, xs, Lam [x]. t) \<and>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    20
     (\<forall>x' y' t' s'. atom x' \<sharp> (xs, Lam [y']. s') \<longrightarrow> atom y' \<sharp> (x', xs, Lam [x']. t') \<longrightarrow> Lam [x]. t = Lam [x']. t' \<longrightarrow> Lam [y]. s = Lam [y']. s'
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    21
        \<longrightarrow> fll x t y s = fll x' t' y' s')) \<Longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    22
     lam2_rec faa fll xs (Lam [x]. t) (Lam [y]. s) = fll x t y s"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    23
| "(atom x \<sharp> (xs, Lam [y]. s) \<and> atom y \<sharp> (x, xs, Lam [x]. t) \<and>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    24
     \<not>(\<forall>x' y' t' s'. atom x' \<sharp> (xs, Lam [y']. s') \<longrightarrow> atom y' \<sharp> (x', xs, Lam [x']. t') \<longrightarrow> Lam [x]. t = Lam [x']. t' \<longrightarrow> Lam [y]. s = Lam [y']. s'
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    25
        \<longrightarrow> fll x t y s = fll x' t' y' s')) \<Longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    26
     lam2_rec faa fll xs (Lam [x]. t) (Lam [y]. s) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    27
  apply (simp add: eqvt_def lam2_rec_graph_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    28
  apply (rule, perm_simp, rule, rule)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    29
  defer
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    30
  apply (simp_all)[53]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    31
  apply clarify
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    32
  apply metis
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    33
  apply simp
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    34
  apply (case_tac x)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    35
  apply (rule_tac y="d" and c="(c, e)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    36
  apply (rule_tac y="e" and c="(c, d)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    37
  apply simp_all[3]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    38
  apply (metis, metis, metis)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    39
  apply (rule_tac y="e" and c="(c, d)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    40
  apply simp_all[3]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    41
  apply (metis, metis, metis)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    42
  apply (rule_tac y="e" and c="(name, c, d)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    43
  apply simp_all[2]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    44
  apply (metis, metis)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    45
  apply (thin_tac "\<And>faa fll xs n m. x = (faa, fll, xs, Var n, Var m) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    46
  apply (thin_tac "\<And>faa fll xs n l r. x = (faa, fll, xs, Var n, App l r) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    47
  apply (thin_tac "\<And>faa fll xs n xa t. x = (faa, fll, xs, Var n, Lam [xa]. t) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    48
  apply (thin_tac "\<And>faa fll xs l1 r1 l2 r2. x = (faa, fll, xs, App l1 r1, App l2 r2) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    49
  apply (thin_tac "\<And>faa fll xs l r n. x = (faa, fll, xs, App l r, Var n) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    50
  apply (thin_tac "\<And>faa fll xs l r xa t. x = (faa, fll, xs, App l r, Lam [xa]. t) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    51
  apply (thin_tac "\<And>faa fll xs xa t n. x = (faa, fll, xs, Lam [xa]. t, Var n) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    52
  apply (thin_tac "\<And>faa fll xs xa t l1 r1. x = (faa, fll, xs, Lam [xa]. t, App l1 r1) \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    53
  apply (drule_tac x="name" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    54
  apply (drule_tac x="c" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    55
  apply (drule_tac x="namea" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    56
  apply (drule_tac x="lama" in meta_spec)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    57
  apply (drule_tac x="lama" in meta_spec)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    58
  apply (drule_tac x="lam" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    59
  apply (drule_tac x="b" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    60
  apply (drule_tac x="a" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    61
  apply (case_tac "
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    62
(\<forall>x' y' t' s'.
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    63
             atom x' \<sharp> (c, Lam [y']. s') \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    64
             atom y' \<sharp> (x', c, Lam [x']. t') \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    65
             Lam [name]. lam = Lam [x']. t' \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    66
             Lam [namea]. lama = Lam [y']. s' \<longrightarrow> b name lam namea lama = b x' t' y' s')
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    67
  ")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    68
  apply clarify
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    69
  apply (simp add: fresh_star_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    70
  apply (thin_tac "\<lbrakk>atom name \<sharp> (c, Lam [namea]. lama) \<and>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    71
         atom namea \<sharp> (name, c, Lam [name]. lam) \<and>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    72
         (\<forall>x' y' t' s'.
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    73
             atom x' \<sharp> (c, Lam [y']. s') \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    74
             atom y' \<sharp> (x', c, Lam [x']. t') \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    75
             Lam [name]. lam = Lam [x']. t' \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    76
             Lam [namea]. lama = Lam [y']. s' \<longrightarrow> b name lam namea lama = b x' t' y' s');
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    77
         x = (a, b, c, Lam [name]. lam, Lam [namea]. lama)\<rbrakk>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    78
        \<Longrightarrow> P")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    79
  apply (simp add: fresh_star_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    80
  done
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    81
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    82
termination (eqvt) by lexicographic_order
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    83
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    84
lemma lam_rec2_cong[fundef_cong]:
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    85
  "(\<And>s1 s2 s3 s4. l = App s1 s2 \<Longrightarrow> l2 = App s3 s4  \<Longrightarrow> faa s1 s2 s3 s4 = faa' s1 s2 s3 s4) \<Longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    86
   (\<And>n t n' t'. l = Lam [n]. t \<Longrightarrow> l2 = Lam [n']. t' \<Longrightarrow> fll n t n' t' = fll' n t n' t') \<Longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    87
  lam2_rec faa fll xs l l2 = lam2_rec faa' fll' xs l l2"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    88
  apply (rule_tac y="l" and c="(xs, l2)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    89
  apply (rule_tac y="l2" and c="(xs, l)" in lam.strong_exhaust) apply auto[3]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    90
  apply (rule_tac y="l2" and c="(xs, l)" in lam.strong_exhaust) apply auto[3]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    91
  apply (rule_tac y="l2" and c="(name, xs, l)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    92
  apply auto[2]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    93
  apply clarify
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    94
  apply (case_tac "(\<forall>x' y' t' s'.
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    95
              atom x' \<sharp> (xs, Lam [y']. s') \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    96
              atom y' \<sharp> (x', xs, Lam [x']. t') \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    97
              Lam [name]. lam = Lam [x']. t' \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    98
              Lam [namea]. lama = Lam [y']. s' \<longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    99
              fll name lam namea lama = fll x' t' y' s')")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   100
  apply (subst lam2_rec.simps) apply (simp add: fresh_star_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   101
  apply (subst lam2_rec.simps) apply (simp add: fresh_star_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   102
  using Abs1_eq_iff lam.eq_iff apply metis
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   103
  apply (subst lam2_rec.simps(10)) apply (simp add: fresh_star_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   104
  apply (subst lam2_rec.simps(10)) apply (simp add: fresh_star_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   105
  apply rule
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   106
  done
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   107
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   108
nominal_primrec aux :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   109
  where
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   110
[simp del]: "aux l r xs = lam2_rec
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   111
  (%t1 t2 t3 t4. (aux t1 t3 xs) \<and> (aux t2 t4 xs))
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   112
  (%x t y s. aux t s ((x, y) # xs)) xs l r"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   113
  unfolding eqvt_def aux_graph_def
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   114
  apply (rule, perm_simp, rule, rule)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   115
  by pat_completeness auto
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   116
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   117
termination (eqvt)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   118
  by (relation "measure (\<lambda>(l, r, xs). size l + size r)") simp_all
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   119
3141
319964ecf1f6 Change definition of Aux to include alpha-convertibility for non-closed terms.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3140
diff changeset
   120
lemma aux_simps[simp]:
319964ecf1f6 Change definition of Aux to include alpha-convertibility for non-closed terms.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3140
diff changeset
   121
  "aux (Var x) (Var y) xs = (x = y \<or> (x, y) \<in> set xs)"
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   122
  "aux (App t1 t2) (App s1 s2) xs = (aux t1 s1 xs \<and> aux t2 s2 xs)"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   123
  "aux (Var x) (App t1 t2) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   124
  "aux (Var x) (Lam [y].t) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   125
  "aux (App t1 t2) (Var x) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   126
  "aux (App t1 t2) (Lam [x].t) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   127
  "aux (Lam [x].t) (Var y) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   128
  "aux (Lam [x].t) (App t1 t2) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   129
  "\<lbrakk>atom x \<sharp> (s, xs); atom y \<sharp> (x, t, xs)\<rbrakk> \<Longrightarrow> aux (Lam [x].t) (Lam [y].s) xs = aux t s ((x, y) # xs)"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   130
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   131
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   132
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   133
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   134
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   135
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   136
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   137
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   138
  apply (subst aux.simps)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   139
  apply (subst lam2_rec.simps)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   140
  prefer 2 apply rule
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   141
  apply (rule, simp add: lam.fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   142
  apply (rule, simp add: lam.fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   143
  apply (intro allI impI)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   144
  apply (rule_tac x="(x, x', y, y', t, t', s, s', xs)" and ?'a="name" in obtain_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   145
  apply (rule_tac x="(a, x, x', y, y', t, t', s, s', xs)" and ?'a="name" in obtain_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   146
  apply (rule_tac s="aux ((atom x \<rightleftharpoons> atom a) \<bullet> t) s ((a, y) # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   147
  apply (rule_tac s="(atom x \<rightleftharpoons> atom a) \<bullet> aux t s ((x, y) # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   148
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   149
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   150
  apply (simp add: lam.fresh fresh_at_base fresh_Pair_elim)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   151
  apply (rename_tac b)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   152
  apply (rule_tac s="aux ((atom x \<rightleftharpoons> atom a) \<bullet> t) ((atom y \<rightleftharpoons> atom b) \<bullet> s) ((a, b) # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   153
  apply (rule_tac s="(atom y \<rightleftharpoons> atom b) \<bullet> aux ((atom x \<rightleftharpoons> atom a) \<bullet> t) s ((a, y) # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   154
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   155
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   156
  apply (simp add: lam.fresh fresh_at_base fresh_Pair_elim)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   157
  apply (subst permute_eqvt)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   158
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   159
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   160
  apply (rule_tac s="aux ((atom x' \<rightleftharpoons> atom a) \<bullet> t') s' ((a, y') # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   161
  apply (rule_tac s="(atom x' \<rightleftharpoons> atom a) \<bullet> aux t' s' ((x', y') # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   162
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   163
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   164
  apply (simp add: lam.fresh fresh_at_base fresh_Pair_elim swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   165
  apply (rule_tac s="aux ((atom x' \<rightleftharpoons> atom a) \<bullet> t') ((atom y' \<rightleftharpoons> atom b) \<bullet> s') ((a, b) # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   166
  apply (rule_tac s="(atom y' \<rightleftharpoons> atom b) \<bullet> aux ((atom x' \<rightleftharpoons> atom a) \<bullet> t') s' ((a, y') # xs)" in trans)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   167
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   168
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   169
  apply (simp add: lam.fresh fresh_at_base fresh_Pair_elim swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   170
  apply (subst permute_eqvt)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   171
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   172
  apply (subgoal_tac "(atom x' \<rightleftharpoons> atom a) \<bullet> t' = (atom x \<rightleftharpoons> atom a) \<bullet> t")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   173
  apply (subgoal_tac "(atom y' \<rightleftharpoons> atom b) \<bullet> s' = (atom y \<rightleftharpoons> atom b) \<bullet> s")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   174
  apply simp
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   175
  apply (subgoal_tac "Lam [y]. s = Lam [b]. ((atom y \<rightleftharpoons> atom b) \<bullet> s)")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   176
  apply (subgoal_tac "Lam [y']. s' = Lam [b]. ((atom y' \<rightleftharpoons> atom b) \<bullet> s')")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   177
  apply (auto simp add: fresh_Pair_elim Abs1_eq_iff)[1]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   178
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   179
  apply (simp add: Abs1_eq_iff fresh_Pair_elim fresh_at_base swap_commute)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   180
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   181
  apply (simp add: Abs1_eq_iff fresh_Pair_elim fresh_at_base swap_commute)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   182
  apply (subgoal_tac "Lam [x]. t = Lam [a]. ((atom x \<rightleftharpoons> atom a) \<bullet> t)")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   183
  apply (subgoal_tac "Lam [x']. t' = Lam [a]. ((atom x' \<rightleftharpoons> atom a) \<bullet> t')")
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   184
  apply (auto simp add: fresh_Pair_elim Abs1_eq_iff)[1]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   185
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   186
  apply (simp add: Abs1_eq_iff fresh_Pair_elim fresh_at_base swap_commute)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   187
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   188
  apply (simp add: Abs1_eq_iff fresh_Pair_elim fresh_at_base swap_commute)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   189
  done
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   190
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   191
end
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   192
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   193
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   194