@@ -16,6 +16,7 @@ nominal_datatype "term" =
1616 | Lam x :: "var" "\<tau>" e :: "term" binds x in e ( "\<lambda> _ : _ . _" 50 )
1717 | TyLam a :: "tyvar" e :: "term" binds a in e ( "\<Lambda> _ . _" 50 )
1818 | App "term" "term"
19+ | TyApp "term" "\<tau>"
1920 | Unit
2021 | Let x :: "var" "term" e2 :: "term" binds x in e2
2122
@@ -26,15 +27,15 @@ declare term.fv_defs[simp]
2627lemma no_vars_in_ty [ simp ]: "atom (x :: var) \<sharp> (ty :: \<tau>)"
2728 by ( induction ty rule : \<tau>.induct ) auto
2829
29- (* nominal_function isin :: "var * \<tau> \<Rightarrow> \<Gamma> \<Rightarrow> bool" (infixr "\<in>" 80) where
30+ nominal_function isin :: "var * \<tau> \<Rightarrow> \<Gamma> \<Rightarrow> bool" ( infixr "\<in>" 80 ) where
3031 "isin _ [] = False"
3132| "isin (x, t) ((y, t')#xs) = (if x = y then t = t' else isin (x, t) xs)"
3233 apply ( all_trivials )
3334 apply ( simp add : eqvt_def isin_graph_aux_def )
34- apply (metis list.exhaust old. prod.exhaust)
35+ apply ( metis list.exhaust prod.exhaust )
3536 apply simp
3637 done
37- nominal_termination (eqvt) by lexicographic_order*)
38+ nominal_termination ( eqvt ) by lexicographic_order
3839
3940(** subrules *)
4041nominal_function
4445| "is_value (\<lambda> x : \<tau> . e) = True"
4546| "is_value (\<Lambda> a . e) = True"
4647| "is_value (App e1 e2) = False"
48+ | "is_value (TyApp e \<tau>) = False"
4749| "is_value Unit = True"
4850| "is_value (Let x e1 e2) = False"
4951 apply ( auto simp : eqvt_def is_value_graph_aux_def )
@@ -90,24 +92,25 @@ proof -
9092qed
9193
9294(** substitutions *)
93- nominal_function
94- subst_term :: "term => var => term => term"
95+ nominal_function subst_term :: "term => var => term => term"
9596where
9697"subst_term e x (Var y) = (if x=y then e else Var y)"
9798| "atom y \<sharp> (x, e) \<Longrightarrow> subst_term e x (\<lambda> y : \<tau> . e2) = (Lam y \<tau> (subst_term e x e2))"
9899| "atom y \<sharp> (x, e) \<Longrightarrow> subst_term e x (\<Lambda> y . e2) = (\<Lambda> y . subst_term e x e2)"
99100| "subst_term e x (App e1 e2) = (App (subst_term e x e1) (subst_term e x e2))"
101+ | "subst_term e x (TyApp e1 \<tau>) = (TyApp (subst_term e x e1) \<tau>)"
100102| "subst_term _ _ Unit = Unit"
101103| "atom y \<sharp> (x, e) \<Longrightarrow> subst_term e x (Let y e1 e2) = (Let y (subst_term e x e1) (subst_term e x e2))"
102104proof goal_cases
105+ next
103106 case ( 3 P x )
104107 then obtain e y t where P : "x = (e, y, t)" by ( metis prod.exhaust )
105108 then show ?case
106109 apply ( cases t rule : term . strong_exhaust [ of _ _ "(y, e)" ])
107110 apply ( auto simp : 3 )
108- using 3 ( 2 ) 3 ( 3 ) 3 ( 6 ) P fresh_star_def by blast +
111+ using 3 ( 2 ) 3 ( 3 ) 3 ( 7 ) P fresh_star_def by blast +
109112next
110- case ( 10 y x e \<tau> e2 y' x' e' \<tau>' e2' )
113+ case ( 11 y x e \<tau> e2 y' x' e' \<tau>' e2' )
111114
112115 obtain c :: var where "atom c \<sharp> (y, y', e, x, e', x', e2, e2', subst_term_sumC (e, x, e2), subst_term_sumC (e', x', e2'))" using obtain_fresh by blast
113116 then have c : "atom c \<sharp> (subst_term_sumC (e, x, e2), x, e)" "atom c \<sharp> (subst_term_sumC (e', x', e2'), x', e')" "atom c \<sharp> (y, e2, y', e2')" using fresh_Pair by fastforce +
@@ -116,14 +119,14 @@ next
116119 have sort_same_y' : "sort_of (atom c) = sort_of (atom y')" by simp
117120
118121 have 1 : "(\<lambda> y : \<tau> . subst_term_sumC (e, x, e2)) = (\<lambda> c : \<tau> . subst_term_sumC (e, x, (y \<leftrightarrow> c) \<bullet> e2))"
119- using Abs_lst_rename_deep [ OF c ( 1 ) 10 ( 5 ) sort_same_y 10 ( 1 )] term . eq_iff ( 2 ) by blast
122+ using Abs_lst_rename_deep [ OF c ( 1 ) 11 ( 5 ) sort_same_y 11 ( 1 )] term . eq_iff ( 2 ) by blast
120123 have 2 : "(\<lambda> y' : \<tau>' . subst_term_sumC (e', x', e2')) = (\<lambda> c : \<tau> . subst_term_sumC (e, x, (y' \<leftrightarrow> c) \<bullet> e2'))"
121- using Abs_lst_rename_deep [ OF c ( 2 ) 10 ( 6 ) sort_same_y' 10 ( 2 )] term . eq_iff ( 2 ) 10 ( 7 ) by auto
122- have 3 : "(y \<leftrightarrow> c) \<bullet> e2 = (y' \<leftrightarrow> c) \<bullet> e2'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_y sort_same_y' ] 10 ( 7 ) by force
124+ using Abs_lst_rename_deep [ OF c ( 2 ) 11 ( 6 ) sort_same_y' 11 ( 2 )] term . eq_iff ( 2 ) 11 ( 7 ) by auto
125+ have 3 : "(y \<leftrightarrow> c) \<bullet> e2 = (y' \<leftrightarrow> c) \<bullet> e2'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_y sort_same_y' ] 11 ( 7 ) by force
123126
124127 show ?case using 1 2 3 by argo
125128next
126- case ( 15 y x e e2 y' x' e' e2' )
129+ case ( 17 y x e e2 y' x' e' e2' )
127130
128131 obtain c :: tyvar where "atom c \<sharp> (y, y', e, x, e', x', e2, e2', subst_term_sumC (e, x, e2), subst_term_sumC (e', x', e2'))" using obtain_fresh by blast
129132 then have c : "atom c \<sharp> (subst_term_sumC (e, x, e2), x, e)" "atom c \<sharp> (subst_term_sumC (e', x', e2'), x', e')" "atom c \<sharp> (y, e2, y', e2')" using fresh_Pair by fastforce +
@@ -132,14 +135,14 @@ next
132135 have sort_same_y' : "sort_of (atom c) = sort_of (atom y')" by simp
133136
134137 have 1 : "(\<Lambda> y . subst_term_sumC (e, x, e2)) = (\<Lambda> c . subst_term_sumC (e, x, (y \<leftrightarrow> c) \<bullet> e2))"
135- using Abs_lst_rename_deep [ OF c ( 1 ) 15 ( 5 ) sort_same_y 15 ( 1 )] term . eq_iff ( 3 ) by presburger
138+ using Abs_lst_rename_deep [ OF c ( 1 ) 17 ( 5 ) sort_same_y 17 ( 1 )] term . eq_iff ( 3 ) by presburger
136139 have 2 : "(\<Lambda> y' . subst_term_sumC (e', x', e2')) = (\<Lambda> c . subst_term_sumC (e, x, (y' \<leftrightarrow> c) \<bullet> e2'))"
137- using Abs_lst_rename_deep [ OF c ( 2 ) 15 ( 6 ) sort_same_y' 15 ( 2 )] term . eq_iff ( 3 ) 15 ( 7 ) by auto
138- have 3 : "(y \<leftrightarrow> c) \<bullet> e2 = (y' \<leftrightarrow> c) \<bullet> e2'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_y sort_same_y' ] 15 ( 7 ) by force
140+ using Abs_lst_rename_deep [ OF c ( 2 ) 17 ( 6 ) sort_same_y' 17 ( 2 )] term . eq_iff ( 3 ) 17 ( 7 ) by auto
141+ have 3 : "(y \<leftrightarrow> c) \<bullet> e2 = (y' \<leftrightarrow> c) \<bullet> e2'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_y sort_same_y' ] 17 ( 7 ) by force
139142
140143 show ?case using 1 2 3 by argo
141144next
142- case ( 24 y x e e1 e2 y' x' e' e1' e2' )
145+ case ( 31 y x e e1 e2 y' x' e' e1' e2' )
143146
144147 obtain c :: var where "atom c \<sharp> (y, y', e, x, e', x', e2, e2', subst_term_sumC (e, x, e2), subst_term_sumC (e', x', e2'))" using obtain_fresh by blast
145148 then have c : "atom c \<sharp> (subst_term_sumC (e, x, e2), x, e)" "atom c \<sharp> (subst_term_sumC (e', x', e2'), x', e')" "atom c \<sharp> (y, e2, y', e2')" using fresh_Pair by fastforce +
@@ -149,17 +152,50 @@ next
149152
150153 let ?e1 = "subst_term_sumC (e, x, e1)"
151154 let ?e1' = "subst_term_sumC (e', x', e1')"
152- have 0 : "?e1 = ?e1'" using 24 by simp
155+ have 0 : "?e1 = ?e1'" using 31 by simp
153156 have 1 : "Let y ?e1 (subst_term_sumC (e, x, e2)) = Let c ?e1 (subst_term_sumC (e, x, (y \<leftrightarrow> c) \<bullet> e2))"
154- using Abs_lst_rename_deep [ OF c ( 1 ) 24 ( 9 ) sort_same_y 24 ( 2 )] 0 term . eq_iff ( 6 ) by blast
157+ using Abs_lst_rename_deep [ OF c ( 1 ) 31 ( 9 ) sort_same_y 31 ( 2 )] 0 term . eq_iff ( 6 ) by fastforce
155158 have 2 : "Let y' ?e1' (subst_term_sumC (e', x', e2')) = Let c ?e1 (subst_term_sumC (e, x, (y' \<leftrightarrow> c) \<bullet> e2'))"
156- using Abs_lst_rename_deep [ OF c ( 2 ) 24 ( 10 ) sort_same_y' 24 ( 4 )] 0 term . eq_iff ( 6 ) 24 ( 11 ) by auto
157- have 3 : "(y \<leftrightarrow> c) \<bullet> e2 = (y' \<leftrightarrow> c) \<bullet> e2'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_y sort_same_y' ] 24 ( 11 ) by force
159+ using Abs_lst_rename_deep [ OF c ( 2 ) 31 ( 10 ) sort_same_y' 31 ( 4 )] 0 term . eq_iff ( 6 ) 31 ( 11 ) by auto
160+ have 3 : "(y \<leftrightarrow> c) \<bullet> e2 = (y' \<leftrightarrow> c) \<bullet> e2'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_y sort_same_y' ] 31 ( 11 ) by force
158161
159162 show ?case using 1 2 3 by argo
160163qed ( auto simp : eqvt_def subst_term_graph_aux_def )
161164nominal_termination ( eqvt ) by lexicographic_order
162165
166+ nominal_function subst_type :: "\<tau> \<Rightarrow> tyvar \<Rightarrow> \<tau> \<Rightarrow> \<tau>" where
167+ "subst_type _ _ TyUnit = TyUnit"
168+ | "subst_type \<tau> a (TyVar b) = (if a=b then \<tau> else TyVar b)"
169+ | "subst_type \<tau> a (TyArrow \<tau>1 \<tau>2) = TyArrow (subst_type \<tau> a \<tau>1) (subst_type \<tau> a \<tau>2)"
170+ | "atom b \<sharp> (\<tau>, a) \<Longrightarrow> subst_type \<tau> a (TyForall b \<sigma>) = TyForall b (subst_type \<tau> a \<sigma>)"
171+ proof goal_cases
172+ case ( 3 P x )
173+ then obtain \<tau> a t where P : "x = (\<tau>, a, t)" by ( metis prod.exhaust )
174+ then show ?case
175+ apply ( cases t rule : \<tau>.strong_exhaust [ of _ _ "(\<tau>, a)" ])
176+ apply ( auto simp : 3 )
177+ using 3 ( 4 ) P fresh_star_def by blast
178+ next
179+ case ( 13 b \<tau> a \<sigma> b' \<tau>' a' \<sigma>' )
180+
181+ obtain c :: tyvar where "atom c \<sharp> (b, b', \<tau>, a, \<tau>', a', \<sigma>, \<sigma>', subst_type_sumC (\<tau>, a, \<sigma>), subst_type_sumC (\<tau>', a', \<sigma>'))" using obtain_fresh by blast
182+ then have c : "atom c \<sharp> (subst_type_sumC (\<tau>, a, \<sigma>), a, \<tau>)" "atom c \<sharp> (subst_type_sumC (\<tau>', a', \<sigma>'), a', \<tau>')" "atom c \<sharp> (b, \<sigma>, b', \<sigma>')" using fresh_Pair by fastforce +
183+
184+ have sort_same_b : "sort_of (atom c) = sort_of (atom b)" by simp
185+ have sort_same_b' : "sort_of (atom c) = sort_of (atom b')" by simp
186+
187+ from 13 have fresh : "atom b \<sharp> (a, \<tau>)" "atom b' \<sharp> (a', \<tau>')" using fresh_Pair by fastforce +
188+
189+ have 1 : "(\<forall> b . subst_type_sumC (\<tau>, a, \<sigma>)) = (\<forall> c . subst_type_sumC (\<tau>, a, (b \<leftrightarrow> c) \<bullet> \<sigma>))"
190+ using Abs_lst_rename_deep [ OF c ( 1 ) fresh ( 1 ) sort_same_b 13 ( 1 )] \<tau>.eq_iff ( 4 ) by blast
191+ have 2 : "(\<forall> b' . subst_type_sumC (\<tau>', a', \<sigma>')) = (\<forall> c . subst_type_sumC (\<tau>, a, (b' \<leftrightarrow> c) \<bullet> \<sigma>'))"
192+ using Abs_lst_rename_deep [ OF c ( 2 ) fresh ( 2 ) sort_same_b' 13 ( 2 )] \<tau>.eq_iff ( 4 ) 13 ( 7 ) by blast
193+ have 3 : "(b \<leftrightarrow> c) \<bullet> \<sigma> = (b' \<leftrightarrow> c) \<bullet> \<sigma>'" using Abs_lst_rename_both [ OF c ( 3 ) sort_same_b sort_same_b' ] 13 ( 7 ) by fastforce
194+
195+ show ?case using 1 2 3 by argo
196+ qed ( auto simp : eqvt_def subst_type_graph_aux_def )
197+ nominal_termination ( eqvt ) by lexicographic_order
198+
163199lemma fresh_subst_term : "\<lbrakk> atom z \<sharp> s ; z = y \<or> atom z \<sharp> t \<rbrakk> \<Longrightarrow> atom z \<sharp> subst_term s y t"
164200 by ( nominal_induct t avoiding : z y s rule : term . strong_induct ) auto
165201
@@ -188,6 +224,8 @@ T_UnitI: "(\<Gamma> \<turnstile> Unit : TyUnit)"
188224( ( x , \<tau>1 ) # \<Gamma> \<turnstile> e2 : \<tau>2) ; (\<Gamma> \<turnstile> e1 : \<tau>1)\<rbrakk> \<Longrightarrow>
189225(\<Gamma> \<turnstile> (Let x e1 e2) : \<tau>2)"
190226
227+ (*| T_InstI: "\<lbrakk> \<Gamma> \<turnstile> e : (\<forall>a . \<sigma>) \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> " *)
228+
191229lemma fresh_not_isin : "atom x \<sharp> \<Gamma> \<Longrightarrow> \<nexists>t'. isin (x, t') \<Gamma>"
192230 by ( induction \<Gamma> ) ( auto simp : fresh_Pair fresh_Cons fresh_at_base ( 2 ))
193231
0 commit comments