You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
subst_term::"term => term \<Rightarrow> var => term"and
69
+
subst_alts::"alts \<Rightarrow> term \<Rightarrow> var \<Rightarrow> alts"where
66
70
"subst_term (Var y) e x = (if x = y then e else Var y)"
67
71
|"subst_term (App e1 e2) e x = App (subst_term e1 e x) (subst_term e2 e x)"
68
72
|"subst_term (TApp e1 \<tau>) e x = TApp (subst_term e1 e x) \<tau>"
69
73
|"subst_term (Ctor D) _ _ = Ctor D"
74
+
|"subst_term (Case t alts) e x = Case (subst_term t e x) (subst_alts alts e x)"
70
75
|"atom y \<sharp> (e, x) \<Longrightarrow> subst_term (\<lambda> y:\<tau>. e2) e x = (\<lambda> y:\<tau>. subst_term e2 e x)"
71
76
|"atom y \<sharp> (e, x) \<Longrightarrow> subst_term (\<Lambda> y:k. e2) e x = (\<Lambda> y:k. subst_term e2 e x)"
72
77
|"atom y \<sharp> (e, x) \<Longrightarrow> subst_term (Let y \<tau> e1 e2) e x = Let y \<tau> (subst_term e1 e x) (subst_term e2 e x)"
78
+
79
+
|"subst_alts ANil _ _ = ANil"
80
+
|"set (map atom tys @ map atom vals) \<sharp>* (e, x) \<Longrightarrow> subst_alts (Alt D tys vals t) e x = Alt D tys vals (subst_term t e x)"
73
81
proof(goal_cases)
82
+
(* this is adapted and simplified from here: https://www.joachim-breitner.de/thesis/isa/Substitution.thy *)
83
+
haveeqvt_at_subst_term:"\<And>e y z . eqvt_at subst_term_subst_alts_sumC (Inl (e, y, z)) \<Longrightarrow> eqvt_at (\<lambda>(a, b, c). subst_term a b c) (e, y, z)"
84
+
apply(simpadd:eqvt_at_defsubst_term_def)
85
+
applyrule
86
+
apply(substProjl_permute)
87
+
apply(simpadd:subst_term_subst_alts_sumC_def)
88
+
apply(simpadd:THE_default_def)
89
+
apply(case_tac"Ex1 (subst_term_subst_alts_graph (Inl (e, y, z)))")
have"(\<Lambda> y : k . subst_term e2 e x) = (\<Lambda> y' : k' . subst_term e2' e' x')"usingAbs_sumC[OF49(5,6)eqvt_at_subst_term[OF49(1)]eqvt_at_subst_term[OF49(2)]]49(7)byfastforce
have"Alt D tys vals (subst_term t e x) = Alt D' tys' vals' (subst_term t' e' x')"usingAbs_sumC_star[OF58(5,6)eqvt_at_subst_term[OF58(1)]eqvt_at_subst_term[OF58(2)]]58(7)byfastforce
|"subst_term_type (App e1 e2) \<tau> a = App (subst_term_type e1 \<tau> a) (subst_term_type e2 \<tau> a)"
115
166
|"subst_term_type (TApp e \<tau>2) \<tau> a = TApp (subst_term_type e \<tau> a) (subst_type \<tau>2 \<tau> a)"
167
+
|"subst_term_type (Case D alts) \<tau> a = Case D (subst_alts_type alts \<tau> a)"
116
168
|"atom y \<sharp> (\<tau>, a) \<Longrightarrow> subst_term_type (\<lambda> y:\<tau>'. e2) \<tau> a = (\<lambda> y:(subst_type \<tau>' \<tau> a). subst_term_type e2 \<tau> a)"
117
169
|"atom b \<sharp> (\<tau>, a) \<Longrightarrow> subst_term_type (\<Lambda> b:k. e2) \<tau> a = (\<Lambda> b:k. subst_term_type e2 \<tau> a)"
118
170
|"atom y \<sharp> (\<tau>, a) \<Longrightarrow> subst_term_type (Let y \<tau>' e1 e2) \<tau> a = Let y (subst_type \<tau>' \<tau> a) (subst_term_type e1 \<tau> a) (subst_term_type e2 \<tau> a)"
171
+
172
+
|"subst_alts_type ANil _ _ = ANil"
173
+
|"set (map atom tys @ map atom vals) \<sharp>* (\<tau>, a) \<Longrightarrow> subst_alts_type (Alt D tys vals e) \<tau> a = Alt D tys vals (subst_term_type e \<tau> a)"
119
174
proofgoal_cases
175
+
(* this is adapted and simplified from here: https://www.joachim-breitner.de/thesis/isa/Substitution.thy *)
176
+
haveeqvt_at_subst_term_type:"\<And>e y z . eqvt_at subst_term_type_subst_alts_type_sumC (Inl (e, y, z)) \<Longrightarrow> eqvt_at (\<lambda>(a, b, c). subst_term_type a b c) (e, y, z)"
have"(\<Lambda> b : k . subst_term_type e2 \<tau> a) = (\<Lambda> b' : k' . subst_term_type e2' \<tau>' a')"usingAbs_sumC[OF49(5,6)eqvt_at_subst_term_type[OF49(1)]eqvt_at_subst_term_type[OF49(2)]]49(7)byfastforce
have"Alt D tys vals (subst_term_type e \<tau> a) = Alt D' tys' vals' (subst_term_type e' \<tau>' a')"usingAbs_sumC_star[OF58(5,6)eqvt_at_subst_term_type[OF58(1)]eqvt_at_subst_term_type[OF58(2)]]58(7)byfastforce
0 commit comments