Nominal/Ex/AuxNoFCB.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 19 Apr 2018 13:58:22 +0100
branchNominal2-Isabelle2016-1
changeset 3246 66114fa3d2ee
parent 3236 e2da10806a34
permissions -rw-r--r--
updated to Isabelle 2016-1
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
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3149
diff changeset
    10
nominal_function lookup where
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    11
  "lookup (n :: name) m [] \<longleftrightarrow> (n = m)"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    12
| "lookup n m ((hn, hm) # t) \<longleftrightarrow>
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    13
     (n, m) = (hn, hm) \<or> (n \<noteq> hn \<and> m \<noteq> hm \<and> lookup n m t)"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    14
  apply (simp add: eqvt_def lookup_graph_def)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    15
  apply (rule, perm_simp, rule, rule)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    16
  by pat_completeness auto
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    17
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
    18
nominal_termination (eqvt) by lexicographic_order
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    19
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3149
diff changeset
    20
nominal_function lam2_rec where
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
    21
  "lam2_rec faa fll xs (Var n) (Var m) = lookup n m xs"
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    22
| "lam2_rec faa fll xs (Var n) (App l r) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    23
| "lam2_rec faa fll xs (Var n) (Lam [x]. t) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    24
| "lam2_rec faa fll xs (App l r) (Var n) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    25
| "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
    26
| "lam2_rec faa fll xs (App l r) (Lam [x]. t) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    27
| "lam2_rec faa fll xs (Lam [x]. t) (Var n) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    28
| "lam2_rec faa fll xs (Lam [x]. t) (App l1 r1) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    29
| "(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
    30
     (\<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
    31
        \<longrightarrow> fll x t y s = fll x' t' y' s')) \<Longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    32
     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
    33
