src/HOL/Nominal/Examples/CR.thy
changeset 23760 aca2c7f80e2f
parent 23393 31781b2de73d
child 25831 7711d60a5293
equal deleted inserted replaced
23759:90bccef65004 23760:aca2c7f80e2f
   145 by (nominal_induct M avoiding: x y N L rule: lam.induct)
   145 by (nominal_induct M avoiding: x y N L rule: lam.induct)
   146    (auto simp add: fresh_fact forget)
   146    (auto simp add: fresh_fact forget)
   147 
   147 
   148 section {* Beta Reduction *}
   148 section {* Beta Reduction *}
   149 
   149 
   150 inductive2
   150 inductive
   151   "Beta" :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta> _" [80,80] 80)
   151   "Beta" :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta> _" [80,80] 80)
   152 where
   152 where
   153     b1[intro]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App s1 t)\<longrightarrow>\<^isub>\<beta>(App s2 t)"
   153     b1[intro]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App s1 t)\<longrightarrow>\<^isub>\<beta>(App s2 t)"
   154   | b2[intro]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App t s1)\<longrightarrow>\<^isub>\<beta>(App t s2)"
   154   | b2[intro]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App t s1)\<longrightarrow>\<^isub>\<beta>(App t s2)"
   155   | b3[intro]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (Lam [a].s1)\<longrightarrow>\<^isub>\<beta> (Lam [a].s2)"
   155   | b3[intro]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (Lam [a].s1)\<longrightarrow>\<^isub>\<beta> (Lam [a].s2)"
   158 equivariance Beta
   158 equivariance Beta
   159 
   159 
   160 nominal_inductive Beta
   160 nominal_inductive Beta
   161   by (simp_all add: abs_fresh fresh_fact')
   161   by (simp_all add: abs_fresh fresh_fact')
   162 
   162 
   163 inductive2
   163 inductive
   164   "Beta_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta>\<^sup>* _" [80,80] 80)
   164   "Beta_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta>\<^sup>* _" [80,80] 80)
   165 where
   165 where
   166     bs1[intro, simp]: "M \<longrightarrow>\<^isub>\<beta>\<^sup>* M"
   166     bs1[intro, simp]: "M \<longrightarrow>\<^isub>\<beta>\<^sup>* M"
   167   | bs2[intro]: "\<lbrakk>M1\<longrightarrow>\<^isub>\<beta>\<^sup>* M2; M2 \<longrightarrow>\<^isub>\<beta> M3\<rbrakk> \<Longrightarrow> M1 \<longrightarrow>\<^isub>\<beta>\<^sup>* M3"
   167   | bs2[intro]: "\<lbrakk>M1\<longrightarrow>\<^isub>\<beta>\<^sup>* M2; M2 \<longrightarrow>\<^isub>\<beta> M3\<rbrakk> \<Longrightarrow> M1 \<longrightarrow>\<^isub>\<beta>\<^sup>* M3"
   168 
   168 
   175 using a2 a1
   175 using a2 a1
   176 by (induct) (auto)
   176 by (induct) (auto)
   177 
   177 
   178 section {* One-Reduction *}
   178 section {* One-Reduction *}
   179 
   179 
   180 inductive2
   180 inductive
   181   One :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1 _" [80,80] 80)
   181   One :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1 _" [80,80] 80)
   182 where
   182 where
   183     o1[intro!]:      "M\<longrightarrow>\<^isub>1M"
   183     o1[intro!]:      "M\<longrightarrow>\<^isub>1M"
   184   | o2[simp,intro!]: "\<lbrakk>t1\<longrightarrow>\<^isub>1t2;s1\<longrightarrow>\<^isub>1s2\<rbrakk> \<Longrightarrow> (App t1 s1)\<longrightarrow>\<^isub>1(App t2 s2)"
   184   | o2[simp,intro!]: "\<lbrakk>t1\<longrightarrow>\<^isub>1t2;s1\<longrightarrow>\<^isub>1s2\<rbrakk> \<Longrightarrow> (App t1 s1)\<longrightarrow>\<^isub>1(App t2 s2)"
   185   | o3[simp,intro!]: "s1\<longrightarrow>\<^isub>1s2 \<Longrightarrow> (Lam [a].s1)\<longrightarrow>\<^isub>1(Lam [a].s2)"
   185   | o3[simp,intro!]: "s1\<longrightarrow>\<^isub>1s2 \<Longrightarrow> (Lam [a].s1)\<longrightarrow>\<^isub>1(Lam [a].s2)"
   188 equivariance One
   188 equivariance One
   189 
   189 
   190 nominal_inductive One
   190 nominal_inductive One
   191   by (simp_all add: abs_fresh fresh_fact')
   191   by (simp_all add: abs_fresh fresh_fact')
   192 
   192 
   193 inductive2
   193 inductive
   194   "One_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1\<^sup>* _" [80,80] 80)
   194   "One_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1\<^sup>* _" [80,80] 80)
   195 where
   195 where
   196     os1[intro, simp]: "M \<longrightarrow>\<^isub>1\<^sup>* M"
   196     os1[intro, simp]: "M \<longrightarrow>\<^isub>1\<^sup>* M"
   197   | os2[intro]: "\<lbrakk>M1\<longrightarrow>\<^isub>1\<^sup>* M2; M2 \<longrightarrow>\<^isub>1 M3\<rbrakk> \<Longrightarrow> M1 \<longrightarrow>\<^isub>1\<^sup>* M3"
   197   | os2[intro]: "\<lbrakk>M1\<longrightarrow>\<^isub>1\<^sup>* M2; M2 \<longrightarrow>\<^isub>1 M3\<rbrakk> \<Longrightarrow> M1 \<longrightarrow>\<^isub>1\<^sup>* M3"
   198 
   198 
   270   and      a :: "name"
   270   and      a :: "name"
   271   assumes a: "(Lam [a].t)\<longrightarrow>\<^isub>1t'"
   271   assumes a: "(Lam [a].t)\<longrightarrow>\<^isub>1t'"
   272   shows "\<exists>t''. t'=Lam [a].t'' \<and> t\<longrightarrow>\<^isub>1t''"
   272   shows "\<exists>t''. t'=Lam [a].t'' \<and> t\<longrightarrow>\<^isub>1t''"
   273   using a
   273   using a
   274   apply -
   274   apply -
   275   apply(ind_cases2 "(Lam [a].t)\<longrightarrow>\<^isub>1t'")
   275   apply(ind_cases "(Lam [a].t)\<longrightarrow>\<^isub>1t'")
   276   apply(auto simp add: lam.inject alpha)
   276   apply(auto simp add: lam.inject alpha)
   277   apply(rule_tac x="[(a,aa)]\<bullet>s2" in exI)
   277   apply(rule_tac x="[(a,aa)]\<bullet>s2" in exI)
   278   apply(rule conjI)
   278   apply(rule conjI)
   279   apply(perm_simp)
   279   apply(perm_simp)
   280   apply(simp add: fresh_left calc_atm)
   280   apply(simp add: fresh_left calc_atm)
   287   assumes a: "App t1 t2 \<longrightarrow>\<^isub>1 t'"
   287   assumes a: "App t1 t2 \<longrightarrow>\<^isub>1 t'"
   288   shows "(\<exists>s1 s2. t' = App s1 s2 \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2) \<or> 
   288   shows "(\<exists>s1 s2. t' = App s1 s2 \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2) \<or> 
   289          (\<exists>a s s1 s2. t1 = Lam [a].s \<and> a\<sharp>(t2,s2) \<and> t' = s1[a::=s2] \<and> s \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2)" 
   289          (\<exists>a s s1 s2. t1 = Lam [a].s \<and> a\<sharp>(t2,s2) \<and> t' = s1[a::=s2] \<and> s \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2)" 
   290   using a
   290   using a
   291   apply -
   291   apply -
   292   apply(ind_cases2 "App t1 t2 \<longrightarrow>\<^isub>1 t'")
   292   apply(ind_cases "App t1 t2 \<longrightarrow>\<^isub>1 t'")
   293   apply(auto simp add: lam.distinct lam.inject)
   293   apply(auto simp add: lam.distinct lam.inject)
   294   done
   294   done
   295 
   295 
   296 lemma one_red: 
   296 lemma one_red: 
   297   assumes a: "App (Lam [a].t1) t2 \<longrightarrow>\<^isub>1 M"
   297   assumes a: "App (Lam [a].t1) t2 \<longrightarrow>\<^isub>1 M"
   298   shows "(\<exists>s1 s2. M = App (Lam [a].s1) s2 \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2) \<or> 
   298   shows "(\<exists>s1 s2. M = App (Lam [a].s1) s2 \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2) \<or> 
   299          (\<exists>s1 s2. M = s1[a::=s2] \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2)" 
   299          (\<exists>s1 s2. M = s1[a::=s2] \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2)" 
   300   using a
   300   using a
   301   apply -
   301   apply -
   302   apply(ind_cases2 "App (Lam [a].t1) t2 \<longrightarrow>\<^isub>1 M")
   302   apply(ind_cases "App (Lam [a].t1) t2 \<longrightarrow>\<^isub>1 M")
   303   apply(simp_all add: lam.inject)
   303   apply(simp_all add: lam.inject)
   304   apply(force)
   304   apply(force)
   305   apply(erule conjE)
   305   apply(erule conjE)
   306   apply(drule sym[of "Lam [a].t1"])
   306   apply(drule sym[of "Lam [a].t1"])
   307   apply(simp)
   307   apply(simp)