src/HOL/Nominal/Nominal.thy
changeset 30990 4872eef36167
parent 30983 e54777ab68bd
child 31723 f5cafe803b55
equal deleted inserted replaced
30989:1f39aea228b0 30990:4872eef36167
    16 (*======================*)
    16 (*======================*)
    17 
    17 
    18 types 
    18 types 
    19   'x prm = "('x \<times> 'x) list"
    19   'x prm = "('x \<times> 'x) list"
    20 
    20 
    21 (* polymorphic operations for permutation and swapping *)
    21 (* polymorphic constants for permutation and swapping *)
    22 consts 
    22 consts 
    23   perm :: "'x prm \<Rightarrow> 'a \<Rightarrow> 'a"     (infixr "\<bullet>" 80)
    23   perm :: "'x prm \<Rightarrow> 'a \<Rightarrow> 'a"     (infixr "\<bullet>" 80)
    24   swap :: "('x \<times> 'x) \<Rightarrow> 'x \<Rightarrow> 'x"
    24   swap :: "('x \<times> 'x) \<Rightarrow> 'x \<Rightarrow> 'x"
    25 
    25 
    26 (* a "private" copy of the option type used in the abstraction function *)
    26 (* a "private" copy of the option type used in the abstraction function *)
    32 (* an auxiliary constant for the decision procedure involving *) 
    32 (* an auxiliary constant for the decision procedure involving *) 
    33 (* permutations (to avoid loops when using perm-compositions)  *)
    33 (* permutations (to avoid loops when using perm-compositions)  *)
    34 constdefs
    34 constdefs
    35   "perm_aux pi x \<equiv> pi\<bullet>x"
    35   "perm_aux pi x \<equiv> pi\<bullet>x"
    36 
    36 
    37 (* permutation operations *)
    37 (* overloaded permutation operations *)
    38 overloading
    38 overloading
    39   perm_fun    \<equiv> "perm :: 'x prm \<Rightarrow> ('a\<Rightarrow>'b) \<Rightarrow> ('a\<Rightarrow>'b)"   (unchecked)
    39   perm_fun    \<equiv> "perm :: 'x prm \<Rightarrow> ('a\<Rightarrow>'b) \<Rightarrow> ('a\<Rightarrow>'b)"   (unchecked)
    40   perm_bool   \<equiv> "perm :: 'x prm \<Rightarrow> bool \<Rightarrow> bool"           (unchecked)
    40   perm_bool   \<equiv> "perm :: 'x prm \<Rightarrow> bool \<Rightarrow> bool"           (unchecked)
    41   perm_unit   \<equiv> "perm :: 'x prm \<Rightarrow> unit \<Rightarrow> unit"           (unchecked)
    41   perm_unit   \<equiv> "perm :: 'x prm \<Rightarrow> unit \<Rightarrow> unit"           (unchecked)
    42   perm_prod   \<equiv> "perm :: 'x prm \<Rightarrow> ('a\<times>'b) \<Rightarrow> ('a\<times>'b)"     (unchecked)
    42   perm_prod   \<equiv> "perm :: 'x prm \<Rightarrow> ('a\<times>'b) \<Rightarrow> ('a\<times>'b)"     (unchecked)
   201    "a \<sharp> x \<equiv> a \<notin> supp x"
   201    "a \<sharp> x \<equiv> a \<notin> supp x"
   202 
   202 
   203    supports :: "'x set \<Rightarrow> 'a \<Rightarrow> bool" (infixl "supports" 80)
   203    supports :: "'x set \<Rightarrow> 'a \<Rightarrow> bool" (infixl "supports" 80)
   204    "S supports x \<equiv> \<forall>a b. (a\<notin>S \<and> b\<notin>S \<longrightarrow> [(a,b)]\<bullet>x=x)"
   204    "S supports x \<equiv> \<forall>a b. (a\<notin>S \<and> b\<notin>S \<longrightarrow> [(a,b)]\<bullet>x=x)"
   205 
   205 
       
   206 (* lemmas about supp *)
   206 lemma supp_fresh_iff: 
   207 lemma supp_fresh_iff: 
   207   fixes x :: "'a"
   208   fixes x :: "'a"
   208   shows "(supp x) = {a::'x. \<not>a\<sharp>x}"
   209   shows "(supp x) = {a::'x. \<not>a\<sharp>x}"
   209 apply(simp add: fresh_def)
   210   by (simp add: fresh_def)
   210 done
   211 
   211 
   212 
   212 lemma supp_unit:
   213 lemma supp_unit:
   213   shows "supp () = {}"
   214   shows "supp () = {}"
   214   by (simp add: supp_def)
   215   by (simp add: supp_def)
   215 
   216 
   236 
   237 
   237 lemma supp_list_cons:
   238 lemma supp_list_cons:
   238   fixes x  :: "'a"
   239   fixes x  :: "'a"
   239   and   xs :: "'a list"
   240   and   xs :: "'a list"
   240   shows "supp (x#xs) = (supp x)\<union>(supp xs)"
   241   shows "supp (x#xs) = (supp x)\<union>(supp xs)"
   241 apply(auto simp add: supp_def Collect_imp_eq Collect_neg_eq)
   242   by (auto simp add: supp_def Collect_imp_eq Collect_neg_eq)
   242 done
       
   243 
   243 
   244 lemma supp_list_append:
   244 lemma supp_list_append:
   245   fixes xs :: "'a list"
   245   fixes xs :: "'a list"
   246   and   ys :: "'a list"
   246   and   ys :: "'a list"
   247   shows "supp (xs@ys) = (supp xs)\<union>(supp ys)"
   247   shows "supp (xs@ys) = (supp xs)\<union>(supp ys)"
   248   by (induct xs, auto simp add: supp_list_nil supp_list_cons)
   248   by (induct xs) (auto simp add: supp_list_nil supp_list_cons)
   249 
   249 
   250 lemma supp_list_rev:
   250 lemma supp_list_rev:
   251   fixes xs :: "'a list"
   251   fixes xs :: "'a list"
   252   shows "supp (rev xs) = (supp xs)"
   252   shows "supp (rev xs) = (supp xs)"
   253   by (induct xs, auto simp add: supp_list_append supp_list_cons supp_list_nil)
   253   by (induct xs, auto simp add: supp_list_append supp_list_cons supp_list_nil)
   285 lemma supp_string:
   285 lemma supp_string:
   286   fixes s::"string"
   286   fixes s::"string"
   287   shows "(supp s) = {}"
   287   shows "(supp s) = {}"
   288   by (simp add: supp_def perm_string)
   288   by (simp add: supp_def perm_string)
   289 
   289 
       
   290 (* lemmas about freshness *)
   290 lemma fresh_set_empty:
   291 lemma fresh_set_empty:
   291   shows "a\<sharp>{}"
   292   shows "a\<sharp>{}"
   292   by (simp add: fresh_def supp_set_empty)
   293   by (simp add: fresh_def supp_set_empty)
   293 
   294 
   294 lemma fresh_unit:
   295 lemma fresh_unit:
   392   val mksimps_pairs = (@{const_name Nominal.fresh}, @{thms fresh_prodD}) :: mksimps_pairs;
   393   val mksimps_pairs = (@{const_name Nominal.fresh}, @{thms fresh_prodD}) :: mksimps_pairs;
   393 *}
   394 *}
   394 declaration {* fn _ =>
   395 declaration {* fn _ =>
   395   Simplifier.map_ss (fn ss => ss setmksimps (mksimps mksimps_pairs))
   396   Simplifier.map_ss (fn ss => ss setmksimps (mksimps mksimps_pairs))
   396 *}
   397 *}
   397 
       
   398 section {* generalisation of freshness to lists and sets of atoms *}
       
   399 (*================================================================*)
       
   400  
       
   401 consts
       
   402   fresh_star :: "'b \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp>* _" [100,100] 100)
       
   403 
       
   404 defs (overloaded)
       
   405   fresh_star_set: "xs\<sharp>*c \<equiv> \<forall>x\<in>xs. x\<sharp>c"
       
   406 
       
   407 defs (overloaded)
       
   408   fresh_star_list: "xs\<sharp>*c \<equiv> \<forall>x\<in>set xs. x\<sharp>c"
       
   409 
       
   410 lemmas fresh_star_def = fresh_star_list fresh_star_set
       
   411 
       
   412 lemma fresh_star_prod_set:
       
   413   fixes xs::"'a set"
       
   414   shows "xs\<sharp>*(a,b) = (xs\<sharp>*a \<and> xs\<sharp>*b)"
       
   415 by (auto simp add: fresh_star_def fresh_prod)
       
   416 
       
   417 lemma fresh_star_prod_list:
       
   418   fixes xs::"'a list"
       
   419   shows "xs\<sharp>*(a,b) = (xs\<sharp>*a \<and> xs\<sharp>*b)"
       
   420   by (auto simp add: fresh_star_def fresh_prod)
       
   421 
       
   422 lemmas fresh_star_prod = fresh_star_prod_list fresh_star_prod_set
       
   423 
       
   424 lemma fresh_star_set_eq: "set xs \<sharp>* c = xs \<sharp>* c"
       
   425   by (simp add: fresh_star_def)
       
   426 
       
   427 lemma fresh_star_Un_elim:
       
   428   "((S \<union> T) \<sharp>* c \<Longrightarrow> PROP C) \<equiv> (S \<sharp>* c \<Longrightarrow> T \<sharp>* c \<Longrightarrow> PROP C)"
       
   429   apply rule
       
   430   apply (simp_all add: fresh_star_def)
       
   431   apply (erule meta_mp)
       
   432   apply blast
       
   433   done
       
   434 
       
   435 lemma fresh_star_insert_elim:
       
   436   "(insert x S \<sharp>* c \<Longrightarrow> PROP C) \<equiv> (x \<sharp> c \<Longrightarrow> S \<sharp>* c \<Longrightarrow> PROP C)"
       
   437   by rule (simp_all add: fresh_star_def)
       
   438 
       
   439 lemma fresh_star_empty_elim:
       
   440   "({} \<sharp>* c \<Longrightarrow> PROP C) \<equiv> PROP C"
       
   441   by (simp add: fresh_star_def)
       
   442 
       
   443 text {* Normalization of freshness results; cf.\ @{text nominal_induct} *}
       
   444 
       
   445 lemma fresh_star_unit_elim: 
       
   446   shows "((a::'a set)\<sharp>*() \<Longrightarrow> PROP C) \<equiv> PROP C"
       
   447   and "((b::'a list)\<sharp>*() \<Longrightarrow> PROP C) \<equiv> PROP C"
       
   448   by (simp_all add: fresh_star_def fresh_def supp_unit)
       
   449 
       
   450 lemma fresh_star_prod_elim: 
       
   451   shows "((a::'a set)\<sharp>*(x,y) \<Longrightarrow> PROP C) \<equiv> (a\<sharp>*x \<Longrightarrow> a\<sharp>*y \<Longrightarrow> PROP C)"
       
   452   and "((b::'a list)\<sharp>*(x,y) \<Longrightarrow> PROP C) \<equiv> (b\<sharp>*x \<Longrightarrow> b\<sharp>*y \<Longrightarrow> PROP C)"
       
   453   by (rule, simp_all add: fresh_star_prod)+
       
   454 
   398 
   455 section {* Abstract Properties for Permutations and  Atoms *}
   399 section {* Abstract Properties for Permutations and  Atoms *}
   456 (*=========================================================*)
   400 (*=========================================================*)
   457 
   401 
   458 (* properties for being a permutation type *)
   402 (* properties for being a permutation type *)
   509   and   c ::"'x"
   453   and   c ::"'x"
   510   assumes a: "at TYPE('x)"
   454   assumes a: "at TYPE('x)"
   511   shows "swap (a,b) c = (if a=c then b else (if b=c then a else c))"
   455   shows "swap (a,b) c = (if a=c then b else (if b=c then a else c))"
   512   using a by (simp only: at_def)
   456   using a by (simp only: at_def)
   513 
   457 
   514 (* rules to calculate simple premutations *)
   458 (* rules to calculate simple permutations *)
   515 lemmas at_calc = at2 at1 at3
   459 lemmas at_calc = at2 at1 at3
   516 
   460 
   517 lemma at_swap_simps:
   461 lemma at_swap_simps:
   518   fixes a ::"'x"
   462   fixes a ::"'x"
   519   and   b ::"'x"
   463   and   b ::"'x"
   704   and   pi2 :: "'x prm"
   648   and   pi2 :: "'x prm"
   705   assumes at: "at TYPE('x)"
   649   assumes at: "at TYPE('x)"
   706   shows "pi1 \<triangleq> pi2 \<Longrightarrow> (rev pi1) \<triangleq> (rev pi2)"
   650   shows "pi1 \<triangleq> pi2 \<Longrightarrow> (rev pi1) \<triangleq> (rev pi2)"
   707   by (simp add: at_prm_rev_eq[OF at])
   651   by (simp add: at_prm_rev_eq[OF at])
   708 
   652 
   709 
       
   710 lemma at_ds1:
   653 lemma at_ds1:
   711   fixes a  :: "'x"
   654   fixes a  :: "'x"
   712   assumes at: "at TYPE('x)"
   655   assumes at: "at TYPE('x)"
   713   shows "[(a,a)] \<triangleq> []"
   656   shows "[(a,a)] \<triangleq> []"
   714   by (force simp add: prm_eq_def at_calc[OF at])
   657   by (force simp add: prm_eq_def at_calc[OF at])
   860   and     fs: "finite ((supp x)::'x set)"
   803   and     fs: "finite ((supp x)::'x set)"
   861   obtains c::"'x" where  "c\<sharp>x"
   804   obtains c::"'x" where  "c\<sharp>x"
   862   by (auto intro: ex_in_inf[OF at, OF fs] simp add: fresh_def)
   805   by (auto intro: ex_in_inf[OF at, OF fs] simp add: fresh_def)
   863 
   806 
   864 lemma at_finite_select: 
   807 lemma at_finite_select: 
   865   shows "at (TYPE('a)) \<Longrightarrow> finite (S::'a set) \<Longrightarrow> \<exists>x. x \<notin> S"
   808   fixes S::"'a set"
   866   apply (drule Diff_infinite_finite)
   809   assumes a: "at TYPE('a)"
   867   apply (simp add: at_def)
   810   and     b: "finite S" 
   868   apply blast
   811   shows "\<exists>x. x \<notin> S" 
   869   apply (subgoal_tac "UNIV - S \<noteq> {}")
   812   using a b
   870   apply (simp only: ex_in_conv [symmetric])
   813   apply(drule_tac S="UNIV::'a set" in Diff_infinite_finite)
   871   apply blast
   814   apply(simp add: at_def)
   872   apply (rule notI)
   815   apply(subgoal_tac "UNIV - S \<noteq> {}")
   873   apply simp
   816   apply(simp only: ex_in_conv [symmetric])
       
   817   apply(blast)
       
   818   apply(rule notI)
       
   819   apply(simp)
   874   done
   820   done
   875 
   821 
   876 lemma at_different:
   822 lemma at_different:
   877   assumes at: "at TYPE('x)"
   823   assumes at: "at TYPE('x)"
   878   shows "\<exists>(b::'x). a\<noteq>b"
   824   shows "\<exists>(b::'x). a\<noteq>b"
  1244   and   x  :: "'a"
  1190   and   x  :: "'a"
  1245   and   y  :: "'a"
  1191   and   y  :: "'a"
  1246   assumes pt: "pt TYPE('a) TYPE('x)"
  1192   assumes pt: "pt TYPE('a) TYPE('x)"
  1247   and     at: "at TYPE('x)"
  1193   and     at: "at TYPE('x)"
  1248   shows "pi\<bullet>(x=y) = (pi\<bullet>x = pi\<bullet>y)"
  1194   shows "pi\<bullet>(x=y) = (pi\<bullet>x = pi\<bullet>y)"
  1249 using assms
  1195   using pt at
  1250 by (auto simp add: pt_bij perm_bool)
  1196   by (auto simp add: pt_bij perm_bool)
  1251 
  1197 
  1252 lemma pt_bij3:
  1198 lemma pt_bij3:
  1253   fixes pi :: "'x prm"
  1199   fixes pi :: "'x prm"
  1254   and   x  :: "'a"
  1200   and   x  :: "'a"
  1255   and   y  :: "'a"
  1201   and   y  :: "'a"
  1256   assumes a:  "x=y"
  1202   assumes a:  "x=y"
  1257   shows "(pi\<bullet>x = pi\<bullet>y)"
  1203   shows "(pi\<bullet>x = pi\<bullet>y)"
  1258 using a by simp 
  1204   using a by simp 
  1259 
  1205 
  1260 lemma pt_bij4:
  1206 lemma pt_bij4:
  1261   fixes pi :: "'x prm"
  1207   fixes pi :: "'x prm"
  1262   and   x  :: "'a"
  1208   and   x  :: "'a"
  1263   and   y  :: "'a"
  1209   and   y  :: "'a"
  1264   assumes pt: "pt TYPE('a) TYPE('x)"
  1210   assumes pt: "pt TYPE('a) TYPE('x)"
  1265   and     at: "at TYPE('x)"
  1211   and     at: "at TYPE('x)"
  1266   and     a:  "pi\<bullet>x = pi\<bullet>y"
  1212   and     a:  "pi\<bullet>x = pi\<bullet>y"
  1267   shows "x = y"
  1213   shows "x = y"
  1268 using a by (simp add: pt_bij[OF pt, OF at])
  1214   using a by (simp add: pt_bij[OF pt, OF at])
  1269 
  1215 
  1270 lemma pt_swap_bij:
  1216 lemma pt_swap_bij:
  1271   fixes a  :: "'x"
  1217   fixes a  :: "'x"
  1272   and   b  :: "'x"
  1218   and   b  :: "'x"
  1273   and   x  :: "'a"
  1219   and   x  :: "'a"
  1596   shows "(pi\<bullet>a)\<sharp>(pi\<bullet>x) = a\<sharp>x"
  1542   shows "(pi\<bullet>a)\<sharp>(pi\<bullet>x) = a\<sharp>x"
  1597 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
  1543 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
  1598 apply(simp add: pt_rev_pi[OF ptb, OF at])
  1544 apply(simp add: pt_rev_pi[OF ptb, OF at])
  1599 done
  1545 done
  1600 
  1546 
  1601 lemma pt_fresh_star_bij_ineq:
       
  1602   fixes  pi :: "'x prm"
       
  1603   and     x :: "'a"
       
  1604   and     a :: "'y set"
       
  1605   and     b :: "'y list"
       
  1606   assumes pta: "pt TYPE('a) TYPE('x)"
       
  1607   and     ptb: "pt TYPE('y) TYPE('x)"
       
  1608   and     at:  "at TYPE('x)"
       
  1609   and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
       
  1610   shows "(pi\<bullet>a)\<sharp>*(pi\<bullet>x) = a\<sharp>*x"
       
  1611   and   "(pi\<bullet>b)\<sharp>*(pi\<bullet>x) = b\<sharp>*x"
       
  1612 apply(unfold fresh_star_def)
       
  1613 apply(auto)
       
  1614 apply(drule_tac x="pi\<bullet>xa" in bspec)
       
  1615 apply(rule pt_set_bij2[OF ptb, OF at])
       
  1616 apply(assumption)
       
  1617 apply(simp add: fresh_star_def pt_fresh_bij_ineq[OF pta, OF ptb, OF at, OF cp])
       
  1618 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
       
  1619 apply(simp add: pt_set_bij1[OF ptb, OF at])
       
  1620 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
       
  1621 apply(drule_tac x="pi\<bullet>xa" in bspec)
       
  1622 apply(simp add: pt_set_bij1[OF ptb, OF at])
       
  1623 apply(simp add: pt_set_eqvt [OF ptb at] pt_rev_pi[OF pt_list_inst[OF ptb], OF at])
       
  1624 apply(simp add: pt_fresh_bij_ineq[OF pta, OF ptb, OF at, OF cp])
       
  1625 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
       
  1626 apply(simp add: pt_set_bij1[OF ptb, OF at] pt_set_eqvt [OF ptb at])
       
  1627 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
       
  1628 done
       
  1629 
       
  1630 lemma pt_fresh_left:  
  1547 lemma pt_fresh_left:  
  1631   fixes  pi :: "'x prm"
  1548   fixes  pi :: "'x prm"
  1632   and     x :: "'a"
  1549   and     x :: "'a"
  1633   and     a :: "'x"
  1550   and     a :: "'x"
  1634   assumes pt: "pt TYPE('a) TYPE('x)"
  1551   assumes pt: "pt TYPE('a) TYPE('x)"
  1672 apply(rule at)+
  1589 apply(rule at)+
  1673 apply(rule cp_pt_inst)
  1590 apply(rule cp_pt_inst)
  1674 apply(rule pt)
  1591 apply(rule pt)
  1675 apply(rule at)
  1592 apply(rule at)
  1676 done
  1593 done
  1677 
       
  1678 lemma pt_fresh_star_bij:
       
  1679   fixes  pi :: "'x prm"
       
  1680   and     x :: "'a"
       
  1681   and     a :: "'x set"
       
  1682   and     b :: "'x list"
       
  1683   assumes pt: "pt TYPE('a) TYPE('x)"
       
  1684   and     at: "at TYPE('x)"
       
  1685   shows "(pi\<bullet>a)\<sharp>*(pi\<bullet>x) = a\<sharp>*x"
       
  1686   and   "(pi\<bullet>b)\<sharp>*(pi\<bullet>x) = b\<sharp>*x"
       
  1687 apply(rule pt_fresh_star_bij_ineq(1))
       
  1688 apply(rule pt)
       
  1689 apply(rule at_pt_inst)
       
  1690 apply(rule at)+
       
  1691 apply(rule cp_pt_inst)
       
  1692 apply(rule pt)
       
  1693 apply(rule at)
       
  1694 apply(rule pt_fresh_star_bij_ineq(2))
       
  1695 apply(rule pt)
       
  1696 apply(rule at_pt_inst)
       
  1697 apply(rule at)+
       
  1698 apply(rule cp_pt_inst)
       
  1699 apply(rule pt)
       
  1700 apply(rule at)
       
  1701 done
       
  1702 
       
  1703 lemma pt_fresh_star_eqvt:
       
  1704   fixes  pi :: "'x prm"
       
  1705   and     x :: "'a"
       
  1706   and     a :: "'x set"
       
  1707   and     b :: "'x list"
       
  1708   assumes pt: "pt TYPE('a) TYPE('x)"
       
  1709   and     at: "at TYPE('x)"
       
  1710   shows "pi\<bullet>(a\<sharp>*x) = (pi\<bullet>a)\<sharp>*(pi\<bullet>x)"
       
  1711   and   "pi\<bullet>(b\<sharp>*x) = (pi\<bullet>b)\<sharp>*(pi\<bullet>x)"
       
  1712   by (simp_all add: perm_bool pt_fresh_star_bij[OF pt, OF at])
       
  1713 
       
  1714 lemma pt_fresh_star_eqvt_ineq:
       
  1715   fixes pi::"'x prm"
       
  1716   and   a::"'y set"
       
  1717   and   b::"'y list"
       
  1718   and   x::"'a"
       
  1719   assumes pta: "pt TYPE('a) TYPE('x)"
       
  1720   and     ptb: "pt TYPE('y) TYPE('x)"
       
  1721   and     at:  "at TYPE('x)"
       
  1722   and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
       
  1723   and     dj:  "disjoint TYPE('y) TYPE('x)"
       
  1724   shows "pi\<bullet>(a\<sharp>*x) = (pi\<bullet>a)\<sharp>*(pi\<bullet>x)"
       
  1725   and   "pi\<bullet>(b\<sharp>*x) = (pi\<bullet>b)\<sharp>*(pi\<bullet>x)"
       
  1726   by (simp_all add: pt_fresh_star_bij_ineq[OF pta, OF ptb, OF at, OF cp] dj_perm_forget[OF dj] perm_bool)
       
  1727 
  1594 
  1728 lemma pt_fresh_bij1:
  1595 lemma pt_fresh_bij1:
  1729   fixes  pi :: "'x prm"
  1596   fixes  pi :: "'x prm"
  1730   and     x :: "'a"
  1597   and     x :: "'a"
  1731   and     a :: "'x"
  1598   and     a :: "'x"
  1775   with a2' neg show False by simp
  1642   with a2' neg show False by simp
  1776 qed
  1643 qed
  1777 
  1644 
  1778 (* the next two lemmas are needed in the proof *)
  1645 (* the next two lemmas are needed in the proof *)
  1779 (* of the structural induction principle       *)
  1646 (* of the structural induction principle       *)
  1780 
       
  1781 lemma pt_fresh_aux:
  1647 lemma pt_fresh_aux:
  1782   fixes a::"'x"
  1648   fixes a::"'x"
  1783   and   b::"'x"
  1649   and   b::"'x"
  1784   and   c::"'x"
  1650   and   c::"'x"
  1785   and   x::"'a"
  1651   and   x::"'a"
  1879   from c2 ineq have "[(a,c),(b,c),(a,c)] \<triangleq> [(a,b)]" by (simp add: at_ds3[OF at])
  1745   from c2 ineq have "[(a,c),(b,c),(a,c)] \<triangleq> [(a,b)]" by (simp add: at_ds3[OF at])
  1880   hence "[(a,c),(b,c),(a,c)]\<bullet>x = [(a,b)]\<bullet>x" by (rule pt3[OF pt])
  1746   hence "[(a,c),(b,c),(a,c)]\<bullet>x = [(a,b)]\<bullet>x" by (rule pt3[OF pt])
  1881   thus ?thesis using eq3 by simp
  1747   thus ?thesis using eq3 by simp
  1882 qed
  1748 qed
  1883 
  1749 
  1884 lemma pt_freshs_freshs:
       
  1885   assumes pt: "pt TYPE('a) TYPE('x)"
       
  1886   and at: "at TYPE ('x)"
       
  1887   and pi: "set (pi::'x prm) \<subseteq> Xs \<times> Ys"
       
  1888   and Xs: "Xs \<sharp>* (x::'a)"
       
  1889   and Ys: "Ys \<sharp>* x"
       
  1890   shows "pi \<bullet> x = x"
       
  1891   using pi
       
  1892 proof (induct pi)
       
  1893   case Nil
       
  1894   show ?case by (simp add: pt1 [OF pt])
       
  1895 next
       
  1896   case (Cons p pi)
       
  1897   obtain a b where p: "p = (a, b)" by (cases p)
       
  1898   with Cons Xs Ys have "a \<sharp> x" "b \<sharp> x"
       
  1899     by (simp_all add: fresh_star_def)
       
  1900   with Cons p show ?case
       
  1901     by (simp add: pt_fresh_fresh [OF pt at]
       
  1902       pt2 [OF pt, of "[(a, b)]" pi, simplified])
       
  1903 qed
       
  1904 
       
  1905 lemma pt_pi_fresh_fresh:
  1750 lemma pt_pi_fresh_fresh:
  1906   fixes   x :: "'a"
  1751   fixes   x :: "'a"
  1907   and     pi :: "'x prm"
  1752   and     pi :: "'x prm"
  1908   assumes pt: "pt TYPE('a) TYPE('x)"
  1753   assumes pt: "pt TYPE('a) TYPE('x)"
  1909   and     at: "at TYPE ('x)"
  1754   and     at: "at TYPE ('x)"
  1965   have "((rev pi2)@(rev pi1)) \<triangleq> ((rev pi1)@(rev (pi1\<bullet>pi2)))" by (rule at_ds9[OF at])
  1810   have "((rev pi2)@(rev pi1)) \<triangleq> ((rev pi1)@(rev (pi1\<bullet>pi2)))" by (rule at_ds9[OF at])
  1966   hence "((rev pi2)@(rev pi1))\<bullet>x = ((rev pi1)@(rev (pi1\<bullet>pi2)))\<bullet>x" by (rule pt3[OF pt])
  1811   hence "((rev pi2)@(rev pi1))\<bullet>x = ((rev pi1)@(rev (pi1\<bullet>pi2)))\<bullet>x" by (rule pt3[OF pt])
  1967   thus ?thesis by (simp add: pt2[OF pt])
  1812   thus ?thesis by (simp add: pt2[OF pt])
  1968 qed
  1813 qed
  1969 
  1814 
  1970 section {* equivaraince for some connectives *}
  1815 section {* equivariance for some connectives *}
  1971 
       
  1972 lemma pt_all_eqvt:
  1816 lemma pt_all_eqvt:
  1973   fixes  pi :: "'x prm"
  1817   fixes  pi :: "'x prm"
  1974   and     x :: "'a"
  1818   and     x :: "'a"
  1975   assumes pt: "pt TYPE('a) TYPE('x)"
  1819   assumes pt: "pt TYPE('a) TYPE('x)"
  1976   and     at: "at TYPE('x)"
  1820   and     at: "at TYPE('x)"
  2011   apply(simp add: pt_ex1_eqvt[OF pt at,symmetric])
  1855   apply(simp add: pt_ex1_eqvt[OF pt at,symmetric])
  2012   apply(simp add: perm_bool unique)
  1856   apply(simp add: perm_bool unique)
  2013   apply(simp add: perm_bool pt_rev_pi [OF pt at])
  1857   apply(simp add: perm_bool pt_rev_pi [OF pt at])
  2014   apply(rule theI'[OF unique])
  1858   apply(rule theI'[OF unique])
  2015   done
  1859   done
  2016 
       
  2017 
       
  2018 
  1860 
  2019 section {* facts about supports *}
  1861 section {* facts about supports *}
  2020 (*==============================*)
  1862 (*==============================*)
  2021 
  1863 
  2022 lemma supports_subset:
  1864 lemma supports_subset:
  2181   fixes X::"'x set" 
  2023   fixes X::"'x set" 
  2182   assumes at: "at TYPE('x)"
  2024   assumes at: "at TYPE('x)"
  2183   and     fs: "finite X"
  2025   and     fs: "finite X"
  2184   shows "(x \<sharp> X) = (x \<notin> X)"
  2026   shows "(x \<sharp> X) = (x \<notin> X)"
  2185   by (simp add: at_fin_set_supp fresh_def at fs)
  2027   by (simp add: at_fin_set_supp fresh_def at fs)
       
  2028 
  2186 
  2029 
  2187 section {* Permutations acting on Functions *}
  2030 section {* Permutations acting on Functions *}
  2188 (*==========================================*)
  2031 (*==========================================*)
  2189 
  2032 
  2190 lemma pt_fun_app_eq:
  2033 lemma pt_fun_app_eq:
  2562   and     fs: "fs TYPE('a) TYPE('x)" 
  2405   and     fs: "fs TYPE('a) TYPE('x)" 
  2563   and     f:  "finite X"
  2406   and     f:  "finite X"
  2564   and     a1:  "a\<sharp>x"
  2407   and     a1:  "a\<sharp>x"
  2565   and     a2:  "a\<sharp>X"
  2408   and     a2:  "a\<sharp>X"
  2566   shows "a\<sharp>(insert x X)"
  2409   shows "a\<sharp>(insert x X)"
  2567 using a1 a2
  2410   using a1 a2
  2568 apply(simp add: fresh_fin_insert[OF pt, OF at, OF fs, OF f])
  2411   by (simp add: fresh_fin_insert[OF pt, OF at, OF fs, OF f])
  2569 done
       
  2570 
  2412 
  2571 lemma pt_list_set_supp:
  2413 lemma pt_list_set_supp:
  2572   fixes xs :: "'a list"
  2414   fixes xs :: "'a list"
  2573   assumes pt: "pt TYPE('a) TYPE('x)"
  2415   assumes pt: "pt TYPE('a) TYPE('x)"
  2574   and     at: "at TYPE('x)"
  2416   and     at: "at TYPE('x)"
  2593   and     at: "at TYPE('x)"
  2435   and     at: "at TYPE('x)"
  2594   and     fs: "fs TYPE('a) TYPE('x)"
  2436   and     fs: "fs TYPE('a) TYPE('x)"
  2595   shows "a\<sharp>(set xs) = a\<sharp>xs"
  2437   shows "a\<sharp>(set xs) = a\<sharp>xs"
  2596 by (simp add: fresh_def pt_list_set_supp[OF pt, OF at, OF fs])
  2438 by (simp add: fresh_def pt_list_set_supp[OF pt, OF at, OF fs])
  2597 
  2439 
       
  2440 
       
  2441 section {* generalisation of freshness to lists and sets of atoms *}
       
  2442 (*================================================================*)
       
  2443  
       
  2444 consts
       
  2445   fresh_star :: "'b \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp>* _" [100,100] 100)
       
  2446 
       
  2447 defs (overloaded)
       
  2448   fresh_star_set: "xs\<sharp>*c \<equiv> \<forall>x\<in>xs. x\<sharp>c"
       
  2449 
       
  2450 defs (overloaded)
       
  2451   fresh_star_list: "xs\<sharp>*c \<equiv> \<forall>x\<in>set xs. x\<sharp>c"
       
  2452 
       
  2453 lemmas fresh_star_def = fresh_star_list fresh_star_set
       
  2454 
       
  2455 lemma fresh_star_prod_set:
       
  2456   fixes xs::"'a set"
       
  2457   shows "xs\<sharp>*(a,b) = (xs\<sharp>*a \<and> xs\<sharp>*b)"
       
  2458 by (auto simp add: fresh_star_def fresh_prod)
       
  2459 
       
  2460 lemma fresh_star_prod_list:
       
  2461   fixes xs::"'a list"
       
  2462   shows "xs\<sharp>*(a,b) = (xs\<sharp>*a \<and> xs\<sharp>*b)"
       
  2463   by (auto simp add: fresh_star_def fresh_prod)
       
  2464 
       
  2465 lemmas fresh_star_prod = fresh_star_prod_list fresh_star_prod_set
       
  2466 
       
  2467 lemma fresh_star_set_eq: "set xs \<sharp>* c = xs \<sharp>* c"
       
  2468   by (simp add: fresh_star_def)
       
  2469 
       
  2470 lemma fresh_star_Un_elim:
       
  2471   "((S \<union> T) \<sharp>* c \<Longrightarrow> PROP C) \<equiv> (S \<sharp>* c \<Longrightarrow> T \<sharp>* c \<Longrightarrow> PROP C)"
       
  2472   apply rule
       
  2473   apply (simp_all add: fresh_star_def)
       
  2474   apply (erule meta_mp)
       
  2475   apply blast
       
  2476   done
       
  2477 
       
  2478 lemma fresh_star_insert_elim:
       
  2479   "(insert x S \<sharp>* c \<Longrightarrow> PROP C) \<equiv> (x \<sharp> c \<Longrightarrow> S \<sharp>* c \<Longrightarrow> PROP C)"
       
  2480   by rule (simp_all add: fresh_star_def)
       
  2481 
       
  2482 lemma fresh_star_empty_elim:
       
  2483   "({} \<sharp>* c \<Longrightarrow> PROP C) \<equiv> PROP C"
       
  2484   by (simp add: fresh_star_def)
       
  2485 
       
  2486 text {* Normalization of freshness results; see \ @{text nominal_induct} *}
       
  2487 
       
  2488 lemma fresh_star_unit_elim: 
       
  2489   shows "((a::'a set)\<sharp>*() \<Longrightarrow> PROP C) \<equiv> PROP C"
       
  2490   and "((b::'a list)\<sharp>*() \<Longrightarrow> PROP C) \<equiv> PROP C"
       
  2491   by (simp_all add: fresh_star_def fresh_def supp_unit)
       
  2492 
       
  2493 lemma fresh_star_prod_elim: 
       
  2494   shows "((a::'a set)\<sharp>*(x,y) \<Longrightarrow> PROP C) \<equiv> (a\<sharp>*x \<Longrightarrow> a\<sharp>*y \<Longrightarrow> PROP C)"
       
  2495   and "((b::'a list)\<sharp>*(x,y) \<Longrightarrow> PROP C) \<equiv> (b\<sharp>*x \<Longrightarrow> b\<sharp>*y \<Longrightarrow> PROP C)"
       
  2496   by (rule, simp_all add: fresh_star_prod)+
       
  2497 
       
  2498 
       
  2499 lemma pt_fresh_star_bij_ineq:
       
  2500   fixes  pi :: "'x prm"
       
  2501   and     x :: "'a"
       
  2502   and     a :: "'y set"
       
  2503   and     b :: "'y list"
       
  2504   assumes pta: "pt TYPE('a) TYPE('x)"
       
  2505   and     ptb: "pt TYPE('y) TYPE('x)"
       
  2506   and     at:  "at TYPE('x)"
       
  2507   and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
       
  2508   shows "(pi\<bullet>a)\<sharp>*(pi\<bullet>x) = a\<sharp>*x"
       
  2509   and   "(pi\<bullet>b)\<sharp>*(pi\<bullet>x) = b\<sharp>*x"
       
  2510 apply(unfold fresh_star_def)
       
  2511 apply(auto)
       
  2512 apply(drule_tac x="pi\<bullet>xa" in bspec)
       
  2513 apply(erule pt_set_bij2[OF ptb, OF at])
       
  2514 apply(simp add: fresh_star_def pt_fresh_bij_ineq[OF pta, OF ptb, OF at, OF cp])
       
  2515 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
       
  2516 apply(simp add: pt_set_bij1[OF ptb, OF at])
       
  2517 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
       
  2518 apply(drule_tac x="pi\<bullet>xa" in bspec)
       
  2519 apply(simp add: pt_set_bij1[OF ptb, OF at])
       
  2520 apply(simp add: pt_set_eqvt [OF ptb at] pt_rev_pi[OF pt_list_inst[OF ptb], OF at])
       
  2521 apply(simp add: pt_fresh_bij_ineq[OF pta, OF ptb, OF at, OF cp])
       
  2522 apply(drule_tac x="(rev pi)\<bullet>xa" in bspec)
       
  2523 apply(simp add: pt_set_bij1[OF ptb, OF at] pt_set_eqvt [OF ptb at])
       
  2524 apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
       
  2525 done
       
  2526 
       
  2527 lemma pt_fresh_star_bij:
       
  2528   fixes  pi :: "'x prm"
       
  2529   and     x :: "'a"
       
  2530   and     a :: "'x set"
       
  2531   and     b :: "'x list"
       
  2532   assumes pt: "pt TYPE('a) TYPE('x)"
       
  2533   and     at: "at TYPE('x)"
       
  2534   shows "(pi\<bullet>a)\<sharp>*(pi\<bullet>x) = a\<sharp>*x"
       
  2535   and   "(pi\<bullet>b)\<sharp>*(pi\<bullet>x) = b\<sharp>*x"
       
  2536 apply(rule pt_fresh_star_bij_ineq(1))
       
  2537 apply(rule pt)
       
  2538 apply(rule at_pt_inst)
       
  2539 apply(rule at)+
       
  2540 apply(rule cp_pt_inst)
       
  2541 apply(rule pt)
       
  2542 apply(rule at)
       
  2543 apply(rule pt_fresh_star_bij_ineq(2))
       
  2544 apply(rule pt)
       
  2545 apply(rule at_pt_inst)
       
  2546 apply(rule at)+
       
  2547 apply(rule cp_pt_inst)
       
  2548 apply(rule pt)
       
  2549 apply(rule at)
       
  2550 done
       
  2551 
       
  2552 lemma pt_fresh_star_eqvt:
       
  2553   fixes  pi :: "'x prm"
       
  2554   and     x :: "'a"
       
  2555   and     a :: "'x set"
       
  2556   and     b :: "'x list"
       
  2557   assumes pt: "pt TYPE('a) TYPE('x)"
       
  2558   and     at: "at TYPE('x)"
       
  2559   shows "pi\<bullet>(a\<sharp>*x) = (pi\<bullet>a)\<sharp>*(pi\<bullet>x)"
       
  2560   and   "pi\<bullet>(b\<sharp>*x) = (pi\<bullet>b)\<sharp>*(pi\<bullet>x)"
       
  2561   by (simp_all add: perm_bool pt_fresh_star_bij[OF pt, OF at])
       
  2562 
       
  2563 lemma pt_fresh_star_eqvt_ineq:
       
  2564   fixes pi::"'x prm"
       
  2565   and   a::"'y set"
       
  2566   and   b::"'y list"
       
  2567   and   x::"'a"
       
  2568   assumes pta: "pt TYPE('a) TYPE('x)"
       
  2569   and     ptb: "pt TYPE('y) TYPE('x)"
       
  2570   and     at:  "at TYPE('x)"
       
  2571   and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
       
  2572   and     dj:  "disjoint TYPE('y) TYPE('x)"
       
  2573   shows "pi\<bullet>(a\<sharp>*x) = (pi\<bullet>a)\<sharp>*(pi\<bullet>x)"
       
  2574   and   "pi\<bullet>(b\<sharp>*x) = (pi\<bullet>b)\<sharp>*(pi\<bullet>x)"
       
  2575   by (simp_all add: pt_fresh_star_bij_ineq[OF pta, OF ptb, OF at, OF cp] dj_perm_forget[OF dj] perm_bool)
       
  2576 
       
  2577 lemma pt_freshs_freshs:
       
  2578   assumes pt: "pt TYPE('a) TYPE('x)"
       
  2579   and at: "at TYPE ('x)"
       
  2580   and pi: "set (pi::'x prm) \<subseteq> Xs \<times> Ys"
       
  2581   and Xs: "Xs \<sharp>* (x::'a)"
       
  2582   and Ys: "Ys \<sharp>* x"
       
  2583   shows "pi\<bullet>x = x"
       
  2584   using pi
       
  2585 proof (induct pi)
       
  2586   case Nil
       
  2587   show ?case by (simp add: pt1 [OF pt])
       
  2588 next
       
  2589   case (Cons p pi)
       
  2590   obtain a b where p: "p = (a, b)" by (cases p)
       
  2591   with Cons Xs Ys have "a \<sharp> x" "b \<sharp> x"
       
  2592     by (simp_all add: fresh_star_def)
       
  2593   with Cons p show ?case
       
  2594     by (simp add: pt_fresh_fresh [OF pt at]
       
  2595       pt2 [OF pt, of "[(a, b)]" pi, simplified])
       
  2596 qed
       
  2597 
       
  2598 lemma pt_fresh_star_pi: 
       
  2599   fixes x::"'a"
       
  2600   and   pi::"'x prm"
       
  2601   assumes pt: "pt TYPE('a) TYPE('x)"
       
  2602   and     at: "at TYPE('x)"
       
  2603   and     a: "((supp x)::'x set)\<sharp>* pi"
       
  2604   shows "pi\<bullet>x = x"
       
  2605 using a
       
  2606 apply(induct pi)
       
  2607 apply(auto simp add: fresh_star_def fresh_list_cons fresh_prod pt1[OF pt])
       
  2608 apply(subgoal_tac "((a,b)#pi)\<bullet>x = ([(a,b)]@pi)\<bullet>x")
       
  2609 apply(simp only: pt2[OF pt])
       
  2610 apply(rule pt_fresh_fresh[OF pt at])
       
  2611 apply(simp add: fresh_def at_supp[OF at])
       
  2612 apply(blast)
       
  2613 apply(simp add: fresh_def at_supp[OF at])
       
  2614 apply(blast)
       
  2615 apply(simp add: pt2[OF pt])
       
  2616 done
       
  2617 
  2598 section {* Infrastructure lemmas for strong rule inductions *}
  2618 section {* Infrastructure lemmas for strong rule inductions *}
  2599 (*==========================================================*)
  2619 (*==========================================================*)
  2600 
       
  2601 
  2620 
  2602 text {* 
  2621 text {* 
  2603   For every set of atoms, there is another set of atoms
  2622   For every set of atoms, there is another set of atoms
  2604   avoiding a finitely supported c and there is a permutation
  2623   avoiding a finitely supported c and there is a permutation
  2605   which make 'translates' between both sets.
  2624   which 'translates' between both sets.
  2606 *}
  2625 *}
  2607 lemma at_set_avoiding_aux:
  2626 lemma at_set_avoiding_aux:
  2608   fixes Xs::"'a set"
  2627   fixes Xs::"'a set"
  2609   and   As::"'a set"
  2628   and   As::"'a set"
  2610   assumes at: "at TYPE('a)"
  2629   assumes at: "at TYPE('a)"
  3387   show "(abs_fun a x)\<in> ABS_set" by (rule ABS_in)
  3406   show "(abs_fun a x)\<in> ABS_set" by (rule ABS_in)
  3388 qed
  3407 qed
  3389 
  3408 
  3390 syntax ABS :: "type \<Rightarrow> type \<Rightarrow> type" ("\<guillemotleft>_\<guillemotright>_" [1000,1000] 1000)
  3409 syntax ABS :: "type \<Rightarrow> type \<Rightarrow> type" ("\<guillemotleft>_\<guillemotright>_" [1000,1000] 1000)
  3391 
  3410 
  3392 
       
  3393 section {* lemmas for deciding permutation equations *}
  3411 section {* lemmas for deciding permutation equations *}
  3394 (*===================================================*)
  3412 (*===================================================*)
  3395 
  3413 
  3396 lemma perm_aux_fold:
  3414 lemma perm_aux_fold:
  3397   shows "perm_aux pi x = pi\<bullet>x" by (simp only: perm_aux_def)
  3415   shows "perm_aux pi x = pi\<bullet>x" by (simp only: perm_aux_def)
  3548 lemma div_int_eqvt:
  3566 lemma div_int_eqvt:
  3549   fixes x::"int"
  3567   fixes x::"int"
  3550   shows "pi\<bullet>(x div y) = (pi\<bullet>x) div (pi\<bullet>y)" 
  3568   shows "pi\<bullet>(x div y) = (pi\<bullet>x) div (pi\<bullet>y)" 
  3551 by (simp add:perm_int_def) 
  3569 by (simp add:perm_int_def) 
  3552 
  3570 
  3553 (*******************************************************************)
  3571 (*******************************************************)
  3554 (* Setup of the theorem attributes eqvt, eqvt_force, fresh and bij *)
  3572 (* Setup of the theorem attributes eqvt and eqvt_force *)
  3555 use "nominal_thmdecls.ML"
  3573 use "nominal_thmdecls.ML"
  3556 setup "NominalThmDecls.setup"
  3574 setup "NominalThmDecls.setup"
  3557 
  3575 
  3558 lemmas [eqvt] = 
  3576 lemmas [eqvt] = 
  3559   (* connectives *)
  3577   (* connectives *)