| "(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
    34
     \<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
    35
        \<longrightarrow> fll x t y s = fll x' t' y' s')) \<Longrightarrow>
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    36
     lam2_rec faa fll xs (Lam [x]. t) (Lam [y]. s) = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    37
  apply (simp add: eqvt_def lam2_rec_graph_def)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    38
  apply (rule, perm_simp, rule, rule)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    39
  apply (case_tac x)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    40
  apply (rule_tac y="d" and c="(c, e)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    41
  apply (rule_tac y="e" and c="(c, d)" in lam.strong_exhaust)
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    42
  apply simp_all[3]  apply (metis, metis, metis)
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    43
  apply (rule_tac y="e" and c="(c, d)" in lam.strong_exhaust)
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    44
  apply simp_all[3]  apply (metis, metis, metis)
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    45
  apply (rule_tac y="e" and c="(name, c, d)" in lam.strong_exhaust)
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    46
  apply simp_all[2]  apply (metis, metis)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    47
  unfolding fresh_star_def
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    48
  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
    49
  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
    50
  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
    51
  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
    52
  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
    53
  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
    54
  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
    55
  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
    56
  apply (drule_tac x="name" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    57
  apply (drule_tac x="c" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    58
  apply (drule_tac x="namea" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    59
  apply (drule_tac x="lama" in meta_spec)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    60
  apply (drule_tac x="lama" in meta_spec)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    61
  apply (drule_tac x="lam" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    62
  apply (drule_tac x="b" in meta_spec)+
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    63
  apply (drule_tac x="a" in meta_spec)+
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    64
  apply (case_tac "(\<forall>x' y' t' s'. atom x' \<sharp> (c, Lam [y']. s') \<longrightarrow>
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    65
             atom y' \<sharp> (x', c, Lam [x']. t') \<longrightarrow> Lam [name]. lam = Lam [x']. t' \<longrightarrow>
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    66
             Lam [namea]. lama = Lam [y']. s' \<longrightarrow> b name lam namea lama = b x' t' y' s')")
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    67
  apply clarify
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    68
  apply (simp)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    69
  apply (simp only: fresh_Pair_elim)
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    70
  apply blast
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    71
  apply (simp_all)[53]
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    72
  apply clarify
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    73
  apply metis
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    74
  apply simp
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    75
  done
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    76
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
    77
nominal_termination (eqvt) by lexicographic_order
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    78
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    79
lemma lam_rec2_cong[fundef_cong]:
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    80
  "(\<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
    81
   (\<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
    82
  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
    83
  apply (rule_tac y="l" and c="(xs, l2)" in lam.strong_exhaust)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    84
  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
    85
  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
    86
  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
    87
  apply auto[2]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    88
  apply clarify
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    89
  apply (case_tac "(\<forall>x' y' t' s'. atom x' \<sharp> (xs, Lam [y']. s') \<longrightarrow>
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    90
    atom y' \<sharp> (x', xs, Lam [x']. t') \<longrightarrow> Lam [name]. lam = Lam [x']. t' \<longrightarrow>
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    91
    Lam [namea]. lama = Lam [y']. s' \<longrightarrow> fll name lam namea lama = fll x' t' y' s')")
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    92
  unfolding fresh_star_def
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    93
  apply (subst lam2_rec.simps) apply simp
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    94
  apply (subst lam2_rec.simps) apply simp
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
    95
  apply metis
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    96
  apply (subst lam2_rec.simps(10)) apply (simp add: fresh_star_def)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
    97
  apply (subst lam2_rec.simps(10)) apply (simp_all add: fresh_star_def)
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    98
  done
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
    99
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3149
diff changeset
   100
nominal_function aux :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool"
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   101
  where
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   102
[simp del]: "aux l r xs = lam2_rec
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   103
  (%t1 t2 t3 t4. (aux t1 t3 xs) \<and> (aux t2 t4 xs))
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   104
  (%x t y s. aux t s ((x, y) # xs)) xs l r"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   105
  unfolding eqvt_def aux_graph_def
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   106
  apply (rule, perm_simp, rule, rule)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   107
  by pat_completeness auto
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   108
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   109
nominal_termination (eqvt)
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   110
  by (relation "measure (\<lambda>(l, r, xs). size l + size r)") simp_all
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   111
3141
319964ecf1f6 Change definition of Aux to include alpha-convertibility for non-closed terms.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3140
diff changeset
   112
lemma aux_simps[simp]:
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   113
  "aux (Var x) (Var y) xs = lookup x y xs"
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   114
  "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
   115
  "aux (Var x) (App t1 t2) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   116
  "aux (Var x) (Lam [y].t) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   117
  "aux (App t1 t2) (Var x) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   118
  "aux (App t1 t2) (Lam [x].t) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   119
  "aux (Lam [x].t) (Var y) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   120
  "aux (Lam [x].t) (App t1 t2) xs = False"
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   121
  "\<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
   122
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   123
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   124
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   125
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   126
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   127
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   128
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   129
  apply (subst aux.simps, simp)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   130
  apply (subst aux.simps)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   131
  apply (subst lam2_rec.simps)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   132
  apply (rule, simp add: lam.fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   133
  apply (rule, simp add: lam.fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   134
  apply (intro allI impI)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   135
  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
   136
  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
   137
  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
   138
  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
   139
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   140
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   141
  apply (simp add: lam.fresh fresh_at_base fresh_Pair_elim)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   142
  apply (rename_tac b)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   143
  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
   144
  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
   145
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   146
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   147
  apply (simp add: lam.fresh fresh_at_base fresh_Pair_elim)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   148
  apply (subst permute_eqvt)
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 (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   151
  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
   152
  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
   153
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   154
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   155
  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
   156
  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
   157
  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
   158
  apply (rule permute_pure[symmetric])
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   159
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   160
  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
   161
  apply (subst permute_eqvt)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   162
  apply (simp add: eqvts swap_fresh_fresh)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   163
  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
   164
  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
   165
  apply simp
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   166
  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
   167
  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
   168
  apply (auto simp add: fresh_Pair_elim Abs1_eq_iff)[1]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   169
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   170
  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
   171
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   172
  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
   173
  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
   174
  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
   175
  apply (auto simp add: fresh_Pair_elim Abs1_eq_iff)[1]
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   176
  apply (rule sym)
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   177
  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
   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)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   180
  apply (rule refl)
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   181
  done
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   182
3142
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   183
lemma aux_induct:  "\<lbrakk>\<And>xs n m. P xs (Var n) (Var m); \<And>xs n l r. P xs (Var n) (App l r);
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   184
 \<And>xs n x t. P xs (Var n) (Lam [x]. t);
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   185
 \<And>xs l r n. P xs (App l r) (Var n);
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   186
 (\<And>xs l1 r1 l2 r2. P xs l1 l2 \<Longrightarrow> P xs r1 r2 \<Longrightarrow> P xs (App l1 r1) (App l2 r2));
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   187
 \<And>xs l r x t. P xs (App l r) (Lam [x]. t);
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   188
 \<And>xs x t n. P xs (Lam [x]. t) (Var n);
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   189
 \<And>xs x t l1 r1. P xs (Lam [x]. t) (App l1 r1);
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   190
 \<And>x xs y s t.
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   191
    atom x \<sharp> (xs, Lam [y]. s) \<and>
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   192
    atom y \<sharp> (x, xs, Lam [x]. t) \<Longrightarrow> P ((x, y) # xs) t s \<Longrightarrow> P xs (Lam [x]. t) (Lam [y]. s)\<rbrakk>
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   193
\<Longrightarrow> P (a :: (name \<times> name) list) b c"
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   194
  apply (induction_schema)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   195
  apply (rule_tac y="b" and c="(a, c)" in lam.strong_exhaust)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   196
  apply (rule_tac y="c" and c="(name, a, b)" in lam.strong_exhaust)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   197
  apply simp_all[3] apply (metis)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   198
  apply (rule_tac y="c" and c="(name, a, b)" in lam.strong_exhaust)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   199
  apply simp_all[3] apply (metis, metis, metis)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   200
  apply (rule_tac y="c" and c="(name, a, b)" in lam.strong_exhaust)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   201
  apply simp_all[3] apply (metis)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   202
  apply (simp add: fresh_star_def)
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   203
  apply metis
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   204
  apply lexicographic_order
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   205
  done
4d01d1056e22 Induction for Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3141
diff changeset
   206
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3149
diff changeset
   207
nominal_function swapequal :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool" where
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   208
  "swapequal l r [] \<longleftrightarrow> l = r"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   209
| "atom x \<sharp> (l, r, hl, hr, t) \<Longrightarrow>
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   210
    swapequal l r ((hl, hr) # t) \<longleftrightarrow> swapequal ((hl \<leftrightarrow> x) \<bullet> l) ((hr \<leftrightarrow> x) \<bullet> r) t"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   211
  unfolding eqvt_def swapequal_graph_def
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   212
  apply (rule, perm_simp, rule, rule TrueI)
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   213
  apply (case_tac x)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   214
  apply (case_tac c)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   215
  apply metis
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   216
  apply (case_tac aa)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   217
  apply (rename_tac l r lst h t hl hr)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   218
  apply (rule_tac x="(l, r, hl, hr, t)" and ?'a="name" in obtain_fresh)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   219
  apply simp
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   220
  apply simp
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   221
  apply simp
3146
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   222
  apply clarify
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   223
  apply (rule_tac s="(x \<leftrightarrow> xa) \<bullet> swapequal_sumC ((hla \<leftrightarrow> x) \<bullet> la, (hra \<leftrightarrow> x) \<bullet> ra, ta)" in trans)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   224
  apply (simp only: permute_pure)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   225
  apply (simp add: eqvt_at_def fresh_Pair_elim)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   226
  apply (simp add: flip_fresh_fresh)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   227
  apply (subgoal_tac "(x \<leftrightarrow> xa) \<bullet> (hla \<leftrightarrow> x) \<bullet> la = (hla \<leftrightarrow> xa) \<bullet> la")
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   228
  apply (subgoal_tac "(x \<leftrightarrow> xa) \<bullet> (hra \<leftrightarrow> x) \<bullet> ra = (hra \<leftrightarrow> xa) \<bullet> ra")
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   229
  apply simp
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   230
  apply (subst permute_eqvt)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   231
  apply (simp add: flip_fresh_fresh flip_eqvt)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   232
  apply (subst permute_eqvt)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   233
  apply (simp add: flip_fresh_fresh flip_eqvt)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   234
  done
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   235
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   236
nominal_termination (eqvt) by lexicographic_order
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   237
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   238
lemma var_eq_swapequal: "atom ab \<sharp> xs \<Longrightarrow> swapequal (Var ab) (Var ab) xs"
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   239
  apply (induct xs)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   240
  apply simp
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   241
  apply (case_tac a)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   242
  apply (simp add: fresh_Cons)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   243
  apply (rule_tac x="(ab, aa, b, xs)" and ?'a="name" in obtain_fresh)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   244
  apply (subst swapequal.simps)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   245
  apply (simp add: fresh_Pair lam.fresh)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   246
  apply (simp add: fresh_Pair_elim)
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   247
  by (metis flip_at_base_simps(3) fresh_Pair fresh_at_base(2))
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   248
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   249
lemma var_neq_swapequal:
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   250
  "atom ab \<sharp> xs \<Longrightarrow> ab \<noteq> m \<Longrightarrow> \<not> swapequal (Var ab) (Var m) xs"
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   251
  "atom ab \<sharp> xs \<Longrightarrow> ab \<noteq> m \<Longrightarrow> \<not> swapequal (Var m) (Var ab) xs"
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   252
  apply (induct xs arbitrary: m)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   253
  apply simp_all[2]
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   254
  apply (case_tac [!] a)
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   255
  apply (simp_all add: fresh_Cons)
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   256
  apply (rule_tac [!] x="(ab, aa, b, m, xs)" and ?'a="name" in obtain_fresh)
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   257
  apply (subst swapequal.simps)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   258
  apply (auto simp add: fresh_Pair lam.fresh)[1]
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   259
  apply (elim conjE)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   260
  apply (simp add: fresh_Pair_elim fresh_at_base permute_flip_at)
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   261
  apply (subst swapequal.simps)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   262
  apply (auto simp add: fresh_Pair lam.fresh)[1]
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   263
  apply (elim conjE)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   264
  apply (simp add: fresh_Pair_elim fresh_at_base permute_flip_at)
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   265
  done
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   266
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   267
lemma lookup_swapequal: "lookup n m xs = swapequal (Var n) (Var m) xs"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   268
  apply (induct xs arbitrary: m n)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   269
  apply simp
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   270
  apply (case_tac a)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   271
  apply (rule_tac x="(n, m, aa, b, xs)" and ?'a="name" in obtain_fresh)
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   272
  apply simp
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   273
  apply (subst swapequal.simps)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   274
  apply (simp add: fresh_Pair lam.fresh fresh_Nil)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   275
  by (metis (hide_lams, mono_tags) flip_at_base_simps(3) flip_at_simps(1) fresh_Pair fresh_at_base(2) lam.perm_simps(1) var_eq_swapequal var_neq_swapequal(1) var_neq_swapequal(2))
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   276
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   277
lemma swapequal_reorder: "
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   278
  a \<noteq> x \<Longrightarrow> a \<noteq> y \<Longrightarrow> b \<noteq> x \<Longrightarrow> b \<noteq> y \<Longrightarrow>
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   279
  swapequal t s ((x, y) # (a, b) # xs) = swapequal t s ((a, b) # (x, y) # xs)"
3146
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   280
  apply (rule_tac x="(a, b, x, y, t, s, xs)" and ?'a="name" in obtain_fresh)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   281
  apply (rule_tac x="(a, b, x, y, t, s, xs, aa)" and ?'a="name" in obtain_fresh)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   282
  apply (rename_tac f g)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   283
  apply (simp add: fresh_Pair_elim fresh_at_base)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   284
  apply (subst swapequal.simps)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   285
  apply (auto simp add: fresh_Pair fresh_Cons fresh_at_base)[1]
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   286
  apply (subgoal_tac "(x \<leftrightarrow> f) \<bullet> atom g \<sharp> t")
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   287
  apply (subst swapequal.simps)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   288
  apply (simp add: fresh_Pair fresh_Cons fresh_permute_left)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   289
  apply rule apply assumption
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   290
  apply (simp add: flip_at_base_simps fresh_at_base flip_def)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   291
  apply (subst swapequal.simps)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   292
  apply (simp add: fresh_Pair fresh_Cons fresh_at_base)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   293
  apply rule apply (rotate_tac 12)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   294
  apply assumption
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   295
  apply (simp add: fresh_Pair fresh_Cons fresh_at_base)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   296
  apply (subst swapequal.simps)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   297
  apply (simp add: fresh_Pair fresh_Cons fresh_at_base fresh_permute_left)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   298
  apply (subgoal_tac "(a \<leftrightarrow> g) \<bullet> atom f \<sharp> t")
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
   299
  apply rule apply assumption
3146
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   300
  apply (simp add: flip_at_base_simps fresh_at_base flip_def)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   301
  apply (simp add: flip_at_base_simps fresh_at_base flip_def)
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   302
  apply (subgoal_tac "(a \<leftrightarrow> g) \<bullet> (x \<leftrightarrow> f) \<bullet> t = (x \<leftrightarrow> f) \<bullet> (a \<leftrightarrow> g) \<bullet> t")
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   303
  apply (subgoal_tac "(b \<leftrightarrow> g) \<bullet> (y \<leftrightarrow> f) \<bullet> s = (y \<leftrightarrow> f) \<bullet> (b \<leftrightarrow> g) \<bullet> s")
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   304
  apply simp
3149
78c0a707fb2d remove smt calls
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3148
diff changeset
   305
  apply (subst permute_eqvt) apply (simp add: flip_eqvt)
78c0a707fb2d remove smt calls
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3148
diff changeset
   306
  apply (subst permute_eqvt) apply (simp add: flip_eqvt)
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
   307
  apply (simp add: flip_at_base_simps fresh_at_base flip_def)
3146
556fcd0e5fcb Finish all subgoals about Aux.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3145
diff changeset
   308
  done
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   309
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   310
lemma swapequal_lambda:
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   311
  assumes "distinct xs \<and> atom x \<sharp> xs \<and> atom y \<sharp> xs"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   312
  shows "swapequal (Lam [x]. t) (Lam [y]. s) xs = swapequal t s ((x, y) # xs)"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   313
  using assms
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   314
  apply (induct xs arbitrary: t s x y)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   315
  apply (rule_tac x="(x, y, t, s)" and ?'a="name" in obtain_fresh)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   316
  apply (simp add: fresh_Pair_elim fresh_Nil)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   317
  apply (subst swapequal.simps)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   318
  apply (simp add: fresh_Pair fresh_Nil)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   319
  apply auto[1]
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   320
  apply simp
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   321
  apply (subgoal_tac "[[atom x]]lst. t = [[atom a]]lst. ((x \<leftrightarrow> a) \<bullet> t)")
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   322
  apply (subgoal_tac "[[atom y]]lst. s = [[atom a]]lst. ((y \<leftrightarrow> a) \<bullet> s)")
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   323
  apply simp
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   324
  apply (simp add: Abs1_eq_iff)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   325
  apply (auto simp add: Abs1_eq_iff flip_def fresh_at_base)[2]
3149
78c0a707fb2d remove smt calls
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3148
diff changeset
   326
  apply (simp add: fresh_permute_left)
78c0a707fb2d remove smt calls
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3148
diff changeset
   327
  apply (simp add: fresh_permute_left)
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   328
  apply clarify
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   329
  apply (simp add: fresh_Cons fresh_Pair fresh_at_base)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   330
  apply clarify
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   331
  apply (simp add: swapequal_reorder)
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   332
  apply (rule_tac x="(x, y, t, s, a, b, xs)" and ?'a="name" in obtain_fresh)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   333
  apply (rename_tac f)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   334
  apply (subst (2) swapequal.simps)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   335
  apply (auto simp add: lam.fresh fresh_Pair fresh_at_base fresh_Cons)[1]
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   336
  apply (subst swapequal.simps)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   337
  apply (auto simp add: lam.fresh fresh_Pair fresh_at_base fresh_Cons)[1]
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   338
  apply (simp add: flip_def fresh_Pair_elim fresh_at_base)
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   339
  done
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   340
3145
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   341
lemma distinct_swapequal: "\<forall>p q. p \<bullet> l \<noteq> q \<bullet> r \<Longrightarrow> \<not>swapequal l r xs"
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   342
  apply (induct xs rule:swapequal.induct)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   343
  apply auto[1]
3145
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   344
  apply (simp add: fresh_Pair_elim)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   345
  apply (subgoal_tac "\<forall>(p\<Colon>perm) q\<Colon>perm. p \<bullet> (hl \<leftrightarrow> x) \<bullet> l \<noteq> q \<bullet> (hr \<leftrightarrow> x) \<bullet> r")
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   346
  apply simp
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   347
  apply (intro allI)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   348
  apply (drule_tac x="p + (hl \<leftrightarrow> x)" in spec)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   349
  apply (drule_tac x="q + (hr \<leftrightarrow> x)" in spec)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   350
  apply simp
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   351
  done
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   352
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   353
lemma swapequal_app: "(swapequal l1 l2 xs \<and> swapequal r1 r2 xs) = swapequal (App l1 r1) (App l2 r2) xs"
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   354
  apply (induct xs arbitrary: l1 l2 r1 r2)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   355
  apply simp
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   356
  apply (case_tac a)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   357
  apply simp
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   358
  apply (rule_tac x="(l1, l2, r1, r2, aa, b, xs)" and ?'a="name" in obtain_fresh)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   359
  apply (simp add: fresh_Pair_elim)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   360
  apply (subst swapequal.simps) apply (auto simp add: fresh_Pair)[1]
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   361
  apply (subst swapequal.simps) apply (auto simp add: fresh_Pair lam.fresh)
3145
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   362
  done
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   363
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   364
lemma [simp]: "distinct (map fst xs) \<Longrightarrow> distinct xs"
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   365
  by (induct xs) auto
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   366
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   367
lemma [simp]:
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   368
  "atom x \<sharp> xs \<Longrightarrow> x \<notin> fst ` set xs"
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   369
  "atom x \<sharp> xs \<Longrightarrow> x \<notin> snd ` set xs"
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   370
  apply (induct xs)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   371
  apply simp_all
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   372
  apply (case_tac [!] a)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   373
  apply (simp_all add: fresh_Cons fresh_Pair fresh_at_base)
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   374
  done
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   375
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   376
lemma aux_alphaish:
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   377
  assumes "distinct (map fst xs @ map snd xs)"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   378
  shows "aux x y xs \<longleftrightarrow> swapequal x y xs"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   379
  using assms
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   380
  apply (induct xs x y rule: aux_induct)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   381
  apply (simp add: lookup_swapequal)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   382
  apply (simp, rule distinct_swapequal, simp)+
3145
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   383
  apply (simp add: swapequal_app)
3148
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   384
  apply (simp, rule distinct_swapequal, simp)+
8a3352cff8d0 More cleaning
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3147
diff changeset
   385
  apply (simp add: fresh_Pair_elim lam.fresh fresh_at_base conjE)
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   386
  apply (elim conjE)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   387
  apply (simp add: fresh_Pair_elim lam.fresh fresh_at_base)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   388
  apply (subgoal_tac "x \<notin> fst ` set xs \<and>
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   389
        x \<notin> snd ` set xs \<and> y \<notin> snd ` set xs \<and> y \<notin> fst ` set xs")
3144
57dcb5c0d5db Close some of the obvious subgoals in Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3143
diff changeset
   390
  apply (subst swapequal_lambda)
3145
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   391
  apply auto[2]
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   392
  apply simp
31bc3e2e80bf More on Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3144
diff changeset
   393
  done
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   394
3147
d24e70483051 Clean the proof of Aux
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3146
diff changeset
   395
lemma aux_is_alpha:
3143
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   396
  "aux x y [] \<longleftrightarrow> (x = y)"
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   397
  by (simp_all add: supp_Nil aux_alphaish)
1da802bd2ab1 Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3142
diff changeset
   398
3140
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   399
end
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   400
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   401
5179ff4806c5 Define 'aux'
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff changeset
   402