Nominal/Ex/SFT/Lambda.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Wed, 06 Jul 2011 07:42:12 +0900
changeset 2953 80f01215d1a6
parent 2898 a95a497e1f4f
child 2984 1b39ba5db2c1
permissions -rw-r--r--
Setup eqvt_at for first goal
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 {* Definition of Lambda terms and convertibility *}
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
2898
a95a497e1f4f Make examples work with non-precompiled image
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2894
diff changeset
     3
theory Lambda imports "../../Nominal2" begin
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
lemma [simp]: "supp x = {} \<Longrightarrow> y \<sharp> x"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
  unfolding fresh_def by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
atom_decl var
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
nominal_datatype lam =
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
  V "var"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
| Ap "lam" "lam" (infixl "\<cdot>" 98)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
| Lm x::"var" l::"lam"  bind x in l ("\<integral> _. _" [97, 97] 99)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
nominal_primrec
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  subst :: "lam \<Rightarrow> var \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::= _]" [90, 90, 90] 90)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
where
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  "(V x)[y ::= s] = (if x = y then s else (V x))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
| "(t1 \<cdot> t2)[y ::= s] = (t1[y ::= s]) \<cdot> (t2[y ::= s])"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
| "atom x \<sharp> (y, s) \<Longrightarrow> (\<integral>x. t)[y ::= s] = \<integral>x.(t[y ::= s])"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
proof auto
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  fix a b :: lam and aa :: var and P
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  assume "\<And>x y s. a = V x \<and> aa = y \<and> b = s \<Longrightarrow> P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
    "\<And>t1 t2 y s. a = t1 \<cdot> t2 \<and> aa = y \<and> b = s \<Longrightarrow> P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
    "\<And>x y s t. \<lbrakk>atom x \<sharp> (y, s); a = \<integral> x. t \<and> aa = y \<and> b = s\<rbrakk> \<Longrightarrow> P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  then show "P"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
    by (rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
       (blast, blast, simp add: fresh_star_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
next
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  fix x :: var and t and xa :: var and ya sa ta
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  assume *: "eqvt_at subst_sumC (t, ya, sa)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
    "atom x \<sharp> (ya, sa)" "atom xa \<sharp> (ya, sa)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
    "[[atom x]]lst. t = [[atom xa]]lst. ta"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  then show "[[atom x]]lst. subst_sumC (t, ya, sa) = [[atom xa]]lst. subst_sumC (ta, ya, sa)"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
    apply -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
    apply (erule Abs_lst1_fcb)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
    apply(simp (no_asm) add: Abs_fresh_iff)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
    apply(drule_tac a="atom xa" in fresh_eqvt_at)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
    apply(simp add: finite_supp)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
    apply(simp_all add: fresh_Pair_elim Abs_fresh_iff Abs1_eq_iff)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
    apply(subgoal_tac "(atom x \<rightleftharpoons> atom xa) \<bullet> ya = ya")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
    apply(subgoal_tac "(atom x \<rightleftharpoons> atom xa) \<bullet> sa = sa")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
    apply(simp add: atom_eqvt eqvt_at_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
    apply(rule perm_supp_eq, simp add: supp_swap fresh_star_def fresh_Pair)+
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
    done
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
next
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
  show "eqvt subst_graph" unfolding eqvt_def subst_graph_def
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
    by (rule, perm_simp, rule)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
termination
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
  by (relation "measure (\<lambda>(t,_,_). size t)")
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
     (simp_all add: lam.size)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
2894
8ec94871de1e More usual names for substitution properties
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2893
diff changeset
    55
lemma subst_eqvt[eqvt]:
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  shows "(p \<bullet> t[x ::= s]) = (p \<bullet> t)[(p \<bullet> x) ::= (p \<bullet> s)]"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  by (induct t x s rule: subst.induct) (simp_all)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
2894
8ec94871de1e More usual names for substitution properties
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2893
diff changeset
    59
lemma forget[simp]:
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  by (nominal_induct t avoiding: x s rule: lam.strong_induct)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
     (auto simp add: lam.fresh fresh_at_base)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
2894
8ec94871de1e More usual names for substitution properties
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2893
diff changeset
    64
lemma forget_closed[simp]: "supp t = {} \<Longrightarrow> t[x ::= s] = t"
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  by (simp add: fresh_def)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
2894
8ec94871de1e More usual names for substitution properties
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2893
diff changeset
    67
lemma subst_id[simp]: "M [x ::= V x] = M"
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  by (rule_tac lam="M" and c="x" in lam.strong_induct)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
     (simp_all add: fresh_star_def lam.fresh fresh_Pair)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
inductive
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
  beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (infix "\<approx>" 80)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
where
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  bI: "(\<integral>x. M) \<cdot> N \<approx> M[x ::= N]"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
| b1: "M \<approx> M"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
| b2: "M \<approx> N \<Longrightarrow> N \<approx> M"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
| b3: "M \<approx> N \<Longrightarrow> N \<approx> L \<Longrightarrow> M \<approx> L"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
| b4: "M \<approx> N \<Longrightarrow> Z \<cdot> M \<approx> Z \<cdot> N"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
| b5: "M \<approx> N \<Longrightarrow> M \<cdot> Z \<approx> N \<cdot> Z"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
| b6: "M \<approx> N \<Longrightarrow> \<integral>x. M \<approx> \<integral>x. N"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
lemmas [trans] = b3
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
equivariance beta
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
end