1811 using fresh |
1815 using fresh |
1812 unfolding fresh_def |
1816 unfolding fresh_def |
1813 using supp_eqvt_at[OF asm fin] |
1817 using supp_eqvt_at[OF asm fin] |
1814 by auto |
1818 by auto |
1815 |
1819 |
|
1820 text {* for handling of freshness of functions *} |
|
1821 |
|
1822 simproc_setup fresh_fun_simproc ("a \<sharp> (f::'a::pt \<Rightarrow>'b::pt)") = {* fn _ => fn ss => fn ctrm => |
|
1823 let |
|
1824 val Const(@{const_name fresh}, _) $ _ $ f = term_of ctrm |
|
1825 in |
|
1826 case (Term.add_frees f [], Term.add_vars f []) of |
|
1827 ([], []) => SOME(@{thm fresh_fun_eqvt[simplified eqvt_def, THEN Eq_TrueI]}) |
|
1828 | (x::_, []) => let |
|
1829 val thy = Proof_Context.theory_of (Simplifier.the_context ss) |
|
1830 val argx = Free x |
|
1831 val absf = absfree x f |
|
1832 val cty_inst = [SOME (ctyp_of thy (fastype_of argx)), SOME (ctyp_of thy (fastype_of f))] |
|
1833 val ctrm_inst = [NONE, SOME (cterm_of thy absf), SOME (cterm_of thy argx)] |
|
1834 val thm = Drule.instantiate' cty_inst ctrm_inst @{thm fresh_fun_app} |
|
1835 in |
|
1836 SOME(thm RS @{thm Eq_TrueI}) |
|
1837 end |
|
1838 | (_, _) => NONE |
|
1839 end |
|
1840 *} |
1816 |
1841 |
1817 subsection {* helper functions for nominal_functions *} |
1842 subsection {* helper functions for nominal_functions *} |
1818 |
1843 |
1819 lemma THE_defaultI2: |
1844 lemma THE_defaultI2: |
1820 assumes "\<exists>!x. P x" "\<And>x. P x \<Longrightarrow> Q x" |
1845 assumes "\<exists>!x. P x" "\<And>x. P x \<Longrightarrow> Q x" |
3166 qed |
3191 qed |
3167 |
3192 |
3168 text {* packaging the freshness lemma into a function *} |
3193 text {* packaging the freshness lemma into a function *} |
3169 |
3194 |
3170 definition |
3195 definition |
3171 fresh_fun :: "('a::at \<Rightarrow> 'b::pt) \<Rightarrow> 'b" |
3196 Fresh :: "('a::at \<Rightarrow> 'b::pt) \<Rightarrow> 'b" |
3172 where |
3197 where |
3173 "fresh_fun h = (THE x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x)" |
3198 "Fresh h = (THE x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x)" |
3174 |
3199 |
3175 lemma fresh_fun_apply: |
3200 lemma Fresh_apply: |
3176 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3201 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3177 assumes a: "\<exists>a. atom a \<sharp> (h, h a)" |
3202 assumes a: "\<exists>a. atom a \<sharp> (h, h a)" |
3178 assumes b: "atom a \<sharp> h" |
3203 assumes b: "atom a \<sharp> h" |
3179 shows "fresh_fun h = h a" |
3204 shows "Fresh h = h a" |
3180 unfolding fresh_fun_def |
3205 unfolding Fresh_def |
3181 proof (rule the_equality) |
3206 proof (rule the_equality) |
3182 show "\<forall>a'. atom a' \<sharp> h \<longrightarrow> h a' = h a" |
3207 show "\<forall>a'. atom a' \<sharp> h \<longrightarrow> h a' = h a" |
3183 proof (intro strip) |
3208 proof (intro strip) |
3184 fix a':: 'a |
3209 fix a':: 'a |
3185 assume c: "atom a' \<sharp> h" |
3210 assume c: "atom a' \<sharp> h" |
3190 fix fr :: 'b |
3215 fix fr :: 'b |
3191 assume "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = fr" |
3216 assume "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = fr" |
3192 with b show "fr = h a" by auto |
3217 with b show "fr = h a" by auto |
3193 qed |
3218 qed |
3194 |
3219 |
3195 lemma fresh_fun_apply': |
3220 lemma Fresh_apply': |
3196 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3221 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3197 assumes a: "atom a \<sharp> h" "atom a \<sharp> h a" |
3222 assumes a: "atom a \<sharp> h" "atom a \<sharp> h a" |
3198 shows "fresh_fun h = h a" |
3223 shows "Fresh h = h a" |
3199 apply (rule fresh_fun_apply) |
3224 apply (rule Fresh_apply) |
3200 apply (auto simp add: fresh_Pair intro: a) |
3225 apply (auto simp add: fresh_Pair intro: a) |
3201 done |
3226 done |
3202 |
3227 |
3203 lemma fresh_fun_eqvt: |
3228 lemma Fresh_eqvt: |
3204 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3229 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3205 assumes a: "\<exists>a. atom a \<sharp> (h, h a)" |
3230 assumes a: "\<exists>a. atom a \<sharp> (h, h a)" |
3206 shows "p \<bullet> (fresh_fun h) = fresh_fun (p \<bullet> h)" |
3231 shows "p \<bullet> (Fresh h) = Fresh (p \<bullet> h)" |
3207 using a |
3232 using a |
3208 apply (clarsimp simp add: fresh_Pair) |
3233 apply (clarsimp simp add: fresh_Pair) |
3209 apply (subst fresh_fun_apply', assumption+) |
3234 apply (subst Fresh_apply', assumption+) |
3210 apply (drule fresh_permute_iff [where p=p, THEN iffD2]) |
3235 apply (drule fresh_permute_iff [where p=p, THEN iffD2]) |
3211 apply (drule fresh_permute_iff [where p=p, THEN iffD2]) |
3236 apply (drule fresh_permute_iff [where p=p, THEN iffD2]) |
3212 apply (simp only: atom_eqvt permute_fun_app_eq [where f=h]) |
3237 apply (simp only: atom_eqvt permute_fun_app_eq [where f=h]) |
3213 apply (erule (1) fresh_fun_apply' [symmetric]) |
3238 apply (erule (1) Fresh_apply' [symmetric]) |
3214 done |
3239 done |
3215 |
3240 |
3216 lemma fresh_fun_supports: |
3241 lemma Fresh_supports: |
3217 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3242 fixes h :: "'a::at \<Rightarrow> 'b::pt" |
3218 assumes a: "\<exists>a. atom a \<sharp> (h, h a)" |
3243 assumes a: "\<exists>a. atom a \<sharp> (h, h a)" |
3219 shows "(supp h) supports (fresh_fun h)" |
3244 shows "(supp h) supports (Fresh h)" |
3220 apply (simp add: supports_def fresh_def [symmetric]) |
3245 apply (simp add: supports_def fresh_def [symmetric]) |
3221 apply (simp add: fresh_fun_eqvt [OF a] swap_fresh_fresh) |
3246 apply (simp add: Fresh_eqvt [OF a] swap_fresh_fresh) |
3222 done |
3247 done |
3223 |
3248 |
3224 notation fresh_fun (binder "FRESH " 10) |
3249 notation Fresh (binder "FRESH " 10) |
3225 |
3250 |
3226 lemma FRESH_f_iff: |
3251 lemma FRESH_f_iff: |
3227 fixes P :: "'a::at \<Rightarrow> 'b::pure" |
3252 fixes P :: "'a::at \<Rightarrow> 'b::pure" |
3228 fixes f :: "'b \<Rightarrow> 'c::pure" |
3253 fixes f :: "'b \<Rightarrow> 'c::pure" |
3229 assumes P: "finite (supp P)" |
3254 assumes P: "finite (supp P)" |
3230 shows "(FRESH x. f (P x)) = f (FRESH x. P x)" |
3255 shows "(FRESH x. f (P x)) = f (FRESH x. P x)" |
3231 proof - |
3256 proof - |
3232 obtain a::'a where "atom a \<sharp> P" using P by (rule obtain_fresh') |
3257 obtain a::'a where "atom a \<sharp> P" using P by (rule obtain_fresh') |
3233 show "(FRESH x. f (P x)) = f (FRESH x. P x)" |
3258 show "(FRESH x. f (P x)) = f (FRESH x. P x)" |
3234 apply (subst fresh_fun_apply' [where a=a, OF _ pure_fresh]) |
3259 apply (subst Fresh_apply' [where a=a, OF _ pure_fresh]) |
3235 apply (cut_tac `atom a \<sharp> P`) |
3260 apply (cut_tac `atom a \<sharp> P`) |
3236 apply (simp add: fresh_conv_MOST) |
3261 apply (simp add: fresh_conv_MOST) |
3237 apply (elim MOST_rev_mp, rule MOST_I, clarify) |
3262 apply (elim MOST_rev_mp, rule MOST_I, clarify) |
3238 apply (simp add: permute_fun_def permute_pure fun_eq_iff) |
3263 apply (simp add: permute_fun_def permute_pure fun_eq_iff) |
3239 apply (subst fresh_fun_apply' [where a=a, OF `atom a \<sharp> P` pure_fresh]) |
3264 apply (subst Fresh_apply' [where a=a, OF `atom a \<sharp> P` pure_fresh]) |
3240 apply (rule refl) |
3265 apply (rule refl) |
3241 done |
3266 done |
3242 qed |
3267 qed |
3243 |
3268 |
3244 lemma FRESH_binop_iff: |
3269 lemma FRESH_binop_iff: |
3251 proof - |
3276 proof - |
3252 from assms have "finite (supp (P, Q))" by (simp add: supp_Pair) |
3277 from assms have "finite (supp (P, Q))" by (simp add: supp_Pair) |
3253 then obtain a::'a where "atom a \<sharp> (P, Q)" by (rule obtain_fresh') |
3278 then obtain a::'a where "atom a \<sharp> (P, Q)" by (rule obtain_fresh') |
3254 then have "atom a \<sharp> P" and "atom a \<sharp> Q" by (simp_all add: fresh_Pair) |
3279 then have "atom a \<sharp> P" and "atom a \<sharp> Q" by (simp_all add: fresh_Pair) |
3255 show ?thesis |
3280 show ?thesis |
3256 apply (subst fresh_fun_apply' [where a=a, OF _ pure_fresh]) |
3281 apply (subst Fresh_apply' [where a=a, OF _ pure_fresh]) |
3257 apply (cut_tac `atom a \<sharp> P` `atom a \<sharp> Q`) |
3282 apply (cut_tac `atom a \<sharp> P` `atom a \<sharp> Q`) |
3258 apply (simp add: fresh_conv_MOST) |
3283 apply (simp add: fresh_conv_MOST) |
3259 apply (elim MOST_rev_mp, rule MOST_I, clarify) |
3284 apply (elim MOST_rev_mp, rule MOST_I, clarify) |
3260 apply (simp add: permute_fun_def permute_pure fun_eq_iff) |
3285 apply (simp add: permute_fun_def permute_pure fun_eq_iff) |
3261 apply (subst fresh_fun_apply' [where a=a, OF `atom a \<sharp> P` pure_fresh]) |
3286 apply (subst Fresh_apply' [where a=a, OF `atom a \<sharp> P` pure_fresh]) |
3262 apply (subst fresh_fun_apply' [where a=a, OF `atom a \<sharp> Q` pure_fresh]) |
3287 apply (subst Fresh_apply' [where a=a, OF `atom a \<sharp> Q` pure_fresh]) |
3263 apply (rule refl) |
3288 apply (rule refl) |
3264 done |
3289 done |
3265 qed |
3290 qed |
3266 |
3291 |
3267 lemma FRESH_conj_iff: |
3292 lemma FRESH_conj_iff: |