src/HOL/Nominal/Nominal.thy
changeset 44683 daeb538c57bf
parent 44567 1fc97d6083fd
child 44689 f247fc952f31
equal deleted inserted replaced
44671:7f0b4515588a 44683:daeb538c57bf
    30 datatype ('a,'b) nprod = nPair 'a 'b
    30 datatype ('a,'b) nprod = nPair 'a 'b
    31 
    31 
    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 definition
    34 definition
    35   "perm_aux pi x \<equiv> pi\<bullet>x"
    35   "perm_aux pi x = pi\<bullet>x"
    36 
    36 
    37 (* overloaded 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)
    49   perm_noption \<equiv> "perm :: 'x prm \<Rightarrow> 'a noption \<Rightarrow> 'a noption"   (unchecked)
    49   perm_noption \<equiv> "perm :: 'x prm \<Rightarrow> 'a noption \<Rightarrow> 'a noption"   (unchecked)
    50   perm_nprod   \<equiv> "perm :: 'x prm \<Rightarrow> ('a, 'b) nprod \<Rightarrow> ('a, 'b) nprod" (unchecked)
    50   perm_nprod   \<equiv> "perm :: 'x prm \<Rightarrow> ('a, 'b) nprod \<Rightarrow> ('a, 'b) nprod" (unchecked)
    51 begin
    51 begin
    52 
    52 
    53 definition
    53 definition
    54   perm_fun_def: "perm_fun pi (f::'a\<Rightarrow>'b) \<equiv> (\<lambda>x. pi\<bullet>f((rev pi)\<bullet>x))"
    54   perm_fun_def: "perm_fun pi (f::'a\<Rightarrow>'b) = (\<lambda>x. pi\<bullet>f((rev pi)\<bullet>x))"
    55 
    55 
    56 fun
    56 primrec perm_bool :: "'x prm \<Rightarrow> bool \<Rightarrow> bool" where
    57   perm_bool :: "'x prm \<Rightarrow> bool \<Rightarrow> bool"
       
    58 where
       
    59   true_eqvt:  "perm_bool pi True  = True"
    57   true_eqvt:  "perm_bool pi True  = True"
    60 | false_eqvt: "perm_bool pi False = False"
    58 | false_eqvt: "perm_bool pi False = False"
    61 
    59 
    62 fun
    60 primrec perm_unit :: "'x prm \<Rightarrow> unit \<Rightarrow> unit"  where 
    63   perm_unit :: "'x prm \<Rightarrow> unit \<Rightarrow> unit" 
       
    64 where 
       
    65   "perm_unit pi () = ()"
    61   "perm_unit pi () = ()"
    66   
    62   
    67 fun
    63 primrec perm_prod :: "'x prm \<Rightarrow> ('a\<times>'b) \<Rightarrow> ('a\<times>'b)" where
    68   perm_prod :: "'x prm \<Rightarrow> ('a\<times>'b) \<Rightarrow> ('a\<times>'b)"
       
    69 where
       
    70   "perm_prod pi (x,y) = (pi\<bullet>x,pi\<bullet>y)"
    64   "perm_prod pi (x,y) = (pi\<bullet>x,pi\<bullet>y)"
    71 
    65 
    72 fun
    66 primrec perm_list :: "'x prm \<Rightarrow> 'a list \<Rightarrow> 'a list" where
    73   perm_list :: "'x prm \<Rightarrow> 'a list \<Rightarrow> 'a list"
       
    74 where
       
    75   nil_eqvt:  "perm_list pi []     = []"
    67   nil_eqvt:  "perm_list pi []     = []"
    76 | cons_eqvt: "perm_list pi (x#xs) = (pi\<bullet>x)#(pi\<bullet>xs)"
    68 | cons_eqvt: "perm_list pi (x#xs) = (pi\<bullet>x)#(pi\<bullet>xs)"
    77 
    69 
    78 fun
    70 primrec perm_option :: "'x prm \<Rightarrow> 'a option \<Rightarrow> 'a option" where
    79   perm_option :: "'x prm \<Rightarrow> 'a option \<Rightarrow> 'a option"
       
    80 where
       
    81   some_eqvt:  "perm_option pi (Some x) = Some (pi\<bullet>x)"
    71   some_eqvt:  "perm_option pi (Some x) = Some (pi\<bullet>x)"
    82 | none_eqvt:  "perm_option pi None     = None"
    72 | none_eqvt:  "perm_option pi None     = None"
    83 
    73 
    84 definition
    74 definition perm_char :: "'x prm \<Rightarrow> char \<Rightarrow> char" where
    85   perm_char :: "'x prm \<Rightarrow> char \<Rightarrow> char"
    75   perm_char_def: "perm_char pi c = c"
    86 where
    76 
    87   perm_char_def: "perm_char pi c \<equiv> c"
    77 definition perm_nat :: "'x prm \<Rightarrow> nat \<Rightarrow> nat" where
    88 
    78   perm_nat_def: "perm_nat pi i = i"
    89 definition
    79 
    90   perm_nat :: "'x prm \<Rightarrow> nat \<Rightarrow> nat"
    80 definition perm_int :: "'x prm \<Rightarrow> int \<Rightarrow> int" where
    91 where
    81   perm_int_def: "perm_int pi i = i"
    92   perm_nat_def: "perm_nat pi i \<equiv> i"
    82 
    93 
    83 primrec perm_noption :: "'x prm \<Rightarrow> 'a noption \<Rightarrow> 'a noption" where
    94 definition
       
    95   perm_int :: "'x prm \<Rightarrow> int \<Rightarrow> int"
       
    96 where
       
    97   perm_int_def: "perm_int pi i \<equiv> i"
       
    98 
       
    99 fun
       
   100   perm_noption :: "'x prm \<Rightarrow> 'a noption \<Rightarrow> 'a noption"
       
   101 where
       
   102   nsome_eqvt:  "perm_noption pi (nSome x) = nSome (pi\<bullet>x)"
    84   nsome_eqvt:  "perm_noption pi (nSome x) = nSome (pi\<bullet>x)"
   103 | nnone_eqvt:  "perm_noption pi nNone     = nNone"
    85 | nnone_eqvt:  "perm_noption pi nNone     = nNone"
   104 
    86 
   105 fun
    87 primrec perm_nprod :: "'x prm \<Rightarrow> ('a, 'b) nprod \<Rightarrow> ('a, 'b) nprod" where
   106   perm_nprod :: "'x prm \<Rightarrow> ('a, 'b) nprod \<Rightarrow> ('a, 'b) nprod"
       
   107 where
       
   108   "perm_nprod pi (nPair x y) = nPair (pi\<bullet>x) (pi\<bullet>y)"
    88   "perm_nprod pi (nPair x y) = nPair (pi\<bullet>x) (pi\<bullet>y)"
       
    89 
   109 end
    90 end
   110 
    91 
   111 
    92 
   112 (* permutations on booleans *)
    93 (* permutations on booleans *)
   113 lemma perm_bool:
    94 lemma perm_bool:
   186 
   167 
   187 section {* permutation equality *}
   168 section {* permutation equality *}
   188 (*==============================*)
   169 (*==============================*)
   189 
   170 
   190 definition prm_eq :: "'x prm \<Rightarrow> 'x prm \<Rightarrow> bool" (" _ \<triangleq> _ " [80,80] 80) where
   171 definition prm_eq :: "'x prm \<Rightarrow> 'x prm \<Rightarrow> bool" (" _ \<triangleq> _ " [80,80] 80) where
   191   "pi1 \<triangleq> pi2 \<equiv> \<forall>a::'x. pi1\<bullet>a = pi2\<bullet>a"
   172   "pi1 \<triangleq> pi2 \<longleftrightarrow> (\<forall>a::'x. pi1\<bullet>a = pi2\<bullet>a)"
   192 
   173 
   193 section {* Support, Freshness and Supports*}
   174 section {* Support, Freshness and Supports*}
   194 (*========================================*)
   175 (*========================================*)
   195 definition supp :: "'a \<Rightarrow> ('x set)" where  
   176 definition supp :: "'a \<Rightarrow> ('x set)" where  
   196    "supp x \<equiv> {a . (infinite {b . [(a,b)]\<bullet>x \<noteq> x})}"
   177    "supp x = {a . (infinite {b . [(a,b)]\<bullet>x \<noteq> x})}"
   197 
   178 
   198 definition fresh :: "'x \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp> _" [80,80] 80) where
   179 definition fresh :: "'x \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp> _" [80,80] 80) where
   199    "a \<sharp> x \<equiv> a \<notin> supp x"
   180    "a \<sharp> x \<longleftrightarrow> a \<notin> supp x"
   200 
   181 
   201 definition supports :: "'x set \<Rightarrow> 'a \<Rightarrow> bool" (infixl "supports" 80) where
   182 definition supports :: "'x set \<Rightarrow> 'a \<Rightarrow> bool" (infixl "supports" 80) where
   202    "S supports x \<equiv> \<forall>a b. (a\<notin>S \<and> b\<notin>S \<longrightarrow> [(a,b)]\<bullet>x=x)"
   183    "S supports x \<longleftrightarrow> (\<forall>a b. (a\<notin>S \<and> b\<notin>S \<longrightarrow> [(a,b)]\<bullet>x=x))"
   203 
   184 
   204 (* lemmas about supp *)
   185 (* lemmas about supp *)
   205 lemma supp_fresh_iff: 
   186 lemma supp_fresh_iff: 
   206   fixes x :: "'a"
   187   fixes x :: "'a"
   207   shows "(supp x) = {a::'x. \<not>a\<sharp>x}"
   188   shows "(supp x) = {a::'x. \<not>a\<sharp>x}"
  1729   have "infinite {c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}" 
  1710   have "infinite {c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}" 
  1730     by (simp add: finite_infinite[OF f3,OF at4[OF at], simplified])
  1711     by (simp add: finite_infinite[OF f3,OF at4[OF at], simplified])
  1731   hence "infinite ({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b})" 
  1712   hence "infinite ({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b})" 
  1732     by (force dest: Diff_infinite_finite)
  1713     by (force dest: Diff_infinite_finite)
  1733   hence "({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b}) \<noteq> {}"
  1714   hence "({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b}) \<noteq> {}"
  1734     by (metis Collect_def finite_set set_empty2)
  1715     by (metis finite_set set_empty2)
  1735   hence "\<exists>c. c\<in>({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b})" by (force)
  1716   hence "\<exists>c. c\<in>({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b})" by (force)
  1736   then obtain c 
  1717   then obtain c 
  1737     where eq1: "[(a,c)]\<bullet>x = x" 
  1718     where eq1: "[(a,c)]\<bullet>x = x" 
  1738       and eq2: "[(b,c)]\<bullet>x = x" 
  1719       and eq2: "[(b,c)]\<bullet>x = x" 
  1739       and ineq: "a\<noteq>c \<and> b\<noteq>c"
  1720       and ineq: "a\<noteq>c \<and> b\<noteq>c"