Nominal/Ex/Classical_Test.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Mon, 27 Jun 2011 08:38:54 +0900
changeset 2905 9448945a1e60
permissions -rw-r--r--
New-style fcb for multiple binders.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2905
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory Classical
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
imports "../Nominal2"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
lemma supp_zero_perm_zero:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
  shows "supp (p :: perm) = {} \<longleftrightarrow> p = 0"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
  by (metis supp_perm_singleton supp_zero_perm)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
lemma permute_atom_list_id:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
  shows "p \<bullet> l = l \<longleftrightarrow> supp p \<inter> set l = {}"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
  by (induct l) (auto simp add: supp_Nil supp_perm)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
lemma permute_length_eq:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  shows "p \<bullet> xs = ys \<Longrightarrow> length xs = length ys"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  by (auto simp add: length_eqvt[symmetric] permute_pure)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
lemma Abs_lst_binder_length:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  shows "[xs]lst. T = [ys]lst. S \<Longrightarrow> length xs = length ys"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  by (auto simp add: Abs_eq_iff alphas length_eqvt[symmetric] permute_pure)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
lemma Abs_lst_binder_eq:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  shows "Abs_lst l T = Abs_lst l S \<longleftrightarrow> T = S"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  by (rule, simp_all add: Abs_eq_iff2 alphas)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
     (metis fresh_star_zero inf_absorb1 permute_atom_list_id supp_perm_eq
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
       supp_zero_perm_zero)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
lemma in_permute_list:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  shows "py \<bullet> p \<bullet> xs = px \<bullet> xs \<Longrightarrow>  x \<in> set xs \<Longrightarrow> py \<bullet> p \<bullet> x = px \<bullet> x"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  by (induct xs) auto
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
lemma obtain_atom_list:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
  assumes eq: "p \<bullet> xs = ys"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
      and fin: "finite (supp c)"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
      and sorts: "map sort_of xs = map sort_of ys"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
  shows "\<exists>ds px py. (set ds \<sharp>* c) \<and> (px \<bullet> xs = ds) \<and> (py \<bullet> ys = ds)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
    \<and> (supp px - set xs) \<sharp>* c \<and> (supp py - set ys) \<sharp>* c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  sorry
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
lemma Abs_lst_fcb2:
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  fixes S T :: "'b :: fs"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
    and c::"'c::fs"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  assumes e: "[xs]lst. T = [ys]lst. S"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  and sorts: "map sort_of xs = map sort_of ys"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
  and fcb1: "\<And>x. x \<in> set xs \<Longrightarrow> x \<sharp> f xs T c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  and fcb2: "\<And>x. x \<in> set ys \<Longrightarrow> x \<sharp> f ys S c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  and fresh: "(set xs \<union> set ys) \<sharp>* c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
  and perm1: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f xs T c) = f (p \<bullet> xs) (p \<bullet> T) c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  and perm2: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f ys S c) = f (p \<bullet> ys) (p \<bullet> S) c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  shows "f xs T c = f ys S c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
proof -
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  have fin1: "finite (supp (f xs T c))"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
    apply(rule_tac S="supp (xs, T, c)" in supports_finite)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
    apply(simp add: supports_def)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
    apply(simp add: fresh_def[symmetric])
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
    apply(clarify)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
    apply(subst perm1)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
    apply(simp add: supp_swap fresh_star_def)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
    apply(simp add: swap_fresh_fresh fresh_Pair)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
    apply(simp add: finite_supp)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
    done
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  have fin2: "finite (supp (f ys S c))"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
    apply(rule_tac S="supp (ys, S, c)" in supports_finite)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
    apply(simp add: supports_def)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
    apply(simp add: fresh_def[symmetric])
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
    apply(clarify)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
    apply(subst perm2)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
    apply(simp add: supp_swap fresh_star_def)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
    apply(simp add: swap_fresh_fresh fresh_Pair)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
    apply(simp add: finite_supp)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
    done
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  obtain p :: perm where xs_ys: "p \<bullet> xs = ys" using e
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
    by (auto simp add: Abs_eq_iff alphas)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
  obtain ds::"atom list" and px and py
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
    where fr: "set ds \<sharp>* (xs, ys, S, T, c, f xs T c, f ys S c)"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
    and pxd: "px \<bullet> xs = ds"     and pyd: "py \<bullet> ys = ds"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
    and spx: "(supp px - set xs) \<sharp>* (xs, ys, S, T, c, f xs T c, f ys S c)"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
    and spy: "(supp py - set ys) \<sharp>* (xs, ys, S, T, c, f xs T c, f ys S c)"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
    using obtain_atom_list[OF xs_ys, of "(xs, ys, S, T, c, f xs T c, f ys S c)"]
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
    sorts by (auto simp add: finite_supp supp_Pair fin1 fin2)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
  have "px \<bullet> (Abs_lst xs T) = py \<bullet> (Abs_lst ys S)"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
    apply (subst perm_supp_eq)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
    using spx apply (auto simp add: fresh_star_def Abs_fresh_iff)[1]
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
    apply (subst perm_supp_eq)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
    using spy apply (auto simp add: fresh_star_def Abs_fresh_iff)[1]
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
    by(rule e)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
  then have "Abs_lst ds (px \<bullet> T) = Abs_lst ds (py \<bullet> S)" by (simp add: pxd pyd)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
  then have eq: "px \<bullet> T = py \<bullet> S" by (simp add: Abs_lst_binder_eq)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
  have "f xs T c = px \<bullet> f xs T c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
    apply(rule perm_supp_eq[symmetric])
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
    using spx unfolding fresh_star_def
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
    apply (intro ballI)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
    by (case_tac "a \<in> set xs") (simp_all add: fcb1)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
  also have "... = f (px \<bullet> xs) (px \<bullet> T) c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
    apply(rule perm1)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
    using spx fresh unfolding fresh_star_def
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
    apply (intro ballI)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
    by (case_tac "a \<in> set xs") (simp_all add: fcb1)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  also have "... = f (py \<bullet> ys) (py \<bullet> S) c" using eq pxd pyd by simp
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
  also have "... = py \<bullet> f ys S c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
    apply(rule perm2[symmetric])
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
    using spy fresh unfolding fresh_star_def
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
    apply (intro ballI)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
    by (case_tac "a \<in> set ys") (simp_all add: fcb1)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  also have "... = f ys S c"
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
    apply(rule perm_supp_eq)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
    using spy unfolding fresh_star_def
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
    apply (intro ballI)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
    by (case_tac "a \<in> set ys") (simp_all add: fcb2)
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  finally show ?thesis by simp
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
qed
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
end
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
9448945a1e60 New-style fcb for multiple binders.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115