Nominal/Ex/SFT/Consts.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 24 Jun 2011 10:30:06 +0900
changeset 2893 589b1a0c75e6
child 2898 a95a497e1f4f
permissions -rw-r--r--
Second Fixed Point Theorem
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
header {* Constant definitions *}
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
theory Consts imports Utils Lambda begin
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
fun Umn :: "nat \<Rightarrow> nat \<Rightarrow> lam"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
where
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
  [simp del]: "Umn 0 n = \<integral>(cn 0). V (cn n)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
| [simp del]: "Umn (Suc m) n = \<integral>(cn (Suc m)). Umn m n"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
lemma [simp]: "2 = Suc 1"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
  by auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
lemma Lam_U:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
  "x \<noteq> y \<Longrightarrow> y \<noteq> z \<Longrightarrow> x \<noteq> z \<Longrightarrow> Umn 2 0 = \<integral>x. \<integral>y. \<integral>z. V z"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  "x \<noteq> y \<Longrightarrow> y \<noteq> z \<Longrightarrow> x \<noteq> z \<Longrightarrow> Umn 2 1 = \<integral>x. \<integral>y. \<integral>z. V y"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  "x \<noteq> y \<Longrightarrow> y \<noteq> z \<Longrightarrow> x \<noteq> z \<Longrightarrow> Umn 2 2 = \<integral>x. \<integral>y. \<integral>z. V x"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  apply (simp_all add: Umn.simps Abs1_eq_iff lam.fresh fresh_at_base flip_def[symmetric] Umn.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  apply (smt Zero_not_Suc cnd flip_at_base_simps flip_at_simps)+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
lemma a: "n \<le> m \<Longrightarrow> atom (cn n) \<notin> supp (Umn m n)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  apply (induct m)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  apply (auto simp add: lam.supp supp_at_base Umn.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  by smt
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
lemma b: "supp (Umn m n) \<subseteq> {atom (cn n)}"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  by (induct m) (auto simp add: lam.supp supp_at_base Umn.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
lemma supp_U[simp]: "n \<le> m \<Longrightarrow> supp (Umn m n) = {}"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  using a b
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
lemma U_eqvt:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
  "n \<le> m \<Longrightarrow> p \<bullet> (Umn m n) = Umn m n"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  by (rule_tac [!] perm_supp_eq) (simp_all add: fresh_star_def fresh_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
definition Var where "Var \<equiv> \<integral>cx. \<integral>cy. (V cy \<cdot> (Umn 2 2) \<cdot> V cx \<cdot> V cy)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
definition "App \<equiv> \<integral>cx. \<integral>cy. \<integral>cz. (V cz \<cdot> Umn 2 1 \<cdot> V cx \<cdot> V cy \<cdot> V cz)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
definition "Abs \<equiv> \<integral>cx. \<integral>cy. (V cy \<cdot> Umn 2 0 \<cdot> V cx \<cdot> V cy)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
lemma Var_App_Abs:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  "x \<noteq> e \<Longrightarrow> Var = \<integral>x. \<integral>e. (V e \<cdot> Umn 2 2 \<cdot> V x \<cdot> V e)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  "e \<noteq> x \<Longrightarrow> e \<noteq> y \<Longrightarrow> x \<noteq> y \<Longrightarrow> App = \<integral>x. \<integral>y. \<integral>e. (V e \<cdot> Umn 2 1 \<cdot> V x \<cdot> V y \<cdot> V e)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  "x \<noteq> e \<Longrightarrow> Abs = \<integral>x. \<integral>e. (V e \<cdot> Umn 2 0 \<cdot> V x \<cdot> V e)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
  unfolding Var_def App_def Abs_def
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  by (simp_all add: Abs1_eq_iff lam.fresh flip_def[symmetric] U_eqvt fresh_def lam.supp supp_at_base)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
     (smt cx_cy_cz permute_flip_at Zero_not_Suc cnd flip_at_base_simps flip_at_simps)+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
lemma Var_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  "Var \<cdot> x \<cdot> e \<approx> e \<cdot> Umn 2 2 \<cdot> x \<cdot> e"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
  by (rule lam2_fast_app) (simp_all add: Var_App_Abs)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
lemma App_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
  "App \<cdot> x \<cdot> y \<cdot> e \<approx> e \<cdot> Umn 2 1 \<cdot> x \<cdot> y \<cdot> e"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
  by (rule lam3_fast_app[OF Var_App_Abs(2)]) (simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
lemma Abs_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  "Abs \<cdot> x \<cdot> e \<approx> e \<cdot> Umn 2 0 \<cdot> x \<cdot> e"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
  by (rule lam2_fast_app) (simp_all add: Var_App_Abs)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
lemma supp_Var_App_Abs[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  "supp Var = {}" "supp App = {}" "supp Abs = {}"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
  by (simp_all add: Var_def App_def Abs_def lam.supp supp_at_base) blast+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
lemma Var_App_Abs_eqvt[eqvt]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  "p \<bullet> Var = Var" "p \<bullet> App = App" "p \<bullet> Abs = Abs"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
  by (rule_tac [!] perm_supp_eq) (simp_all add: fresh_star_def fresh_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
nominal_primrec
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  Numeral :: "lam \<Rightarrow> lam" ("\<lbrace>_\<rbrace>" 1000)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
where
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  "\<lbrace>V x\<rbrace> = Var \<cdot> (V x)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
| Ap: "\<lbrace>M \<cdot> N\<rbrace> = App \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
| "\<lbrace>\<integral>x. M\<rbrace> = Abs \<cdot> (\<integral>x. \<lbrace>M\<rbrace>)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
proof auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  fix x :: lam and P
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
  assume "\<And>xa. x = V xa \<Longrightarrow> P" "\<And>M N. x = M \<cdot> N \<Longrightarrow> P" "\<And>xa M. x = \<integral> xa. M \<Longrightarrow> P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
  then show "P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
    by (rule_tac y="x" and c="0 :: perm" in lam.strong_exhaust)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
       (auto simp add: Abs1_eq_iff fresh_star_def)[3]
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
next
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
  fix x :: var and M and xa :: var and Ma
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
  assume "[[atom x]]lst. M = [[atom xa]]lst. Ma"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
    "eqvt_at Numeral_sumC M"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
  then show "[[atom x]]lst. Numeral_sumC M = [[atom xa]]lst. Numeral_sumC Ma"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
    apply -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
    apply (erule Abs_lst1_fcb)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
    apply (simp_all add: Abs_fresh_iff)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
    apply (erule fresh_eqvt_at)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
    apply (simp_all add: finite_supp Abs1_eq_iff eqvt_at_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
    done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
next
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
  show "eqvt Numeral_graph" unfolding eqvt_def Numeral_graph_def
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
    by (rule, perm_simp, rule)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
termination
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
  by (relation "measure (\<lambda>(t). size t)")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
     (simp_all add: lam.size)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
lemma numeral_eqvt[eqvt]: "p \<bullet> \<lbrace>x\<rbrace> = \<lbrace>p \<bullet> x\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
  by (induct x rule: lam.induct)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
     (simp_all add: Var_App_Abs_eqvt)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
lemma supp_numeral[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
  "supp \<lbrace>x\<rbrace> = supp x"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
  by (induct x rule: lam.induct)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
     (simp_all add: lam.supp)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
lemma fresh_numeral[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
  "x \<sharp> \<lbrace>y\<rbrace> = x \<sharp> y"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
  unfolding fresh_def by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
fun app_lst :: "var \<Rightarrow> lam list \<Rightarrow> lam" where
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
  "app_lst n [] = V n"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
| "app_lst n (h # t) = Ap (app_lst n t) h"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
lemma app_lst_eqvt[eqvt]: "p \<bullet> (app_lst t ts) = app_lst (p \<bullet> t) (p \<bullet> ts)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
  by (induct ts arbitrary: t p) (simp_all add: eqvts)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
lemma supp_app_lst: "supp (app_lst x l) = {atom x} \<union> supp l"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
  apply (induct l)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
  apply (simp_all add: supp_Nil lam.supp supp_at_base supp_Cons)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
  by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
lemma app_lst_eq_iff: "app_lst n M = app_lst n N \<Longrightarrow> M = N"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
  by (induct M N rule: list_induct2') simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
lemma app_lst_rev_eq_iff: "app_lst n (rev M) = app_lst n (rev N) \<Longrightarrow> M = N"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
  by (drule app_lst_eq_iff) simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
nominal_primrec
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
  Ltgt :: "lam list \<Rightarrow> lam" ("\<guillemotleft>_\<guillemotright>" 1000)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
where
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
  [simp del]: "atom x \<sharp> l \<Longrightarrow> \<guillemotleft>l\<guillemotright> = \<integral>x. (app_lst x (rev l))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
  unfolding eqvt_def Ltgt_graph_def
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
  apply (rule, perm_simp, rule, rule)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  apply (rule_tac x="x" and ?'a="var" in obtain_fresh)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
  apply (simp_all add: Abs1_eq_iff lam.fresh swap_fresh_fresh fresh_at_base)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
  apply (simp add: eqvts swap_fresh_fresh)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
  apply (case_tac "x = xa")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
  apply simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
  apply (subgoal_tac "eqvt app_lst")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
  apply (erule fresh_fun_eqvt_app2)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
  apply (simp_all add: fresh_at_base lam.fresh eqvt_def eqvts_raw fresh_rev)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
termination
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
  by (relation "measure (\<lambda>t. size t)")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
     (simp_all add: lam.size)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
lemma ltgt_eqvt[eqvt]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
  "p \<bullet> \<guillemotleft>t\<guillemotright> = \<guillemotleft>p \<bullet> t\<guillemotright>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
  obtain x :: var where "atom x \<sharp> (t, p \<bullet> t)" using obtain_fresh by auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
  then have *: "atom x \<sharp> t" "atom x \<sharp> (p \<bullet> t)" using fresh_Pair by simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
  then show ?thesis using *[unfolded fresh_def]
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
    apply (simp add: Abs1_eq_iff lam.fresh app_lst_eqvt Ltgt.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
    apply (case_tac "p \<bullet> x = x")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
    apply (simp_all add: eqvts)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
    apply rule
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   161
    apply (subst swap_fresh_fresh)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
    apply (simp_all add: fresh_at_base_permute_iff fresh_def[symmetric] fresh_at_base)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
    apply (subgoal_tac "eqvt app_lst")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
    apply (erule fresh_fun_eqvt_app2)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
    apply (simp_all add: fresh_at_base lam.fresh eqvt_def eqvts_raw fresh_rev)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
    done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
lemma ltgt_eq_iff[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
  "\<guillemotleft>M\<guillemotright> = \<guillemotleft>N\<guillemotright> \<longleftrightarrow> M = N"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
proof auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
  obtain x :: var where "atom x \<sharp> (M, N)" using obtain_fresh by auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  then have *: "atom x \<sharp> M" "atom x \<sharp> N" using fresh_Pair by simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
  then show "(\<guillemotleft>M\<guillemotright> = \<guillemotleft>N\<guillemotright>) \<Longrightarrow> (M = N)" by (simp add: Abs1_eq_iff app_lst_rev_eq_iff Ltgt.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
lemma Ltgt1_app: "\<guillemotleft>[M]\<guillemotright> \<cdot> N \<approx> N \<cdot> M"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
  obtain x :: var where "atom x \<sharp> (M, N)" using obtain_fresh by auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
  then have "atom x \<sharp> M" "atom x \<sharp> N" using fresh_Pair by simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
  then show ?thesis
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
  apply (subst Ltgt.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
  apply (simp add: fresh_Cons fresh_Nil)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
  apply (rule b3, rule bI, simp add: b1)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
lemma Ltgt3_app: "\<guillemotleft>[M,N,P]\<guillemotright> \<cdot> R \<approx> R \<cdot> M \<cdot> N \<cdot> P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
  obtain x :: var where "atom x \<sharp> (M, N, P, R)" using obtain_fresh by auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
  then have *: "atom x \<sharp> (M,N,P)" "atom x \<sharp> R" using fresh_Pair by simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
  then have s: "V x \<cdot> M \<cdot> N \<cdot> P [x ::= R] \<approx> R \<cdot> M \<cdot> N \<cdot> P" using b1 by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
  show ?thesis using *
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   194
    apply (subst Ltgt.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
  apply (simp add: fresh_Cons fresh_Nil fresh_Pair_elim)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
  apply auto[1]
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
  apply (rule b3, rule bI, simp add: b1)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
lemma supp_ltgt[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
  "supp \<guillemotleft>t\<guillemotright> = supp t"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
  obtain x :: var where *:"atom x \<sharp> t" using obtain_fresh by auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
  show ?thesis using *
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
  by (simp_all add: Ltgt.simps lam.supp supp_at_base supp_Nil supp_app_lst supp_rev fresh_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
lemma fresh_ltgt[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
  "x \<sharp> \<guillemotleft>[y]\<guillemotright> = x \<sharp> y"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   211
  "x \<sharp> \<guillemotleft>[t,r,s]\<guillemotright> = x \<sharp> (t,r,s)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   212
  by (simp_all add: fresh_def supp_Cons supp_Nil supp_Pair)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
lemma Ltgt1_subst[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
  "\<guillemotleft>[M]\<guillemotright> [y ::= A] = \<guillemotleft>[M [y ::= A]]\<guillemotright>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
  obtain x :: var where a: "atom x \<sharp> (M, A, y, M [y ::= A])" using obtain_fresh by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   218
  have "x \<noteq> y" using a[simplified fresh_Pair fresh_at_base] by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   219
  then show ?thesis
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
    apply (subst Ltgt.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   221
    using a apply (simp add: fresh_Nil fresh_Cons fresh_Pair_elim)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
    apply (subst Ltgt.simps)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
    using a apply (simp add: fresh_Pair_elim fresh_Nil fresh_Cons)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
    apply (simp add: a)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
    done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   226
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
lemma U_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
  "\<guillemotleft>[A,B,C]\<guillemotright> \<cdot> Umn 2 2 \<approx> A" "\<guillemotleft>[A,B,C]\<guillemotright> \<cdot> Umn 2 1 \<approx> B" "\<guillemotleft>[A,B,C]\<guillemotright> \<cdot> Umn 2 0 \<approx> C"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   230
  by (rule b3, rule Ltgt3_app, rule lam3_fast_app, rule Lam_U, simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
     (rule b3, rule Ltgt3_app, rule lam3_fast_app, rule Lam_U[simplified], simp_all)+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   232
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
definition "F1 \<equiv> \<integral>cx. (App \<cdot> \<lbrace>Var\<rbrace> \<cdot> (Var \<cdot> V cx))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
definition "F2 \<equiv> \<integral>cx. \<integral>cy. \<integral>cz. ((App \<cdot> (App \<cdot> \<lbrace>App\<rbrace> \<cdot> (V cz \<cdot> V cx))) \<cdot> (V cz \<cdot> V cy))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
definition "F3 \<equiv> \<integral>cx. \<integral>cy. (App \<cdot> \<lbrace>Abs\<rbrace> \<cdot> (Abs \<cdot> (\<integral>cz. (V cy \<cdot> (V cx \<cdot> V cz)))))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
lemma Lam_F:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
  "F1 = \<integral>x. (App \<cdot> \<lbrace>Var\<rbrace> \<cdot> (Var \<cdot> V x))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
  "a \<noteq> b \<Longrightarrow> a \<noteq> c \<Longrightarrow> c \<noteq> b \<Longrightarrow> F2 = \<integral>a. \<integral>b. \<integral>c. ((App \<cdot> (App \<cdot> \<lbrace>App\<rbrace> \<cdot> (V c \<cdot> V a))) \<cdot> (V c \<cdot> V b))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
  "a \<noteq> b \<Longrightarrow> a \<noteq> x \<Longrightarrow> x \<noteq> b \<Longrightarrow> F3 = \<integral>a. \<integral>b. (App \<cdot> \<lbrace>Abs\<rbrace> \<cdot> (Abs \<cdot> (\<integral>x. (V b \<cdot> (V a \<cdot> V x)))))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
  apply (simp_all add: F1_def F2_def F3_def Abs1_eq_iff lam.fresh supp_at_base Var_App_Abs_eqvt numeral_eqvt flip_def[symmetric] fresh_at_base)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
  apply (smt cx_cy_cz permute_flip_at)+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   246
lemma supp_F[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
  "supp F1 = {}" "supp F2 = {}" "supp F3 = {}"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
  by (simp_all add: F1_def F2_def F3_def lam.supp supp_at_base)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
     blast+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   250
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
lemma F_eqvt[eqvt]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   252
  "p \<bullet> F1 = F1" "p \<bullet> F2 = F2" "p \<bullet> F3 = F3"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   253
  by (rule_tac [!] perm_supp_eq)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   254
     (simp_all add: fresh_star_def fresh_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   255
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
lemma F_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
  "F1 \<cdot> A \<approx> App \<cdot> \<lbrace>Var\<rbrace> \<cdot> (Var \<cdot> A)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
  "F2 \<cdot> A \<cdot> B \<cdot> C \<approx> (App \<cdot> (App \<cdot> \<lbrace>App\<rbrace> \<cdot> (C \<cdot> A))) \<cdot> (C \<cdot> B)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
  by (rule lam1_fast_app, rule Lam_F, simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
     (rule lam3_fast_app, rule Lam_F, simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
lemma F3_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
  assumes f: "atom x \<sharp> A" "atom x \<sharp> B" (* or A and B have empty support *)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   264
  shows "F3 \<cdot> A \<cdot> B \<approx> App \<cdot> \<lbrace>Abs\<rbrace> \<cdot> (Abs \<cdot> (\<integral>x. (B \<cdot> (A \<cdot> V x))))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
  obtain y :: var where b: "atom y \<sharp> (x, A, B)" using obtain_fresh by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
  obtain z :: var where c: "atom z \<sharp> (x, y, A, B)" using obtain_fresh by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   268
  have *: "x \<noteq> z" "x \<noteq> y" "y \<noteq> z"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
    using b c by (simp_all add: fresh_Pair fresh_at_base) blast+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
  have **:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
    "atom y \<sharp> z" "atom x \<sharp> z" "atom y \<sharp> x"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
    "atom z \<sharp> y" "atom z \<sharp> x" "atom x \<sharp> y"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
    "atom x \<sharp> A" "atom y \<sharp> A" "atom z \<sharp> A"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
    "atom x \<sharp> B" "atom y \<sharp> B" "atom z \<sharp> B"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   275
    using b c f by (simp_all add: fresh_Pair fresh_at_base) blast+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
  show ?thesis
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
    apply (simp add: Lam_F(3)[of y z x] * *[symmetric])
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
    apply (rule b3) apply (rule b5) apply (rule bI)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   279
    apply (simp add: ** fresh_Pair * *[symmetric])
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   280
    apply (rule b3) apply (rule bI)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
    apply (simp add: ** fresh_Pair * *[symmetric])
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   282
    apply (rule b1)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
    done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   284
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   285
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   286
definition Lam_A1_pre : "A1 \<equiv> \<integral>cx. \<integral>cy. (F1 \<cdot> V cx)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
definition Lam_A2_pre : "A2 \<equiv> \<integral>cx. \<integral>cy. \<integral>cz. (F2 \<cdot> V cx \<cdot> V cy \<cdot> \<guillemotleft>[V cz]\<guillemotright>)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   288
definition Lam_A3_pre : "A3 \<equiv> \<integral>cx. \<integral>cy. (F3 \<cdot> V cx \<cdot> \<guillemotleft>[V cy]\<guillemotright>)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   289
lemma Lam_A:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
  "x \<noteq> y \<Longrightarrow> A1 = \<integral>x. \<integral>y. (F1 \<cdot> V x)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
  "a \<noteq> b \<Longrightarrow> a \<noteq> c \<Longrightarrow> c \<noteq> b \<Longrightarrow> A2 = \<integral>a. \<integral>b. \<integral>c. (F2 \<cdot> V a \<cdot> V b \<cdot> \<guillemotleft>[V c]\<guillemotright>)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   292
  "a \<noteq> b \<Longrightarrow> A3 = \<integral>a. \<integral>b. (F3 \<cdot> V a \<cdot> \<guillemotleft>[V b]\<guillemotright>)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   293
  apply (simp_all add: Lam_A1_pre Lam_A2_pre Lam_A3_pre Abs1_eq_iff lam.fresh supp_at_base Var_App_Abs_eqvt numeral_eqvt flip_def[symmetric] fresh_at_base F_eqvt ltgt_eqvt)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
  apply (smt cx_cy_cz permute_flip_at)+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   295
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   296
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   297
lemma supp_A[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
  "supp A1 = {}" "supp A2 = {}" "supp A3 = {}"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   299
  by (auto simp add: Lam_A1_pre Lam_A2_pre Lam_A3_pre lam.supp supp_at_base supp_Cons supp_Nil)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   300
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   301
lemma A_app:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   302
  "A1 \<cdot> A \<cdot> B \<approx> F1 \<cdot> A"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   303
  "A2 \<cdot> A \<cdot> B \<cdot> C \<approx> F2 \<cdot> A \<cdot> B \<cdot> \<guillemotleft>[C]\<guillemotright>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   304
  "A3 \<cdot> A \<cdot> B \<approx> F3 \<cdot> A \<cdot> \<guillemotleft>[B]\<guillemotright>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   305
  apply (rule lam2_fast_app, rule Lam_A, simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   306
  apply (rule lam3_fast_app, rule Lam_A, simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
  apply (rule lam2_fast_app, rule Lam_A, simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
  done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   310
definition "Num \<equiv> \<guillemotleft>[\<guillemotleft>[A1,A2,A3]\<guillemotright>]\<guillemotright>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
lemma supp_Num[simp]:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
  "supp Num = {}"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   314
  by (auto simp only: Num_def supp_ltgt supp_Pair supp_A supp_Cons supp_Nil)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
end