Quot/Nominal/LamEx2.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 01 Feb 2010 16:23:47 +0100
changeset 1013 e63838c26f28
parent 1011 1dd314a00b0c
child 1017 4239a0784e5f
permissions -rw-r--r--
updated from huffman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1011
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory LamEx
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
imports Nominal "../QuotMain" "../QuotList"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
atom_decl name
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
datatype rlam =
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
  rVar "name"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
| rApp "rlam" "rlam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
| rLam "name" "rlam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
fun
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
  rfv :: "rlam \<Rightarrow> name set"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
where
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  rfv_var: "rfv (rVar a) = {a}"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
| rfv_app: "rfv (rApp t1 t2) = (rfv t1) \<union> (rfv t2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
| rfv_lam: "rfv (rLam a t) = (rfv t) - {a}"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
overloading
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  perm_rlam \<equiv> "perm :: 'x prm \<Rightarrow> rlam \<Rightarrow> rlam"   (unchecked)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
begin
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
fun
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  perm_rlam
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
where
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  "perm_rlam pi (rVar a) = rVar (pi \<bullet> a)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
| "perm_rlam pi (rApp t1 t2) = rApp (perm_rlam pi t1) (perm_rlam pi t2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
| "perm_rlam pi (rLam a t) = rLam (pi \<bullet> a) (perm_rlam pi t)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
end
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
declare perm_rlam.simps[eqvt]
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
instance rlam::pt_name
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
  apply(default)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
  apply(induct_tac [!] x rule: rlam.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  apply(simp_all add: pt_name2 pt_name3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
instance rlam::fs_name
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  apply(default)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  apply(induct_tac [!] x rule: rlam.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  apply(simp add: supp_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
  apply(fold supp_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  apply(simp add: supp_atm)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  apply(simp add: supp_def Collect_imp_eq Collect_neg_eq)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
  apply(simp add: supp_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  apply(simp add: supp_def Collect_imp_eq Collect_neg_eq[symmetric])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  apply(fold supp_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
  apply(simp add: supp_atm)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
declare set_diff_eqvt[eqvt]
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
lemma rfv_eqvt[eqvt]:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  fixes pi::"name prm"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  shows "(pi\<bullet>rfv t) = rfv (pi\<bullet>t)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
apply(induct t)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
apply(simp add: perm_set_eq)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
apply(simp add: union_eqvt)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
apply(simp add: set_diff_eqvt)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
apply(simp add: perm_set_eq)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
inductive
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
    alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
where
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
| a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
| a3: "\<exists>pi::name prm. (rfv t - {a} = rfv s - {b} \<and> (rfv t - {a})\<sharp>* pi \<and> (pi \<bullet> t) \<approx> s \<and> (pi \<bullet> a) = b)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
       \<Longrightarrow> rLam a t \<approx> rLam b s"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
(* should be automatic with new version of eqvt-machinery *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
lemma alpha_eqvt:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
  fixes pi::"name prm"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
  shows "t \<approx> s \<Longrightarrow> (pi \<bullet> t) \<approx> (pi \<bullet> s)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
apply(induct rule: alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
apply(simp add: a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
apply(simp add: a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
apply(rule a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
apply(erule conjE)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
apply(erule exE)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
apply(erule conjE)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
apply(rule_tac x="pi \<bullet> pia" in exI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
apply(rule conjI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
apply(rule_tac pi1="rev pi" in perm_bij[THEN iffD1])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
apply(perm_simp add: eqvts)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
apply(rule conjI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
apply(rule_tac pi1="rev pi" in pt_fresh_star_bij(1)[OF pt_name_inst at_name_inst, THEN iffD1])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
apply(perm_simp add: eqvts)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
apply(rule conjI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
apply(subst perm_compose[symmetric])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
apply(subst perm_compose[symmetric])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
lemma alpha_refl:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  shows "t \<approx> t"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
apply(induct t rule: rlam.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
apply(simp add: a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
apply(simp add: a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
apply(rule a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
apply(rule_tac x="[]" in exI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
apply(simp_all add: fresh_star_def fresh_list_nil)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
lemma alpha_sym:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
  shows "t \<approx> s \<Longrightarrow> s \<approx> t"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
apply(induct rule: alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
apply(simp add: a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
apply(simp add: a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
apply(rule a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
apply(erule exE)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
apply(rule_tac x="rev pi" in exI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
apply(simp add: fresh_star_def fresh_list_rev)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
apply(rule conjI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
apply(erule conjE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
apply(rotate_tac 3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
apply(drule_tac pi="rev pi" in alpha_eqvt)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
apply(perm_simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
apply(rule pt_bij2[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
lemma alpha_trans:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
  shows "t1 \<approx> t2 \<Longrightarrow> t2 \<approx> t3 \<Longrightarrow> t1 \<approx> t3"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
apply(induct arbitrary: t3 rule: alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
apply(simp add: a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
apply(rotate_tac 4)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
apply(simp add: a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
apply(rotate_tac 1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
apply(erule conjE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
apply(erule exE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
apply(erule conjE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
apply(rule a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
apply(rule_tac x="pia @ pi" in exI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
apply(simp add: fresh_star_def fresh_list_append)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
apply(simp add: pt_name2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
apply(drule_tac x="rev pia \<bullet> sa" in spec)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
apply(drule mp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
apply(rotate_tac 8)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
apply(drule_tac pi="rev pia" in alpha_eqvt)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
apply(perm_simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
apply(rotate_tac 11)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
apply(drule_tac pi="pia" in alpha_eqvt)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
apply(perm_simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   161
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
lemma alpha_equivp:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  shows "equivp alpha"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
apply(rule equivpI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
unfolding reflp_def symp_def transp_def
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
apply(auto intro: alpha_refl alpha_sym alpha_trans)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
lemma alpha_rfv:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
  shows "t \<approx> s \<Longrightarrow> rfv t = rfv s"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
apply(induct rule: alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
quotient_type lam = rlam / alpha
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
  by (rule alpha_equivp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
quotient_definition
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
  "Var :: name \<Rightarrow> lam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
as
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
  "rVar"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
quotient_definition
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
   "App :: lam \<Rightarrow> lam \<Rightarrow> lam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
as
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
  "rApp"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
quotient_definition
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
  "Lam :: name \<Rightarrow> lam \<Rightarrow> lam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
as
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   194
  "rLam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
quotient_definition
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
  "fv :: lam \<Rightarrow> name set"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
as
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
  "rfv"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
(* definition of overloaded permutation function *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
(* for the lifted type lam                       *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
overloading
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
  perm_lam \<equiv> "perm :: 'x prm \<Rightarrow> lam \<Rightarrow> lam"   (unchecked)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
begin
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
quotient_definition
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
  "perm_lam :: 'x prm \<Rightarrow> lam \<Rightarrow> lam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
as
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
  "perm::'x prm \<Rightarrow> rlam \<Rightarrow> rlam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   211
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   212
end
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
lemma perm_rsp[quot_respect]:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
  "(op = ===> alpha ===> alpha) op \<bullet> op \<bullet>"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
  apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
  (* this is propably true if some type conditions are imposed ;o) *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   218
  sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   219
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
lemma fresh_rsp:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   221
  "(op = ===> alpha ===> op =) fresh fresh"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
  apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
  (* this is probably only true if some type conditions are imposed *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
  sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   226
lemma rVar_rsp[quot_respect]:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
  "(op = ===> alpha) rVar rVar"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
  by (auto intro: a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   230
lemma rApp_rsp[quot_respect]: "(alpha ===> alpha ===> alpha) rApp rApp"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
  by (auto intro: a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   232
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
lemma rLam_rsp[quot_respect]: "(op = ===> alpha ===> alpha) rLam rLam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
  apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
  apply(rule a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
  apply(rule_tac x="[]" in exI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
  unfolding fresh_star_def
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
  apply(simp add: fresh_list_nil)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
  apply(simp add: alpha_rfv)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
  done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
lemma rfv_rsp[quot_respect]: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
  "(alpha ===> op =) rfv rfv"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
apply(simp add: alpha_rfv)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   246
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
section {* lifted theorems *}
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
lemma lam_induct:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   250
  "\<lbrakk>\<And>name. P (Var name);
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
    \<And>lam1 lam2. \<lbrakk>P lam1; P lam2\<rbrakk> \<Longrightarrow> P (App lam1 lam2);
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   252
    \<And>name lam. P lam \<Longrightarrow> P (Lam name lam)\<rbrakk> 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   253
    \<Longrightarrow> P lam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   254
  by (lifting rlam.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   255
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
lemma perm_lam [simp]:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
  fixes pi::"'a prm"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
  shows "pi \<bullet> Var a = Var (pi \<bullet> a)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
  and   "pi \<bullet> App t1 t2 = App (pi \<bullet> t1) (pi \<bullet> t2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
  and   "pi \<bullet> Lam a t = Lam (pi \<bullet> a) (pi \<bullet> t)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
apply(lifting perm_rlam.simps)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   264
instance lam::pt_name
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
apply(default)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
apply(induct_tac [!] x rule: lam_induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
apply(simp_all add: pt_name2 pt_name3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   268
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
lemma fv_lam [simp]: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
  shows "fv (Var a) = {a}"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
  and   "fv (App t1 t2) = fv t1 \<union> fv t2"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
  and   "fv (Lam a t) = fv t - {a}"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
apply(lifting rfv_var rfv_app rfv_lam)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   275
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
lemma a1: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   279
  "a = b \<Longrightarrow> Var a = Var b"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   280
  by  (lifting a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   282
lemma a2: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
  "\<lbrakk>x = xa; xb = xc\<rbrakk> \<Longrightarrow> App x xb = App xa xc"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   284
  by  (lifting a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   285
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   286
lemma a3: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
  "\<lbrakk>\<exists>pi::name prm. (fv t - {a} = fv s - {b} \<and> (fv t - {a})\<sharp>* pi \<and> (pi \<bullet> t) = s \<and> (pi \<bullet> a) = b)\<rbrakk> 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   288
   \<Longrightarrow> Lam a t = Lam b s"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   289
  by  (lifting a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
lemma alpha_cases: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   292
  "\<lbrakk>a1 = a2; \<And>a b. \<lbrakk>a1 = Var a; a2 = Var b; a = b\<rbrakk> \<Longrightarrow> P;
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   293
    \<And>x xa xb xc. \<lbrakk>a1 = App x xb; a2 = App xa xc; x = xa; xb = xc\<rbrakk> \<Longrightarrow> P;
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
    \<And>t a s b. \<lbrakk>a1 = Lam a t; a2 = Lam b s; 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   295
         \<exists>pi::name prm. fv t - {a} = fv s - {b} \<and> (fv t - {a}) \<sharp>* pi \<and> (pi \<bullet> t) = s \<and> pi \<bullet> a = b\<rbrakk> \<Longrightarrow> P\<rbrakk>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   296
    \<Longrightarrow> P"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   297
  by (lifting alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   299
lemma alpha_induct: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   300
  "\<lbrakk>qx = qxa; \<And>a b. a = b \<Longrightarrow> qxb (Var a) (Var b);
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   301
    \<And>x xa xb xc. \<lbrakk>x = xa; qxb x xa; xb = xc; qxb xb xc\<rbrakk> \<Longrightarrow> qxb (App x xb) (App xa xc);
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   302
     \<And>t a s b.
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   303
        \<lbrakk>\<exists>pi::name prm. fv t - {a} = fv s - {b} \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   304
         (fv t - {a}) \<sharp>* pi \<and> ((pi \<bullet> t) = s \<and> qxb (pi \<bullet> t) s) \<and> pi \<bullet> a = b\<rbrakk> \<Longrightarrow> qxb (Lam a t) (Lam b s)\<rbrakk>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   305
    \<Longrightarrow> qxb qx qxa"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   306
  by (lifting alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
lemma lam_inject [simp]: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
  shows "(Var a = Var b) = (a = b)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   310
  and   "(App t1 t2 = App s1 s2) = (t1 = s1 \<and> t2 = s2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
apply(lifting rlam.inject(1) rlam.inject(2))
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
apply(drule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   314
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
apply(simp add: alpha.a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
apply(drule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   317
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
apply(drule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
apply(rule alpha.a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   322
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   323
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   324
lemma rlam_distinct:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   325
  shows "\<not>(rVar nam \<approx> rApp rlam1' rlam2')"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   326
  and   "\<not>(rApp rlam1' rlam2' \<approx> rVar nam)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
  and   "\<not>(rVar nam \<approx> rLam nam' rlam')"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   328
  and   "\<not>(rLam nam' rlam' \<approx> rVar nam)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   329
  and   "\<not>(rApp rlam1 rlam2 \<approx> rLam nam' rlam')"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   330
  and   "\<not>(rLam nam' rlam' \<approx> rApp rlam1 rlam2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
apply auto
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   333
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   334
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   335
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   336
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   338
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   339
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   340
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   341
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   342
apply(erule alpha.cases)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   343
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   344
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   345
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   346
lemma lam_distinct[simp]:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   347
  shows "Var nam \<noteq> App lam1' lam2'"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   348
  and   "App lam1' lam2' \<noteq> Var nam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   349
  and   "Var nam \<noteq> Lam nam' lam'"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
  and   "Lam nam' lam' \<noteq> Var nam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   351
  and   "App lam1 lam2 \<noteq> Lam nam' lam'"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   352
  and   "Lam nam' lam' \<noteq> App lam1 lam2"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   353
apply(lifting rlam_distinct(1) rlam_distinct(2) rlam_distinct(3) rlam_distinct(4) rlam_distinct(5) rlam_distinct(6))
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   354
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   355
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   356
lemma var_supp1:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   357
  shows "(supp (Var a)) = ((supp a)::name set)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   358
  by (simp add: supp_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   359
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   360
lemma var_supp:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   361
  shows "(supp (Var a)) = {a::name}"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   362
  using var_supp1 by (simp add: supp_atm)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   363
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   364
lemma app_supp:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   365
  shows "supp (App t1 t2) = (supp t1) \<union> ((supp t2)::name set)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
apply(simp only: perm_lam supp_def lam_inject)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
apply(simp add: Collect_imp_eq Collect_neg_eq)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   368
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   369
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   370
lemma lam_supp:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   371
  shows "supp (Lam x t) = ((supp ([x].t))::name set)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
apply(simp add: supp_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   373
apply(simp add: abs_perm)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   374
sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   376
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   377
instance lam::fs_name
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   378
apply(default)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   379
apply(induct_tac x rule: lam_induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
apply(simp add: var_supp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   381
apply(simp add: app_supp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   382
apply(simp add: lam_supp abs_supp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   383
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   385
lemma fresh_lam:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   386
  "(a \<sharp> Lam b t) \<longleftrightarrow> (a = b) \<or> (a \<noteq> b \<and> a \<sharp> t)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   387
apply(simp add: fresh_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   388
apply(simp add: lam_supp abs_supp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   389
apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   390
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   391
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   392
lemma lam_induct_strong:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   393
  fixes a::"'a::fs_name"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   394
  assumes a1: "\<And>name b. P b (Var name)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   395
  and     a2: "\<And>lam1 lam2 b. \<lbrakk>\<And>c. P c lam1; \<And>c. P c lam2\<rbrakk> \<Longrightarrow> P b (App lam1 lam2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   396
  and     a3: "\<And>name lam b. \<lbrakk>\<And>c. P c lam; name \<sharp> b\<rbrakk> \<Longrightarrow> P b (Lam name lam)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   397
  shows "P a lam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   398
proof -
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   399
  have "\<And>(pi::name prm) a. P a (pi \<bullet> lam)" 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   400
  proof (induct lam rule: lam_induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   401
    case (1 name pi)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   402
    show "P a (pi \<bullet> Var name)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   403
      apply (simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   404
      apply (rule a1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   405
      done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   406
  next
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   407
    case (2 lam1 lam2 pi)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   408
    have b1: "\<And>(pi::name prm) a. P a (pi \<bullet> lam1)" by fact
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   409
    have b2: "\<And>(pi::name prm) a. P a (pi \<bullet> lam2)" by fact
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   410
    show "P a (pi \<bullet> App lam1 lam2)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   411
      apply (simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   412
      apply (rule a2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   413
      apply (rule b1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   414
      apply (rule b2)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   415
      done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   416
  next
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   417
    case (3 name lam pi a)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   418
    have b: "\<And>(pi::name prm) a. P a (pi \<bullet> lam)" by fact
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   419
    obtain c::name where fr: "c\<sharp>(a, pi\<bullet>name, pi\<bullet>lam)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   420
      apply(rule exists_fresh[of "(a, pi\<bullet>name, pi\<bullet>lam)"])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   421
      apply(simp_all add: fs_name1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   422
      done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   423
    from b fr have p: "P a (Lam c (([(c, pi\<bullet>name)]@pi)\<bullet>lam))" 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   424
      apply -
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   425
      apply(rule a3)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   426
      apply(blast)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   427
      apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   428
      done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   429
    have eq: "[(c, pi\<bullet>name)] \<bullet> Lam (pi \<bullet> name) (pi \<bullet> lam) = Lam (pi \<bullet> name) (pi \<bullet> lam)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   430
      apply(rule perm_fresh_fresh)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   431
      using fr
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   432
      apply(simp add: fresh_lam)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   433
      apply(simp add: fresh_lam)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   434
      done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   435
    show "P a (pi \<bullet> Lam name lam)" 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   436
      apply (simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   437
      apply(subst eq[symmetric])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   438
      using p
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   439
      apply(simp only: perm_lam pt_name2 swap_simps)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   440
      done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   441
  qed
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   442
  then have "P a (([]::name prm) \<bullet> lam)" by blast
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   443
  then show "P a lam" by simp 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   444
qed
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   445
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   446
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   447
lemma var_fresh:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   448
  fixes a::"name"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   449
  shows "(a \<sharp> (Var b)) = (a \<sharp> b)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   450
  apply(simp add: fresh_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   451
  apply(simp add: var_supp1)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   452
  done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   453
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   454
(* lemma hom_reg: *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   455
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   456
lemma rlam_rec_eqvt:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   457
  fixes pi::"name prm"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   458
  and   f1::"name \<Rightarrow> ('a::pt_name)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   459
  shows "(pi\<bullet>rlam_rec f1 f2 f3 t) = rlam_rec (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3) (pi\<bullet>t)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   460
apply(induct t)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   461
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   462
apply(simp add: perm_fun_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   463
apply(perm_simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   464
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   465
back
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   466
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   467
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   468
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   469
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   470
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   471
back
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   472
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   473
apply(subst pt_fun_app_eq[OF pt_name_inst at_name_inst])
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   474
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   475
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   476
 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   477
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   478
lemma rlam_rec_respects:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   479
  assumes f1: "f_var \<in> Respects (op= ===> op=)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   480
  and     f2: "f_app \<in> Respects (alpha ===> alpha ===> op= ===> op= ===> op=)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   481
  and     f3: "f_lam \<in> Respects (op= ===> alpha ===> op= ===> op=)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   482
  shows "rlam_rec f_var f_app f_lam \<in> Respects (alpha ===> op =)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   483
apply(simp add: mem_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   484
apply(simp add: Respects_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   485
apply(rule allI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   486
apply(rule allI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   487
apply(rule impI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   488
apply(erule alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   489
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   490
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   491
using f2
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   492
apply(simp add: mem_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   493
apply(simp add: Respects_def)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   494
using f3[simplified mem_def Respects_def]
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   495
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   496
apply(case_tac "a=b")
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   497
apply(clarify)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   498
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   499
(* probably true *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   500
sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   501
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   502
function
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   503
  term1_hom :: "(name \<Rightarrow> 'a) \<Rightarrow>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   504
                (rlam \<Rightarrow> rlam \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   505
                ((name \<Rightarrow> rlam) \<Rightarrow> (name \<Rightarrow> 'a) \<Rightarrow> 'a) \<Rightarrow> rlam \<Rightarrow> 'a"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   506
where
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   507
  "term1_hom var app abs' (rVar x) = (var x)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   508
| "term1_hom var app abs' (rApp t u) =
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   509
     app t u (term1_hom var app abs' t) (term1_hom var app abs' u)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   510
| "term1_hom var app abs' (rLam x u) =
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   511
     abs' (\<lambda>y. [(x, y)] \<bullet> u) (\<lambda>y. term1_hom var app abs' ([(x, y)] \<bullet> u))"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   512
apply(pat_completeness)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   513
apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   514
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   515
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   516
lemma pi_size:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   517
  fixes pi::"name prm"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   518
  and   t::"rlam"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   519
  shows "size (pi \<bullet> t) = size t"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   520
apply(induct t)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   521
apply(auto)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   522
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   523
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   524
termination term1_hom
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   525
  apply(relation "measure (\<lambda>(f1, f2, f3, t). size t)")
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   526
apply(auto simp add: pi_size)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   527
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   528
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   529
lemma lam_exhaust:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   530
  "\<lbrakk>\<And>name. y = Var name \<Longrightarrow> P; \<And>rlam1 rlam2. y = App rlam1 rlam2 \<Longrightarrow> P; \<And>name rlam. y = Lam name rlam \<Longrightarrow> P\<rbrakk>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   531
    \<Longrightarrow> P"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   532
apply(lifting rlam.exhaust)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   533
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   534
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   535
(* THIS IS NOT TRUE, but it lets prove the existence of the hom function *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   536
lemma lam_inject':
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   537
  "(Lam a x = Lam b y) = ((\<lambda>c. [(a, c)] \<bullet> x) = (\<lambda>c. [(b, c)] \<bullet> y))"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   538
sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   539
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   540
function
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   541
  hom :: "(name \<Rightarrow> 'a) \<Rightarrow>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   542
                (lam \<Rightarrow> lam \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   543
                ((name \<Rightarrow> lam) \<Rightarrow> (name \<Rightarrow> 'a) \<Rightarrow> 'a) \<Rightarrow> lam \<Rightarrow> 'a"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   544
where
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   545
  "hom f_var f_app f_lam (Var x) = f_var x"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   546
| "hom f_var f_app f_lam (App l r) = f_app l r (hom f_var f_app f_lam l) (hom f_var f_app f_lam r)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   547
| "hom f_var f_app f_lam (Lam a x) = f_lam (\<lambda>b. ([(a,b)] \<bullet> x)) (\<lambda>b. hom f_var f_app f_lam ([(a,b)] \<bullet> x))"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   548
defer
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   549
apply(simp_all add: lam_inject') (* inject, distinct *)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   550
apply(tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   551
apply(rule refl)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   552
apply(rule ext)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   553
apply(tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   554
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   555
apply(erule conjE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   556
apply(rule_tac x="b" in cong)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   557
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   558
apply auto
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   559
apply(rule_tac y="b" in lam_exhaust)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   560
apply simp_all
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   561
apply auto
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   562
apply meson
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   563
apply(simp_all add: lam_inject')
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   564
apply metis
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   565
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   566
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   567
termination hom
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   568
  apply -
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   569
(*
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   570
ML_prf {* Size.size_thms @{theory} "LamEx.lam" *}
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   571
*)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   572
sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   573
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   574
thm hom.simps
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   575
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   576
lemma term1_hom_rsp:
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   577
  "\<lbrakk>(alpha ===> alpha ===> op =) f_app f_app; ((op = ===> alpha) ===> op =) f_lam f_lam\<rbrakk>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   578
       \<Longrightarrow> (alpha ===> op =) (term1_hom f_var f_app f_lam) (term1_hom f_var f_app f_lam)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   579
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   580
apply(rule allI)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   581
apply(rule impI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   582
apply(erule alpha.induct)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   583
apply(auto)[1]
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   584
apply(auto)[1]
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   585
apply(simp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   586
apply(erule conjE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   587
apply(erule exE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   588
apply(erule conjE)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   589
apply(clarify)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   590
sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   591
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   592
lemma hom: "
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   593
\<forall>f_var. \<forall>f_app \<in> Respects(alpha ===> alpha ===> op =).
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   594
\<forall>f_lam \<in> Respects((op = ===> alpha) ===> op =).
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   595
\<exists>hom\<in>Respects (alpha ===> op =). 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   596
    ((\<forall>x. hom (rVar x) = f_var x) \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   597
     (\<forall>l r. hom (rApp l r) = f_app l r (hom l) (hom r)) \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   598
     (\<forall>x a. hom (rLam a x) = f_lam (\<lambda>b. ([(a,b)]\<bullet> x)) (\<lambda>b. hom ([(a,b)] \<bullet> x))))"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   599
apply(rule allI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   600
apply(rule ballI)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   601
apply(rule_tac x="term1_hom f_var f_app f_lam" in bexI)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   602
apply(simp_all)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   603
apply(simp only: in_respects)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   604
apply(rule term1_hom_rsp)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   605
apply(assumption)+
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   606
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   607
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   608
lemma hom':
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   609
"\<exists>hom.
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   610
  ((\<forall>x. hom (Var x) = f_var x) \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   611
   (\<forall>l r. hom (App l r) = f_app l r (hom l) (hom r)) \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   612
   (\<forall>x a. hom (Lam a x) = f_lam (\<lambda>b. ([(a,b)] \<bullet> x)) (\<lambda>b. hom ([(a,b)] \<bullet> x))))"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   613
apply (lifting hom)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   614
done
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   615
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   616
(* test test
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   617
lemma raw_hom_correct: 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   618
  assumes f1: "f_var \<in> Respects (op= ===> op=)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   619
  and     f2: "f_app \<in> Respects (alpha ===> alpha ===> op= ===> op= ===> op=)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   620
  and     f3: "f_lam \<in> Respects ((op= ===> alpha) ===> (op= ===> op=) ===> op=)"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   621
  shows "\<exists>!hom\<in>Respects (alpha ===> op =). 
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   622
    ((\<forall>x. hom (rVar x) = f_var x) \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   623
     (\<forall>l r. hom (rApp l r) = f_app l r (hom l) (hom r)) \<and>
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   624
     (\<forall>x a. hom (rLam a x) = f_lam (\<lambda>b. ([(a,b)]\<bullet> x)) (\<lambda>b. hom ([(a,b)] \<bullet> x))))"
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   625
unfolding Bex1_def
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   626
apply(rule ex1I)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   627
sorry
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   628
*)
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   629
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   630
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   631
end
1dd314a00b0c Fixed wrong rename.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   632