@@ -18,7 +18,7 @@ nominal_datatype "term" =
1818 | Unit
1919 | Lam x :: "var" "\<tau>" e :: "term" binds x in e ( "\<lambda> _ : _ . _" 50 )
2020 | TyLam a :: "tyvar" e :: "term" binds a in e ( "\<Lambda> _ . _" 50 )
21- | Let x :: "var" "term" e2 :: "term" binds x in e2
21+ | Let x :: "var" "\<tau>" " term" e2 :: "term" binds x in e2
2222
2323nominal_datatype "binder" =
2424 "BVar" "var" "\<tau>"
6767| "is_value (App e1 e2) = False"
6868| "is_value (TyApp e \<tau>) = False"
6969| "is_value Unit = True"
70- | "is_value (Let x e1 e2) = False"
70+ | "is_value (Let x \<tau> e1 e2) = False"
7171 apply ( auto simp : eqvt_def is_value_graph_aux_def )
7272 using term . exhaust by blast
7373nominal_termination ( eqvt ) by lexicographic_order
@@ -119,9 +119,8 @@ nominal_function subst_term :: "term => var => term => term" where
119119| "subst_term e x (App e1 e2) = (App (subst_term e x e1) (subst_term e x e2))"
120120| "subst_term e x (TyApp e1 \<tau>) = (TyApp (subst_term e x e1) \<tau>)"
121121| "subst_term _ _ Unit = Unit"
122- | "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))"
122+ | "atom y \<sharp> (x, e) \<Longrightarrow> subst_term e x (Let y \<tau> e1 e2) = (Let y \<tau> (subst_term e x e1) (subst_term e x e2))"
123123proof goal_cases
124- next
125124 case ( 3 P x )
126125 then obtain e y t where P : "x = (e, y, t)" by ( metis prod.exhaust )
127126 then show ?case
146145 show ?case using 1 2 3 by argo
147146next
148147 case ( 17 y x e e2 y' x' e' e2' )
149-
148+
150149 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
151150 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 +
152151
161160
162161 show ?case using 1 2 3 by argo
163162next
164- case ( 31 y x e e1 e2 y' x' e' e1' e2' )
163+ case ( 31 y x e \<tau> e1 e2 y' x' e' \<tau> ' e1' e2' )
165164
166165 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
167166 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 +
172171 let ?e1 = "subst_term_sumC (e, x, e1)"
173172 let ?e1' = "subst_term_sumC (e', x', e1')"
174173 have 0 : "?e1 = ?e1'" using 31 by simp
175- have 1 : "Let y ?e1 (subst_term_sumC (e, x, e2)) = Let c ?e1 (subst_term_sumC (e, x, (y \<leftrightarrow> c) \<bullet> e2))"
174+ have 1 : "Let y \<tau> ?e1 (subst_term_sumC (e, x, e2)) = Let c \<tau> ?e1 (subst_term_sumC (e, x, (y \<leftrightarrow> c) \<bullet> e2))"
176175 using Abs_lst_rename_deep [ OF c ( 1 ) 31 ( 9 ) sort_same_y 31 ( 2 )] 0 term . eq_iff ( 6 ) by fastforce
177- have 2 : "Let y' ?e1' (subst_term_sumC (e', x', e2')) = Let c ?e1 (subst_term_sumC (e, x, (y' \<leftrightarrow> c) \<bullet> e2'))"
176+ have 2 : "Let y' \<tau>' ?e1' (subst_term_sumC (e', x', e2')) = Let c \<tau> ?e1 (subst_term_sumC (e, x, (y' \<leftrightarrow> c) \<bullet> e2'))"
178177 using Abs_lst_rename_deep [ OF c ( 2 ) 31 ( 10 ) sort_same_y' 31 ( 4 )] 0 term . eq_iff ( 6 ) 31 ( 11 ) by auto
179178 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
180179
@@ -222,7 +221,7 @@ nominal_function subst_term_type :: "\<tau> \<Rightarrow> tyvar \<Rightarrow> te
222221| "atom b \<sharp> (a, \<tau>) \<Longrightarrow> subst_term_type \<tau> a (\<Lambda> b . e2) = (TyLam b (subst_term_type \<tau> a e2))"
223222| "subst_term_type \<tau> a (App e1 e2) = App (subst_term_type \<tau> a e1) (subst_term_type \<tau> a e2)"
224223| "subst_term_type \<tau> a (TyApp e \<tau>2) = TyApp (subst_term_type \<tau> a e) (subst_type \<tau> a \<tau>2)"
225- | "atom y \<sharp> (a, \<tau>) \<Longrightarrow> subst_term_type \<tau> a (Let y e1 e2) = Let y (subst_term_type \<tau> a e1) (subst_term_type \<tau> a e2)"
224+ | "atom y \<sharp> (a, \<tau>) \<Longrightarrow> subst_term_type \<tau> a (Let y \<tau>' e1 e2) = Let y (subst_type \<tau> a \<tau>') (subst_term_type \<tau> a e1) (subst_term_type \<tau> a e2)"
226225proof goal_cases
227226 case ( 3 P x )
228227 then obtain \<tau> a t where P : "x = (\<tau>, a, t)" by ( metis prod.exhaust )
@@ -264,19 +263,18 @@ next
264263
265264 show ?case using 1 2 3 by argo
266265next
267- case ( 31 y \<tau> a e1 e2 y' \<tau>' a' e1' e2' )
268-
269- obtain c :: var where "atom c \<sharp> (y, y', \<tau>, a, \<tau>', a', e1, e1', e2, e2', subst_term_type_sumC (a, \<tau>, e2), subst_term_type_sumC (a', \<tau>', e2'))" using obtain_fresh by blast
270- then have c : "atom c \<sharp> (subst_term_type_sumC (a, \<tau>, e2), \<tau>, a)" "atom c \<sharp> (subst_term_type_sumC (a', \<tau>', e2'), \<tau>', a')" "atom c \<sharp> (y, e2, y', e2')" using fresh_Pair by fastforce +
266+ case ( 31 y a \<tau> \<tau>2 e1 e2 y' a' \<tau>' \<tau>2' e1' e2' )
267+ obtain c :: var where "atom c \<sharp> (y, y', \<tau>, a, \<tau>', a', e1, e1', e2, e2', subst_term_type_sumC (\<tau>, a, e2), subst_term_type_sumC (\<tau>', a', e2'))" using obtain_fresh by blast
268+ then have c : "atom c \<sharp> (subst_term_type_sumC (\<tau>, a, e2), a, \<tau>)" "atom c \<sharp> (subst_term_type_sumC (\<tau>', a', e2'), a', \<tau>')" "atom c \<sharp> (y, e2, y', e2')" using fresh_Pair by fastforce +
271269
272270 have sort_same_y : "sort_of (atom c) = sort_of (atom y)" by simp
273271 have sort_same_y' : "sort_of (atom c) = sort_of (atom y')" by simp
274- let ?e1 = "subst_term_type_sumC (a, \<tau>, e1)"
275- let ?e2 = "subst_term_type_sumC (a', \<tau>', e1')"
272+ let ?e1 = "subst_term_type_sumC (\<tau>, a , e1)"
273+ let ?e2 = "subst_term_type_sumC (\<tau>', a ', e1')"
276274
277- have 1 : "Let y ?e1 (subst_term_type_sumC (a, \<tau>, e2)) = Let c ?e1 (subst_term_type_sumC (a, \<tau>, (y \<leftrightarrow> c) \<bullet> e2))"
275+ have 1 : "Let y (subst_type \<tau> a \<tau>2) ?e1 (subst_term_type_sumC (\<tau>, a, e2)) = Let c (subst_type \<tau> a \<tau>2) ?e1 (subst_term_type_sumC (\<tau>, a , (y \<leftrightarrow> c) \<bullet> e2))"
278276 using Abs_lst_rename_deep [ OF c ( 1 ) 31 ( 9 ) sort_same_y 31 ( 2 )] by auto
279- have 2 : "Let y' ?e2 (subst_term_type_sumC (a', \<tau>', e2')) = Let c ?e1 (subst_term_type_sumC (a, \<tau>, (y' \<leftrightarrow> c) \<bullet> e2'))"
277+ have 2 : "Let y' (subst_type \<tau>' a' \<tau>2') ?e2 (subst_term_type_sumC (\<tau>', a', e2')) = Let c (subst_type \<tau> a \<tau>2) ?e1 (subst_term_type_sumC (\<tau>, a , (y' \<leftrightarrow> c) \<bullet> e2'))"
280278 using Abs_lst_rename_deep [ OF c ( 2 ) 31 ( 10 ) sort_same_y' 31 ( 4 )] 31 ( 11 ) by auto
281279 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
282280
@@ -295,7 +293,7 @@ proof (nominal_induct e avoiding: c a e' rule: term.strong_induct)
295293next
296294 case ( Let x e1 e2 )
297295 then show ?case
298- by ( smt fresh_Pair fresh_at_base ( 2 ) list.set ( 1 ) list.set ( 2 ) permute_flip_at singletonD subst_term.simps ( 7 ) term . fresh ( 7 ) term . perm_simps ( 7 ))
296+ by ( smt flip_fresh_fresh fresh_Pair fresh_at_base ( 2 ) list.set ( 1 ) list.set ( 2 ) no_vars_in_ty singletonD subst_term.simps ( 7 ) term . fresh ( 7 ) term . perm_simps ( 7 ))
299297qed ( auto simp : flip_fresh_fresh fresh_Pair fresh_at_base ( 2 ))
300298
301299lemma subst_type_var_name : "atom c \<sharp> (a, \<tau>) \<Longrightarrow> subst_type \<tau>' a \<tau> = subst_type \<tau>' c ((a \<leftrightarrow> c) \<bullet> \<tau>)"
313311next
314312 case ( Let x1a x2 x3 )
315313 then show ?case
316- by ( smt flip_fresh_fresh fresh_Pair fresh_at_base ( 2 ) list.set ( 1 ) list.set ( 2 ) singletonD subst_term_type.simps ( 7 ) term . fresh ( 7 ) term . perm_simps ( 7 ))
314+ by ( smt flip_fresh_fresh fresh_Pair fresh_at_base ( 2 ) list.set ( 1 ) list.set ( 2 ) singletonD subst_term_type.simps ( 7 ) subst_type_var_name term . fresh ( 7 ) term . perm_simps ( 7 ))
317315qed ( auto simp : flip_fresh_fresh fresh_Pair fresh_at_base ( 2 ) subst_type_var_name )
318316
319317lemma subst_term_det : "[[atom a]]lst. e = [[atom b]]lst. e2 \<Longrightarrow> subst_term e' a e = subst_term e' b e2"
@@ -364,6 +362,24 @@ proof -
364362 show ?thesis using 1 2 3 by argo
365363qed
366364
365+ inductive Ty :: "\<Gamma> \<Rightarrow> \<tau> \<Rightarrow> bool"
366+ and "Ty'" :: "\<Gamma> \<Rightarrow> \<tau> \<Rightarrow> bool" ( "_ \<turnstile>\<^sub>t\<^sub>y _" )
367+ where
368+ "(\<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau>) \<equiv> Ty \<Gamma> \<tau>"
369+
370+ | Ty_Unit : "\<Gamma> \<turnstile>\<^sub>t\<^sub>y TyUnit"
371+
372+ | Ty_Var : "\<lbrakk> BTyVar a \<in> \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile>\<^sub>t\<^sub>y TyVar a"
373+
374+ | Ty_Arrow : "\<lbrakk> \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau>1 ; \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile>\<^sub>t\<^sub>y (\<tau>1 \<rightarrow> \<tau>2)"
375+
376+ | Ty_Forall : "\<lbrakk> BTyVar a # \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<sigma> ; atom a \<sharp> \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile>\<^sub>t\<^sub>y (\<forall>a. \<sigma>)"
377+
378+ equivariance Ty
379+ nominal_inductive Ty avoids
380+ Ty_Forall : a
381+ by ( auto simp : fresh_star_def fresh_Unit fresh_Pair )
382+
367383(** definitions *)
368384(* defns Jwf *)
369385inductive T :: "\<Gamma> \<Rightarrow> term \<Rightarrow> \<tau> \<Rightarrow> bool"
@@ -375,11 +391,11 @@ where
375391
376392| T_VarI : "\<lbrakk> BVar x \<tau> \<in> \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (Var x) : \<tau>"
377393
378- | T_AbsI : "\<lbrakk>atom x \<sharp> \<Gamma> ; BVar x \<tau>1 # \<Gamma> \<turnstile> e : \<tau>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (\<lambda> x : \<tau>1 . e) : (\<tau>1 \<rightarrow> \<tau>2)"
394+ | T_AbsI : "\<lbrakk>atom x \<sharp> \<Gamma> ; \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau>1 ; BVar x \<tau>1 # \<Gamma> \<turnstile> e : \<tau>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (\<lambda> x : \<tau>1 . e) : (\<tau>1 \<rightarrow> \<tau>2)"
379395
380396| T_AppI : "\<lbrakk> \<Gamma> \<turnstile> e1 : (\<tau>1 \<rightarrow> \<tau>2) ; \<Gamma> \<turnstile> e2 : \<tau>1 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App e1 e2 : \<tau>2"
381397
382- | T_LetI : "\<lbrakk> atom x \<sharp> (\<Gamma>, e1) ; BVar x \<tau>1 # \<Gamma> \<turnstile> e2 : \<tau>2 ; \<Gamma> \<turnstile> e1 : \<tau>1 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Let x e1 e2 : \<tau>2"
398+ | T_LetI : "\<lbrakk> atom x \<sharp> (\<Gamma>, e1) ; \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau>1 ; BVar x \<tau>1 # \<Gamma> \<turnstile> e2 : \<tau>2 ; \<Gamma> \<turnstile> e1 : \<tau>1 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Let x \<tau>1 e1 e2 : \<tau>2"
383399
384400| T_AppTI : "\<lbrakk> \<Gamma> \<turnstile> e : (\<forall>a . \<sigma>) \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> TyApp e \<tau> : subst_type \<tau> a \<sigma>"
385401
@@ -415,9 +431,9 @@ where
415431
416432| ST_App2I : "\<lbrakk> is_value v ; e1 \<longrightarrow> e2 \<rbrakk> \<Longrightarrow> App v e1 \<longrightarrow> App v e2"
417433
418- | ST_SubstI : "\<lbrakk> is_value v \<rbrakk> \<Longrightarrow> Let x v e \<longrightarrow> subst_term v x e"
434+ | ST_SubstI : "\<lbrakk> is_value v \<rbrakk> \<Longrightarrow> Let x \<tau> v e \<longrightarrow> subst_term v x e"
419435
420- | ST_LetI : "\<lbrakk> e1 \<longrightarrow> e2 \<rbrakk> \<Longrightarrow> Let x e1 e \<longrightarrow> Let x e2 e"
436+ | ST_LetI : "\<lbrakk> e1 \<longrightarrow> e2 \<rbrakk> \<Longrightarrow> Let x \<tau> e1 e \<longrightarrow> Let x \<tau> e2 e"
421437
422438| ST_BetaTI : "TyApp (\<Lambda> a . e) \<tau> \<longrightarrow> subst_term_type \<tau> a e"
423439
461477 using ST_App2I value_beta_nf beta_nf_def by auto
462478next
463479 case ( ST_SubstI v x e )
464- from \<open>Let x v e \<longrightarrow> e2\<close> show ?case
480+ from ST_SubstI ( 2 ) show ?case
465481 proof cases
466482 case ( ST_SubstI x e )
467483 then show ?thesis using subst_term_det by blast
470486 then show ?thesis using ST_SubstI.hyps value_beta_nf beta_nf_def by blast
471487 qed
472488next
473- case ( ST_LetI e1 e2 x e )
474- from \<open>Let x e1 e \<longrightarrow> e2\<close> show ?case
489+ case ( ST_LetI t1 t2 x \<tau> e )
490+ from \<open>Let x \<tau> t1 e \<longrightarrow> e2\<close> show ?case
475491 apply cases
476492 using ST_LetI value_beta_nf beta_nf_def by auto
477493next
0 commit comments