# HG changeset patch # User wenzelm # Date 1728392537 -7200 # Node ID 12990a6dddcb01059fc6660e2d97932b79411907 # Parent ef362328b93167fea4a2e8424d91f64380fbf936 avoid syntax clashes; diff -r ef362328b931 -r 12990a6dddcb src/HOL/Nominal/Examples/CK_Machine.thy --- a/src/HOL/Nominal/Examples/CK_Machine.thy Tue Oct 08 13:13:53 2024 +0200 +++ b/src/HOL/Nominal/Examples/CK_Machine.thy Tue Oct 08 15:02:17 2024 +0200 @@ -152,43 +152,43 @@ equivariance val inductive - machine :: "lam\ctx list\lam\ctx list\bool" (\<_,_> \ <_,_>\) + machine :: "lam\ctx list\lam\ctx list\bool" (\<_,_> \ <_,_>\) where - m1[intro]: " \ e2)#Es>" -| m2[intro]: "val v \ e2)#Es> \ )#Es>" -| m3[intro]: "val v \ )#Es> \ " -| m4[intro]: " \ e2)#Es>" -| m5[intro]: " e2)#Es> \ )#Es>" -| m6[intro]: ")#Es> \ " -| m4'[intro]:" \ e2)#Es>" -| m5'[intro]:" e2)#Es> \ )#Es>" -| m6'[intro]:")#Es> \ " -| m7[intro]: " \ e2 e3)#Es>" -| m8[intro]: " e1 e2)#Es> \ " -| m9[intro]: " e1 e2)#Es> \ " -| mA[intro]: " \ " -| mB[intro]: " \ )#Es>" -| mC[intro]: ")#Es> \ " -| mD[intro]: "0 < n \ )#Es> \ " -| mE[intro]: " \ e2)#Es>" -| mF[intro]: " e2)#Es> \ )#Es>" -| mG[intro]: ")#Es> \ " -| mH[intro]: "n1\n2 \ )#Es> \ " + m1[intro]: " \ e2)#Es>" +| m2[intro]: "val v \ e2)#Es> \ )#Es>" +| m3[intro]: "val v \ )#Es> \ " +| m4[intro]: " \ e2)#Es>" +| m5[intro]: " e2)#Es> \ )#Es>" +| m6[intro]: ")#Es> \ " +| m4'[intro]:" \ e2)#Es>" +| m5'[intro]:" e2)#Es> \ )#Es>" +| m6'[intro]:")#Es> \ " +| m7[intro]: " \ e2 e3)#Es>" +| m8[intro]: " e1 e2)#Es> \ " +| m9[intro]: " e1 e2)#Es> \ " +| mA[intro]: " \ " +| mB[intro]: " \ )#Es>" +| mC[intro]: ")#Es> \ " +| mD[intro]: "0 < n \ )#Es> \ " +| mE[intro]: " \ e2)#Es>" +| mF[intro]: " e2)#Es> \ )#Es>" +| mG[intro]: ")#Es> \ " +| mH[intro]: "n1\n2 \ )#Es> \ " inductive - "machine_star" :: "lam\ctx list\lam\ctx list\bool" (\<_,_> \* <_,_>\) + "machine_star" :: "lam\ctx list\lam\ctx list\bool" (\<_,_> \* <_,_>\) where - ms1[intro]: " \* " -| ms2[intro]: "\ \ ; \* \ \ \* " + ms1[intro]: " \* " +| ms2[intro]: "\ \ ; \* \ \ \* " lemma ms3[intro,trans]: - assumes a: " \* " " \* " - shows " \* " + assumes a: " \* " " \* " + shows " \* " using a by (induct) (auto) lemma ms4[intro]: - assumes a: " \ " - shows " \* " + assumes a: " \ " + shows " \* " using a by (rule ms2) (rule ms1) section \The Evaluation Relation (Big-Step Semantics)\ @@ -238,14 +238,14 @@ theorem eval_implies_machine_star_ctx: assumes a: "t \ t'" - shows " \* " + shows " \* " using a by (induct arbitrary: Es) (metis eval_to machine.intros ms1 ms2 ms3 ms4 v_LAM)+ corollary eval_implies_machine_star: assumes a: "t \ t'" - shows " \* " + shows " \* " using a by (auto dest: eval_implies_machine_star_ctx) section \The CBV Reduction Relation (Small-Step Semantics)\ @@ -313,18 +313,18 @@ using a by (induct E) (auto) lemma machine_implies_cbv_star_ctx: - assumes a: " \ " + assumes a: " \ " shows "(Es\)\e\ \cbv* (Es'\)\e'\" using a by (induct) (auto simp add: ctx_compose intro: cbv_in_ctx) lemma machine_star_implies_cbv_star_ctx: - assumes a: " \* " + assumes a: " \* " shows "(Es\)\e\ \cbv* (Es'\)\e'\" using a by (induct) (auto dest: machine_implies_cbv_star_ctx) lemma machine_star_implies_cbv_star: - assumes a: " \* " + assumes a: " \* " shows "e \cbv* e'" using a by (auto dest: machine_star_implies_cbv_star_ctx) @@ -350,7 +350,7 @@ text \The Soundness Property\ theorem machine_star_implies_eval: - assumes a: " \* " + assumes a: " \* " and b: "val t2" shows "t1 \ t2" proof - @@ -536,7 +536,7 @@ section \The Type-Preservation Property for the Machine and Evaluation Relation\ theorem machine_type_preservation: - assumes a: " \* " + assumes a: " \* " and b: "\ \ t : T" shows "\ \ t' : T" proof - @@ -549,7 +549,7 @@ and b: "\ \ t : T" shows "\ \ t' : T" proof - - from a have " \* " by (simp add: eval_implies_machine_star) + from a have " \* " by (simp add: eval_implies_machine_star) then show "\ \ t' : T" using b by (simp add: machine_type_preservation) qed diff -r ef362328b931 -r 12990a6dddcb src/HOL/Nominal/Examples/Compile.thy --- a/src/HOL/Nominal/Examples/Compile.thy Tue Oct 08 13:13:53 2024 +0200 +++ b/src/HOL/Nominal/Examples/Compile.thy Tue Oct 08 15:02:17 2024 +0200 @@ -41,7 +41,7 @@ | IUnit | INat "nat" | ISucc "trmI" - | IAss "trmI" "trmI" (\_\_\ [100,100] 100) + | IAss "trmI" "trmI" (\_\_\ [100,100] 100) | IRef "trmI" | ISeq "trmI" "trmI" (\_;;_\ [100,100] 100) | Iif "trmI" "trmI" "trmI" @@ -84,7 +84,7 @@ | t4[intro]: "valid \ \ \ I\ INat(n) : DataI(NatI)" | t5[intro]: "\ I\ e : DataI(NatI) \ \ I\ ISucc(e) : DataI(NatI)" | t6[intro]: "\\ I\ e : DataI(NatI)\ \ \ I\ IRef e : DataI (NatI)" -| t7[intro]: "\\ I\ e1 : DataI(NatI); \ I\ e2 : DataI(NatI)\ \ \ I\ e1\e2 : DataI(OneI)" +| t7[intro]: "\\ I\ e1 : DataI(NatI); \ I\ e2 : DataI(NatI)\ \ \ I\ e1\e2 : DataI(OneI)" | t8[intro]: "\\ I\ e1 : DataI(NatI); \ I\ e2 : \\ \ \ I\ e1;;e2 : \" | t9[intro]: "\\ I\ e: DataI(NatI); \ I\ e1 : \; \ I\ e2 : \\ \ \ I\ Iif e e1 e2 : \" @@ -192,7 +192,7 @@ | m3[intro]: "(m,INat(n))I\(m,INat(n))" | m4[intro]: "(m,e)I\(m',INat(n)) \ (m,ISucc(e))I\(m',INat(n+1))" | m5[intro]: "(m,e)I\(m',INat(n)) \ (m,IRef(e))I\(m',INat(m' n))" -| m6[intro]: "\(m,e1)I\(m',INat(n1)); (m',e2)I\(m'',INat(n2))\ \ (m,e1\e2)I\(m''(n1:=n2),IUnit)" +| m6[intro]: "\(m,e1)I\(m',INat(n1)); (m',e2)I\(m'',INat(n2))\ \ (m,e1\e2)I\(m''(n1:=n2),IUnit)" | m7[intro]: "\(m,e1)I\(m',IUnit); (m',e2)I\(m'',e)\ \ (m,e1;;e2)I\(m'',e)" | m8[intro]: "\(m,e)I\(m',INat(n)); n\0; (m',e1)I\(m'',e)\ \ (m,Iif e e1 e2)I\(m'',e)" | m9[intro]: "\(m,e)I\(m',INat(0)); (m',e2)I\(m'',e)\ \ (m,Iif e e1 e2)I\(m'',e)" @@ -210,17 +210,17 @@ (let limit = IRef(INat 0) in let v1 = (trans e1) in let v2 = (trans e2) in - (((ISucc limit)\v1);;(ISucc(ISucc limit)\v2));;(INat 0 \ ISucc(ISucc(limit))))" + (((ISucc limit)\v1);;(ISucc(ISucc limit)\v2));;(INat 0 \ ISucc(ISucc(limit))))" | "trans (Fst e) = IRef (ISucc (trans e))" | "trans (Snd e) = IRef (ISucc (ISucc (trans e)))" | "trans (InL e) = (let limit = IRef(INat 0) in let v = (trans e) in - (((ISucc limit)\INat(0));;(ISucc(ISucc limit)\v));;(INat 0 \ ISucc(ISucc(limit))))" + (((ISucc limit)\INat(0));;(ISucc(ISucc limit)\v));;(INat 0 \ ISucc(ISucc(limit))))" | "trans (InR e) = (let limit = IRef(INat 0) in let v = (trans e) in - (((ISucc limit)\INat(1));;(ISucc(ISucc limit)\v));;(INat 0 \ ISucc(ISucc(limit))))" + (((ISucc limit)\INat(1));;(ISucc(ISucc limit)\v));;(INat 0 \ ISucc(ISucc(limit))))" | "\x2\x1; x1\e; x1\e2; x2\e; x2\e1\ \ trans (Case e of inl x1 \ e1 | inr x2 \ e2) = (let v = (trans e) in diff -r ef362328b931 -r 12990a6dddcb src/HOL/Nominal/Examples/Fsub.thy --- a/src/HOL/Nominal/Examples/Fsub.thy Tue Oct 08 13:13:53 2024 +0200 +++ b/src/HOL/Nominal/Examples/Fsub.thy Tue Oct 08 15:02:17 2024 +0200 @@ -16,9 +16,6 @@ section \Types for Names, Nominal Datatype Declaration for Types and Terms\ -no_syntax - "_Map" :: "maplets => 'a \ 'b" (\(\indent=1 notation=\mixfix map\\[_])\) - text \The main point of this solution is to use names everywhere (be they bound, binding or free). In System \FSUB{} there are two kinds of names corresponding to type-variables and to term-variables. These two kinds of names are represented in @@ -386,183 +383,183 @@ by (finite_guess | fresh_guess | simp)+ nominal_primrec - subst_ty :: "ty \ tyvrs \ ty \ ty" (\_[_ \ _]\<^sub>\\ [300, 0, 0] 300) + subst_ty :: "ty \ tyvrs \ ty \ ty" (\_[_ \ _]\<^sub>\\ [300, 0, 0] 300) where - "(Tvar X)[Y \ T]\<^sub>\ = (if X=Y then T else Tvar X)" -| "(Top)[Y \ T]\<^sub>\ = Top" -| "(T\<^sub>1 \ T\<^sub>2)[Y \ T]\<^sub>\ = T\<^sub>1[Y \ T]\<^sub>\ \ T\<^sub>2[Y \ T]\<^sub>\" -| "X\(Y,T,T\<^sub>1) \ (\X<:T\<^sub>1. T\<^sub>2)[Y \ T]\<^sub>\ = (\X<:T\<^sub>1[Y \ T]\<^sub>\. T\<^sub>2[Y \ T]\<^sub>\)" + "(Tvar X)[Y \ T]\<^sub>\ = (if X=Y then T else Tvar X)" +| "(Top)[Y \ T]\<^sub>\ = Top" +| "(T\<^sub>1 \ T\<^sub>2)[Y \ T]\<^sub>\ = T\<^sub>1[Y \ T]\<^sub>\ \ T\<^sub>2[Y \ T]\<^sub>\" +| "X\(Y,T,T\<^sub>1) \ (\X<:T\<^sub>1. T\<^sub>2)[Y \ T]\<^sub>\ = (\X<:T\<^sub>1[Y \ T]\<^sub>\. T\<^sub>2[Y \ T]\<^sub>\)" by (finite_guess | fresh_guess | simp add: abs_fresh)+ lemma subst_eqvt[eqvt]: fixes pi::"tyvrs prm" and T::"ty" - shows "pi\(T[X \ T']\<^sub>\) = (pi\T)[(pi\X) \ (pi\T')]\<^sub>\" + shows "pi\(T[X \ T']\<^sub>\) = (pi\T)[(pi\X) \ (pi\T')]\<^sub>\" by (nominal_induct T avoiding: X T' rule: ty.strong_induct) (perm_simp add: fresh_bij)+ lemma subst_eqvt'[eqvt]: fixes pi::"vrs prm" and T::"ty" - shows "pi\(T[X \ T']\<^sub>\) = (pi\T)[(pi\X) \ (pi\T')]\<^sub>\" + shows "pi\(T[X \ T']\<^sub>\) = (pi\T)[(pi\X) \ (pi\T')]\<^sub>\" by (nominal_induct T avoiding: X T' rule: ty.strong_induct) (perm_simp add: fresh_left)+ lemma type_subst_fresh: fixes X::"tyvrs" assumes "X\T" and "X\P" - shows "X\T[Y \ P]\<^sub>\" + shows "X\T[Y \ P]\<^sub>\" using assms by (nominal_induct T avoiding: X Y P rule:ty.strong_induct) (auto simp: abs_fresh) lemma fresh_type_subst_fresh: assumes "X\T'" - shows "X\T[X \ T']\<^sub>\" + shows "X\T[X \ T']\<^sub>\" using assms by (nominal_induct T avoiding: X T' rule: ty.strong_induct) (auto simp: fresh_atm abs_fresh) lemma type_subst_identity: - "X\T \ T[X \ U]\<^sub>\ = T" + "X\T \ T[X \ U]\<^sub>\ = T" by (nominal_induct T avoiding: X U rule: ty.strong_induct) (simp_all add: fresh_atm abs_fresh) lemma type_substitution_lemma: - "X \ Y \ X\L \ M[X \ N]\<^sub>\[Y \ L]\<^sub>\ = M[Y \ L]\<^sub>\[X \ N[Y \ L]\<^sub>\]\<^sub>\" + "X \ Y \ X\L \ M[X \ N]\<^sub>\[Y \ L]\<^sub>\ = M[Y \ L]\<^sub>\[X \ N[Y \ L]\<^sub>\]\<^sub>\" by (nominal_induct M avoiding: X Y N L rule: ty.strong_induct) (auto simp: type_subst_fresh type_subst_identity) lemma type_subst_rename: - "Y\T \ ([(Y,X)]\T)[Y \ U]\<^sub>\ = T[X \ U]\<^sub>\" + "Y\T \ ([(Y,X)]\T)[Y \ U]\<^sub>\ = T[X \ U]\<^sub>\" by (nominal_induct T avoiding: X Y U rule: ty.strong_induct) (simp_all add: fresh_atm calc_atm abs_fresh fresh_aux) nominal_primrec - subst_tyb :: "binding \ tyvrs \ ty \ binding" (\_[_ \ _]\<^sub>b\ [100,100,100] 100) + subst_tyb :: "binding \ tyvrs \ ty \ binding" (\_[_ \ _]\<^sub>b\ [100,100,100] 100) where - "(TVarB X U)[Y \ T]\<^sub>b = TVarB X (U[Y \ T]\<^sub>\)" -| "(VarB X U)[Y \ T]\<^sub>b = VarB X (U[Y \ T]\<^sub>\)" + "(TVarB X U)[Y \ T]\<^sub>b = TVarB X (U[Y \ T]\<^sub>\)" +| "(VarB X U)[Y \ T]\<^sub>b = VarB X (U[Y \ T]\<^sub>\)" by auto lemma binding_subst_fresh: fixes X::"tyvrs" assumes "X\a" and "X\P" - shows "X\a[Y \ P]\<^sub>b" + shows "X\a[Y \ P]\<^sub>b" using assms by (nominal_induct a rule: binding.strong_induct) (auto simp: type_subst_fresh) lemma binding_subst_identity: - shows "X\B \ B[X \ U]\<^sub>b = B" + shows "X\B \ B[X \ U]\<^sub>b = B" by (induct B rule: binding.induct) (simp_all add: fresh_atm type_subst_identity) -primrec subst_tyc :: "env \ tyvrs \ ty \ env" (\_[_ \ _]\<^sub>e\ [100,100,100] 100) where - "([])[Y \ T]\<^sub>e= []" -| "(B#\)[Y \ T]\<^sub>e = (B[Y \ T]\<^sub>b)#(\[Y \ T]\<^sub>e)" +primrec subst_tyc :: "env \ tyvrs \ ty \ env" (\_[_ \ _]\<^sub>e\ [100,100,100] 100) where + "([])[Y \ T]\<^sub>e= []" +| "(B#\)[Y \ T]\<^sub>e = (B[Y \ T]\<^sub>b)#(\[Y \ T]\<^sub>e)" lemma ctxt_subst_fresh': fixes X::"tyvrs" assumes "X\\" and "X\P" - shows "X\\[Y \ P]\<^sub>e" + shows "X\\[Y \ P]\<^sub>e" using assms by (induct \) (auto simp: fresh_list_cons binding_subst_fresh) -lemma ctxt_subst_mem_TVarB: "TVarB X T \ set \ \ TVarB X (T[Y \ U]\<^sub>\) \ set (\[Y \ U]\<^sub>e)" +lemma ctxt_subst_mem_TVarB: "TVarB X T \ set \ \ TVarB X (T[Y \ U]\<^sub>\) \ set (\[Y \ U]\<^sub>e)" by (induct \) auto -lemma ctxt_subst_mem_VarB: "VarB x T \ set \ \ VarB x (T[Y \ U]\<^sub>\) \ set (\[Y \ U]\<^sub>e)" +lemma ctxt_subst_mem_VarB: "VarB x T \ set \ \ VarB x (T[Y \ U]\<^sub>\) \ set (\[Y \ U]\<^sub>e)" by (induct \) auto -lemma ctxt_subst_identity: "X\\ \ \[X \ U]\<^sub>e = \" +lemma ctxt_subst_identity: "X\\ \ \[X \ U]\<^sub>e = \" by (induct \) (simp_all add: fresh_list_cons binding_subst_identity) -lemma ctxt_subst_append: "(\ @ \)[X \ T]\<^sub>e = \[X \ T]\<^sub>e @ \[X \ T]\<^sub>e" +lemma ctxt_subst_append: "(\ @ \)[X \ T]\<^sub>e = \[X \ T]\<^sub>e @ \[X \ T]\<^sub>e" by (induct \) simp_all nominal_primrec - subst_trm :: "trm \ vrs \ trm \ trm" (\_[_ \ _]\ [300, 0, 0] 300) + subst_trm :: "trm \ vrs \ trm \ trm" (\_[_ \ _]\ [300, 0, 0] 300) where - "(Var x)[y \ t'] = (if x=y then t' else (Var x))" -| "(t1 \ t2)[y \ t'] = t1[y \ t'] \ t2[y \ t']" -| "(t \\<^sub>\ T)[y \ t'] = t[y \ t'] \\<^sub>\ T" -| "X\(T,t') \ (\X<:T. t)[y \ t'] = (\X<:T. t[y \ t'])" -| "x\(y,t') \ (\x:T. t)[y \ t'] = (\x:T. t[y \ t'])" + "(Var x)[y \ t'] = (if x=y then t' else (Var x))" +| "(t1 \ t2)[y \ t'] = t1[y \ t'] \ t2[y \ t']" +| "(t \\<^sub>\ T)[y \ t'] = t[y \ t'] \\<^sub>\ T" +| "X\(T,t') \ (\X<:T. t)[y \ t'] = (\X<:T. t[y \ t'])" +| "x\(y,t') \ (\x:T. t)[y \ t'] = (\x:T. t[y \ t'])" by (finite_guess | simp add: abs_fresh | fresh_guess add: ty_vrs_fresh abs_fresh)+ lemma subst_trm_fresh_tyvar: fixes X::"tyvrs" - shows "X\t \ X\u \ X\t[x \ u]" + shows "X\t \ X\u \ X\t[x \ u]" by (nominal_induct t avoiding: x u rule: trm.strong_induct) (auto simp: abs_fresh) lemma subst_trm_fresh_var: - "x\u \ x\t[x \ u]" + "x\u \ x\t[x \ u]" by (nominal_induct t avoiding: x u rule: trm.strong_induct) (simp_all add: abs_fresh fresh_atm ty_vrs_fresh) lemma subst_trm_eqvt[eqvt]: fixes pi::"tyvrs prm" and t::"trm" - shows "pi\(t[x \ u]) = (pi\t)[(pi\x) \ (pi\u)]" + shows "pi\(t[x \ u]) = (pi\t)[(pi\x) \ (pi\u)]" by (nominal_induct t avoiding: x u rule: trm.strong_induct) (perm_simp add: fresh_left)+ lemma subst_trm_eqvt'[eqvt]: fixes pi::"vrs prm" and t::"trm" - shows "pi\(t[x \ u]) = (pi\t)[(pi\x) \ (pi\u)]" + shows "pi\(t[x \ u]) = (pi\t)[(pi\x) \ (pi\u)]" by (nominal_induct t avoiding: x u rule: trm.strong_induct) (perm_simp add: fresh_left)+ lemma subst_trm_rename: - "y\t \ ([(y, x)] \ t)[y \ u] = t[x \ u]" + "y\t \ ([(y, x)] \ t)[y \ u] = t[x \ u]" by (nominal_induct t avoiding: x y u rule: trm.strong_induct) (simp_all add: fresh_atm calc_atm abs_fresh fresh_aux ty_vrs_fresh perm_fresh_fresh) nominal_primrec (freshness_context: "T2::ty") - subst_trm_ty :: "trm \ tyvrs \ ty \ trm" (\_[_ \\<^sub>\ _]\ [300, 0, 0] 300) + subst_trm_ty :: "trm \ tyvrs \ ty \ trm" (\_[_ \\<^sub>\ _]\ [300, 0, 0] 300) where - "(Var x)[Y \\<^sub>\ T2] = Var x" -| "(t1 \ t2)[Y \\<^sub>\ T2] = t1[Y \\<^sub>\ T2] \ t2[Y \\<^sub>\ T2]" -| "(t1 \\<^sub>\ T)[Y \\<^sub>\ T2] = t1[Y \\<^sub>\ T2] \\<^sub>\ T[Y \ T2]\<^sub>\" -| "X\(Y,T,T2) \ (\X<:T. t)[Y \\<^sub>\ T2] = (\X<:T[Y \ T2]\<^sub>\. t[Y \\<^sub>\ T2])" -| "(\x:T. t)[Y \\<^sub>\ T2] = (\x:T[Y \ T2]\<^sub>\. t[Y \\<^sub>\ T2])" + "(Var x)[Y \\<^sub>\ T2] = Var x" +| "(t1 \ t2)[Y \\<^sub>\ T2] = t1[Y \\<^sub>\ T2] \ t2[Y \\<^sub>\ T2]" +| "(t1 \\<^sub>\ T)[Y \\<^sub>\ T2] = t1[Y \\<^sub>\ T2] \\<^sub>\ T[Y \ T2]\<^sub>\" +| "X\(Y,T,T2) \ (\X<:T. t)[Y \\<^sub>\ T2] = (\X<:T[Y \ T2]\<^sub>\. t[Y \\<^sub>\ T2])" +| "(\x:T. t)[Y \\<^sub>\ T2] = (\x:T[Y \ T2]\<^sub>\. t[Y \\<^sub>\ T2])" apply(finite_guess | simp add: abs_fresh ty_vrs_fresh type_subst_fresh)+ apply(fresh_guess add: ty_vrs_fresh abs_fresh)+ done lemma subst_trm_ty_fresh: fixes X::"tyvrs" - shows "X\t \ X\T \ X\t[Y \\<^sub>\ T]" + shows "X\t \ X\T \ X\t[Y \\<^sub>\ T]" by (nominal_induct t avoiding: Y T rule: trm.strong_induct) (auto simp: abs_fresh type_subst_fresh) lemma subst_trm_ty_fresh': - "X\T \ X\t[X \\<^sub>\ T]" + "X\T \ X\t[X \\<^sub>\ T]" by (nominal_induct t avoiding: X T rule: trm.strong_induct) (simp_all add: abs_fresh fresh_type_subst_fresh fresh_atm) lemma subst_trm_ty_eqvt[eqvt]: fixes pi::"tyvrs prm" and t::"trm" - shows "pi\(t[X \\<^sub>\ T]) = (pi\t)[(pi\X) \\<^sub>\ (pi\T)]" + shows "pi\(t[X \\<^sub>\ T]) = (pi\t)[(pi\X) \\<^sub>\ (pi\T)]" by (nominal_induct t avoiding: X T rule: trm.strong_induct) (perm_simp add: fresh_bij subst_eqvt)+ lemma subst_trm_ty_eqvt'[eqvt]: fixes pi::"vrs prm" and t::"trm" - shows "pi\(t[X \\<^sub>\ T]) = (pi\t)[(pi\X) \\<^sub>\ (pi\T)]" + shows "pi\(t[X \\<^sub>\ T]) = (pi\t)[(pi\X) \\<^sub>\ (pi\T)]" by (nominal_induct t avoiding: X T rule: trm.strong_induct) (perm_simp add: fresh_left subst_eqvt')+ lemma subst_trm_ty_rename: - "Y\t \ ([(Y, X)] \ t)[Y \\<^sub>\ U] = t[X \\<^sub>\ U]" + "Y\t \ ([(Y, X)] \ t)[Y \\<^sub>\ U] = t[X \\<^sub>\ U]" by (nominal_induct t avoiding: X Y U rule: trm.strong_induct) (simp_all add: fresh_atm calc_atm abs_fresh fresh_aux type_subst_rename) @@ -1024,14 +1021,14 @@ | T_Abs[intro]: "\ VarB x T\<^sub>1 # \ \ t\<^sub>2 : T\<^sub>2 \ \ \ \ (\x:T\<^sub>1. t\<^sub>2) : T\<^sub>1 \ T\<^sub>2" | T_Sub[intro]: "\ \ \ t : S; \ \ S <: T \ \ \ \ t : T" | T_TAbs[intro]:"\ TVarB X T\<^sub>1 # \ \ t\<^sub>2 : T\<^sub>2 \ \ \ \ (\X<:T\<^sub>1. t\<^sub>2) : (\X<:T\<^sub>1. T\<^sub>2)" -| T_TApp[intro]:"\X\(\,t\<^sub>1,T\<^sub>2); \ \ t\<^sub>1 : (\X<:T\<^sub>11. T\<^sub>12); \ \ T\<^sub>2 <: T\<^sub>11\ \ \ \ t\<^sub>1 \\<^sub>\ T\<^sub>2 : (T\<^sub>12[X \ T\<^sub>2]\<^sub>\)" +| T_TApp[intro]:"\X\(\,t\<^sub>1,T\<^sub>2); \ \ t\<^sub>1 : (\X<:T\<^sub>11. T\<^sub>12); \ \ T\<^sub>2 <: T\<^sub>11\ \ \ \ t\<^sub>1 \\<^sub>\ T\<^sub>2 : (T\<^sub>12[X \ T\<^sub>2]\<^sub>\)" equivariance typing lemma better_T_TApp: assumes H1: "\ \ t\<^sub>1 : (\X<:T11. T12)" and H2: "\ \ T2 <: T11" - shows "\ \ t\<^sub>1 \\<^sub>\ T2 : (T12[X \ T2]\<^sub>\)" + shows "\ \ t\<^sub>1 \\<^sub>\ T2 : (T12[X \ T2]\<^sub>\)" proof - obtain Y::tyvrs where Y: "Y \ (X, T12, \, t\<^sub>1, T2)" by (rule exists_fresh) (rule fin_supp) @@ -1039,7 +1036,7 @@ moreover from Y have "(\X<:T11. T12) = (\Y<:T11. [(Y, X)] \ T12)" by (auto simp: ty.inject alpha' fresh_prod fresh_atm) with H1 have "\ \ t\<^sub>1 : (\Y<:T11. [(Y, X)] \ T12)" by simp - ultimately have "\ \ t\<^sub>1 \\<^sub>\ T2 : (([(Y, X)] \ T12)[Y \ T2]\<^sub>\)" using H2 + ultimately have "\ \ t\<^sub>1 \\<^sub>\ T2 : (([(Y, X)] \ T12)[Y \ T2]\<^sub>\)" using H2 by (rule T_TApp) with Y show ?thesis by (simp add: type_subst_rename) qed @@ -1058,20 +1055,20 @@ shows "VarB x T \ set \ \ T closed_in \" using ok by induct (auto simp: binding.inject closed_in_def) -lemma tyvrs_of_subst: "tyvrs_of (B[X \ T]\<^sub>b) = tyvrs_of B" +lemma tyvrs_of_subst: "tyvrs_of (B[X \ T]\<^sub>b) = tyvrs_of B" by (nominal_induct B rule: binding.strong_induct) simp_all -lemma ty_dom_subst: "ty_dom (\[X \ T]\<^sub>e) = ty_dom \" +lemma ty_dom_subst: "ty_dom (\[X \ T]\<^sub>e) = ty_dom \" by (induct \) (simp_all add: tyvrs_of_subst) -lemma vrs_of_subst: "vrs_of (B[X \ T]\<^sub>b) = vrs_of B" +lemma vrs_of_subst: "vrs_of (B[X \ T]\<^sub>b) = vrs_of B" by (nominal_induct B rule: binding.strong_induct) simp_all -lemma trm_dom_subst: "trm_dom (\[X \ T]\<^sub>e) = trm_dom \" +lemma trm_dom_subst: "trm_dom (\[X \ T]\<^sub>e) = trm_dom \" by (induct \) (simp_all add: vrs_of_subst) lemma subst_closed_in: - "T closed_in (\ @ TVarB X S # \) \ U closed_in \ \ T[X \ U]\<^sub>\ closed_in (\[X \ U]\<^sub>e @ \)" + "T closed_in (\ @ TVarB X S # \) \ U closed_in \ \ T[X \ U]\<^sub>\ closed_in (\[X \ U]\<^sub>e @ \)" proof (nominal_induct T avoiding: X U \ rule: ty.strong_induct) case (Tvar tyvrs) then show ?case @@ -1086,7 +1083,7 @@ by (simp add: closed_in_def ty.supp) next case (Forall tyvrs ty1 ty2) - then have "supp (ty1[X \ U]\<^sub>\) \ ty_dom (\[X \ U]\<^sub>e @ TVarB tyvrs ty2 # \)" + then have "supp (ty1[X \ U]\<^sub>\) \ ty_dom (\[X \ U]\<^sub>e @ TVarB tyvrs ty2 # \)" apply (simp add: closed_in_def ty.supp abs_supp) by (metis Diff_subset_conv Un_left_commute doms_append(1) le_supI2 ty_dom.simps(2) tyvrs_of.simps(2)) with Forall show ?case @@ -1147,36 +1144,36 @@ inductive eval :: "trm \ trm \ bool" (\_ \ _\ [60,60] 60) where - E_Abs : "\ x \ v\<^sub>2; val v\<^sub>2 \ \ (\x:T\<^sub>11. t\<^sub>12) \ v\<^sub>2 \ t\<^sub>12[x \ v\<^sub>2]" + E_Abs : "\ x \ v\<^sub>2; val v\<^sub>2 \ \ (\x:T\<^sub>11. t\<^sub>12) \ v\<^sub>2 \ t\<^sub>12[x \ v\<^sub>2]" | E_App1 [intro]: "t \ t' \ t \ u \ t' \ u" | E_App2 [intro]: "\ val v; t \ t' \ \ v \ t \ v \ t'" -| E_TAbs : "X \ (T\<^sub>11, T\<^sub>2) \ (\X<:T\<^sub>11. t\<^sub>12) \\<^sub>\ T\<^sub>2 \ t\<^sub>12[X \\<^sub>\ T\<^sub>2]" +| E_TAbs : "X \ (T\<^sub>11, T\<^sub>2) \ (\X<:T\<^sub>11. t\<^sub>12) \\<^sub>\ T\<^sub>2 \ t\<^sub>12[X \\<^sub>\ T\<^sub>2]" | E_TApp [intro]: "t \ t' \ t \\<^sub>\ T \ t' \\<^sub>\ T" lemma better_E_Abs[intro]: assumes H: "val v2" - shows "(\x:T11. t12) \ v2 \ t12[x \ v2]" + shows "(\x:T11. t12) \ v2 \ t12[x \ v2]" proof - obtain y::vrs where y: "y \ (x, t12, v2)" by (rule exists_fresh) (rule fin_supp) then have "y \ v2" by simp - then have "(\y:T11. [(y, x)] \ t12) \ v2 \ ([(y, x)] \ t12)[y \ v2]" using H + then have "(\y:T11. [(y, x)] \ t12) \ v2 \ ([(y, x)] \ t12)[y \ v2]" using H by (rule E_Abs) moreover from y have "(\x:T11. t12) \ v2 = (\y:T11. [(y, x)] \ t12) \ v2" by (auto simp: trm.inject alpha' fresh_prod fresh_atm) - ultimately have "(\x:T11. t12) \ v2 \ ([(y, x)] \ t12)[y \ v2]" + ultimately have "(\x:T11. t12) \ v2 \ ([(y, x)] \ t12)[y \ v2]" by simp with y show ?thesis by (simp add: subst_trm_rename) qed -lemma better_E_TAbs[intro]: "(\X<:T11. t12) \\<^sub>\ T2 \ t12[X \\<^sub>\ T2]" +lemma better_E_TAbs[intro]: "(\X<:T11. t12) \\<^sub>\ T2 \ t12[X \\<^sub>\ T2]" proof - obtain Y::tyvrs where Y: "Y \ (X, t12, T11, T2)" by (rule exists_fresh) (rule fin_supp) then have "Y \ (T11, T2)" by simp - then have "(\Y<:T11. [(Y, X)] \ t12) \\<^sub>\ T2 \ ([(Y, X)] \ t12)[Y \\<^sub>\ T2]" + then have "(\Y<:T11. [(Y, X)] \ t12) \\<^sub>\ T2 \ ([(Y, X)] \ t12)[Y \\<^sub>\ T2]" by (rule E_TAbs) moreover from Y have "(\X<:T11. t12) \\<^sub>\ T2 = (\Y<:T11. [(Y, X)] \ t12) \\<^sub>\ T2" by (auto simp: trm.inject alpha' fresh_prod fresh_atm) - ultimately have "(\X<:T11. t12) \\<^sub>\ T2 \ ([(Y, X)] \ t12)[Y \\<^sub>\ T2]" + ultimately have "(\X<:T11. t12) \\<^sub>\ T2 \ ([(Y, X)] \ t12)[Y \\<^sub>\ T2]" by simp with Y show ?thesis by (simp add: subst_trm_ty_rename) qed @@ -1210,7 +1207,7 @@ lemma valid_subst: assumes ok: "\ (\ @ TVarB X Q # \) ok" and closed: "P closed_in \" - shows "\ (\[X \ P]\<^sub>e @ \) ok" using ok closed + shows "\ (\[X \ P]\<^sub>e @ \) ok" using ok closed proof (induct \) case Nil then show ?case @@ -1409,7 +1406,7 @@ theorem subst_type: \ \A.8\ assumes H: "(\ @ (VarB x U) # \) \ t : T" - shows "\ \ u : U \ \ @ \ \ t[x \ u] : T" using H + shows "\ \ u : U \ \ @ \ \ t[x \ u] : T" using H proof (nominal_induct "\ @ (VarB x U) # \" t T avoiding: x u arbitrary: \ rule: typing.strong_induct) case (T_Var y T x u D) show ?case @@ -1431,7 +1428,7 @@ then show ?case by force next case (T_Sub t S T x u D) - then have "D @ \ \ t[x \ u] : S" by auto + then have "D @ \ \ t[x \ u] : S" by auto moreover have "(D @ \) \ S<:T" using T_Sub by (auto dest: strengthening) ultimately show ?case by auto next @@ -1442,7 +1439,7 @@ next case (T_TApp X t1 T2 T11 T12 x u D) then have "(D@\) \T2<:T11" using T_TApp by (auto dest: strengthening) - then show "((D @ \) \ ((t1 \\<^sub>\ T2)[x \ u]) : (T12[X \ T2]\<^sub>\))" using T_TApp + then show "((D @ \) \ ((t1 \\<^sub>\ T2)[x \ u]) : (T12[X \ T2]\<^sub>\))" using T_TApp by (force simp: fresh_prod fresh_list_append fresh_list_cons subst_trm_fresh_tyvar) qed @@ -1450,24 +1447,24 @@ lemma substT_subtype: \ \A.10\ assumes H: "(\ @ ((TVarB X Q) # \)) \ S <: T" - shows "\ \ P <: Q \ (\[X \ P]\<^sub>e @ \) \ S[X \ P]\<^sub>\ <: T[X \ P]\<^sub>\" + shows "\ \ P <: Q \ (\[X \ P]\<^sub>e @ \) \ S[X \ P]\<^sub>\ <: T[X \ P]\<^sub>\" using H proof (nominal_induct "\ @ TVarB X Q # \" S T avoiding: X P arbitrary: \ rule: subtype_of.strong_induct) case (SA_Top S X P D) then have "\ (D @ TVarB X Q # \) ok" by simp moreover have closed: "P closed_in \" using SA_Top subtype_implies_closed by auto - ultimately have "\ (D[X \ P]\<^sub>e @ \) ok" by (rule valid_subst) + ultimately have "\ (D[X \ P]\<^sub>e @ \) ok" by (rule valid_subst) moreover from SA_Top have "S closed_in (D @ TVarB X Q # \)" by simp - then have "S[X \ P]\<^sub>\ closed_in (D[X \ P]\<^sub>e @ \)" using closed by (rule subst_closed_in) + then have "S[X \ P]\<^sub>\ closed_in (D[X \ P]\<^sub>e @ \)" using closed by (rule subst_closed_in) ultimately show ?case by auto next case (SA_trans_TVar Y S T X P D) have h:"(D @ TVarB X Q # \)\S<:T" by fact - then have ST: "(D[X \ P]\<^sub>e @ \) \ S[X \ P]\<^sub>\ <: T[X \ P]\<^sub>\" using SA_trans_TVar by auto + then have ST: "(D[X \ P]\<^sub>e @ \) \ S[X \ P]\<^sub>\ <: T[X \ P]\<^sub>\" using SA_trans_TVar by auto from h have G_ok: "\ (D @ TVarB X Q # \) ok" by (rule subtype_implies_ok) from G_ok and SA_trans_TVar have X_\_ok: "\ (TVarB X Q # \) ok" by (auto intro: validE_append) - show "(D[X \ P]\<^sub>e @ \) \ Tvar Y[X \ P]\<^sub>\<:T[X \ P]\<^sub>\" + show "(D[X \ P]\<^sub>e @ \) \ Tvar Y[X \ P]\<^sub>\<:T[X \ P]\<^sub>\" proof (cases "X = Y") assume eq: "X = Y" from eq and SA_trans_TVar have "TVarB Y Q \ set (D @ TVarB X Q # \)" by simp @@ -1476,13 +1473,13 @@ from X_\_ok have "X \ ty_dom \" and "Q closed_in \" by auto then have XQ: "X \ Q" by (rule closed_in_fresh) note \\\P<:Q\ - moreover from ST have "\ (D[X \ P]\<^sub>e @ \) ok" by (rule subtype_implies_ok) - moreover have "(D[X \ P]\<^sub>e @ \) extends \" by (simp add: extends_def) - ultimately have "(D[X \ P]\<^sub>e @ \) \ P<:Q" by (rule weakening) - with QS have "(D[X \ P]\<^sub>e @ \) \ P<:S" by simp - moreover from XQ and ST and QS have "(D[X \ P]\<^sub>e @ \) \ S<:T[X \ P]\<^sub>\" + moreover from ST have "\ (D[X \ P]\<^sub>e @ \) ok" by (rule subtype_implies_ok) + moreover have "(D[X \ P]\<^sub>e @ \) extends \" by (simp add: extends_def) + ultimately have "(D[X \ P]\<^sub>e @ \) \ P<:Q" by (rule weakening) + with QS have "(D[X \ P]\<^sub>e @ \) \ P<:S" by simp + moreover from XQ and ST and QS have "(D[X \ P]\<^sub>e @ \) \ S<:T[X \ P]\<^sub>\" by (simp add: type_subst_identity) - ultimately have "(D[X \ P]\<^sub>e @ \) \ P<:T[X \ P]\<^sub>\" + ultimately have "(D[X \ P]\<^sub>e @ \) \ P<:T[X \ P]\<^sub>\" by (rule subtype_transitivity) with eq show ?case by simp next @@ -1492,9 +1489,9 @@ then show ?case proof assume "TVarB Y S \ set D" - then have "TVarB Y (S[X \ P]\<^sub>\) \ set (D[X \ P]\<^sub>e)" + then have "TVarB Y (S[X \ P]\<^sub>\) \ set (D[X \ P]\<^sub>e)" by (rule ctxt_subst_mem_TVarB) - then have "TVarB Y (S[X \ P]\<^sub>\) \ set (D[X \ P]\<^sub>e @ \)" by simp + then have "TVarB Y (S[X \ P]\<^sub>\) \ set (D[X \ P]\<^sub>e @ \)" by simp with neq and ST show ?thesis by auto next assume Y: "TVarB Y S \ set \" @@ -1502,9 +1499,9 @@ then have "X \ \" by (simp add: valid_ty_dom_fresh) with Y have "X \ S" by (induct \) (auto simp: fresh_list_nil fresh_list_cons) - with ST have "(D[X \ P]\<^sub>e @ \)\S<:T[X \ P]\<^sub>\" + with ST have "(D[X \ P]\<^sub>e @ \)\S<:T[X \ P]\<^sub>\" by (simp add: type_subst_identity) - moreover from Y have "TVarB Y S \ set (D[X \ P]\<^sub>e @ \)" by simp + moreover from Y have "TVarB Y S \ set (D[X \ P]\<^sub>e @ \)" by simp ultimately show ?thesis using neq by auto qed qed @@ -1513,8 +1510,8 @@ note \\ (D @ TVarB X Q # \) ok\ moreover from SA_refl_TVar have closed: "P closed_in \" by (auto dest: subtype_implies_closed) - ultimately have ok: "\ (D[X \ P]\<^sub>e @ \) ok" using valid_subst by auto - from closed have closed': "P closed_in (D[X \ P]\<^sub>e @ \)" + ultimately have ok: "\ (D[X \ P]\<^sub>e @ \) ok" using valid_subst by auto + from closed have closed': "P closed_in (D[X \ P]\<^sub>e @ \)" by (simp add: closed_in_weaken') show ?case proof (cases "X = Y") @@ -1523,14 +1520,14 @@ by (auto intro: subtype_reflexivity) next assume neq: "X \ Y" - with SA_refl_TVar have "Y \ ty_dom (D[X \ P]\<^sub>e @ \)" + with SA_refl_TVar have "Y \ ty_dom (D[X \ P]\<^sub>e @ \)" by (simp add: ty_dom_subst doms_append) with neq and ok show ?thesis by auto qed next case (SA_arrow T1 S1 S2 T2 X P D) - then have h1:"(D[X \ P]\<^sub>e @ \)\T1[X \ P]\<^sub>\<:S1[X \ P]\<^sub>\" using SA_arrow by auto - from SA_arrow have h2:"(D[X \ P]\<^sub>e @ \)\S2[X \ P]\<^sub>\<:T2[X \ P]\<^sub>\" using SA_arrow by auto + then have h1:"(D[X \ P]\<^sub>e @ \)\T1[X \ P]\<^sub>\<:S1[X \ P]\<^sub>\" using SA_arrow by auto + from SA_arrow have h2:"(D[X \ P]\<^sub>e @ \)\S2[X \ P]\<^sub>\<:T2[X \ P]\<^sub>\" using SA_arrow by auto show ?case using subtype_of.SA_arrow h1 h2 by auto next case (SA_all T1 S1 Y S2 T2 X P D) @@ -1550,19 +1547,19 @@ theorem substT_type: \ \A.11\ assumes H: "(D @ TVarB X Q # G) \ t : T" shows "G \ P <: Q \ - (D[X \ P]\<^sub>e @ G) \ t[X \\<^sub>\ P] : T[X \ P]\<^sub>\" using H + (D[X \ P]\<^sub>e @ G) \ t[X \\<^sub>\ P] : T[X \ P]\<^sub>\" using H proof (nominal_induct "D @ TVarB X Q # G" t T avoiding: X P arbitrary: D rule: typing.strong_induct) case (T_Var x T X P D') have "G\P<:Q" by fact then have "P closed_in G" using subtype_implies_closed by auto moreover note \\ (D' @ TVarB X Q # G) ok\ - ultimately have "\ (D'[X \ P]\<^sub>e @ G) ok" using valid_subst by auto + ultimately have "\ (D'[X \ P]\<^sub>e @ G) ok" using valid_subst by auto moreover note \VarB x T \ set (D' @ TVarB X Q # G)\ then have "VarB x T \ set D' \ VarB x T \ set G" by simp - then have "(VarB x (T[X \ P]\<^sub>\)) \ set (D'[X \ P]\<^sub>e @ G)" + then have "(VarB x (T[X \ P]\<^sub>\)) \ set (D'[X \ P]\<^sub>e @ G)" proof assume "VarB x T \ set D'" - then have "VarB x (T[X \ P]\<^sub>\) \ set (D'[X \ P]\<^sub>e)" + then have "VarB x (T[X \ P]\<^sub>\) \ set (D'[X \ P]\<^sub>e)" by (rule ctxt_subst_mem_VarB) then show ?thesis by simp next @@ -1571,7 +1568,7 @@ then have "X \ ty_dom G" using T_Var by (auto dest: validE_append) with ok have "X \ G" by (simp add: valid_ty_dom_fresh) moreover from x have "VarB x T \ set (D' @ G)" by simp - then have "VarB x (T[X \ P]\<^sub>\) \ set ((D' @ G)[X \ P]\<^sub>e)" + then have "VarB x (T[X \ P]\<^sub>\) \ set ((D' @ G)[X \ P]\<^sub>e)" by (rule ctxt_subst_mem_VarB) ultimately show ?thesis by (simp add: ctxt_subst_append ctxt_subst_identity) @@ -1579,8 +1576,8 @@ ultimately show ?case by auto next case (T_App t1 T1 T2 t2 X P D') - then have "D'[X \ P]\<^sub>e @ G \ t1[X \\<^sub>\ P] : (T1 \ T2)[X \ P]\<^sub>\" by auto - moreover from T_App have "D'[X \ P]\<^sub>e @ G \ t2[X \\<^sub>\ P] : T1[X \ P]\<^sub>\" by auto + then have "D'[X \ P]\<^sub>e @ G \ t1[X \\<^sub>\ P] : (T1 \ T2)[X \ P]\<^sub>\" by auto + moreover from T_App have "D'[X \ P]\<^sub>e @ G \ t2[X \\<^sub>\ P] : T1[X \ P]\<^sub>\" by auto ultimately show ?case by auto next case (T_Abs x T1 t2 T2 X P D') @@ -1602,7 +1599,7 @@ moreover from T_TApp have "T11 closed_in (D' @ TVarB X Q # G)" by (auto dest: subtype_implies_closed) ultimately have X': "X' \ T11" by (rule closed_in_fresh) - from T_TApp have "D'[X \ P]\<^sub>e @ G \ t1[X \\<^sub>\ P] : (\X'<:T11. T12)[X \ P]\<^sub>\" + from T_TApp have "D'[X \ P]\<^sub>e @ G \ t1[X \\<^sub>\ P] : (\X'<:T11. T12)[X \ P]\<^sub>\" by simp with X' and T_TApp show ?case by (auto simp: fresh_atm type_substitution_lemma @@ -1723,9 +1720,9 @@ by (rule Abs_type') blast from \\ \ t\<^sub>2 : T\<^sub>11\ have "\ \ t\<^sub>2 : T\<^sub>11'" using T\<^sub>11 by (rule T_Sub) - with t\<^sub>12 have "\ \ t\<^sub>12[x \ t\<^sub>2] : S'" + with t\<^sub>12 have "\ \ t\<^sub>12[x \ t\<^sub>2] : S'" by (rule subst_type [where \="[]", simplified]) - hence "\ \ t\<^sub>12[x \ t\<^sub>2] : T\<^sub>12" using S' by (rule T_Sub) + hence "\ \ t\<^sub>12[x \ t\<^sub>2] : T\<^sub>12" using S' by (rule T_Sub) with E_Abs and x_fresh show ?thesis by (simp add: trm.inject fresh_prod) next case (E_App1 t''' t'' u) @@ -1759,14 +1756,14 @@ and "(TVarB X T\<^sub>11 # \) \ S' <: T\<^sub>12" by (rule TAbs_type') blast hence "TVarB X T\<^sub>11 # \ \ t\<^sub>12 : T\<^sub>12" by (rule T_Sub) - hence "\ \ t\<^sub>12[X \\<^sub>\ T\<^sub>2] : T\<^sub>12[X \ T\<^sub>2]\<^sub>\" using \\ \ T\<^sub>2 <: T\<^sub>11\ + hence "\ \ t\<^sub>12[X \\<^sub>\ T\<^sub>2] : T\<^sub>12[X \ T\<^sub>2]\<^sub>\" using \\ \ T\<^sub>2 <: T\<^sub>11\ by (rule substT_type [where D="[]", simplified]) with T_TApp and E_TAbs show ?thesis by (simp add: trm.inject) next case (E_TApp t''' t'' T) from E_TApp have "t\<^sub>1 \ t''" by (simp add: trm.inject) then have "\ \ t'' : (\X<:T\<^sub>11. T\<^sub>12)" by (rule T_TApp) - then have "\ \ t'' \\<^sub>\ T\<^sub>2 : T\<^sub>12[X \ T\<^sub>2]\<^sub>\" using \\ \ T\<^sub>2 <: T\<^sub>11\ + then have "\ \ t'' \\<^sub>\ T\<^sub>2 : T\<^sub>12[X \ T\<^sub>2]\<^sub>\" using \\ \ T\<^sub>2 <: T\<^sub>11\ by (rule better_T_TApp) with E_TApp show ?thesis by (simp add: trm.inject) qed (simp_all add: fresh_prod) @@ -1817,7 +1814,7 @@ thus ?case proof assume "val t\<^sub>2" - with t\<^sub>1 have "t\<^sub>1 \ t\<^sub>2 \ t3[x \ t\<^sub>2]" by auto + with t\<^sub>1 have "t\<^sub>1 \ t\<^sub>2 \ t3[x \ t\<^sub>2]" by auto thus ?case by auto next assume "\t'. t\<^sub>2 \ t'" @@ -1839,7 +1836,7 @@ assume "val t\<^sub>1" with T_TApp obtain x t S where "t\<^sub>1 = (\x<:S. t)" by (auto dest!: TyAll_canonical) - hence "t\<^sub>1 \\<^sub>\ T\<^sub>2 \ t[x \\<^sub>\ T\<^sub>2]" by auto + hence "t\<^sub>1 \\<^sub>\ T\<^sub>2 \ t[x \\<^sub>\ T\<^sub>2]" by auto thus ?case by auto next assume "\t'. t\<^sub>1 \ t'" thus ?case by auto diff -r ef362328b931 -r 12990a6dddcb src/HOL/Nominal/Examples/Pattern.thy --- a/src/HOL/Nominal/Examples/Pattern.thy Tue Oct 08 13:13:53 2024 +0200 +++ b/src/HOL/Nominal/Examples/Pattern.thy Tue Oct 08 15:02:17 2024 +0200 @@ -4,9 +4,6 @@ imports "HOL-Nominal.Nominal" begin -no_syntax - "_Map" :: "maplets => 'a \ 'b" (\(\indent=1 notation=\mixfix map\\[_])\) - atom_decl name nominal_datatype ty = @@ -320,14 +317,14 @@ (simp_all add: eqvts fresh_bij) abbreviation - subst :: "trm \ name \ trm \ trm" (\_[_\_]\ [100,0,0] 100) + subst :: "trm \ name \ trm \ trm" (\_[_\_]\ [100,0,0] 100) where - "t[x\t'] \ [(x,t')]\t\" + "t[x\t'] \ [(x,t')]\t\" abbreviation - substb :: "btrm \ name \ trm \ btrm" (\_[_\_]\<^sub>b\ [100,0,0] 100) + substb :: "btrm \ name \ trm \ btrm" (\_[_\_]\<^sub>b\ [100,0,0] 100) where - "t[x\t']\<^sub>b \ [(x,t')]\t\\<^sub>b" + "t[x\t']\<^sub>b \ [(x,t')]\t\\<^sub>b" lemma lookup_forget: "(supp (map fst \)::name set) \* x \ lookup \ x = Var x" @@ -360,7 +357,7 @@ lemma psubst_cons: assumes "(supp (map fst \)::name set) \* u" - shows "((x, u) # \)\t\ = \\t[x\u]\" and "((x, u) # \)\t'\\<^sub>b = \\t'[x\u]\<^sub>b\\<^sub>b" + shows "((x, u) # \)\t\ = \\t[x\u]\" and "((x, u) # \)\t'\\<^sub>b = \\t'[x\u]\<^sub>b\\<^sub>b" using assms by (nominal_induct t and t' avoiding: x u \ rule: trm_btrm.strong_inducts) (simp_all add: fresh_list_nil fresh_list_cons psubst_forget) @@ -406,38 +403,38 @@ lemma subst_type_aux: assumes a: "\ @ [(x, U)] @ \ \ t : T" and b: "\ \ u : U" - shows "\ @ \ \ t[x\u] : T" using a b + shows "\ @ \ \ t[x\u] : T" using a b proof (nominal_induct \'\"\ @ [(x, U)] @ \" t T avoiding: x u \ rule: typing.strong_induct) case (Var y T x u \) from \valid (\ @ [(x, U)] @ \)\ have valid: "valid (\ @ \)" by (rule valid_insert) - show "\ @ \ \ Var y[x\u] : T" + show "\ @ \ \ Var y[x\u] : T" proof cases assume eq: "x = y" from Var eq have "T = U" by (auto intro: context_unique) - with Var eq valid show "\ @ \ \ Var y[x\u] : T" by (auto intro: weakening) + with Var eq valid show "\ @ \ \ Var y[x\u] : T" by (auto intro: weakening) next assume ineq: "x \ y" from Var ineq have "(y, T) \ set (\ @ \)" by simp - then show "\ @ \ \ Var y[x\u] : T" using ineq valid by auto + then show "\ @ \ \ Var y[x\u] : T" using ineq valid by auto qed next case (Tuple t\<^sub>1 T\<^sub>1 t\<^sub>2 T\<^sub>2) from refl \\ \ u : U\ - have "\ @ \ \ t\<^sub>1[x\u] : T\<^sub>1" by (rule Tuple) + have "\ @ \ \ t\<^sub>1[x\u] : T\<^sub>1" by (rule Tuple) moreover from refl \\ \ u : U\ - have "\ @ \ \ t\<^sub>2[x\u] : T\<^sub>2" by (rule Tuple) - ultimately have "\ @ \ \ \t\<^sub>1[x\u], t\<^sub>2[x\u]\ : T\<^sub>1 \ T\<^sub>2" .. + have "\ @ \ \ t\<^sub>2[x\u] : T\<^sub>2" by (rule Tuple) + ultimately have "\ @ \ \ \t\<^sub>1[x\u], t\<^sub>2[x\u]\ : T\<^sub>1 \ T\<^sub>2" .. then show ?case by simp next case (Let p t T \' s S) from refl \\ \ u : U\ - have "\ @ \ \ t[x\u] : T" by (rule Let) + have "\ @ \ \ t[x\u] : T" by (rule Let) moreover note \\ p : T \ \'\ moreover have "\' @ (\ @ [(x, U)] @ \) = (\' @ \) @ [(x, U)] @ \" by simp - then have "(\' @ \) @ \ \ s[x\u] : S" using \\ \ u : U\ by (rule Let) - then have "\' @ \ @ \ \ s[x\u] : S" by simp - ultimately have "\ @ \ \ (LET p = t[x\u] IN s[x\u]) : S" + then have "(\' @ \) @ \ \ s[x\u] : S" using \\ \ u : U\ by (rule Let) + then have "\' @ \ @ \ \ s[x\u] : S" by simp + ultimately have "\ @ \ \ (LET p = t[x\u] IN s[x\u]) : S" by (rule better_T_Let) moreover from Let have "(supp p::name set) \* [(x, u)]" by (simp add: fresh_star_def fresh_list_nil fresh_list_cons) @@ -446,9 +443,9 @@ case (Abs y T t S) have "(y, T) # \ @ [(x, U)] @ \ = ((y, T) # \) @ [(x, U)] @ \" by simp - then have "((y, T) # \) @ \ \ t[x\u] : S" using \\ \ u : U\ by (rule Abs) - then have "(y, T) # \ @ \ \ t[x\u] : S" by simp - then have "\ @ \ \ (\y:T. t[x\u]) : T \ S" + then have "((y, T) # \) @ \ \ t[x\u] : S" using \\ \ u : U\ by (rule Abs) + then have "(y, T) # \ @ \ \ t[x\u] : S" by simp + then have "\ @ \ \ (\y:T. t[x\u]) : T \ S" by (rule typing.Abs) moreover from Abs have "y \ [(x, u)]" by (simp add: fresh_list_nil fresh_list_cons) @@ -456,10 +453,10 @@ next case (App t\<^sub>1 T S t\<^sub>2) from refl \\ \ u : U\ - have "\ @ \ \ t\<^sub>1[x\u] : T \ S" by (rule App) + have "\ @ \ \ t\<^sub>1[x\u] : T \ S" by (rule App) moreover from refl \\ \ u : U\ - have "\ @ \ \ t\<^sub>2[x\u] : T" by (rule App) - ultimately have "\ @ \ \ (t\<^sub>1[x\u]) \ (t\<^sub>2[x\u]) : S" + have "\ @ \ \ t\<^sub>2[x\u] : T" by (rule App) + ultimately have "\ @ \ \ (t\<^sub>1[x\u]) \ (t\<^sub>2[x\u]) : S" by (rule typing.App) then show ?case by simp qed @@ -488,7 +485,7 @@ proof (induct arbitrary: \\<^sub>1 \\<^sub>2 t u T \) case (PVar x U) from \\\<^sub>1 @ [(x, U)] @ \\<^sub>2 \ t : T\ \\\<^sub>2 \ u : U\ - have "\\<^sub>1 @ \\<^sub>2 \ t[x\u] : T" by (rule subst_type_aux) + have "\\<^sub>1 @ \\<^sub>2 \ t[x\u] : T" by (rule subst_type_aux) moreover from \\ PVar x U \ u \ \\ have "\ = [(x, u)]" by cases simp_all ultimately show ?case by simp @@ -532,7 +529,7 @@ | Abs: "t \ t' \ (\x:T. t) \ (\x:T. t')" | AppL: "t \ t' \ t \ u \ t' \ u" | AppR: "u \ u' \ t \ u \ t \ u'" -| Beta: "x \ u \ (\x:T. t) \ u \ t[x\u]" +| Beta: "x \ u \ (\x:T. t) \ u \ t[x\u]" | Let: "((supp p)::name set) \* t \ distinct (pat_vars p) \ \ p \ t \ \ \ (LET p = t IN u) \ \\u\" @@ -556,7 +553,7 @@ | Beta: "{x}" | Let: "(supp p)::name set" proof (simp_all add: fresh_star_def abs_fresh fin_supp) - show "x \ t[x\u]" if "x \ u" for x t u + show "x \ t[x\u]" if "x \ u" for x t u by (simp add: \x \ u\ psubst_fresh(1)) next show "\x\supp p. (x::name) \ \\u\" diff -r ef362328b931 -r 12990a6dddcb src/HOL/Nominal/Examples/VC_Condition.thy --- a/src/HOL/Nominal/Examples/VC_Condition.thy Tue Oct 08 13:13:53 2024 +0200 +++ b/src/HOL/Nominal/Examples/VC_Condition.thy Tue Oct 08 15:02:17 2024 +0200 @@ -27,11 +27,11 @@ of the algorithm W.\ inductive - unbind :: "lam \ name list \ lam \ bool" (\_ \ _,_\ [60,60,60] 60) + unbind :: "lam \ name list \ lam \ bool" (\_ \ _,_\ [60,60,60] 60) where - u_var: "(Var a) \ [],(Var a)" -| u_app: "(App t1 t2) \ [],(App t1 t2)" -| u_lam: "t\xs,t' \ (Lam [x].t) \ (x#xs),t'" + u_var: "(Var a) \ [],(Var a)" +| u_app: "(App t1 t2) \ [],(App t1 t2)" +| u_lam: "t\xs,t' \ (Lam [x].t) \ (x#xs),t'" text \ We can show that Lam [x].Lam [x].Var x unbinds to [x,x],Var x @@ -39,19 +39,19 @@ bit clumsy).\ lemma unbind_lambda_lambda1: - shows "Lam [x].Lam [x].(Var x)\[x,x],(Var x)" + shows "Lam [x].Lam [x].(Var x)\[x,x],(Var x)" by (auto intro: unbind.intros) lemma unbind_lambda_lambda2: - shows "Lam [x].Lam [x].(Var x)\[y,z],(Var z)" + shows "Lam [x].Lam [x].(Var x)\[y,z],(Var z)" proof - have "Lam [x].Lam [x].(Var x) = Lam [y].Lam [z].(Var z)" by (auto simp add: lam.inject alpha calc_atm abs_fresh fresh_atm) moreover - have "Lam [y].Lam [z].(Var z) \ [y,z],(Var z)" + have "Lam [y].Lam [z].(Var z) \ [y,z],(Var z)" by (auto intro: unbind.intros) ultimately - show "Lam [x].Lam [x].(Var x)\[y,z],(Var z)" by simp + show "Lam [x].Lam [x].(Var x)\[y,z],(Var z)" by simp qed text \Unbind is equivariant ...\ @@ -86,7 +86,7 @@ easily prove that bind undoes the unbinding.\ lemma bind_unbind: - assumes a: "t \ xs,t'" + assumes a: "t \ xs,t'" shows "t = bind xs t'" using a by (induct) (auto) @@ -113,7 +113,7 @@ the binder x is fresh w.r.t. to the xs unbound previously.\ lemma faulty1: - assumes a: "t\(x#xs),t'" + assumes a: "t\(x#xs),t'" shows "\(x\t') \ \(x\bind xs t')" using a by (nominal_induct t xs'\"x#xs" t' avoiding: xs rule: unbind.strong_induct) @@ -121,14 +121,14 @@ text \ Obviously this lemma is bogus. For example, in - case Lam [x].Lam [x].(Var x) \ [x,x],(Var x). + case Lam [x].Lam [x].(Var x) \ [x,x],(Var x). As a result, we can prove False.\ lemma false1: shows "False" proof - fix x - have "Lam [x].Lam [x].(Var x)\[x,x],(Var x)" + have "Lam [x].Lam [x].(Var x)\[x,x],(Var x)" and "\(x\Var x)" by (simp_all add: unbind_lambda_lambda1 fresh_atm) then have "\(x\(bind [x] (Var x)))" by (rule faulty1) moreover