src/HOL/Nominal/Examples/CR_Takahashi.thy
changeset 26966 071f40487734
parent 26458 5c21ec1ff293
child 29097 68245155eb58
equal deleted inserted replaced
26965:003b5781b845 26966:071f40487734
    34 
    34 
    35 section {* Lemmas about Capture-Avoiding Substitution *}
    35 section {* Lemmas about Capture-Avoiding Substitution *}
    36  
    36  
    37 lemma  subst_eqvt[eqvt]:
    37 lemma  subst_eqvt[eqvt]:
    38   fixes pi::"name prm"
    38   fixes pi::"name prm"
    39   shows "pi\<bullet>t1[x::=t2] = (pi\<bullet>t1)[(pi\<bullet>x)::=(pi\<bullet>t2)]"
    39   shows "pi\<bullet>(t1[x::=t2]) = (pi\<bullet>t1)[(pi\<bullet>x)::=(pi\<bullet>t2)]"
    40 by (nominal_induct t1 avoiding: x t2 rule: lam.induct)
    40 by (nominal_induct t1 avoiding: x t2 rule: lam.strong_induct)
    41    (auto simp add: perm_bij fresh_atm fresh_bij)
    41    (auto simp add: perm_bij fresh_atm fresh_bij)
    42 
    42 
    43 lemma forget:
    43 lemma forget:
    44   shows "x\<sharp>t \<Longrightarrow> t[x::=s] = t"
    44   shows "x\<sharp>t \<Longrightarrow> t[x::=s] = t"
    45 by (nominal_induct t avoiding: x s rule: lam.induct)
    45 by (nominal_induct t avoiding: x s rule: lam.strong_induct)
    46    (auto simp add: abs_fresh fresh_atm)
    46    (auto simp add: abs_fresh fresh_atm)
    47 
    47 
    48 lemma fresh_fact:
    48 lemma fresh_fact:
    49   fixes z::"name"
    49   fixes z::"name"
    50   shows "z\<sharp>s \<and> (z=y \<or> z\<sharp>t) \<Longrightarrow> z\<sharp>t[y::=s]"
    50   shows "\<lbrakk>z\<sharp>s; (z=y \<or> z\<sharp>t)\<rbrakk> \<Longrightarrow> z\<sharp>t[y::=s]"
    51 by (nominal_induct t avoiding: z y s rule: lam.induct)
    51 by (nominal_induct t avoiding: z y s rule: lam.strong_induct)
    52    (auto simp add: abs_fresh fresh_prod fresh_atm)
    52    (auto simp add: abs_fresh fresh_prod fresh_atm)
    53 
    53 
    54 lemma substitution_lemma:  
    54 lemma substitution_lemma:  
    55   assumes a: "x\<noteq>y" "x\<sharp>u"
    55   assumes a: "x\<noteq>y" "x\<sharp>u"
    56   shows "t[x::=s][y::=u] = t[y::=u][x::=s[y::=u]]"
    56   shows "t[x::=s][y::=u] = t[y::=u][x::=s[y::=u]]"
    57 using a by (nominal_induct t avoiding: x y s u rule: lam.induct)
    57 using a by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
    58            (auto simp add: fresh_fact forget)
    58            (auto simp add: fresh_fact forget)
    59 
    59 
    60 lemma subst_rename: 
    60 lemma subst_rename: 
    61   assumes a: "y\<sharp>t"
    61   assumes a: "y\<sharp>t"
    62   shows "t[x::=s] = ([(y,x)]\<bullet>t)[y::=s]"
    62   shows "t[x::=s] = ([(y,x)]\<bullet>t)[y::=s]"
    63 using a by (nominal_induct t avoiding: x y s rule: lam.induct)
    63 using a by (nominal_induct t avoiding: x y s rule: lam.strong_induct)
    64            (auto simp add: calc_atm fresh_atm abs_fresh)
    64            (auto simp add: calc_atm fresh_atm abs_fresh)
    65 
    65 
    66 section {* Beta-Reduction *}
    66 section {* Beta-Reduction *}
    67 
    67 
    68 inductive 
    68 inductive 
    96 nominal_inductive One 
    96 nominal_inductive One 
    97   by (simp_all add: abs_fresh fresh_fact)
    97   by (simp_all add: abs_fresh fresh_fact)
    98 
    98 
    99 lemma One_refl:
    99 lemma One_refl:
   100   shows "t \<longrightarrow>\<^isub>1 t"
   100   shows "t \<longrightarrow>\<^isub>1 t"
   101 by (nominal_induct t rule: lam.induct) (auto)
   101 by (nominal_induct t rule: lam.strong_induct) (auto)
   102 
   102 
   103 lemma One_subst: 
   103 lemma One_subst: 
   104   assumes a: "t1 \<longrightarrow>\<^isub>1 t2" "s1 \<longrightarrow>\<^isub>1 s2"
   104   assumes a: "t1 \<longrightarrow>\<^isub>1 t2" "s1 \<longrightarrow>\<^isub>1 s2"
   105   shows "t1[x::=s1] \<longrightarrow>\<^isub>1 t2[x::=s2]" 
   105   shows "t1[x::=s1] \<longrightarrow>\<^isub>1 t2[x::=s2]" 
   106 using a by (nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
   106 using a by (nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
   132 
   132 
   133 lemma One_App: 
   133 lemma One_App: 
   134   assumes a: "App t s \<longrightarrow>\<^isub>1 r"
   134   assumes a: "App t s \<longrightarrow>\<^isub>1 r"
   135   shows "(\<exists>t' s'. r = App t' s' \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s') \<or> 
   135   shows "(\<exists>t' s'. r = App t' s' \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s') \<or> 
   136          (\<exists>x p p' s'. r = p'[x::=s'] \<and> t = Lam [x].p \<and> p \<longrightarrow>\<^isub>1 p' \<and> s \<longrightarrow>\<^isub>1 s' \<and> x\<sharp>(s,s'))" 
   136          (\<exists>x p p' s'. r = p'[x::=s'] \<and> t = Lam [x].p \<and> p \<longrightarrow>\<^isub>1 p' \<and> s \<longrightarrow>\<^isub>1 s' \<and> x\<sharp>(s,s'))" 
   137 using a by (cases rule: One.cases) (auto simp add: lam.inject)
       
   138 
       
   139 lemma One_App_: 
       
   140   assumes a: "App t s \<longrightarrow>\<^isub>1 r"
       
   141   obtains t' s' where "r = App t' s'" "t \<longrightarrow>\<^isub>1 t'" "s \<longrightarrow>\<^isub>1 s'" 
       
   142         | x p p' s' where "r = p'[x::=s']" "t = Lam [x].p" "p \<longrightarrow>\<^isub>1 p'" "s \<longrightarrow>\<^isub>1 s'" "x\<sharp>(s,s')"
       
   143 using a by (cases rule: One.cases) (auto simp add: lam.inject)
   137 using a by (cases rule: One.cases) (auto simp add: lam.inject)
   144 
   138 
   145 lemma One_Redex: 
   139 lemma One_Redex: 
   146   assumes a: "App (Lam [x].t) s \<longrightarrow>\<^isub>1 r" "x\<sharp>(s,r)"
   140   assumes a: "App (Lam [x].t) s \<longrightarrow>\<^isub>1 r" "x\<sharp>(s,r)"
   147   shows "(\<exists>t' s'. r = App (Lam [x].t') s' \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s') \<or> 
   141   shows "(\<exists>t' s'. r = App (Lam [x].t') s' \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s') \<or> 
   203        (auto simp add: lam.inject abs_fresh alpha)
   197        (auto simp add: lam.inject abs_fresh alpha)
   204 qed
   198 qed
   205 
   199 
   206 lemma Development_existence:
   200 lemma Development_existence:
   207   shows "\<exists>M'. M \<longrightarrow>\<^isub>d M'"
   201   shows "\<exists>M'. M \<longrightarrow>\<^isub>d M'"
   208 by (nominal_induct M rule: lam.induct)
   202 by (nominal_induct M rule: lam.strong_induct)
   209    (auto dest!: Dev_Lam intro: better_d4_intro)
   203    (auto dest!: Dev_Lam intro: better_d4_intro)
   210 
   204 
       
   205 (* needs fixing *)
   211 lemma Triangle:
   206 lemma Triangle:
   212   assumes a: "t \<longrightarrow>\<^isub>d t1" "t \<longrightarrow>\<^isub>1 t2"
   207   assumes a: "t \<longrightarrow>\<^isub>d t1" "t \<longrightarrow>\<^isub>1 t2"
   213   shows "t2 \<longrightarrow>\<^isub>1 t1"
   208   shows "t2 \<longrightarrow>\<^isub>1 t1"
   214 using a 
   209 using a 
   215 proof(nominal_induct avoiding: t2 rule: Dev.strong_induct)
   210 proof(nominal_induct avoiding: t2 rule: Dev.strong_induct)
   218   and  ih2: "\<And>s. s1 \<longrightarrow>\<^isub>1 s \<Longrightarrow>  s \<longrightarrow>\<^isub>1 s2"
   213   and  ih2: "\<And>s. s1 \<longrightarrow>\<^isub>1 s \<Longrightarrow>  s \<longrightarrow>\<^isub>1 s2"
   219   and  fc: "x\<sharp>t2" "x\<sharp>s1" "x\<sharp>s2" by fact+ 
   214   and  fc: "x\<sharp>t2" "x\<sharp>s1" "x\<sharp>s2" by fact+ 
   220   have "App (Lam [x].t1) s1 \<longrightarrow>\<^isub>1 t2" by fact
   215   have "App (Lam [x].t1) s1 \<longrightarrow>\<^isub>1 t2" by fact
   221   then obtain t' s' where "(t2 = App (Lam [x].t') s' \<and> t1 \<longrightarrow>\<^isub>1 t' \<and> s1 \<longrightarrow>\<^isub>1 s') \<or> 
   216   then obtain t' s' where "(t2 = App (Lam [x].t') s' \<and> t1 \<longrightarrow>\<^isub>1 t' \<and> s1 \<longrightarrow>\<^isub>1 s') \<or> 
   222                            (t2 = t'[x::=s'] \<and> t1 \<longrightarrow>\<^isub>1 t' \<and> s1 \<longrightarrow>\<^isub>1 s')"
   217                            (t2 = t'[x::=s'] \<and> t1 \<longrightarrow>\<^isub>1 t' \<and> s1 \<longrightarrow>\<^isub>1 s')"
   223     (* MARKUS: How does I do this better *) using fc by (auto dest!: One_Redex)
   218   using fc by (auto dest!: One_Redex)
   224   then show "t2 \<longrightarrow>\<^isub>1 t1'[x::=s2]"
   219   then show "t2 \<longrightarrow>\<^isub>1 t1'[x::=s2]"
   225     apply -
   220     apply -
   226     apply(erule disjE)
   221     apply(erule disjE)
   227     apply(erule conjE)+
   222     apply(erule conjE)+
   228     apply(simp)
   223     apply(simp)
   280 lemma One_implies_Beta_star: 
   275 lemma One_implies_Beta_star: 
   281   assumes a: "t \<longrightarrow>\<^isub>1 s"
   276   assumes a: "t \<longrightarrow>\<^isub>1 s"
   282   shows "t \<longrightarrow>\<^isub>\<beta>\<^sup>* s"
   277   shows "t \<longrightarrow>\<^isub>\<beta>\<^sup>* s"
   283 using a by (induct) (auto intro!: Beta_congs)
   278 using a by (induct) (auto intro!: Beta_congs)
   284 
   279 
   285 lemma One_star_Lam_cong: 
   280 lemma One_congs: 
   286   assumes a: "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" 
   281   assumes a: "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" 
   287   shows "Lam [x].t1 \<longrightarrow>\<^isub>1\<^sup>* Lam [x].t2"
   282   shows "Lam [x].t1 \<longrightarrow>\<^isub>1\<^sup>* Lam [x].t2"
   288 using a by (induct) (auto)
   283   and   "App t1 s \<longrightarrow>\<^isub>1\<^sup>* App t2 s"
   289 
       
   290 lemma One_star_App_cong: 
       
   291   assumes a: "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" 
       
   292   shows "App t1 s \<longrightarrow>\<^isub>1\<^sup>* App t2 s"
       
   293   and   "App s t1 \<longrightarrow>\<^isub>1\<^sup>* App s t2"
   284   and   "App s t1 \<longrightarrow>\<^isub>1\<^sup>* App s t2"
   294 using a by (induct) (auto intro: One_refl)
   285 using a by (induct) (auto intro: One_refl)
   295 
       
   296 lemmas One_congs = One_star_App_cong One_star_Lam_cong
       
   297 
   286 
   298 lemma Beta_implies_One_star: 
   287 lemma Beta_implies_One_star: 
   299   assumes a: "t1 \<longrightarrow>\<^isub>\<beta> t2" 
   288   assumes a: "t1 \<longrightarrow>\<^isub>\<beta> t2" 
   300   shows "t1 \<longrightarrow>\<^isub>1\<^sup>* t2"
   289   shows "t1 \<longrightarrow>\<^isub>1\<^sup>* t2"
   301 using a by (induct) (auto intro: One_refl One_congs better_o4_intro)
   290 using a by (induct) (auto intro: One_refl One_congs better_o4_intro)