src/HOL/Nominal/Nominal.thy
changeset 46179 47bcf3d5d1f0
parent 45961 5cefe17916a6
child 46947 b8c7eb0c2f89
equal deleted inserted replaced
46177:adac34829e10 46179:47bcf3d5d1f0
    56 
    56 
    57 definition perm_bool :: "'x prm \<Rightarrow> bool \<Rightarrow> bool" where
    57 definition perm_bool :: "'x prm \<Rightarrow> bool \<Rightarrow> bool" where
    58   "perm_bool pi b = b"
    58   "perm_bool pi b = b"
    59 
    59 
    60 definition perm_set :: "'x prm \<Rightarrow> 'a set \<Rightarrow> 'a set" where
    60 definition perm_set :: "'x prm \<Rightarrow> 'a set \<Rightarrow> 'a set" where
    61   "perm_set pi A = {x. rev pi \<bullet> x \<in> A}"
    61   "perm_set pi X = {pi \<bullet> x | x. x \<in> X}"
    62 
    62 
    63 primrec perm_unit :: "'x prm \<Rightarrow> unit \<Rightarrow> unit"  where 
    63 primrec perm_unit :: "'x prm \<Rightarrow> unit \<Rightarrow> unit"  where 
    64   "perm_unit pi () = ()"
    64   "perm_unit pi () = ()"
    65   
    65   
    66 primrec perm_prod :: "'x prm \<Rightarrow> ('a\<times>'b) \<Rightarrow> ('a\<times>'b)" where
    66 primrec perm_prod :: "'x prm \<Rightarrow> ('a\<times>'b) \<Rightarrow> ('a\<times>'b)" where
   135   by (simp add: perm_bool)
   135   by (simp add: perm_bool)
   136 
   136 
   137 (* permutation on sets *)
   137 (* permutation on sets *)
   138 lemma empty_eqvt:
   138 lemma empty_eqvt:
   139   shows "pi\<bullet>{} = {}"
   139   shows "pi\<bullet>{} = {}"
   140   by (simp add: perm_set_def fun_eq_iff)
   140   by (simp add: perm_set_def)
   141 
   141 
   142 lemma union_eqvt:
   142 lemma union_eqvt:
   143   shows "(pi\<bullet>(X\<union>Y)) = (pi\<bullet>X) \<union> (pi\<bullet>Y)"
   143   shows "(pi\<bullet>(X\<union>Y)) = (pi\<bullet>X) \<union> (pi\<bullet>Y)"
   144   by (simp add: perm_set_def fun_eq_iff Un_def)
   144   by (auto simp add: perm_set_def)
       
   145 
       
   146 lemma insert_eqvt:
       
   147   shows "pi\<bullet>(insert x X) = insert (pi\<bullet>x) (pi\<bullet>X)"
       
   148   by (auto simp add: perm_set_def)
   145 
   149 
   146 (* permutations on products *)
   150 (* permutations on products *)
   147 lemma fst_eqvt:
   151 lemma fst_eqvt:
   148   "pi\<bullet>(fst x) = fst (pi\<bullet>x)"
   152   "pi\<bullet>(fst x) = fst (pi\<bullet>x)"
   149  by (cases x) simp
   153  by (cases x) simp
   163 lemma rev_eqvt:
   167 lemma rev_eqvt:
   164   fixes pi :: "'x prm"
   168   fixes pi :: "'x prm"
   165   and   l  :: "'a list"
   169   and   l  :: "'a list"
   166   shows "pi\<bullet>(rev l) = rev (pi\<bullet>l)"
   170   shows "pi\<bullet>(rev l) = rev (pi\<bullet>l)"
   167   by (induct l) (simp_all add: append_eqvt)
   171   by (induct l) (simp_all add: append_eqvt)
       
   172 
       
   173 lemma set_eqvt:
       
   174   fixes pi :: "'x prm"
       
   175   and   xs :: "'a list"
       
   176   shows "pi\<bullet>(set xs) = set (pi\<bullet>xs)"
       
   177 by (induct xs) (auto simp add: empty_eqvt insert_eqvt)
   168 
   178 
   169 (* permutation on characters and strings *)
   179 (* permutation on characters and strings *)
   170 lemma perm_string:
   180 lemma perm_string:
   171   fixes s::"string"
   181   fixes s::"string"
   172   shows "pi\<bullet>s = s"
   182   shows "pi\<bullet>s = s"
  1016 lemma pt_bool_inst:
  1026 lemma pt_bool_inst:
  1017   shows  "pt TYPE(bool) TYPE('x)"
  1027   shows  "pt TYPE(bool) TYPE('x)"
  1018   by (simp add: pt_def perm_bool_def)
  1028   by (simp add: pt_def perm_bool_def)
  1019 
  1029 
  1020 lemma pt_set_inst:
  1030 lemma pt_set_inst:
  1021   assumes pta: "pt TYPE('a) TYPE('x)"
  1031   assumes pt: "pt TYPE('a) TYPE('x)"
  1022   and     at:  "at TYPE('x)"
  1032   shows  "pt TYPE('a set) TYPE('x)"
  1023   shows "pt TYPE('a set) TYPE('x)"
  1033 apply(simp add: pt_def)
  1024 proof -
  1034 apply(simp_all add: perm_set_def)
  1025   have *: "\<And>pi A. pi \<bullet> A = {x. (pi \<bullet> (\<lambda>x. x \<in> A)) x}"
  1035 apply(simp add: pt1[OF pt])
  1026     by (simp add: perm_fun_def perm_bool_def perm_set_def)
  1036 apply(force simp add: pt2[OF pt] pt3[OF pt])
  1027   from pta pt_bool_inst at
  1037 done
  1028     have "pt TYPE('a \<Rightarrow> bool) TYPE('x)" by (rule pt_fun_inst)
       
  1029   then show ?thesis by (simp add: pt_def *)
       
  1030 qed
       
  1031 
  1038 
  1032 lemma pt_unit_inst:
  1039 lemma pt_unit_inst:
  1033   shows "pt TYPE(unit) TYPE('x)"
  1040   shows "pt TYPE(unit) TYPE('x)"
  1034   by (simp add: pt_def)
  1041   by (simp add: pt_def)
  1035 
  1042 
  1243 apply(rule pt3[OF pt])
  1250 apply(rule pt3[OF pt])
  1244 apply(rule at_ds1[OF at])
  1251 apply(rule at_ds1[OF at])
  1245 apply(rule pt1[OF pt])
  1252 apply(rule pt1[OF pt])
  1246 done
  1253 done
  1247 
  1254 
  1248 lemma perm_set_eq:
       
  1249   assumes pt: "pt TYPE('a) TYPE('x)"
       
  1250   and at: "at TYPE('x)" 
       
  1251   shows "(pi::'x prm)\<bullet>(X::'a set) = {pi\<bullet>x | x. x\<in>X}"
       
  1252   apply (auto simp add: perm_fun_def perm_bool perm_set_def)
       
  1253   apply (rule_tac x="rev pi \<bullet> x" in exI)
       
  1254   apply (simp add: pt_pi_rev [OF pt at])
       
  1255   apply (simp add: pt_rev_pi [OF pt at])
       
  1256   done
       
  1257 
       
  1258 lemma pt_insert_eqvt:
       
  1259   fixes pi::"'x prm"
       
  1260   and   x::"'a"
       
  1261   assumes pt: "pt TYPE('a) TYPE('x)"
       
  1262   and at: "at TYPE('x)" 
       
  1263   shows "(pi\<bullet>(insert x X)) = insert (pi\<bullet>x) (pi\<bullet>X)"
       
  1264   by (auto simp add: perm_set_eq [OF pt at])
       
  1265 
       
  1266 lemma pt_set_eqvt:
       
  1267   fixes pi :: "'x prm"
       
  1268   and   xs :: "'a list"
       
  1269   assumes pt: "pt TYPE('a) TYPE('x)"
       
  1270   and at: "at TYPE('x)" 
       
  1271   shows "pi\<bullet>(set xs) = set (pi\<bullet>xs)"
       
  1272 by (induct xs) (auto simp add: empty_eqvt pt_insert_eqvt [OF pt at])
       
  1273 
       
  1274 lemma supp_singleton:
  1255 lemma supp_singleton:
  1275   assumes pt: "pt TYPE('a) TYPE('x)"
  1256   shows "supp {x} = supp x"
  1276   and at: "at TYPE('x)" 
  1257   by (force simp add: supp_def perm_set_def)
  1277   shows "(supp {x::'a} :: 'x set) = supp x"
       
  1278   by (force simp add: supp_def perm_set_eq [OF pt at])
       
  1279 
  1258 
  1280 lemma fresh_singleton:
  1259 lemma fresh_singleton:
  1281   assumes pt: "pt TYPE('a) TYPE('x)"
  1260   shows "a\<sharp>{x} = a\<sharp>x"
  1282   and at: "at TYPE('x)" 
  1261   by (simp add: fresh_def supp_singleton)
  1283   shows "(a::'x)\<sharp>{x::'a} = a\<sharp>x"
       
  1284   by (simp add: fresh_def supp_singleton [OF pt at])
       
  1285 
  1262 
  1286 lemma pt_set_bij1:
  1263 lemma pt_set_bij1:
  1287   fixes pi :: "'x prm"
  1264   fixes pi :: "'x prm"
  1288   and   x  :: "'a"
  1265   and   x  :: "'a"
  1289   and   X  :: "'a set"
  1266   and   X  :: "'a set"
  1290   assumes pt: "pt TYPE('a) TYPE('x)"
  1267   assumes pt: "pt TYPE('a) TYPE('x)"
  1291   and     at: "at TYPE('x)"
  1268   and     at: "at TYPE('x)"
  1292   shows "((pi\<bullet>x)\<in>X) = (x\<in>((rev pi)\<bullet>X))"
  1269   shows "((pi\<bullet>x)\<in>X) = (x\<in>((rev pi)\<bullet>X))"
  1293   by (force simp add: perm_set_eq [OF pt at] pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
  1270   by (force simp add: perm_set_def pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
  1294 
  1271 
  1295 lemma pt_set_bij1a:
  1272 lemma pt_set_bij1a:
  1296   fixes pi :: "'x prm"
  1273   fixes pi :: "'x prm"
  1297   and   x  :: "'a"
  1274   and   x  :: "'a"
  1298   and   X  :: "'a set"
  1275   and   X  :: "'a set"
  1299   assumes pt: "pt TYPE('a) TYPE('x)"
  1276   assumes pt: "pt TYPE('a) TYPE('x)"
  1300   and     at: "at TYPE('x)"
  1277   and     at: "at TYPE('x)"
  1301   shows "(x\<in>(pi\<bullet>X)) = (((rev pi)\<bullet>x)\<in>X)"
  1278   shows "(x\<in>(pi\<bullet>X)) = (((rev pi)\<bullet>x)\<in>X)"
  1302   by (force simp add: perm_set_eq [OF pt at] pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
  1279   by (force simp add: perm_set_def pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
  1303 
  1280 
  1304 lemma pt_set_bij:
  1281 lemma pt_set_bij:
  1305   fixes pi :: "'x prm"
  1282   fixes pi :: "'x prm"
  1306   and   x  :: "'a"
  1283   and   x  :: "'a"
  1307   and   X  :: "'a set"
  1284   and   X  :: "'a set"
  1308   assumes pt: "pt TYPE('a) TYPE('x)"
  1285   assumes pt: "pt TYPE('a) TYPE('x)"
  1309   and     at: "at TYPE('x)"
  1286   and     at: "at TYPE('x)"
  1310   shows "((pi\<bullet>x)\<in>(pi\<bullet>X)) = (x\<in>X)"
  1287   shows "((pi\<bullet>x)\<in>(pi\<bullet>X)) = (x\<in>X)"
  1311   by (simp add: perm_set_eq [OF pt at] pt_bij[OF pt, OF at])
  1288   by (simp add: perm_set_def pt_bij[OF pt, OF at])
  1312 
  1289 
  1313 lemma pt_in_eqvt:
  1290 lemma pt_in_eqvt:
  1314   fixes pi :: "'x prm"
  1291   fixes pi :: "'x prm"
  1315   and   x  :: "'a"
  1292   and   x  :: "'a"
  1316   and   X  :: "'a set"
  1293   and   X  :: "'a set"
  1353   and   Y  :: "'a set"
  1330   and   Y  :: "'a set"
  1354   and   X  :: "'a set"
  1331   and   X  :: "'a set"
  1355   assumes pt: "pt TYPE('a) TYPE('x)"
  1332   assumes pt: "pt TYPE('a) TYPE('x)"
  1356   and     at: "at TYPE('x)"
  1333   and     at: "at TYPE('x)"
  1357   shows "(pi\<bullet>(X\<subseteq>Y)) = ((pi\<bullet>X)\<subseteq>(pi\<bullet>Y))"
  1334   shows "(pi\<bullet>(X\<subseteq>Y)) = ((pi\<bullet>X)\<subseteq>(pi\<bullet>Y))"
  1358 by (auto simp add: perm_set_eq [OF pt at] perm_bool pt_bij[OF pt, OF at])
  1335 by (auto simp add: perm_set_def perm_bool pt_bij[OF pt, OF at])
  1359 
  1336 
  1360 lemma pt_set_diff_eqvt:
  1337 lemma pt_set_diff_eqvt:
  1361   fixes X::"'a set"
  1338   fixes X::"'a set"
  1362   and   Y::"'a set"
  1339   and   Y::"'a set"
  1363   and   pi::"'x prm"
  1340   and   pi::"'x prm"
  1364   assumes pt: "pt TYPE('a) TYPE('x)"
  1341   assumes pt: "pt TYPE('a) TYPE('x)"
  1365   and     at: "at TYPE('x)"
  1342   and     at: "at TYPE('x)"
  1366   shows "pi\<bullet>(X - Y) = (pi\<bullet>X) - (pi\<bullet>Y)"
  1343   shows "pi\<bullet>(X - Y) = (pi\<bullet>X) - (pi\<bullet>Y)"
  1367   by (auto simp add: perm_set_eq [OF pt at] pt_bij[OF pt, OF at])
  1344   by (auto simp add: perm_set_def pt_bij[OF pt, OF at])
  1368 
  1345 
  1369 lemma pt_Collect_eqvt:
  1346 lemma pt_Collect_eqvt:
  1370   fixes pi::"'x prm"
  1347   fixes pi::"'x prm"
  1371   assumes pt: "pt TYPE('a) TYPE('x)"
  1348   assumes pt: "pt TYPE('a) TYPE('x)"
  1372   and     at: "at TYPE('x)"
  1349   and     at: "at TYPE('x)"
  1373   shows "pi\<bullet>{x::'a. P x} = {x. P ((rev pi)\<bullet>x)}"
  1350   shows "pi\<bullet>{x::'a. P x} = {x. P ((rev pi)\<bullet>x)}"
  1374 apply(auto simp add: perm_set_eq [OF pt at] pt_rev_pi[OF pt, OF at])
  1351 apply(auto simp add: perm_set_def pt_rev_pi[OF pt, OF at])
  1375 apply(rule_tac x="(rev pi)\<bullet>x" in exI)
  1352 apply(rule_tac x="(rev pi)\<bullet>x" in exI)
  1376 apply(simp add: pt_pi_rev[OF pt, OF at])
  1353 apply(simp add: pt_pi_rev[OF pt, OF at])
  1377 done
  1354 done
  1378 
  1355 
  1379 -- "some helper lemmas for the pt_perm_supp_ineq lemma"
  1356 -- "some helper lemmas for the pt_perm_supp_ineq lemma"
  1413   and   pi :: "'y prm"
  1390   and   pi :: "'y prm"
  1414   assumes pt: "pt TYPE('x) TYPE('y)"
  1391   assumes pt: "pt TYPE('x) TYPE('y)"
  1415   and     at: "at TYPE('y)"
  1392   and     at: "at TYPE('y)"
  1416   shows "finite (pi\<bullet>X) = finite X"
  1393   shows "finite (pi\<bullet>X) = finite X"
  1417 proof -
  1394 proof -
  1418   have image: "(pi\<bullet>X) = (perm pi ` X)" by (force simp only: perm_set_eq [OF pt at])
  1395   have image: "(pi\<bullet>X) = (perm pi ` X)" by (force simp only: perm_set_def)
  1419   show ?thesis
  1396   show ?thesis
  1420   proof (rule iffI)
  1397   proof (rule iffI)
  1421     assume "finite (pi\<bullet>X)"
  1398     assume "finite (pi\<bullet>X)"
  1422     hence "finite (perm pi ` X)" using image by (simp)
  1399     hence "finite (perm pi ` X)" using image by (simp)
  1423     thus "finite X" using pt_inject_on_ineq[OF pt, OF at] by (rule finite_imageD)
  1400     thus "finite X" using pt_inject_on_ineq[OF pt, OF at] by (rule finite_imageD)
  1443   and     ptb: "pt TYPE('y) TYPE('x)"
  1420   and     ptb: "pt TYPE('y) TYPE('x)"
  1444   and     at:  "at TYPE('x)"
  1421   and     at:  "at TYPE('x)"
  1445   and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
  1422   and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
  1446   shows "(pi\<bullet>((supp x)::'y set)) = supp (pi\<bullet>x)" (is "?LHS = ?RHS")
  1423   shows "(pi\<bullet>((supp x)::'y set)) = supp (pi\<bullet>x)" (is "?LHS = ?RHS")
  1447 proof -
  1424 proof -
  1448   have "?LHS = {pi\<bullet>a | a. infinite {b. [(a,b)]\<bullet>x \<noteq> x}}" by (simp add: supp_def perm_set_eq [OF ptb at])
  1425   have "?LHS = {pi\<bullet>a | a. infinite {b. [(a,b)]\<bullet>x \<noteq> x}}" by (simp add: supp_def perm_set_def)
  1449   also have "\<dots> = {pi\<bullet>a | a. infinite {pi\<bullet>b | b. [(a,b)]\<bullet>x \<noteq> x}}" 
  1426   also have "\<dots> = {pi\<bullet>a | a. infinite {pi\<bullet>b | b. [(a,b)]\<bullet>x \<noteq> x}}" 
  1450   proof (rule Collect_permI, rule allI, rule iffI)
  1427   proof (rule Collect_permI, rule allI, rule iffI)
  1451     fix a
  1428     fix a
  1452     assume "infinite {b::'y. [(a,b)]\<bullet>x  \<noteq> x}"
  1429     assume "infinite {b::'y. [(a,b)]\<bullet>x  \<noteq> x}"
  1453     hence "infinite (pi\<bullet>{b::'y. [(a,b)]\<bullet>x \<noteq> x})" by (simp add: pt_set_infinite_ineq[OF ptb, OF at])
  1430     hence "infinite (pi\<bullet>{b::'y. [(a,b)]\<bullet>x \<noteq> x})" by (simp add: pt_set_infinite_ineq[OF ptb, OF at])
  1454     thus "infinite {pi\<bullet>b |b::'y. [(a,b)]\<bullet>x  \<noteq> x}" by (simp add: perm_set_eq [OF ptb at])
  1431     thus "infinite {pi\<bullet>b |b::'y. [(a,b)]\<bullet>x  \<noteq> x}" by (simp add: perm_set_def)
  1455   next
  1432   next
  1456     fix a
  1433     fix a
  1457     assume "infinite {pi\<bullet>b |b::'y. [(a,b)]\<bullet>x \<noteq> x}"
  1434     assume "infinite {pi\<bullet>b |b::'y. [(a,b)]\<bullet>x \<noteq> x}"
  1458     hence "infinite (pi\<bullet>{b::'y. [(a,b)]\<bullet>x \<noteq> x})" by (simp add: perm_set_eq [OF ptb at])
  1435     hence "infinite (pi\<bullet>{b::'y. [(a,b)]\<bullet>x \<noteq> x})" by (simp add: perm_set_def)
  1459     thus "infinite {b::'y. [(a,b)]\<bullet>x  \<noteq> x}" 
  1436     thus "infinite {b::'y. [(a,b)]\<bullet>x  \<noteq> x}" 
  1460       by (simp add: pt_set_infinite_ineq[OF ptb, OF at])
  1437       by (simp add: pt_set_infinite_ineq[OF ptb, OF at])
  1461   qed
  1438   qed
  1462   also have "\<dots> = {a. infinite {b::'y. [((rev pi)\<bullet>a,(rev pi)\<bullet>b)]\<bullet>x \<noteq> x}}" 
  1439   also have "\<dots> = {a. infinite {b::'y. [((rev pi)\<bullet>a,(rev pi)\<bullet>b)]\<bullet>x \<noteq> x}}" 
  1463     by (simp add: pt_set_eq_ineq[OF ptb, OF at])
  1440     by (simp add: pt_set_eq_ineq[OF ptb, OF at])
  1979   fixes X::"'x set"
  1956   fixes X::"'x set"
  1980   assumes at: "at TYPE('x)"
  1957   assumes at: "at TYPE('x)"
  1981   shows "X supports X"
  1958   shows "X supports X"
  1982 proof -
  1959 proof -
  1983   have "\<forall>a b. a\<notin>X \<and> b\<notin>X \<longrightarrow> [(a,b)]\<bullet>X = X"
  1960   have "\<forall>a b. a\<notin>X \<and> b\<notin>X \<longrightarrow> [(a,b)]\<bullet>X = X"
  1984     by (auto simp add: perm_set_eq [OF at_pt_inst [OF at] at] at_calc[OF at])
  1961     by (auto simp add: perm_set_def at_calc[OF at])
  1985   then show ?thesis by (simp add: supports_def)
  1962   then show ?thesis by (simp add: supports_def)
  1986 qed
  1963 qed
  1987 
  1964 
  1988 lemma infinite_Collection:
  1965 lemma infinite_Collection:
  1989   assumes a1:"infinite X"
  1966   assumes a1:"infinite X"
  2006 next
  1983 next
  2007   have inf: "infinite (UNIV-X)" using at4[OF at] fs by (auto simp add: Diff_infinite_finite)
  1984   have inf: "infinite (UNIV-X)" using at4[OF at] fs by (auto simp add: Diff_infinite_finite)
  2008   { fix a::"'x"
  1985   { fix a::"'x"
  2009     assume asm: "a\<in>X"
  1986     assume asm: "a\<in>X"
  2010     hence "\<forall>b\<in>(UNIV-X). [(a,b)]\<bullet>X\<noteq>X"
  1987     hence "\<forall>b\<in>(UNIV-X). [(a,b)]\<bullet>X\<noteq>X"
  2011       by (auto simp add: perm_set_eq [OF at_pt_inst [OF at] at] at_calc[OF at])
  1988       by (auto simp add: perm_set_def at_calc[OF at])
  2012     with inf have "infinite {b\<in>(UNIV-X). [(a,b)]\<bullet>X\<noteq>X}" by (rule infinite_Collection)
  1989     with inf have "infinite {b\<in>(UNIV-X). [(a,b)]\<bullet>X\<noteq>X}" by (rule infinite_Collection)
  2013     hence "infinite {b. [(a,b)]\<bullet>X\<noteq>X}" by (rule_tac infinite_super, auto)
  1990     hence "infinite {b. [(a,b)]\<bullet>X\<noteq>X}" by (rule_tac infinite_super, auto)
  2014     hence "a\<in>(supp X)" by (simp add: supp_def)
  1991     hence "a\<in>(supp X)" by (simp add: supp_def)
  2015   }
  1992   }
  2016   then show "X\<subseteq>(supp X)" by blast
  1993   then show "X\<subseteq>(supp X)" by blast
  2227   have pt_x: "pt TYPE('x) TYPE('x)" by (force intro: at_pt_inst at)
  2204   have pt_x: "pt TYPE('x) TYPE('x)" by (force intro: at_pt_inst at)
  2228   show ?thesis
  2205   show ?thesis
  2229   proof (rule equalityI)
  2206   proof (rule equalityI)
  2230     case goal1
  2207     case goal1
  2231     show "pi\<bullet>(\<Union>x\<in>X. f x) \<subseteq> (\<Union>x\<in>(pi\<bullet>X). (pi\<bullet>f) x)"
  2208     show "pi\<bullet>(\<Union>x\<in>X. f x) \<subseteq> (\<Union>x\<in>(pi\<bullet>X). (pi\<bullet>f) x)"
  2232       apply(auto simp add: perm_set_eq [OF pt at] perm_set_eq [OF at_pt_inst [OF at] at])
  2209       apply(auto simp add: perm_set_def)
  2233       apply(rule_tac x="pi\<bullet>xb" in exI)
  2210       apply(rule_tac x="pi\<bullet>xb" in exI)
  2234       apply(rule conjI)
  2211       apply(rule conjI)
  2235       apply(rule_tac x="xb" in exI)
  2212       apply(rule_tac x="xb" in exI)
  2236       apply(simp)
  2213       apply(simp)
  2237       apply(subgoal_tac "(pi\<bullet>f) (pi\<bullet>xb) = pi\<bullet>(f xb)")(*A*)
  2214       apply(subgoal_tac "(pi\<bullet>f) (pi\<bullet>xb) = pi\<bullet>(f xb)")(*A*)
  2243       apply(rule pt_fun_app_eq[OF pt, OF at])
  2220       apply(rule pt_fun_app_eq[OF pt, OF at])
  2244       done
  2221       done
  2245   next
  2222   next
  2246     case goal2
  2223     case goal2
  2247     show "(\<Union>x\<in>(pi\<bullet>X). (pi\<bullet>f) x) \<subseteq> pi\<bullet>(\<Union>x\<in>X. f x)"
  2224     show "(\<Union>x\<in>(pi\<bullet>X). (pi\<bullet>f) x) \<subseteq> pi\<bullet>(\<Union>x\<in>X. f x)"
  2248       apply(auto simp add: perm_set_eq [OF pt at] perm_set_eq [OF at_pt_inst [OF at] at])
  2225       apply(auto simp add: perm_set_def)
  2249       apply(rule_tac x="(rev pi)\<bullet>x" in exI)
  2226       apply(rule_tac x="(rev pi)\<bullet>x" in exI)
  2250       apply(rule conjI)
  2227       apply(rule conjI)
  2251       apply(simp add: pt_pi_rev[OF pt_x, OF at])
  2228       apply(simp add: pt_pi_rev[OF pt_x, OF at])
  2252       apply(rule_tac x="xb" in bexI)
  2229       apply(rule_tac x="xb" in bexI)
  2253       apply(simp add: pt_set_bij1[OF pt_x, OF at])
  2230       apply(simp add: pt_set_bij1[OF pt_x, OF at])
  2276   shows "(\<Union>x\<in>X. ((supp x)::'x set)) supports X"
  2253   shows "(\<Union>x\<in>X. ((supp x)::'x set)) supports X"
  2277   apply(simp add: supports_def fresh_def[symmetric])
  2254   apply(simp add: supports_def fresh_def[symmetric])
  2278   apply(rule allI)+
  2255   apply(rule allI)+
  2279   apply(rule impI)
  2256   apply(rule impI)
  2280   apply(erule conjE)
  2257   apply(erule conjE)
  2281   apply(simp add: perm_set_eq [OF pt at])
  2258   apply(simp add: perm_set_def)
  2282   apply(auto)
  2259   apply(auto)
  2283   apply(subgoal_tac "[(a,b)]\<bullet>xa = xa")(*A*)
  2260   apply(subgoal_tac "[(a,b)]\<bullet>xa = xa")(*A*)
  2284   apply(simp)
  2261   apply(simp)
  2285   apply(rule pt_fresh_fresh[OF pt, OF at])
  2262   apply(rule pt_fresh_fresh[OF pt, OF at])
  2286   apply(force)
  2263   apply(force)
  2360 proof -
  2337 proof -
  2361   have "(supp (insert x X)) = ((supp ({x}\<union>(X::'a set)))::'x set)" by simp
  2338   have "(supp (insert x X)) = ((supp ({x}\<union>(X::'a set)))::'x set)" by simp
  2362   also have "\<dots> = (supp {x})\<union>(supp X)"
  2339   also have "\<dots> = (supp {x})\<union>(supp X)"
  2363     by (rule supp_fin_union[OF pt, OF at, OF fs], simp_all add: f)
  2340     by (rule supp_fin_union[OF pt, OF at, OF fs], simp_all add: f)
  2364   finally show "(supp (insert x X)) = (supp x)\<union>((supp X)::'x set)" 
  2341   finally show "(supp (insert x X)) = (supp x)\<union>((supp X)::'x set)" 
  2365     by (simp add: supp_singleton [OF pt at])
  2342     by (simp add: supp_singleton)
  2366 qed
  2343 qed
  2367 
  2344 
  2368 lemma fresh_fin_union:
  2345 lemma fresh_fin_union:
  2369   fixes X::"('a set)"
  2346   fixes X::"('a set)"
  2370   and   Y::"('a set)"
  2347   and   Y::"('a set)"
  2511 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
  2488 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
  2512 apply(simp add: pt_set_bij1[OF ptb, OF at])
  2489 apply(simp add: pt_set_bij1[OF ptb, OF at])
  2513 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
  2490 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
  2514 apply(drule_tac x="pi\<bullet>xa" in bspec)
  2491 apply(drule_tac x="pi\<bullet>xa" in bspec)
  2515 apply(simp add: pt_set_bij1[OF ptb, OF at])
  2492 apply(simp add: pt_set_bij1[OF ptb, OF at])
  2516 apply(simp add: pt_set_eqvt [OF ptb at] pt_rev_pi[OF pt_list_inst[OF ptb], OF at])
  2493 apply(simp add: set_eqvt pt_rev_pi[OF pt_list_inst[OF ptb], OF at])
  2517 apply(simp add: pt_fresh_bij_ineq[OF pta, OF ptb, OF at, OF cp])
  2494 apply(simp add: pt_fresh_bij_ineq[OF pta, OF ptb, OF at, OF cp])
  2518 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
  2495 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
  2519 apply(simp add: pt_set_bij1[OF ptb, OF at] pt_set_eqvt [OF ptb at])
  2496 apply(simp add: pt_set_bij1[OF ptb, OF at] set_eqvt)
  2520 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
  2497 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
  2521 done
  2498 done
  2522 
  2499 
  2523 lemma pt_fresh_star_bij:
  2500 lemma pt_fresh_star_bij:
  2524   fixes  pi :: "'x prm"
  2501   fixes  pi :: "'x prm"
  2636     have "({}::'a set)\<sharp>*c" by (simp add: fresh_star_def)
  2613     have "({}::'a set)\<sharp>*c" by (simp add: fresh_star_def)
  2637     moreover
  2614     moreover
  2638     have "({}::'a set) \<inter> As = {}" by simp
  2615     have "({}::'a set) \<inter> As = {}" by simp
  2639     moreover
  2616     moreover
  2640     have "set ([]::'a prm) \<subseteq> {} \<times> {}" by simp
  2617     have "set ([]::'a prm) \<subseteq> {} \<times> {}" by simp
  2641     moreover
  2618     ultimately show ?case by (simp add: empty_eqvt)
  2642     have "([]::'a prm)\<bullet>{} = ({}::'a set)" 
       
  2643       by (rule pt1 [OF pt_set_inst, OF at_pt_inst [OF at] at])
       
  2644     ultimately show ?case by simp
       
  2645   next
  2619   next
  2646     case (insert x Xs)
  2620     case (insert x Xs)
  2647     then have ih: "\<exists>pi. (pi\<bullet>Xs)\<sharp>*c \<and> (pi\<bullet>Xs) \<inter> As = {} \<and> set pi \<subseteq> Xs \<times> (pi\<bullet>Xs)" by simp
  2621     then have ih: "\<exists>pi. (pi\<bullet>Xs)\<sharp>*c \<and> (pi\<bullet>Xs) \<inter> As = {} \<and> set pi \<subseteq> Xs \<times> (pi\<bullet>Xs)" by simp
  2648     then obtain pi where a1: "(pi\<bullet>Xs)\<sharp>*c" and a2: "(pi\<bullet>Xs) \<inter> As = {}" and 
  2622     then obtain pi where a1: "(pi\<bullet>Xs)\<sharp>*c" and a2: "(pi\<bullet>Xs) \<inter> As = {}" and 
  2649       a4: "set pi \<subseteq> Xs \<times> (pi\<bullet>Xs)" by blast
  2623       a4: "set pi \<subseteq> Xs \<times> (pi\<bullet>Xs)" by blast
  2653     have d3: "({x} \<union> Xs) \<subseteq> As" using insert(4) by simp
  2627     have d3: "({x} \<union> Xs) \<subseteq> As" using insert(4) by simp
  2654     from d d1 d2
  2628     from d d1 d2
  2655     obtain y::"'a" where fr: "y\<sharp>(c,pi\<bullet>Xs,As)" 
  2629     obtain y::"'a" where fr: "y\<sharp>(c,pi\<bullet>Xs,As)" 
  2656       apply(rule_tac at_exists_fresh[OF at, where x="(c,pi\<bullet>Xs,As)"])
  2630       apply(rule_tac at_exists_fresh[OF at, where x="(c,pi\<bullet>Xs,As)"])
  2657       apply(auto simp add: supp_prod at_supp[OF at] at_fin_set_supp[OF at]
  2631       apply(auto simp add: supp_prod at_supp[OF at] at_fin_set_supp[OF at]
  2658         pt_supp_finite_pi[OF pt_set_inst[OF at_pt_inst[OF at] at] at])
  2632         pt_supp_finite_pi[OF pt_set_inst[OF at_pt_inst[OF at]] at])
  2659       done
  2633       done
  2660     have "({y}\<union>(pi\<bullet>Xs))\<sharp>*c" using a1 fr by (simp add: fresh_star_def)
  2634     have "({y}\<union>(pi\<bullet>Xs))\<sharp>*c" using a1 fr by (simp add: fresh_star_def)
  2661     moreover
  2635     moreover
  2662     have "({y}\<union>(pi\<bullet>Xs))\<inter>As = {}" using a2 d1 fr 
  2636     have "({y}\<union>(pi\<bullet>Xs))\<inter>As = {}" using a2 d1 fr 
  2663       by (simp add: fresh_prod at_fin_set_fresh[OF at])
  2637       by (simp add: fresh_prod at_fin_set_fresh[OF at])
  2669     have "(((pi\<bullet>x,y)#pi)\<bullet>({x} \<union> Xs)) = {y}\<union>(pi\<bullet>Xs)"
  2643     have "(((pi\<bullet>x,y)#pi)\<bullet>({x} \<union> Xs)) = {y}\<union>(pi\<bullet>Xs)"
  2670     proof -
  2644     proof -
  2671       have eq: "[(pi\<bullet>x,y)]\<bullet>(pi\<bullet>Xs) = (pi\<bullet>Xs)" 
  2645       have eq: "[(pi\<bullet>x,y)]\<bullet>(pi\<bullet>Xs) = (pi\<bullet>Xs)" 
  2672       proof -
  2646       proof -
  2673         have "(pi\<bullet>x)\<sharp>(pi\<bullet>Xs)" using b d2 
  2647         have "(pi\<bullet>x)\<sharp>(pi\<bullet>Xs)" using b d2 
  2674           by (simp add: pt_fresh_bij [OF pt_set_inst, OF at_pt_inst [OF at], 
  2648           by (simp add: pt_fresh_bij [OF pt_set_inst [OF at_pt_inst [OF at]], OF at]
  2675             OF at, OF at]
       
  2676             at_fin_set_fresh [OF at])
  2649             at_fin_set_fresh [OF at])
  2677         moreover
  2650         moreover
  2678         have "y\<sharp>(pi\<bullet>Xs)" using fr by simp
  2651         have "y\<sharp>(pi\<bullet>Xs)" using fr by simp
  2679         ultimately show "[(pi\<bullet>x,y)]\<bullet>(pi\<bullet>Xs) = (pi\<bullet>Xs)" 
  2652         ultimately show "[(pi\<bullet>x,y)]\<bullet>(pi\<bullet>Xs) = (pi\<bullet>Xs)" 
  2680           by (simp add: pt_fresh_fresh[OF pt_set_inst, 
  2653           by (simp add: pt_fresh_fresh[OF pt_set_inst
  2681             OF at_pt_inst[OF at], OF at, OF at])
  2654             [OF at_pt_inst[OF at]], OF at])
  2682       qed
  2655       qed
  2683       have "(((pi\<bullet>x,y)#pi)\<bullet>({x}\<union>Xs)) = ([(pi\<bullet>x,y)]\<bullet>(pi\<bullet>({x}\<union>Xs)))"
  2656       have "(((pi\<bullet>x,y)#pi)\<bullet>({x}\<union>Xs)) = ([(pi\<bullet>x,y)]\<bullet>(pi\<bullet>({x}\<union>Xs)))"
  2684         by (simp add: pt2[symmetric, OF pt_set_inst, OF at_pt_inst[OF at], 
  2657         by (simp add: pt2[symmetric, OF pt_set_inst [OF at_pt_inst[OF at]]])
  2685           OF at])
       
  2686       also have "\<dots> = {y}\<union>([(pi\<bullet>x,y)]\<bullet>(pi\<bullet>Xs))" 
  2658       also have "\<dots> = {y}\<union>([(pi\<bullet>x,y)]\<bullet>(pi\<bullet>Xs))" 
  2687         by (simp only: union_eqvt perm_set_eq[OF at_pt_inst[OF at], OF at] at_calc[OF at])(auto)
  2659         by (simp only: union_eqvt perm_set_def at_calc[OF at])(auto)
  2688       finally show "(((pi\<bullet>x,y)#pi)\<bullet>({x} \<union> Xs)) = {y}\<union>(pi\<bullet>Xs)" using eq by simp
  2660       finally show "(((pi\<bullet>x,y)#pi)\<bullet>({x} \<union> Xs)) = {y}\<union>(pi\<bullet>Xs)" using eq by simp
  2689     qed
  2661     qed
  2690     ultimately 
  2662     ultimately 
  2691     show ?case by (rule_tac x="(pi\<bullet>x,y)#pi" in exI) (auto)
  2663     show ?case by (rule_tac x="(pi\<bullet>x,y)#pi" in exI) (auto)
  2692   qed
  2664   qed
  2709   shows "cp TYPE ('a list) TYPE('x) TYPE('y)"
  2681   shows "cp TYPE ('a list) TYPE('x) TYPE('y)"
  2710 using c1
  2682 using c1
  2711 apply(simp add: cp_def)
  2683 apply(simp add: cp_def)
  2712 apply(auto)
  2684 apply(auto)
  2713 apply(induct_tac x)
  2685 apply(induct_tac x)
       
  2686 apply(auto)
       
  2687 done
       
  2688 
       
  2689 lemma cp_set_inst:
       
  2690   assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
       
  2691   shows "cp TYPE ('a set) TYPE('x) TYPE('y)"
       
  2692 using c1
       
  2693 apply(simp add: cp_def)
       
  2694 apply(auto)
       
  2695 apply(auto simp add: perm_set_def)
       
  2696 apply(rule_tac x="pi2\<bullet>xc" in exI)
  2714 apply(auto)
  2697 apply(auto)
  2715 done
  2698 done
  2716 
  2699 
  2717 lemma cp_option_inst:
  2700 lemma cp_option_inst:
  2718   assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
  2701   assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
  3594   (* ints *)
  3577   (* ints *)
  3595   Zero_int_eqvt One_int_eqvt min_int_eqvt max_int_eqvt
  3578   Zero_int_eqvt One_int_eqvt min_int_eqvt max_int_eqvt
  3596   plus_int_eqvt minus_int_eqvt mult_int_eqvt div_int_eqvt
  3579   plus_int_eqvt minus_int_eqvt mult_int_eqvt div_int_eqvt
  3597   
  3580   
  3598   (* sets *)
  3581   (* sets *)
  3599   union_eqvt empty_eqvt
  3582   union_eqvt empty_eqvt insert_eqvt set_eqvt
  3600   
  3583   
  3601  
  3584  
  3602 (* the lemmas numeral_nat_eqvt numeral_int_eqvt do not conform with the *)
  3585 (* the lemmas numeral_nat_eqvt numeral_int_eqvt do not conform with the *)
  3603 (* usual form of an eqvt-lemma, but they are needed for analysing       *)
  3586 (* usual form of an eqvt-lemma, but they are needed for analysing       *)
  3604 (* permutations on nats and ints *)
  3587 (* permutations on nats and ints *)