src/HOL/Nominal/Examples/Class1.thy
changeset 63167 0909deb8059b
parent 61594 07a903c8cc91
child 66453 cc19f7ca2ed6
equal deleted inserted replaced
63166:143f58bb34f9 63167:0909deb8059b
     1 theory Class1
     1 theory Class1
     2 imports "../Nominal" 
     2 imports "../Nominal" 
     3 begin
     3 begin
     4 
     4 
     5 section {* Term-Calculus from Urban's PhD *}
     5 section \<open>Term-Calculus from Urban's PhD\<close>
     6 
     6 
     7 atom_decl name coname
     7 atom_decl name coname
     8 
     8 
     9 text {* types *}
     9 text \<open>types\<close>
    10 
    10 
    11 nominal_datatype ty =
    11 nominal_datatype ty =
    12     PR "string"
    12     PR "string"
    13   | NOT  "ty"
    13   | NOT  "ty"
    14   | AND  "ty" "ty"   ("_ AND _" [100,100] 100)
    14   | AND  "ty" "ty"   ("_ AND _" [100,100] 100)
    42   and   T::"ty"
    42   and   T::"ty"
    43   shows "a\<sharp>T" and "x\<sharp>T"
    43   shows "a\<sharp>T" and "x\<sharp>T"
    44 by (nominal_induct T rule: ty.strong_induct)
    44 by (nominal_induct T rule: ty.strong_induct)
    45    (auto simp add: fresh_string)
    45    (auto simp add: fresh_string)
    46 
    46 
    47 text {* terms *}
    47 text \<open>terms\<close>
    48 
    48 
    49 nominal_datatype trm = 
    49 nominal_datatype trm = 
    50     Ax   "name" "coname"
    50     Ax   "name" "coname"
    51   | Cut  "\<guillemotleft>coname\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm"            ("Cut <_>._ (_)._" [100,100,100,100] 100)
    51   | Cut  "\<guillemotleft>coname\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm"            ("Cut <_>._ (_)._" [100,100,100,100] 100)
    52   | NotR "\<guillemotleft>name\<guillemotright>trm" "coname"                 ("NotR (_)._ _" [100,100,100] 100)
    52   | NotR "\<guillemotleft>name\<guillemotright>trm" "coname"                 ("NotR (_)._ _" [100,100,100] 100)
    58   | OrR2 "\<guillemotleft>coname\<guillemotright>trm" "coname"               ("OrR2 <_>._ _" [100,100,100] 100)
    58   | OrR2 "\<guillemotleft>coname\<guillemotright>trm" "coname"               ("OrR2 <_>._ _" [100,100,100] 100)
    59   | OrL "\<guillemotleft>name\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm" "name"        ("OrL (_)._ (_)._ _" [100,100,100,100,100] 100)
    59   | OrL "\<guillemotleft>name\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm" "name"        ("OrL (_)._ (_)._ _" [100,100,100,100,100] 100)
    60   | ImpR "\<guillemotleft>name\<guillemotright>(\<guillemotleft>coname\<guillemotright>trm)" "coname"       ("ImpR (_).<_>._ _" [100,100,100,100] 100)
    60   | ImpR "\<guillemotleft>name\<guillemotright>(\<guillemotleft>coname\<guillemotright>trm)" "coname"       ("ImpR (_).<_>._ _" [100,100,100,100] 100)
    61   | ImpL "\<guillemotleft>coname\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm" "name"     ("ImpL <_>._ (_)._ _" [100,100,100,100,100] 100)
    61   | ImpL "\<guillemotleft>coname\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm" "name"     ("ImpL <_>._ (_)._ _" [100,100,100,100,100] 100)
    62 
    62 
    63 text {* named terms *}
    63 text \<open>named terms\<close>
    64 
    64 
    65 nominal_datatype ntrm = Na "\<guillemotleft>name\<guillemotright>trm" ("((_):_)" [100,100] 100)
    65 nominal_datatype ntrm = Na "\<guillemotleft>name\<guillemotright>trm" ("((_):_)" [100,100] 100)
    66 
    66 
    67 text {* conamed terms *}
    67 text \<open>conamed terms\<close>
    68 
    68 
    69 nominal_datatype ctrm = Co "\<guillemotleft>coname\<guillemotright>trm" ("(<_>:_)" [100,100] 100)
    69 nominal_datatype ctrm = Co "\<guillemotleft>coname\<guillemotright>trm" ("(<_>:_)" [100,100] 100)
    70 
    70 
    71 text {* renaming functions *}
    71 text \<open>renaming functions\<close>
    72 
    72 
    73 nominal_primrec (freshness_context: "(d::coname,e::coname)") 
    73 nominal_primrec (freshness_context: "(d::coname,e::coname)") 
    74   crename :: "trm \<Rightarrow> coname \<Rightarrow> coname \<Rightarrow> trm"  ("_[_\<turnstile>c>_]" [100,100,100] 100) 
    74   crename :: "trm \<Rightarrow> coname \<Rightarrow> coname \<Rightarrow> trm"  ("_[_\<turnstile>c>_]" [100,100,100] 100) 
    75 where
    75 where
    76   "(Ax x a)[d\<turnstile>c>e] = (if a=d then Ax x e else Ax x a)" 
    76   "(Ax x a)[d\<turnstile>c>e] = (if a=d then Ax x e else Ax x a)" 
   305 using a
   305 using a
   306 apply(nominal_induct M avoiding: x y z a rule: trm.strong_induct)
   306 apply(nominal_induct M avoiding: x y z a rule: trm.strong_induct)
   307 apply(simp_all add: trm.inject split: if_splits)
   307 apply(simp_all add: trm.inject split: if_splits)
   308 done
   308 done
   309 
   309 
   310 text {* substitution functions *}
   310 text \<open>substitution functions\<close>
   311 
   311 
   312 lemma fresh_perm_coname:
   312 lemma fresh_perm_coname:
   313   fixes c::"coname"
   313   fixes c::"coname"
   314   and   pi::"coname prm"
   314   and   pi::"coname prm"
   315   and   M::"trm"
   315   and   M::"trm"
  2833 lemmas subst_comm = substn_crename_comm substc_crename_comm
  2833 lemmas subst_comm = substn_crename_comm substc_crename_comm
  2834                     substn_nrename_comm substc_nrename_comm
  2834                     substn_nrename_comm substc_nrename_comm
  2835 lemmas subst_comm' = substn_crename_comm' substc_crename_comm'
  2835 lemmas subst_comm' = substn_crename_comm' substc_crename_comm'
  2836                      substn_nrename_comm' substc_nrename_comm'
  2836                      substn_nrename_comm' substc_nrename_comm'
  2837 
  2837 
  2838 text {* typing contexts *}
  2838 text \<open>typing contexts\<close>
  2839 
  2839 
  2840 type_synonym ctxtn = "(name\<times>ty) list"
  2840 type_synonym ctxtn = "(name\<times>ty) list"
  2841 type_synonym ctxtc = "(coname\<times>ty) list"
  2841 type_synonym ctxtc = "(coname\<times>ty) list"
  2842 
  2842 
  2843 inductive
  2843 inductive
  2866   show "a\<sharp>\<Gamma>" by (induct \<Gamma>) (auto simp add: fresh_list_nil fresh_list_cons fresh_prod fresh_atm fresh_ty)
  2866   show "a\<sharp>\<Gamma>" by (induct \<Gamma>) (auto simp add: fresh_list_nil fresh_list_cons fresh_prod fresh_atm fresh_ty)
  2867 next
  2867 next
  2868   show "x\<sharp>\<Delta>" by (induct \<Delta>) (auto simp add: fresh_list_nil fresh_list_cons fresh_prod fresh_atm fresh_ty)
  2868   show "x\<sharp>\<Delta>" by (induct \<Delta>) (auto simp add: fresh_list_nil fresh_list_cons fresh_prod fresh_atm fresh_ty)
  2869 qed
  2869 qed
  2870 
  2870 
  2871 text {* cut-reductions *}
  2871 text \<open>cut-reductions\<close>
  2872 
  2872 
  2873 declare abs_perm[eqvt]
  2873 declare abs_perm[eqvt]
  2874 
  2874 
  2875 inductive
  2875 inductive
  2876   fin :: "trm \<Rightarrow> name \<Rightarrow> bool"
  2876   fin :: "trm \<Rightarrow> name \<Rightarrow> bool"
  4690   also have "\<dots> = ImpR (x).<a>.M' b" 
  4690   also have "\<dots> = ImpR (x).<a>.M' b" 
  4691     using fs2 red by (auto simp add: trm.inject alpha fresh_atm fresh_prod calc_atm fresh_a_redu)
  4691     using fs2 red by (auto simp add: trm.inject alpha fresh_atm fresh_prod calc_atm fresh_a_redu)
  4692   finally show ?thesis by simp
  4692   finally show ?thesis by simp
  4693 qed
  4693 qed
  4694 
  4694 
  4695 text {* axioms do not reduce *}
  4695 text \<open>axioms do not reduce\<close>
  4696 
  4696 
  4697 lemma ax_do_not_l_reduce:
  4697 lemma ax_do_not_l_reduce:
  4698   shows "Ax x a \<longrightarrow>\<^sub>l M \<Longrightarrow> False"
  4698   shows "Ax x a \<longrightarrow>\<^sub>l M \<Longrightarrow> False"
  4699 by (erule_tac l_redu.cases) (simp_all add: trm.inject)
  4699 by (erule_tac l_redu.cases) (simp_all add: trm.inject)
  4700  
  4700  
  5158 apply(rule trans)
  5158 apply(rule trans)
  5159 apply(rule perm_compose)
  5159 apply(rule perm_compose)
  5160 apply(simp add: calc_atm perm_swap)
  5160 apply(simp add: calc_atm perm_swap)
  5161 done
  5161 done
  5162 
  5162 
  5163 text {* Transitive Closure*}
  5163 text \<open>Transitive Closure\<close>
  5164 
  5164 
  5165 abbreviation
  5165 abbreviation
  5166  a_star_redu :: "trm \<Rightarrow> trm \<Rightarrow> bool" ("_ \<longrightarrow>\<^sub>a* _" [100,100] 100)
  5166  a_star_redu :: "trm \<Rightarrow> trm \<Rightarrow> bool" ("_ \<longrightarrow>\<^sub>a* _" [100,100] 100)
  5167 where
  5167 where
  5168   "M \<longrightarrow>\<^sub>a* M' \<equiv> (a_redu)^** M M'"
  5168   "M \<longrightarrow>\<^sub>a* M' \<equiv> (a_redu)^** M M'"
  5187   and     a2: "M2\<longrightarrow>\<^sub>a* M3"
  5187   and     a2: "M2\<longrightarrow>\<^sub>a* M3"
  5188   shows "M1 \<longrightarrow>\<^sub>a* M3"
  5188   shows "M1 \<longrightarrow>\<^sub>a* M3"
  5189 using a2 a1
  5189 using a2 a1
  5190 by (induct) (auto)
  5190 by (induct) (auto)
  5191 
  5191 
  5192 text {* congruence rules for \<open>\<longrightarrow>\<^sub>a*\<close> *}
  5192 text \<open>congruence rules for \<open>\<longrightarrow>\<^sub>a*\<close>\<close>
  5193 
  5193 
  5194 lemma ax_do_not_a_star_reduce:
  5194 lemma ax_do_not_a_star_reduce:
  5195   shows "Ax x a \<longrightarrow>\<^sub>a* M \<Longrightarrow> M = Ax x a"
  5195   shows "Ax x a \<longrightarrow>\<^sub>a* M \<Longrightarrow> M = Ax x a"
  5196 apply(induct set: rtranclp)
  5196 apply(induct set: rtranclp)
  5197 apply(auto)
  5197 apply(auto)
  5377 apply(auto)
  5377 apply(auto)
  5378 apply(drule a_redu_ImpL_elim)
  5378 apply(drule a_redu_ImpL_elim)
  5379 apply(auto simp add: alpha trm.inject)
  5379 apply(auto simp add: alpha trm.inject)
  5380 done
  5380 done
  5381 
  5381 
  5382 text {* Substitution *}
  5382 text \<open>Substitution\<close>
  5383 
  5383 
  5384 lemma subst_not_fin1:
  5384 lemma subst_not_fin1:
  5385   shows "\<not>fin(M{x:=<c>.P}) x"
  5385   shows "\<not>fin(M{x:=<c>.P}) x"
  5386 apply(nominal_induct M avoiding: x c P rule: trm.strong_induct)
  5386 apply(nominal_induct M avoiding: x c P rule: trm.strong_induct)
  5387 apply(auto)
  5387 apply(auto)
  5642 apply(drule fic_elims, simp)
  5642 apply(drule fic_elims, simp)
  5643 apply(rule exists_fresh'(1)[OF fs_name1])
  5643 apply(rule exists_fresh'(1)[OF fs_name1])
  5644 apply(drule fic_elims, simp)
  5644 apply(drule fic_elims, simp)
  5645 done
  5645 done
  5646 
  5646 
  5647 text {* Reductions *}
  5647 text \<open>Reductions\<close>
  5648 
  5648 
  5649 lemma fin_l_reduce:
  5649 lemma fin_l_reduce:
  5650   assumes  a: "fin M x"
  5650   assumes  a: "fin M x"
  5651   and      b: "M \<longrightarrow>\<^sub>l M'"
  5651   and      b: "M \<longrightarrow>\<^sub>l M'"
  5652   shows "fin M' x"
  5652   shows "fin M' x"
  5780 using b a
  5780 using b a
  5781 apply(induct set: rtranclp)
  5781 apply(induct set: rtranclp)
  5782 apply(auto simp add: fic_a_reduce)
  5782 apply(auto simp add: fic_a_reduce)
  5783 done
  5783 done
  5784 
  5784 
  5785 text {* substitution properties *}
  5785 text \<open>substitution properties\<close>
  5786 
  5786 
  5787 lemma subst_with_ax1:
  5787 lemma subst_with_ax1:
  5788   shows "M{x:=<a>.Ax y a} \<longrightarrow>\<^sub>a* M[x\<turnstile>n>y]"
  5788   shows "M{x:=<a>.Ax y a} \<longrightarrow>\<^sub>a* M[x\<turnstile>n>y]"
  5789 proof(nominal_induct M avoiding: x a y rule: trm.strong_induct)
  5789 proof(nominal_induct M avoiding: x a y rule: trm.strong_induct)
  5790   case (Ax z b x a y)
  5790   case (Ax z b x a y)
  6293     using ih1 ih2 by (auto intro: a_star_congs)
  6293     using ih1 ih2 by (auto intro: a_star_congs)
  6294   finally show "(ImpL <c>.M (u).N v){b:=(x).Ax x a} \<longrightarrow>\<^sub>a* (ImpL <c>.M (u).N v)[b\<turnstile>c>a]" 
  6294   finally show "(ImpL <c>.M (u).N v){b:=(x).Ax x a} \<longrightarrow>\<^sub>a* (ImpL <c>.M (u).N v)[b\<turnstile>c>a]" 
  6295     using fs by simp
  6295     using fs by simp
  6296 qed
  6296 qed
  6297 
  6297 
  6298 text {* substitution lemmas *}
  6298 text \<open>substitution lemmas\<close>
  6299 
  6299 
  6300 lemma not_Ax1:
  6300 lemma not_Ax1:
  6301   shows "\<not>(b\<sharp>M) \<Longrightarrow> M{b:=(y).Q} \<noteq> Ax x a"
  6301   shows "\<not>(b\<sharp>M) \<Longrightarrow> M{b:=(y).Q} \<noteq> Ax x a"
  6302 apply(nominal_induct M avoiding: b y Q x a rule: trm.strong_induct)
  6302 apply(nominal_induct M avoiding: b y Q x a rule: trm.strong_induct)
  6303 apply(auto simp add: fresh_atm abs_fresh abs_supp fin_supp)
  6303 apply(auto simp add: fresh_atm abs_fresh abs_supp fin_supp)