@@ -41,78 +41,92 @@ where
4141 using term . exhaust by blast
4242nominal_termination ( eqvt ) by lexicographic_order
4343
44- (** substitutions *)
45- nominal_function subst_term :: "term => var => term => term" where
46- "subst_term e x (Var y) = (if x=y then e else Var y)"
47- | "atom y \<sharp> (e, x) \<Longrightarrow> subst_term e x (\<lambda> y : \<tau> . e2) = (Lam y \<tau> (subst_term e x e2))"
48- | "atom y \<sharp> (e, x) \<Longrightarrow> subst_term e x (\<Lambda> y : k . e2) = (\<Lambda> y : k . subst_term e x e2)"
49- | "subst_term e x (App e1 e2) = (App (subst_term e x e1) (subst_term e x e2))"
50- | "subst_term e x (TyApp e1 \<tau>) = (TyApp (subst_term e x e1) \<tau>)"
51- | "subst_term _ _ Unit = Unit"
52- | "atom y \<sharp> (e, x) \<Longrightarrow> subst_term e x (Let y \<tau> e1 e2) = (Let y \<tau> (subst_term e x e1) (subst_term e x e2))"
53- proof goal_cases
44+ nominal_function subst_term :: "term => term \<Rightarrow> var => term" ( "_[_'/_]" [ 1000 , 0 , 0 ] 1000 ) where
45+ "(Var y)[e/x] = (if x = y then e else Var y)"
46+ | "(App e1 e2)[e/x] = App e1[e/x] e2[e/x]"
47+ | "(TyApp e1 \<tau>)[e/x] = TyApp e1[e/x] \<tau>"
48+ | "Unit[_/_] = Unit"
49+ | "atom y \<sharp> (e, x) \<Longrightarrow> (\<lambda> y:\<tau>. e2)[e/x] = (\<lambda> y:\<tau>. e2[e/x])"
50+ | "atom y \<sharp> (e, x) \<Longrightarrow> (\<Lambda> y:k. e2)[e/x] = (\<Lambda> y:k. e2[e/x])"
51+ | "atom y \<sharp> (e, x) \<Longrightarrow> (Let y \<tau> e1 e2)[e/x] = (Let y \<tau> e1[e/x] e2[e/x])"
52+ proof ( goal_cases )
5453 case ( 3 P x )
55- then obtain e y t where P : "x = (e, y, t )" by ( metis prod.exhaust )
54+ then obtain t e y where P : "x = (t, e, y )" by ( metis prod.exhaust )
5655 then show ?case
5756 apply ( cases t rule : term . strong_exhaust [ of _ _ "(e, y)" ])
58- apply ( auto simp : 3 )
59- using 3 ( 2 ) 3 ( 3 ) 3 ( 7 ) P fresh_star_def by blast +
57+ apply ( auto simp : 3 )
58+ using 3 ( 5 - 7 ) P fresh_star_def by blast +
6059next
61- case ( 11 y x e \<tau> e2 y' x' e ' \<tau>' e2' )
62- then show ?case using Abs_sumC [ OF 11 ( 5 ) 11 ( 6 ) 11 ( 1 ) 11 ( 2 )] by fastforce
60+ case ( 26 y e x \<tau> e2 y' e' x ' \<tau>' e2' )
61+ then show ?case using Abs_sumC [ OF 26 ( 5 , 6 , 1 , 2 )] by fastforce
6362next
64- case ( 17 y x e e2 y' x' e ' e2' )
65- then show ?case using Abs_sumC [ OF 17 ( 5 ) 17 ( 6 ) 17 ( 1 ) 17 ( 2 )] by fastforce
63+ case ( 29 y e x k e2 y' e' x' k ' e2' )
64+ then show ?case using Abs_sumC [ OF 29 ( 5 , 6 , 1 , 2 )] by fastforce
6665next
67- case ( 31 y x e \<tau> e1 e2 y' x' e ' \<tau>' e1' e2' )
68- then show ?case using Abs_sumC [ OF 31 ( 9 ) 31 ( 10 ) 31 ( 2 ) 31 ( 4 )] by fastforce
66+ case ( 31 y e x \<tau> e1 e2 y' e' x ' \<tau>' e1' e2' )
67+ then show ?case using Abs_sumC [ OF 31 ( 9 , 10 , 2 , 4 )] by fastforce
6968qed ( auto simp : eqvt_def subst_term_graph_aux_def )
7069nominal_termination ( eqvt ) by lexicographic_order
7170
72- nominal_function subst_type :: "\<tau> \<Rightarrow> tyvar \<Rightarrow > \<tau> \<Rightarrow> \<tau>" where
73- "subst_type _ _ TyUnit = TyUnit"
74- | "subst_type \<tau> a (TyVar b) = (if a=b then \<tau> else TyVar b)"
75- | "subst_type \<tau> a (TyArrow \<tau>1 \<tau>2) = TyArrow (subst_type \<tau> a \<tau>1) (subst_type \<tau> a \<tau>2)"
76- | "subst_type \<tau> a (TyConApp \<tau>1 \<tau>2) = TyConApp (subst_type \<tau> a \<tau>1) (subst_type \<tau> a \<tau>2) "
77- | "atom b \<sharp> (\<tau>, a) \<Longrightarrow> subst_type \<tau> a (TyForall b k \<sigma>) = TyForall b k (subst_type \<tau> a \<sigma>)"
71+ nominal_function subst_type :: "\<tau> \<Rightarrow> \<tau > \<Rightarrow> tyvar \<Rightarrow> \<tau>" ( "_[_'/_]" [ 1000 , 0 , 0 ] 1000 ) where
72+ "TyUnit[_/_] = TyUnit"
73+ | "(TyVar b)[ \<tau>/a] = (if a=b then \<tau> else TyVar b)"
74+ | "( \<tau>1 \<rightarrow> \<tau>2)[ \<tau>/a] = ( \<tau>1[ \<tau>/a] \<rightarrow> \< tau>2[\<tau>/a] )"
75+ | "(TyConApp \<tau>1 \<tau>2)[ \<tau>/a] = TyConApp \<tau>1[ \<tau>/a] \<tau>2[\<tau>/a] "
76+ | "atom b \<sharp> (\<tau>, a) \<Longrightarrow> (\<forall> b:k. \<sigma>)[\<tau>/a] = (\<forall>b:k. \<sigma>[\<tau>/a] )"
7877proof goal_cases
7978 case ( 3 P x )
80- then obtain \<tau> a t where P : "x = (\<tau>, a, t )" by ( metis prod.exhaust )
79+ then obtain t \<tau> a where P : "x = (t, \<tau>, a)" by ( metis prod.exhaust )
8180 then show ?case
8281 apply ( cases t rule : \<tau>.strong_exhaust [ of _ _ "(\<tau>, a)" ])
8382 apply ( auto simp : 3 )
8483 using 3 ( 5 ) P fresh_star_def by blast
8584next
8685 case ( 18 b \<tau> a k \<sigma> b' \<tau>' a' k' \<sigma>' )
87- then show ?case using Abs_sumC [ OF 18 ( 5 ) 18 ( 6 ) 18 ( 1 ) 18 ( 2 )] by fastforce
86+ then show ?case using Abs_sumC [ OF 18 ( 5 , 6 , 1 , 2 )] by fastforce
8887qed ( auto simp : eqvt_def subst_type_graph_aux_def )
8988nominal_termination ( eqvt ) by lexicographic_order
9089
91- nominal_function subst_term_type :: "\<tau > \<Rightarrow> tyvar \<Rightarrow> term \<Rightarrow> term" where
92- "subst_term_type _ _ (Var x) = Var x"
93- | "subst_term_type _ _ Unit = Unit"
94- | "atom y \<sharp> (\<tau>, a ) \<Longrightarrow> subst_term_type \< tau> a (\<lambda> y : \<tau>' . e2) = (Lam y (subst_type \<tau> a \<tau>') (subst_term_type \<tau> a e2)) "
95- | "atom b \<sharp> ( \<tau>, a) \<Longrightarrow> subst_term_type \<tau> a (\<Lambda> b : k . e2) = (TyLam b k (subst_term_type \<tau> a e2)) "
96- | "subst_term_type \< tau> a (App e1 e2) = App (subst_term_type \<tau> a e1) (subst_term_type \<tau> a e2)"
97- | "subst_term_type \<tau> a (TyApp e \<tau>2) = TyApp (subst_term_type \<tau> a e) (subst_type \<tau> a \<tau>2 )"
98- | "atom y \<sharp> (\<tau>, a) \<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) "
90+ nominal_function subst_term_type :: "term \<Rightarrow > \<tau> \<Rightarrow> tyvar \<Rightarrow> term" ( "_[_'/_]" [ 1000 , 0 , 0 ] 1000 ) where
91+ "subst_term_type (Var x) _ _ = Var x"
92+ | "subst_term_type Unit _ _ = Unit"
93+ | "subst_term_type (App e1 e2 ) \<tau> a = App e1[ \<tau>/a] e2[ \<tau>/a] "
94+ | "subst_term_type (TyApp e \<tau>2) \<tau> a = TyApp e[ \<tau>/a] \<tau>2[ \<tau>/a] "
95+ | "atom y \<sharp> (\< tau>, a) \<Longrightarrow> subst_term_type (\<lambda> y:\<tau>'. e2) \<tau> a = (\<lambda> y: \<tau>'[\<tau>/a]. e2[\<tau>/a] )"
96+ | "atom b \<sharp> ( \<tau>, a) \<Longrightarrow> subst_term_type (\<Lambda> b:k. e2) \<tau> a = (\<Lambda> b:k. e2[ \<tau>/a] )"
97+ | "atom y \<sharp> (\<tau>, a) \<Longrightarrow> subst_term_type (Let y \<tau>' e1 e2) \<tau> a = Let y \<tau>'[ \<tau>/a] e1[ \<tau>/a] e2[\<tau>/a] "
9998proof goal_cases
10099 case ( 3 P x )
101- then obtain \<tau> a t where P : "x = (\<tau>, a, t )" by ( metis prod.exhaust )
100+ then obtain t \<tau> a where P : "x = (t, \<tau>, a)" by ( metis prod.exhaust )
102101 then show ?case
103102 apply ( cases t rule : term . strong_exhaust [ of _ _ "(\<tau>, a)" ])
104103 using 3 P apply auto [ 4 ]
105- using 3 ( 3 ) 3 ( 4 ) 3 ( 7 ) P fresh_star_def by blast +
104+ using 3 ( 5 , 6 , 7 ) P fresh_star_def by blast +
106105next
107- case ( 17 y \<tau> a \<tau>2 e y' \<tau>' a' \<tau>2' e ')
108- then show ?case using Abs_sumC [ OF 17 ( 5 ) 17 ( 6 ) 17 ( 1 ) 17 ( 2 )] by fastforce
106+ case ( 26 y \<tau> a \<tau>1 e2 y' \<tau>' a' \<tau>1' e2 ')
107+ then show ?case using Abs_sumC [ OF 26 ( 5 , 6 , 1 , 2 )] by fastforce
109108next
110- case ( 22 b \<tau> a e b' \<tau>' a' e ')
111- then show ?case using Abs_sumC [ OF 22 ( 5 ) 22 ( 6 ) 22 ( 1 ) 22 ( 2 )] by fastforce
109+ case ( 29 b \<tau> a k e2 b' \<tau>' a' k' e2 ')
110+ then show ?case using Abs_sumC [ OF 29 ( 5 , 6 , 1 , 2 )] by fastforce
112111next
113- case ( 31 y a \<tau> \<tau>2 e1 e2 y' a' \<tau>' \<tau>2 ' e1' e2' )
114- then show ?case using Abs_sumC [ OF 31 ( 9 ) 31 ( 10 ) 31 ( 2 ) 31 ( 4 )] by fastforce
112+ case ( 31 y \<tau> a \<tau>1 e1 e2 y' \<tau>' a' \<tau>1 ' e1' e2' )
113+ then show ?case using Abs_sumC [ OF 31 ( 9 , 10 , 2 , 4 )] by fastforce
115114qed ( auto simp : eqvt_def subst_term_type_graph_aux_def )
116115nominal_termination ( eqvt ) by lexicographic_order
117116
117+ nominal_function subst_context :: "\<Gamma> \<Rightarrow> \<tau> \<Rightarrow> tyvar \<Rightarrow> \<Gamma>" ( "_[_'/_]" [ 1000 , 0 , 0 ] 1000 ) where
118+ "subst_context [] _ _ = []"
119+ | "subst_context (BVar x \<tau> # \<Gamma>) \<tau>' a = BVar x \<tau>[\<tau>'/a] # subst_context \<Gamma> \<tau>' a"
120+ | "subst_context (BTyVar b k # \<Gamma>) \<tau>' a = (if a = b then subst_context \<Gamma> \<tau>' a else BTyVar b k # subst_context \<Gamma> \<tau>' a)"
121+ proof goal_cases
122+ case ( 3 P x )
123+ then obtain xs \<tau>' a where P : "x = (xs, \<tau>', a)" by ( metis prod.exhaust )
124+ then show ?case using 3
125+ proof ( cases xs )
126+ case ( Cons a list )
127+ then show ?thesis using 3 P by ( cases a rule : binder . exhaust ) auto
128+ qed auto
129+ qed ( auto simp : eqvt_def subst_context_graph_aux_def )
130+ nominal_termination ( eqvt ) by lexicographic_order
131+
118132end
0 commit comments