src/HOL/Nominal/Examples/Support.thy
changeset 63167 0909deb8059b
parent 62390 842917225d56
child 66453 cc19f7ca2ed6
equal deleted inserted replaced
63166:143f58bb34f9 63167:0909deb8059b
     1 theory Support 
     1 theory Support 
     2   imports "../Nominal" 
     2   imports "../Nominal" 
     3 begin
     3 begin
     4 
     4 
     5 text {* 
     5 text \<open>
     6   An example showing that in general
     6   An example showing that in general
     7 
     7 
     8   x\<sharp>(A \<union> B) does not imply  x\<sharp>A and  x\<sharp>B
     8   x\<sharp>(A \<union> B) does not imply  x\<sharp>A and  x\<sharp>B
     9 
     9 
    10   For this we set A to the set of even atoms and B to 
    10   For this we set A to the set of even atoms and B to 
    11   the set of odd atoms. Then A \<union> B, that is the set of 
    11   the set of odd atoms. Then A \<union> B, that is the set of 
    12   all atoms, has empty support. The sets A, respectively B, 
    12   all atoms, has empty support. The sets A, respectively B, 
    13   however have the set of all atoms as their support. 
    13   however have the set of all atoms as their support. 
    14 *}
    14 \<close>
    15 
    15 
    16 atom_decl atom
    16 atom_decl atom
    17 
    17 
    18 text {* The set of even atoms. *}
    18 text \<open>The set of even atoms.\<close>
    19 abbreviation
    19 abbreviation
    20   EVEN :: "atom set"
    20   EVEN :: "atom set"
    21 where
    21 where
    22   "EVEN \<equiv> {atom n | n. \<exists>i. n=2*i}"
    22   "EVEN \<equiv> {atom n | n. \<exists>i. n=2*i}"
    23 
    23 
    24 text {* The set of odd atoms: *}
    24 text \<open>The set of odd atoms:\<close>
    25 abbreviation  
    25 abbreviation  
    26   ODD :: "atom set"
    26   ODD :: "atom set"
    27 where
    27 where
    28   "ODD \<equiv> {atom n | n. \<exists>i. n=2*i+1}"
    28   "ODD \<equiv> {atom n | n. \<exists>i. n=2*i+1}"
    29 
    29 
    30 text {* An atom is either even or odd. *}
    30 text \<open>An atom is either even or odd.\<close>
    31 lemma even_or_odd:
    31 lemma even_or_odd:
    32   fixes n :: nat
    32   fixes n :: nat
    33   shows "\<exists>i. (n = 2*i) \<or> (n=2*i+1)"
    33   shows "\<exists>i. (n = 2*i) \<or> (n=2*i+1)"
    34   by (induct n) (presburger)+
    34   by (induct n) (presburger)+
    35 
    35 
    36 text {* 
    36 text \<open>
    37   The union of even and odd atoms is the set of all atoms. 
    37   The union of even and odd atoms is the set of all atoms. 
    38   (Unfortunately I do not know a simpler proof of this fact.) *}
    38   (Unfortunately I do not know a simpler proof of this fact.)\<close>
    39 lemma EVEN_union_ODD:
    39 lemma EVEN_union_ODD:
    40   shows "EVEN \<union> ODD = UNIV"
    40   shows "EVEN \<union> ODD = UNIV"
    41   using even_or_odd
    41   using even_or_odd
    42 proof -
    42 proof -
    43   have "EVEN \<union> ODD = (\<lambda>n. atom n) ` {n. \<exists>i. n = 2*i} \<union> (\<lambda>n. atom n) ` {n. \<exists>i. n = 2*i+1}" by auto
    43   have "EVEN \<union> ODD = (\<lambda>n. atom n) ` {n. \<exists>i. n = 2*i} \<union> (\<lambda>n. atom n) ` {n. \<exists>i. n = 2*i+1}" by auto
    47   also have "\<dots> = (UNIV::atom set)" using atom.exhaust
    47   also have "\<dots> = (UNIV::atom set)" using atom.exhaust
    48     by (auto simp add: surj_def)
    48     by (auto simp add: surj_def)
    49   finally show "EVEN \<union> ODD = UNIV" by simp
    49   finally show "EVEN \<union> ODD = UNIV" by simp
    50 qed
    50 qed
    51 
    51 
    52 text {* The sets of even and odd atoms are disjunct. *}
    52 text \<open>The sets of even and odd atoms are disjunct.\<close>
    53 lemma EVEN_intersect_ODD:
    53 lemma EVEN_intersect_ODD:
    54   shows "EVEN \<inter> ODD = {}"
    54   shows "EVEN \<inter> ODD = {}"
    55   using even_or_odd
    55   using even_or_odd
    56   by (auto) (presburger)
    56   by (auto) (presburger)
    57 
    57 
    58 text {* 
    58 text \<open>
    59   The preceeding two lemmas help us to prove 
    59   The preceeding two lemmas help us to prove 
    60   the following two useful equalities: *}
    60   the following two useful equalities:\<close>
    61 
    61 
    62 lemma UNIV_subtract:
    62 lemma UNIV_subtract:
    63   shows "UNIV - EVEN = ODD"
    63   shows "UNIV - EVEN = ODD"
    64   and   "UNIV - ODD  = EVEN"
    64   and   "UNIV - ODD  = EVEN"
    65   using EVEN_union_ODD EVEN_intersect_ODD
    65   using EVEN_union_ODD EVEN_intersect_ODD
    66   by (blast)+
    66   by (blast)+
    67 
    67 
    68 text {* The sets EVEN and ODD are infinite. *}
    68 text \<open>The sets EVEN and ODD are infinite.\<close>
    69 lemma EVEN_ODD_infinite:
    69 lemma EVEN_ODD_infinite:
    70   shows "infinite EVEN"
    70   shows "infinite EVEN"
    71   and   "infinite ODD"
    71   and   "infinite ODD"
    72 unfolding infinite_iff_countable_subset
    72 unfolding infinite_iff_countable_subset
    73 proof -
    73 proof -
    78   let ?f = "\<lambda>n. atom (2*n+1)"
    78   let ?f = "\<lambda>n. atom (2*n+1)"
    79   have "inj ?f \<and> range ?f \<subseteq> ODD" by (auto simp add: inj_on_def)
    79   have "inj ?f \<and> range ?f \<subseteq> ODD" by (auto simp add: inj_on_def)
    80   then show "\<exists>f::nat\<Rightarrow>atom. inj f \<and> range f \<subseteq> ODD" by (rule_tac exI)
    80   then show "\<exists>f::nat\<Rightarrow>atom. inj f \<and> range f \<subseteq> ODD" by (rule_tac exI)
    81 qed
    81 qed
    82 
    82 
    83 text {* 
    83 text \<open>
    84   A general fact about a set S of atoms that is both infinite and 
    84   A general fact about a set S of atoms that is both infinite and 
    85   coinfinite. Then S has all atoms as its support. Steve Zdancewic 
    85   coinfinite. Then S has all atoms as its support. Steve Zdancewic 
    86   helped with proving this fact. *}
    86   helped with proving this fact.\<close>
    87 
    87 
    88 lemma supp_infinite_coinfinite:
    88 lemma supp_infinite_coinfinite:
    89   fixes S::"atom set"
    89   fixes S::"atom set"
    90   assumes asm1: "infinite S"
    90   assumes asm1: "infinite S"
    91   and     asm2: "infinite (UNIV-S)"
    91   and     asm2: "infinite (UNIV-S)"
   112     qed
   112     qed
   113   qed
   113   qed
   114   then show "(supp S) = (UNIV::atom set)" by auto
   114   then show "(supp S) = (UNIV::atom set)" by auto
   115 qed
   115 qed
   116 
   116 
   117 text {* As a corollary we get that EVEN and ODD have infinite support. *}
   117 text \<open>As a corollary we get that EVEN and ODD have infinite support.\<close>
   118 lemma EVEN_ODD_supp:
   118 lemma EVEN_ODD_supp:
   119   shows "supp EVEN = (UNIV::atom set)"
   119   shows "supp EVEN = (UNIV::atom set)"
   120   and   "supp ODD  = (UNIV::atom set)"
   120   and   "supp ODD  = (UNIV::atom set)"
   121   using supp_infinite_coinfinite UNIV_subtract EVEN_ODD_infinite
   121   using supp_infinite_coinfinite UNIV_subtract EVEN_ODD_infinite
   122   by simp_all
   122   by simp_all
   123 
   123 
   124 text {* 
   124 text \<open>
   125   The set of all atoms has empty support, since any swappings leaves 
   125   The set of all atoms has empty support, since any swappings leaves 
   126   this set unchanged. *}
   126   this set unchanged.\<close>
   127 
   127 
   128 lemma UNIV_supp:
   128 lemma UNIV_supp:
   129   shows "supp (UNIV::atom set) = ({}::atom set)"
   129   shows "supp (UNIV::atom set) = ({}::atom set)"
   130 proof -
   130 proof -
   131   have "\<forall>(x::atom) (y::atom). [(x,y)]\<bullet>UNIV = (UNIV::atom set)"
   131   have "\<forall>(x::atom) (y::atom). [(x,y)]\<bullet>UNIV = (UNIV::atom set)"
   132     by (auto simp add: perm_set_def calc_atm)
   132     by (auto simp add: perm_set_def calc_atm)
   133   then show "supp (UNIV::atom set) = ({}::atom set)" by (simp add: supp_def)
   133   then show "supp (UNIV::atom set) = ({}::atom set)" by (simp add: supp_def)
   134 qed
   134 qed
   135 
   135 
   136 text {* Putting everything together. *}
   136 text \<open>Putting everything together.\<close>
   137 theorem EVEN_ODD_freshness:
   137 theorem EVEN_ODD_freshness:
   138   fixes x::"atom"
   138   fixes x::"atom"
   139   shows "x\<sharp>(EVEN \<union> ODD)"
   139   shows "x\<sharp>(EVEN \<union> ODD)"
   140   and   "\<not>x\<sharp>EVEN"
   140   and   "\<not>x\<sharp>EVEN"
   141   and   "\<not>x\<sharp>ODD"
   141   and   "\<not>x\<sharp>ODD"
   142   by (auto simp only: fresh_def EVEN_union_ODD EVEN_ODD_supp UNIV_supp)
   142   by (auto simp only: fresh_def EVEN_union_ODD EVEN_ODD_supp UNIV_supp)
   143 
   143 
   144 text {* Moral: support is a sublte notion. *}
   144 text \<open>Moral: support is a sublte notion.\<close>
   145 
   145 
   146 end
   146 end