Nominal/Ex/CR.thy
author Cezary Kaliszyk <cezarykaliszyk@gmail.com>
Tue, 27 Mar 2012 14:56:06 +0200
changeset 3140 5179ff4806c5
parent 3090 19f5e7afad89
child 3235 5ebd327ffb96
permissions -rw-r--r--
Define 'aux'
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
(* CR_Takahashi from Nominal1 ported to Nominal2 *)
3090
19f5e7afad89 fixed problem with equivariance for beta_star
Christian Urban <urbanc@in.tum.de>
parents: 3086
diff changeset
     2
theory CR 
19f5e7afad89 fixed problem with equivariance for beta_star
Christian Urban <urbanc@in.tum.de>
parents: 3086
diff changeset
     3
imports "../Nominal2" 
19f5e7afad89 fixed problem with equivariance for beta_star
Christian Urban <urbanc@in.tum.de>
parents: 3086
diff changeset
     4
begin
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
atom_decl name
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
nominal_datatype lam =
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
  Var "name"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
| App "lam" "lam"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
| Lam x::"name" l::"lam"  binds x in l ("Lam [_]. _" [100, 100] 100)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
nominal_primrec
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::= _]" [90, 90, 90] 90)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
where
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  "(Var x)[y ::= s] = (if x = y then s else (Var x))"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  unfolding eqvt_def subst_graph_def
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  apply (rule, perm_simp, rule)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  apply(rule TrueI)
3086
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
    22
  apply(auto)
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  apply(blast)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  apply(simp_all add: fresh_star_def fresh_Pair_elim)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  apply(simp_all add: Abs_fresh_iff)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  apply(simp add: fresh_star_def fresh_Pair)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  done
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
termination (eqvt)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  by lexicographic_order
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
lemma forget:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  by (nominal_induct t avoiding: x s rule: lam.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
     (auto simp add: lam.fresh fresh_at_base)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
lemma fresh_fact:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  fixes z::"name"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  assumes a: "atom z \<sharp> s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
      and b: "z = y \<or> atom z \<sharp> t"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  shows "atom z \<sharp> t[y ::= s]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  using a b
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
  by (nominal_induct t avoiding: z y s rule: lam.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
     (auto simp add: lam.fresh fresh_at_base)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
lemma substitution_lemma:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  assumes a: "x \<noteq> y" "atom x \<sharp> u"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
  shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
  by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
     (auto simp add: fresh_fact forget)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
lemma subst_rename:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
  assumes a: "atom y \<sharp> t"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
  shows "t[x ::= s] = ((y \<leftrightarrow> x) \<bullet>t)[y ::= s]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  by (nominal_induct t avoiding: x y s rule: lam.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
     (auto simp add: lam.fresh fresh_at_base)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
lemma supp_subst:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  shows "supp (t[x ::= s]) \<subseteq> (supp t - {atom x}) \<union> supp s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
  by (induct t x s rule: subst.induct) (auto simp add: lam.supp supp_at_base)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
inductive
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b _" [80,80] 80)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
where
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  b1[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> App t1 s \<longrightarrow>b App t2 s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
| b2[intro]: "s1 \<longrightarrow>b s2 \<Longrightarrow> App t s1 \<longrightarrow>b App t s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
| b3[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> Lam [x]. t1 \<longrightarrow>b Lam [x]. t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
| b4[intro]: "atom x \<sharp> s \<Longrightarrow> App (Lam [x]. t) s \<longrightarrow>b t[x ::= s]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
equivariance beta
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
nominal_inductive beta
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
  avoids b3: x
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
       | b4: x
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
  by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
section {* Transitive Closure of Beta *}
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
inductive
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
  beta_star :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b* _" [80,80] 80)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
where
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
  bs1[intro, simp]: "M \<longrightarrow>b* M"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
| bs2[intro]: "\<lbrakk>M1\<longrightarrow>b* M2; M2 \<longrightarrow>b M3\<rbrakk> \<Longrightarrow> M1 \<longrightarrow>b* M3"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
3090
19f5e7afad89 fixed problem with equivariance for beta_star
Christian Urban <urbanc@in.tum.de>
parents: 3086
diff changeset
    91
equivariance beta_star
19f5e7afad89 fixed problem with equivariance for beta_star
Christian Urban <urbanc@in.tum.de>
parents: 3086
diff changeset
    92
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
lemma bs3[intro, trans]:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
  assumes "A \<longrightarrow>b* B"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
  and     "B \<longrightarrow>b* C"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
  shows   "A \<longrightarrow>b* C"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
  using assms(2) assms(1)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  by induct auto
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
section {* One-Reduction *}
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
inductive
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  One :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>1 _" [80,80] 80)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
where
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
  o1[intro]: "Var x \<longrightarrow>1 Var x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
| o2[intro]: "\<lbrakk>t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>1 App t2 s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
| o3[intro]: "t1 \<longrightarrow>1 t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>1 Lam [x].t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
| o4[intro]: "\<lbrakk>atom x \<sharp> (s1, s2); t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
equivariance One
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
nominal_inductive One
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
  avoids o3: "x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
      |  o4: "x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
  by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
lemma One_refl:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
  shows "t \<longrightarrow>1 t"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
  by (nominal_induct t rule: lam.strong_induct) (auto)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
lemma One_subst:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
  assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
  shows "t1[x ::= s1] \<longrightarrow>1 t2[x ::= s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
  by (nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
     (auto simp add: substitution_lemma fresh_at_base fresh_fact fresh_Pair)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
lemma better_o4_intro:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
  assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
  shows "App (Lam [x]. t1) s1 \<longrightarrow>1 t2[ x ::= s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
proof -
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
  obtain y::"name" where fs: "atom y \<sharp> (x, t1, s1, t2, s2)" by (rule obtain_fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
  have "App (Lam [x]. t1) s1 = App (Lam [y]. ((y \<leftrightarrow> x) \<bullet> t1)) s1" using fs
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
    by (auto simp add: lam.eq_iff Abs1_eq_iff' flip_def fresh_Pair fresh_at_base)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
  also have "\<dots> \<longrightarrow>1 ((y \<leftrightarrow> x) \<bullet> t2)[y ::= s2]" using fs a by (auto simp add: One.eqvt)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
  also have "\<dots> = t2[x ::= s2]" using fs by (simp add: subst_rename[symmetric])
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  finally show "App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]" by simp
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
qed
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
lemma One_Var:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
  assumes a: "Var x \<longrightarrow>1 M"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
  shows "M = Var x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
  using a by (cases rule: One.cases) (simp_all)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
lemma One_Lam:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
  assumes a: "Lam [x].t \<longrightarrow>1 s" "atom x \<sharp> s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
  shows "\<exists>t'. s = Lam [x].t' \<and> t \<longrightarrow>1 t'"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
  apply (cases rule: One.cases)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
  apply (auto simp add: Abs1_eq_iff)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
  apply (rule_tac x="(atom xa \<rightleftharpoons> atom x) \<bullet> t2" in exI)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
  apply (auto simp add: fresh_permute_left lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
  by (metis swap_commute One.eqvt)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
lemma One_App:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
  assumes a: "App t s \<longrightarrow>1 r"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
  shows "(\<exists>t' s'. r = App t' s' \<and> t \<longrightarrow>1 t' \<and> s \<longrightarrow>1 s') \<or>
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
         (\<exists>x p p' s'. r = p'[x ::= s'] \<and> t = Lam [x].p \<and> p \<longrightarrow>1 p' \<and> s \<longrightarrow>1 s' \<and> atom x \<sharp> (s,s'))"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
  using a by (cases rule: One.cases) auto
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   161
lemma One_preserves_fresh:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
  fixes x::"name"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  assumes a: "M \<longrightarrow>1 N"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
  shows "atom x \<sharp> M \<Longrightarrow> atom x \<sharp> N"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
  by (induct, auto simp add: lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
     (metis fresh_fact)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
(* TODO *)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
lemma One_strong_cases[consumes 1]:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
  "\<lbrakk> a1 \<longrightarrow>1 a2; \<And>x. \<lbrakk>a1 = Var x; a2 = Var x\<rbrakk> \<Longrightarrow> P;
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
 \<And>t1 t2 s1 s2. \<lbrakk>a1 = App t1 s1; a2 = App t2 s2;  t1 \<longrightarrow>1 t2;  s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> P;
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
 \<And>t1 t2. (\<lbrakk>atom xa \<sharp> a1; atom xa \<sharp> a2\<rbrakk> \<Longrightarrow> a1 = Lam [xa].t1 \<and> a2 = Lam [xa].t2 \<and>  t1 \<longrightarrow>1 t2) \<Longrightarrow> P;
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
 \<And>s1 s2 t1 t2.
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
    (\<lbrakk>atom xaa \<sharp> a1; atom xaa \<sharp> a2\<rbrakk>
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
     \<Longrightarrow> a1 = App (Lam [xaa].t1) s1 \<and> a2 = t2[xaa::=s2] \<and> atom xaa \<sharp> (s1, s2) \<and>  t1 \<longrightarrow>1 t2 \<and>  s1 \<longrightarrow>1 s2) \<Longrightarrow>
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
    P\<rbrakk>
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
  \<Longrightarrow> P"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
  apply (nominal_induct avoiding: a1 a2 rule: One.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
  apply blast
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
  apply blast
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
  apply (simp add: fresh_Pair_elim Abs1_eq_iff lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
  apply (case_tac "xa = x")
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
  apply (simp_all)[2]
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
  apply blast
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
  apply (rotate_tac 6)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
  apply (drule_tac x="(atom x \<rightleftharpoons> atom xa) \<bullet> t1" in meta_spec)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
  apply (rotate_tac -1)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
  apply (drule_tac x="(atom x \<rightleftharpoons> atom xa) \<bullet> t2" in meta_spec)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
  apply (simp add: One.eqvt fresh_permute_left)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
  apply (simp add: fresh_Pair_elim Abs1_eq_iff lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
  apply (case_tac "xaa = x")
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
  apply (simp_all add: fresh_Pair)[2]
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   194
  apply blast
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
  apply (rotate_tac -2)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
  apply (drule_tac x="s1" in meta_spec)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
  apply (rotate_tac -1)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
  apply (drule_tac x="s2" in meta_spec)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
  apply (rotate_tac -1)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
  apply (drule_tac x="(atom x \<rightleftharpoons> atom xaa) \<bullet> t1" in meta_spec)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
  apply (rotate_tac -1)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
  apply (drule_tac x="(atom x \<rightleftharpoons> atom xaa) \<bullet> t2" in meta_spec)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
  apply (rotate_tac -1)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
  apply (simp add: One_preserves_fresh fresh_permute_left One.eqvt)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
  by (metis Nominal2_Base.swap_commute One_preserves_fresh flip_def subst_rename)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
lemma One_Redex:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
  assumes a: "App (Lam [x].t) s \<longrightarrow>1 r" "atom x \<sharp> (s,r)"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
  shows "(\<exists>t' s'. r = App (Lam [x].t') s' \<and> t \<longrightarrow>1 t' \<and> s \<longrightarrow>1 s') \<or>
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
         (\<exists>t' s'. r = t'[x ::= s'] \<and> t \<longrightarrow>1 t' \<and> s \<longrightarrow>1 s')"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   211
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   212
  by (cases rule: One_strong_cases)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
     (auto dest!: One_Lam simp add: fresh_Pair lam.fresh Abs1_eq_iff)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
inductive
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
  One_star :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>1* _" [80,80] 80)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
where
3086
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   218
  os1[intro, simp]: "t \<longrightarrow>1* t"
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   219
| os2[intro]: "t \<longrightarrow>1* r \<Longrightarrow> r \<longrightarrow>1 s \<Longrightarrow> t \<longrightarrow>1* s"
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   220
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   221
lemma os3[intro, trans]:
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   222
  assumes a1: "M1 \<longrightarrow>1* M2"
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   223
  and     a2: "M2 \<longrightarrow>1* M3"
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   224
  shows "M1 \<longrightarrow>1* M3"
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   225
  using a2 a1
3750c08f627e Remove transitivity from the definition of One_star and show it instead.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3085
diff changeset
   226
  by induct auto
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
section {* Complete Development Reduction *}
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   230
inductive
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
  Dev :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>d _" [80,80] 80)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   232
where
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
  d1[intro]: "Var x \<longrightarrow>d Var x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
| d2[intro]: "t \<longrightarrow>d s \<Longrightarrow> Lam [x].t \<longrightarrow>d Lam[x].s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
| d3[intro]: "\<lbrakk>\<not>(\<exists>y t'. t1 = Lam [y].t'); t1 \<longrightarrow>d t2; s1 \<longrightarrow>d s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>d App t2 s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
| d4[intro]: "\<lbrakk>atom x \<sharp> (s1,s2); t1 \<longrightarrow>d t2; s1 \<longrightarrow>d s2\<rbrakk> \<Longrightarrow> App (Lam [x].t1) s1 \<longrightarrow>d t2[x::=s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
equivariance Dev
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
nominal_inductive Dev
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
  avoids d2: "x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
      |  d4: "x"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
  by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
lemma better_d4_intro:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
  assumes a: "t1 \<longrightarrow>d t2" "s1 \<longrightarrow>d s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   246
  shows "App (Lam [x].t1) s1 \<longrightarrow>d t2[x::=s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
proof -
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
  obtain y::"name" where fs: "atom y\<sharp>(x,t1,s1,t2,s2)" by (rule obtain_fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
  have "App (Lam [x].t1) s1 = App (Lam [y].((y \<leftrightarrow> x)\<bullet>t1)) s1" using fs
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   250
    by (auto simp add: Abs1_eq_iff' flip_def fresh_Pair fresh_at_base)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
  also have "\<dots> \<longrightarrow>d  ((y \<leftrightarrow> x) \<bullet> t2)[y ::= s2]" using fs a by (auto simp add: Dev.eqvt)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   252
  also have "\<dots> = t2[x::=s2]" using fs by (simp add: subst_rename[symmetric])
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   253
  finally show "App (Lam [x].t1) s1 \<longrightarrow>d t2[x::=s2]" by simp
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   254
qed
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   255
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
lemma Dev_preserves_fresh:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
  fixes x::"name"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
  assumes a: "M\<longrightarrow>d N"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
  shows "atom x\<sharp>M \<Longrightarrow> atom x\<sharp>N"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
  using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
  by (induct, auto simp add: lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
     (metis fresh_fact)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   264
lemma Dev_Lam:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
  assumes a: "Lam [x].M \<longrightarrow>d N"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
  shows "\<exists>N'. N = Lam [x].N' \<and> M \<longrightarrow>d N'"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
proof -
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   268
  from a have "atom x \<sharp> Lam [x].M" by (simp add: lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
  with a have "atom x \<sharp> N" by (simp add: Dev_preserves_fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
  with a show "\<exists>N'. N = Lam [x].N' \<and> M \<longrightarrow>d N'"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
    apply (cases rule: Dev.cases)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
    apply (auto simp add: Abs1_eq_iff lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
    apply (rule_tac x="(atom xa \<rightleftharpoons> atom x) \<bullet> s" in exI)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
    apply (auto simp add: fresh_permute_left lam.fresh)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   275
    by (metis swap_commute Dev.eqvt)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
qed
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
lemma Development_existence:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   279
  shows "\<exists>M'. M \<longrightarrow>d M'"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   280
by (nominal_induct M rule: lam.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
   (auto dest!: Dev_Lam intro: better_d4_intro)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   282
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
lemma Triangle:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   284
  assumes a: "t \<longrightarrow>d t1" "t \<longrightarrow>1 t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   285
  shows "t2 \<longrightarrow>1 t1"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   286
using a
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
proof(nominal_induct avoiding: t2 rule: Dev.strong_induct)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   288
  case (d4 x s1 s2 t1 t1' t2)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   289
  have  fc: "atom x\<sharp>t2" "atom x\<sharp>s1" by fact+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
  have "App (Lam [x].t1) s1 \<longrightarrow>1 t2" by fact
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
  then obtain t' s' where reds:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   292
             "(t2 = App (Lam [x].t') s' \<and> t1 \<longrightarrow>1 t' \<and> s1 \<longrightarrow>1 s') \<or>
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   293
              (t2 = t'[x::=s'] \<and> t1 \<longrightarrow>1 t' \<and> s1 \<longrightarrow>1 s')"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
  using fc by (auto dest!: One_Redex)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   295
  have ih1: "t1 \<longrightarrow>1 t' \<Longrightarrow>  t' \<longrightarrow>1 t1'" by fact
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   296
  have ih2: "s1 \<longrightarrow>1 s' \<Longrightarrow>  s' \<longrightarrow>1 s2" by fact
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   297
  { assume "t1 \<longrightarrow>1 t'" "s1 \<longrightarrow>1 s'"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
    then have "App (Lam [x].t') s' \<longrightarrow>1 t1'[x::=s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   299
      using ih1 ih2 by (auto intro: better_o4_intro)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   300
  }
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   301
  moreover
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   302
  { assume "t1 \<longrightarrow>1 t'" "s1 \<longrightarrow>1 s'"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   303
    then have "t'[x::=s'] \<longrightarrow>1 t1'[x::=s2]"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   304
      using ih1 ih2 by (auto intro: One_subst)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   305
  }
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   306
  ultimately show "t2 \<longrightarrow>1 t1'[x::=s2]" using reds by auto
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
qed (auto dest!: One_Lam One_Var One_App)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
lemma Diamond_for_One:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   310
  assumes a: "t \<longrightarrow>1 t1" "t \<longrightarrow>1 t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
  shows "\<exists>t3. t2 \<longrightarrow>1 t3 \<and> t1 \<longrightarrow>1 t3"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
proof -
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
  obtain tc where "t \<longrightarrow>d tc" using Development_existence by blast
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   314
  with a have "t2 \<longrightarrow>1 tc" and "t1 \<longrightarrow>1 tc" by (simp_all add: Triangle)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
  then show "\<exists>t3. t2 \<longrightarrow>1 t3 \<and> t1 \<longrightarrow>1 t3" by blast
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
qed
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   317
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
lemma Rectangle_for_One:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
  assumes a:  "t \<longrightarrow>1* t1" "t \<longrightarrow>1 t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
  shows "\<exists>t3. t1 \<longrightarrow>1 t3 \<and> t2 \<longrightarrow>1* t3"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
using a Diamond_for_One by (induct arbitrary: t2) (blast)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   322
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   323
lemma CR_for_One_star:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   324
  assumes a: "t \<longrightarrow>1* t1" "t \<longrightarrow>1* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   325
    shows "\<exists>t3. t2 \<longrightarrow>1* t3 \<and> t1 \<longrightarrow>1* t3"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   326
using a Rectangle_for_One by (induct arbitrary: t2) (blast)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   328
section {* Establishing the Equivalence of Beta-star and One-star *}
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   329
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   330
lemma Beta_Lam_cong:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
  assumes a: "t1 \<longrightarrow>b* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
  shows "Lam [x].t1 \<longrightarrow>b* Lam [x].t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   333
using a by (induct) (blast)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   334
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   335
lemma Beta_App_cong_aux:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   336
  assumes a: "t1 \<longrightarrow>b* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
  shows "App t1 s\<longrightarrow>b* App t2 s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   338
    and "App s t1 \<longrightarrow>b* App s t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   339
using a by (induct) (blast)+
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   340
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   341
lemma Beta_App_cong:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   342
  assumes a: "t1 \<longrightarrow>b* t2" "s1 \<longrightarrow>b* s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   343
  shows "App t1 s1 \<longrightarrow>b* App t2 s2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   344
using a by (blast intro: Beta_App_cong_aux)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   345
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   346
lemmas Beta_congs = Beta_Lam_cong Beta_App_cong
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   347
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   348
lemma One_implies_Beta_star:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   349
  assumes a: "t \<longrightarrow>1 s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
  shows "t \<longrightarrow>b* s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   351
using a by (induct, auto intro!: Beta_congs)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   352
  (metis (hide_lams, no_types) Beta_App_cong_aux(1) Beta_App_cong_aux(2) Beta_Lam_cong b4 bs2 bs3 fresh_PairD(2))
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   353
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   354
lemma One_congs:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   355
  assumes a: "t1 \<longrightarrow>1* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   356
  shows "Lam [x].t1 \<longrightarrow>1* Lam [x].t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   357
  and   "App t1 s \<longrightarrow>1* App t2 s"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   358
  and   "App s t1 \<longrightarrow>1* App s t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   359
using a by (induct) (auto intro: One_refl)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   360
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   361
lemma Beta_implies_One_star:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   362
  assumes a: "t1 \<longrightarrow>b t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   363
  shows "t1 \<longrightarrow>1* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   364
using a by (induct) (auto intro: One_refl One_congs better_o4_intro)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   365
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
lemma Beta_star_equals_One_star:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
  shows "t1 \<longrightarrow>1* t2 = t1 \<longrightarrow>b* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   368
proof
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   369
  assume "t1 \<longrightarrow>1* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   370
  then show "t1 \<longrightarrow>b* t2" by (induct) (auto intro: One_implies_Beta_star)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   371
next
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
  assume "t1 \<longrightarrow>b* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   373
  then show "t1 \<longrightarrow>1* t2" by (induct) (auto intro: Beta_implies_One_star)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   374
qed
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   376
section {* The Church-Rosser Theorem *}
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   377
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   378
theorem CR_for_Beta_star:
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   379
  assumes a: "t \<longrightarrow>b* t1" "t\<longrightarrow>b* t2"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
  shows "\<exists>t3. t1 \<longrightarrow>b* t3 \<and> t2 \<longrightarrow>b* t3"
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   381
proof -
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   382
  from a have "t \<longrightarrow>1* t1" and "t\<longrightarrow>1* t2" by (simp_all add: Beta_star_equals_One_star)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   383
  then have "\<exists>t3. t1 \<longrightarrow>1* t3 \<and> t2 \<longrightarrow>1* t3" by (simp add: CR_for_One_star)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384
  then show "\<exists>t3. t1 \<longrightarrow>b* t3 \<and> t2 \<longrightarrow>b* t3" by (simp add: Beta_star_equals_One_star)
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   385
qed
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   386
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   387
end