11 sort_of ("sort _" [1000] 100) and |
11 sort_of ("sort _" [1000] 100) and |
12 Abs_perm ("_") and |
12 Abs_perm ("_") and |
13 Rep_perm ("_") and |
13 Rep_perm ("_") and |
14 swap ("'(_ _')" [1000, 1000] 1000) and |
14 swap ("'(_ _')" [1000, 1000] 1000) and |
15 fresh ("_ # _" [51, 51] 50) and |
15 fresh ("_ # _" [51, 51] 50) and |
|
16 fresh_star ("_ #\<^sup>* _" [51, 51] 50) and |
16 Cons ("_::_" [78,77] 73) and |
17 Cons ("_::_" [78,77] 73) and |
17 supp ("supp _" [78] 73) and |
18 supp ("supp _" [78] 73) and |
18 uminus ("-_" [78] 73) and |
19 uminus ("-_" [78] 73) and |
19 atom ("|_|") and |
20 atom ("|_|") and |
20 If ("if _ then _ else _" 10) and |
21 If ("if _ then _ else _" 10) and |
46 |
47 |
47 section {* Introduction *} |
48 section {* Introduction *} |
48 |
49 |
49 text {* |
50 text {* |
50 Nominal Isabelle provides a proving infratructure for convenient reasoning |
51 Nominal Isabelle provides a proving infratructure for convenient reasoning |
51 about programming languages involving binders such as lambda abstractions or |
52 about programming language calculi involving binders such as lambda abstractions or |
52 quantifications in type schemes: |
53 quantifications in type schemes: |
53 |
54 |
54 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
55 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
55 @{text "\<lambda>x. t \<forall>{x\<^isub>1,\<dots>,x\<^isub>n}. \<tau>"} |
56 @{text "\<lambda>x. t \<forall>{x\<^isub>1,\<dots>,x\<^isub>n}. \<tau>"} |
56 \hfill\numbered{atomperm} |
57 \hfill\numbered{atomperm} |
59 \noindent |
60 \noindent |
60 At its core Nominal Isabelle is based on the nominal logic work by Pitts at |
61 At its core Nominal Isabelle is based on the nominal logic work by Pitts at |
61 al \cite{GabbayPitts02,Pitts03}. The most basic notion in this work is a |
62 al \cite{GabbayPitts02,Pitts03}. The most basic notion in this work is a |
62 sort-respecting permutation operation defined over a countably infinite |
63 sort-respecting permutation operation defined over a countably infinite |
63 collection of sorted atoms. The atoms are used for representing variable names |
64 collection of sorted atoms. The atoms are used for representing variable names |
64 that might be binding, bound or free. Multiple sorts are necessary for being able to |
65 that might be bound or free. Multiple sorts are necessary for being able to |
65 represent different kinds of variables. For example, in the language Mini-ML |
66 represent different kinds of variables. For example, in the language Mini-ML |
66 there are bound term variables in lambda abstractions and bound type variables in |
67 there are bound term variables in lambda abstractions and bound type variables in |
67 type schemes. In order to be able to separate them, each kind of variables needs to be |
68 type schemes. In order to be able to separate them, each kind of variables needs to be |
68 represented by a different sort of atoms. |
69 represented by a different sort of atoms. |
69 |
70 |
70 In our formalisation of the nominal logic work, we have to make a design decision |
71 The existing nominal logic work usually leaves implicit the sorting |
71 about how to represent sorted atoms and sort-respecting permutations. One possibility |
72 information for atoms and as far as we know leaves out a description of how |
72 is to have separate types for the different kinds of atoms, say @{text "\<alpha>\<^isub>1,\<dots>,\<alpha>\<^isub>n"}. |
73 sorts are represented. In our formalisation, we therefore have to make a |
73 With this design one can represent |
74 design decision about how to implement sorted atoms and sort-respecting |
74 permutations as lists of pairs of atoms and the operation of applying |
75 permutations. One possibility, which we described in \cite{Urban08}, is to |
75 a permutation to an object as the overloaded function |
76 have separate types for the different |
|
77 kinds of atoms, say types @{text "\<alpha>\<^isub>1,\<dots>,\<alpha>\<^isub>n"}. With this |
|
78 design one can represent permutations as lists of pairs of atoms and the |
|
79 operation of applying a permutation to an object as the function |
|
80 |
76 |
81 |
77 @{text [display,indent=10] "_ \<bullet> _ :: (\<alpha> \<times> \<alpha>) list \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
82 @{text [display,indent=10] "_ \<bullet> _ :: (\<alpha> \<times> \<alpha>) list \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
78 |
83 |
79 \noindent |
84 \noindent |
80 where @{text "\<alpha>"} stands for a type of atoms and @{text "\<beta>"} for the type |
85 where @{text "\<alpha>"} stands for a type of atoms and @{text "\<beta>"} for the type |
91 \end{tabular}\hfill\numbered{atomperm} |
96 \end{tabular}\hfill\numbered{atomperm} |
92 \end{isabelle} |
97 \end{isabelle} |
93 |
98 |
94 \noindent |
99 \noindent |
95 where we write @{text "(a b)"} for a swapping of atoms @{text "a"} and |
100 where we write @{text "(a b)"} for a swapping of atoms @{text "a"} and |
96 @{text "b"}. For atoms of different type, the permutation operation |
101 @{text "b"}. For atoms with different type than the permutation, we |
97 is defined as @{text "\<pi> \<bullet> c \<equiv> c"}. |
102 define @{text "\<pi> \<bullet> c \<equiv> c"}. |
98 |
103 |
99 With the separate atom types and the list representation of permutations it |
104 With the separate atom types and the list representation of permutations it |
100 is impossible in systems like Isabelle/HOL to state an ``ill-sorted'' |
105 is impossible in systems like Isabelle/HOL to state an ``ill-sorted'' |
101 permutation, since the type system excludes lists containing atoms of |
106 permutation, since the type system excludes lists containing atoms of |
102 different type. However, a disadvantage is that whenever we need to |
107 different type. However, a disadvantage is that whenever we need to |
106 @{text [display,indent=10] "\<forall>\<pi>\<^isub>1 \<dots> \<forall>\<pi>\<^isub>n. \<dots>"} |
111 @{text [display,indent=10] "\<forall>\<pi>\<^isub>1 \<dots> \<forall>\<pi>\<^isub>n. \<dots>"} |
107 |
112 |
108 \noindent |
113 \noindent |
109 where the @{text "\<pi>\<^isub>i"} are of type @{text "(\<alpha>\<^isub>i \<times> \<alpha>\<^isub>i) list"}. |
114 where the @{text "\<pi>\<^isub>i"} are of type @{text "(\<alpha>\<^isub>i \<times> \<alpha>\<^isub>i) list"}. |
110 The reason is that the permutation operation behaves differently for |
115 The reason is that the permutation operation behaves differently for |
111 every @{text "\<alpha>\<^isub>i"}. Similarly, the notion of support |
116 every @{text "\<alpha>\<^isub>i"} and the type system does not allow use to have a |
|
117 single quantification to stand for all permutations. Similarly, the |
|
118 notion of support |
112 |
119 |
113 @{text [display,indent=10] "supp _ :: \<beta> \<Rightarrow> \<alpha> set"} |
120 @{text [display,indent=10] "supp _ :: \<beta> \<Rightarrow> \<alpha> set"} |
114 |
121 |
115 \noindent |
122 \noindent |
116 which we will define later, cannot be |
123 which we will define later, cannot be |
125 @{text "finite ((supp x) :: \<alpha>\<^isub>1 set) , \<dots>, finite ((supp x) :: \<alpha>\<^isub>n set)"} |
132 @{text "finite ((supp x) :: \<alpha>\<^isub>1 set) , \<dots>, finite ((supp x) :: \<alpha>\<^isub>n set)"} |
126 \end{tabular}\hfill\numbered{fssequence} |
133 \end{tabular}\hfill\numbered{fssequence} |
127 \end{isabelle} |
134 \end{isabelle} |
128 |
135 |
129 \noindent |
136 \noindent |
130 Because of these disadvantages, we will use a single unified atom type to |
137 Because of these disadvantages, we will use in this paper a single unified atom type to |
131 represent atoms of different sorts. As a result, we have to deal with the |
138 represent atoms of different sorts. Consequently, we have to deal with the |
132 case that a swapping of two atoms is ill-sorted: we cannot rely anymore on |
139 case that a swapping of two atoms is ill-sorted: we cannot rely anymore on |
133 the type systems to exclude them. |
140 the type systems to exclude them. |
134 |
141 |
135 We also will not represent permutations as lists of pairs of atoms. An |
142 We also will not represent permutations as lists of pairs of atoms (as done in |
|
143 \cite{Urban08}). Although an |
136 advantage of this representation is that the basic operations on |
144 advantage of this representation is that the basic operations on |
137 permutations are already defined in Isabelle's list library: composition of |
145 permutations are already defined in Isabelle's list library: composition of |
138 two permutations (written @{text "_ @ _"}) is just list append, and |
146 two permutations (written @{text "_ @ _"}) is just list append, and |
139 inversion of a permutation (written @{text "_\<^sup>-\<^sup>1"}) is just |
147 inversion of a permutation (written @{text "_\<^sup>-\<^sup>1"}) is just |
140 list reversal. Another advantage is that there is a well-understood |
148 list reversal, and another advantage is that there is a well-understood |
141 induction principle for lists. A disadvantage, however, is that permutations |
149 induction principle for lists, a disadvantage is that permutations |
142 do not have unique representations as lists; we have to explicitly identify |
150 do not have unique representations as lists. We have to explicitly identify |
143 them according to the relation |
151 them according to the relation |
144 |
152 |
145 |
153 |
146 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
154 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
147 \begin{tabular}{@ {}l} |
155 \begin{tabular}{@ {}l} |
149 \end{tabular}\hfill\numbered{permequ} |
157 \end{tabular}\hfill\numbered{permequ} |
150 \end{isabelle} |
158 \end{isabelle} |
151 |
159 |
152 \noindent |
160 \noindent |
153 This is a problem when lifting the permutation operation to other types, for |
161 This is a problem when lifting the permutation operation to other types, for |
154 example sets, functions and so on, we need to ensure that every definition |
162 example sets, functions and so on. For this we need to ensure that every definition |
155 is well-behaved in the sense that it satisfies some |
163 is well-behaved in the sense that it satisfies some |
156 \emph{permutation properties}. In the list representation we need |
164 \emph{permutation properties}. In the list representation we need |
157 to state these properties as follows: |
165 to state these properties as follows: |
158 |
166 |
159 |
167 |
165 \end{tabular}\hfill\numbered{permprops} |
173 \end{tabular}\hfill\numbered{permprops} |
166 \end{isabelle} |
174 \end{isabelle} |
167 |
175 |
168 \noindent |
176 \noindent |
169 where the last clause explicitly states that the permutation operation has |
177 where the last clause explicitly states that the permutation operation has |
170 to produce the same result for related permutations. Moreover, permutations |
178 to produce the same result for related permutations. Moreover, |
171 as list do not satisfy the usual properties about groups. This means by |
179 ``permutations-as-lists'' do not satisfy the group properties. This means by |
172 using this representation we will not be able to reuse the extensive |
180 using this representation we will not be able to reuse the extensive |
173 reasoning infrastructure in Isabelle about groups. Therefore, we will use |
181 reasoning infrastructure in Isabelle about groups. Because of this, we will represent |
174 in this paper a unique representation for permutations by representing them |
182 in this paper permutations as functions from atoms to atoms. This representation |
175 as functions from atoms to atoms. |
183 is unique and satisfies the laws of non-commutative groups. |
176 |
184 |
177 Using a single atom type to represent atoms of different sorts and |
185 Using a single atom type to represent atoms of different sorts and |
178 representing permutations as functions are not new ideas. The main |
186 representing permutations as functions are not new ideas; see |
179 contribution of this paper is to show an example of how to make better |
187 \cite{GunterOsbornPopescu09} \footnote{function rep.} The main contribution |
180 theorem proving tools by choosing the right level of abstraction for the |
188 of this paper is to show an example of how to make better theorem proving |
181 underlying theory---our design choices take advantage of Isabelle's type |
189 tools by choosing the right level of abstraction for the underlying |
182 system, type classes and reasoning infrastructure. The novel technical |
190 theory---our design choices take advantage of Isabelle's type system, type |
183 contribution is a mechanism for dealing with ``Church-style'' lambda-terms |
191 classes and reasoning infrastructure. The novel technical contribution is a |
184 \cite{Church40} and HOL-based languages \cite{PittsHOL4} where variables and |
192 mechanism for dealing with ``Church-style'' lambda-terms \cite{Church40} and |
185 variable binding depend on type annotations. |
193 HOL-based languages \cite{PittsHOL4} where variables and variable binding |
186 |
194 depend on type annotations. |
187 The paper is organised as follows |
195 |
|
196 The paper is organised as follows\ldots |
188 *} |
197 *} |
189 |
198 |
190 section {* Sorted Atoms and Sort-Respecting Permutations *} |
199 section {* Sorted Atoms and Sort-Respecting Permutations *} |
191 |
200 |
192 text {* |
201 text {* |
201 |
210 |
202 text {* |
211 text {* |
203 \noindent |
212 \noindent |
204 whereby the string argument specifies the sort of the atom.\footnote{A |
213 whereby the string argument specifies the sort of the atom.\footnote{A |
205 similar design choice was made by Gunter et al \cite{GunterOsbornPopescu09} |
214 similar design choice was made by Gunter et al \cite{GunterOsbornPopescu09} |
206 for their variables.} (The use type \emph{string} is merely for |
215 for their variables.} (The use of type \emph{string} is merely for |
207 convenience; any countably infinite type would work as well.) We have an |
216 convenience; any countably infinite type would work as well.) We have an |
208 auxiliary function @{text sort} that is defined as @{thm |
217 auxiliary function @{text sort} that is defined as @{thm |
209 sort_of.simps[no_vars]}, and we clearly have for every finite set @{text X} |
218 sort_of.simps[no_vars]}, and we clearly have for every finite set @{text X} |
210 of atoms and every sort @{text s} the property: |
219 of atoms and every sort @{text s} the property: |
211 |
220 |
372 @{thm permute_minus_cancel(2)[where p="\<pi>", no_vars]} |
381 @{thm permute_minus_cancel(2)[where p="\<pi>", no_vars]} |
373 \end{tabular}\hfill\numbered{cancel} |
382 \end{tabular}\hfill\numbered{cancel} |
374 \end{isabelle} |
383 \end{isabelle} |
375 |
384 |
376 \noindent |
385 \noindent |
377 Consequently, in a permutation type the permutation operation @{text "\<pi> \<bullet> _"} is bijective, |
386 Consequently, in a permutation type the permutation operation @{text "\<pi> \<bullet> _"}~~is bijective, |
378 which in turn implies the property |
387 which in turn implies the property |
379 |
388 |
380 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
389 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
381 \begin{tabular}{@ {}l} |
390 \begin{tabular}{@ {}l} |
382 @{thm (lhs) permute_eq_iff[where p="\<pi>", no_vars]} |
391 @{thm (lhs) permute_eq_iff[where p="\<pi>", no_vars]} |
384 @{thm (rhs) permute_eq_iff[where p="\<pi>", no_vars]}. |
393 @{thm (rhs) permute_eq_iff[where p="\<pi>", no_vars]}. |
385 \end{tabular}\hfill\numbered{permuteequ} |
394 \end{tabular}\hfill\numbered{permuteequ} |
386 \end{isabelle} |
395 \end{isabelle} |
387 |
396 |
388 \noindent |
397 \noindent |
|
398 We can also show that the following property holds for any permutation type. |
|
399 |
|
400 \begin{lemma}\label{permutecompose} |
|
401 Given @{term x} is of permutation type, then |
|
402 @{text "\<pi>\<^isub>1 \<bullet> (\<pi>\<^isub>2 \<bullet> x) = (\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2) \<bullet> (\<pi>\<^isub>1 \<bullet> x)"}. |
|
403 \end{lemma} |
|
404 |
|
405 \begin{proof} The proof is as follows: |
|
406 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
407 \begin{tabular}[b]{@ {}rcl@ {\hspace{8mm}}l} |
|
408 @{text "\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2 \<bullet> x"} |
|
409 & @{text "="} & @{text "\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2 \<bullet> (-\<pi>\<^isub>1) \<bullet> \<pi>\<^isub>1 \<bullet> x"} & by \eqref{cancel}\\ |
|
410 & @{text "="} & @{text "(\<pi>\<^isub>1 + \<pi>\<^isub>2 - \<pi>\<^isub>1) \<bullet> \<pi>\<^isub>1 \<bullet> x"} & by {\rm(\ref{newpermprops}.@{text "ii"})}\\ |
|
411 & @{text "\<equiv>"} & @{text "(\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2) \<bullet> (\<pi>\<^isub>1 \<bullet> x)"}\\ |
|
412 \end{tabular}\hfill\qed |
|
413 \end{isabelle} |
|
414 \end{proof} |
|
415 |
|
416 \noindent |
389 In order to lift the permutation operation to other types, we can define for: |
417 In order to lift the permutation operation to other types, we can define for: |
390 |
418 |
391 \begin{isabelle} |
419 \begin{equation}\label{permdefs} |
392 \begin{tabular}{@ {}c@ {\hspace{-1mm}}c@ {}} |
420 \mbox{ |
393 \begin{tabular}{@ {}r@ {\hspace{2mm}}l@ {}} |
421 \begin{tabular}{@ {}ll@ {\hspace{2mm}}l@ {}} |
394 atoms: & @{thm permute_atom_def[where p="\<pi>",no_vars, THEN eq_reflection]}\\ |
422 1) & atoms: & @{thm permute_atom_def[where p="\<pi>",no_vars, THEN eq_reflection]}\\ |
395 functions: & @{text "\<pi> \<bullet> f \<equiv> \<lambda>x. \<pi> \<bullet> (f ((-\<pi>) \<bullet> x))"}\\ |
423 2) & functions: & @{text "\<pi> \<bullet> f \<equiv> \<lambda>x. \<pi> \<bullet> (f ((-\<pi>) \<bullet> x))"}\\ |
396 permutations: & @{thm permute_perm_def[where p="\<pi>" and q="\<pi>'", THEN eq_reflection]}\\ |
424 3) & permutations: & @{thm permute_perm_def[where p="\<pi>" and q="\<pi>'", THEN eq_reflection]}\\ |
397 sets: & @{thm permute_set_eq[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
425 4) & sets: & @{thm permute_set_eq[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
398 booleans: & @{thm permute_bool_def[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
426 5) & booleans: & @{thm permute_bool_def[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
399 \end{tabular} & |
427 6) & lists: & @{thm permute_list.simps(1)[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
400 \begin{tabular}{@ {}r@ {\hspace{2mm}}l@ {}} |
428 & & @{thm permute_list.simps(2)[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
401 lists: & @{thm permute_list.simps(1)[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
429 7) & products: & @{thm permute_prod.simps[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
402 & @{thm permute_list.simps(2)[where p="\<pi>", no_vars, THEN eq_reflection]}\\[2mm] |
430 8) & nats: & @{thm permute_nat_def[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
403 products: & @{thm permute_prod.simps[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
431 \end{tabular}} |
404 nats: & @{thm permute_nat_def[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
432 \end{equation} |
405 \end{tabular} |
|
406 \end{tabular} |
|
407 \end{isabelle} |
|
408 |
433 |
409 \noindent |
434 \noindent |
410 and then establish: |
435 and then establish: |
411 |
436 |
412 \begin{theorem} |
437 \begin{theorem} |
428 & @{text "="} & @{text "(\<pi>\<^isub>1 + \<pi>\<^isub>2) + \<pi>' - \<pi>\<^isub>2 - \<pi>\<^isub>1"}\\ |
453 & @{text "="} & @{text "(\<pi>\<^isub>1 + \<pi>\<^isub>2) + \<pi>' - \<pi>\<^isub>2 - \<pi>\<^isub>1"}\\ |
429 & @{text "="} & @{text "\<pi>\<^isub>1 + (\<pi>\<^isub>2 + \<pi>' - \<pi>\<^isub>2) - \<pi>\<^isub>1"} @{text "\<equiv>"} @{text "\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2 \<bullet> \<pi>'"} |
454 & @{text "="} & @{text "\<pi>\<^isub>1 + (\<pi>\<^isub>2 + \<pi>' - \<pi>\<^isub>2) - \<pi>\<^isub>1"} @{text "\<equiv>"} @{text "\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2 \<bullet> \<pi>'"} |
430 \end{tabular}\hfill\qed |
455 \end{tabular}\hfill\qed |
431 \end{isabelle} |
456 \end{isabelle} |
432 \end{proof} |
457 \end{proof} |
433 |
|
434 \noindent |
|
435 The main point is that the above reasoning blends smoothly with the reasoning |
|
436 infrastructure of Isabelle/HOL; no custom ML-code is necessary and a single |
|
437 type class suffices. We can also show once and for all that the following |
|
438 property---which caused so many headaches in our earlier setup---holds for any |
|
439 permutation type. |
|
440 |
|
441 \begin{lemma}\label{permutecompose} |
|
442 Given @{term x} is of permutation type, then |
|
443 @{text "\<pi>\<^isub>1 \<bullet> (\<pi>\<^isub>2 \<bullet> x) = (\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2) \<bullet> (\<pi>\<^isub>1 \<bullet> x)"}. |
|
444 \end{lemma} |
|
445 |
|
446 \begin{proof} The proof is as follows: |
|
447 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
448 \begin{tabular}[b]{@ {}rcl@ {\hspace{8mm}}l} |
|
449 @{text "\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2 \<bullet> x"} |
|
450 & @{text "="} & @{text "\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2 \<bullet> (-\<pi>\<^isub>1) \<bullet> \<pi>\<^isub>1 \<bullet> x"} & by \eqref{cancel}\\ |
|
451 & @{text "="} & @{text "(\<pi>\<^isub>1 + \<pi>\<^isub>2 - \<pi>\<^isub>1) \<bullet> \<pi>\<^isub>1 \<bullet> x"} & by {\rm(\ref{newpermprops}.@{text "ii"})}\\ |
|
452 & @{text "\<equiv>"} & @{text "(\<pi>\<^isub>1 \<bullet> \<pi>\<^isub>2) \<bullet> (\<pi>\<^isub>1 \<bullet> x)"}\\ |
|
453 \end{tabular}\hfill\qed |
|
454 \end{isabelle} |
|
455 \end{proof} |
|
456 |
|
457 *} |
458 *} |
458 |
459 |
459 section {* Equivariance *} |
460 section {* Equivariance *} |
460 |
461 |
461 text {* |
462 text {* |
462 |
463 An important notion in the nominal logic work is \emph{equivariance}. |
463 An \emph{equivariant} function or predicate is one that is invariant under |
464 An equivariant function or predicate is one that is invariant under |
464 the swapping of atoms. Having a notion of equivariance with nice logical |
465 the swapping of atoms. This notion can be defined |
465 properties is a major advantage of bijective permutations over traditional |
466 uniformly as follows: |
466 renaming substitutions \cite[\S2]{Pitts03}. Equivariance can be defined |
|
467 uniformly for all permutation types, and it is satisfied by most HOL |
|
468 functions and constants. |
|
469 |
467 |
470 |
468 |
471 \begin{definition}\label{equivariance} |
469 \begin{definition}\label{equivariance} |
472 A function @{text f} is \emph{equivariant} if @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}. |
470 A function @{text f} is \emph{equivariant} if @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}. |
473 \end{definition} |
471 \end{definition} |
499 which follows again directly |
497 which follows again directly |
500 from the definition of the permutation operation for functions and the cancellation |
498 from the definition of the permutation operation for functions and the cancellation |
501 property. Similarly for functions with more than one argument. |
499 property. Similarly for functions with more than one argument. |
502 |
500 |
503 Both formulations of equivariance have their advantages and disadvantages: |
501 Both formulations of equivariance have their advantages and disadvantages: |
504 \eqref{altequivariance} is often easier to establish. For example we |
502 the definition, \eqref{permutefunapp} and (\ref{permdefs}.2) lead to a simple |
505 can easily show that equality is equivariant |
503 rewrite system that pushes permutations inside a term until they reach |
|
504 either function constants or variables. The permutations in front of |
|
505 equivariant functions disappear. Such a rewrite system is often very helpful |
|
506 in determining whether @{text "p \<bullet> t = t"} holds for a compound term @{text t}. In contrast |
|
507 \eqref{altequivariance} is usually easier to establish, since statements are |
|
508 commonly given in a form where functions are fully applied. For example we can |
|
509 easily show that equality is equivariant |
506 |
510 |
507 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
511 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
508 \begin{tabular}{@ {}l} |
512 \begin{tabular}{@ {}l} |
509 @{thm eq_eqvt[where p="\<pi>", no_vars]} |
513 @{thm eq_eqvt[where p="\<pi>", no_vars]} |
510 \end{tabular} |
514 \end{tabular} |
547 need to explicitly restrict @{text a} and @{text b} to have the same sort.) |
549 need to explicitly restrict @{text a} and @{text b} to have the same sort.) |
548 There is also the derived notion for when an atom @{text a} is \emph{fresh} |
550 There is also the derived notion for when an atom @{text a} is \emph{fresh} |
549 for an @{text x}, defined as |
551 for an @{text x}, defined as |
550 |
552 |
551 @{thm [display,indent=10] fresh_def[no_vars]} |
553 @{thm [display,indent=10] fresh_def[no_vars]} |
|
554 |
|
555 \noindent |
|
556 We also use the notation @{thm (lhs) fresh_star_def[no_vars]} for sets ot atoms |
|
557 defined as follows |
|
558 |
|
559 @{thm [display,indent=10] fresh_star_def[no_vars]} |
552 |
560 |
553 \noindent |
561 \noindent |
554 A striking consequence of these definitions is that we can prove |
562 A striking consequence of these definitions is that we can prove |
555 without knowing anything about the structure of @{term x} that |
563 without knowing anything about the structure of @{term x} that |
556 swapping two fresh atoms, say @{text a} and @{text b}, leave |
564 swapping two fresh atoms, say @{text a} and @{text b}, leave |
636 While the abstract properties of support and freshness, particularly |
644 While the abstract properties of support and freshness, particularly |
637 Theorem~\ref{swapfreshfresh}, are useful for developing Nominal Isabelle, |
645 Theorem~\ref{swapfreshfresh}, are useful for developing Nominal Isabelle, |
638 one often has to calculate the support of some concrete object. This is |
646 one often has to calculate the support of some concrete object. This is |
639 straightforward for example for booleans, nats, products and lists: |
647 straightforward for example for booleans, nats, products and lists: |
640 |
648 |
641 \begin{center} |
649 \begin{equation} |
642 \begin{tabular}{@ {}c@ {\hspace{2mm}}c@ {}} |
650 \mbox{ |
643 \begin{tabular}{@ {}r@ {\hspace{2mm}}l} |
651 \begin{tabular}{@ {}r@ {\hspace{2mm}}l} |
644 @{text "booleans"}: & @{term "supp b = {}"}\\ |
652 @{text "booleans"}: & @{term "supp b = {}"}\\ |
645 @{text "nats"}: & @{term "supp n = {}"}\\ |
653 @{text "nats"}: & @{term "supp n = {}"}\\ |
646 @{text "products"}: & @{thm supp_Pair[no_vars]}\\ |
654 @{text "products"}: & @{thm supp_Pair[no_vars]}\\ |
647 \end{tabular} & |
|
648 \begin{tabular}{r@ {\hspace{2mm}}l@ {}} |
|
649 @{text "lists:"} & @{thm supp_Nil[no_vars]}\\ |
655 @{text "lists:"} & @{thm supp_Nil[no_vars]}\\ |
650 & @{thm supp_Cons[no_vars]}\\ |
656 & @{thm supp_Cons[no_vars]}\\ |
651 \end{tabular} |
657 \end{tabular}} |
652 \end{tabular} |
658 \end{equation} |
653 \end{center} |
659 |
654 |
660 \noindent |
655 \noindent |
661 But establishing the support of atoms and permutations is a bit |
656 But establishing the support of atoms and permutations in our setup here is a bit |
|
657 trickier. To do so we will use the following notion about a \emph{supporting set}. |
662 trickier. To do so we will use the following notion about a \emph{supporting set}. |
658 |
663 |
659 \begin{definition} |
664 \begin{definition} |
660 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
665 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
661 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
666 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
771 |
776 |
772 The main point about support is that whenever an object @{text x} has finite |
777 The main point about support is that whenever an object @{text x} has finite |
773 support, then Proposition~\ref{choosefresh} allows us to choose for @{text x} a |
778 support, then Proposition~\ref{choosefresh} allows us to choose for @{text x} a |
774 fresh atom with arbitrary sort. This is an important operation in Nominal |
779 fresh atom with arbitrary sort. This is an important operation in Nominal |
775 Isabelle in situations where, for example, a bound variable needs to be |
780 Isabelle in situations where, for example, a bound variable needs to be |
776 renamed. To allow such a choice, we only have to assume \emph{one} premise |
781 renamed. To allow such a choice, we only have to assume that |
777 of the form @{text "finite (supp x)"} |
782 @{text "finite (supp x)"} holds. For more convenience we |
778 for each @{text x}. Compare that with the sequence of premises in our earlier |
|
779 version of Nominal Isabelle (see~\eqref{fssequence}). For more convenience we |
|
780 can define a type class for types where every element has finite support, and |
783 can define a type class for types where every element has finite support, and |
781 prove that the types @{term "atom"}, @{term "perm"}, lists, products and |
784 prove that the types @{term "atom"}, @{term "perm"}, lists, products and |
782 booleans are instances of this type class. Then \emph{no} premise is needed, |
785 booleans are instances of this type class. |
783 as the type system of Isabelle/HOL can figure out automatically when an object |
786 |
784 is finitely supported. |
787 Unfortunately, this does not work for sets or Isabelle/HOL's function |
785 |
788 type.\footnote{Isabelle/HOL takes the type @{text "\<alpha> set"} as an abbreviation |
786 Unfortunately, this does not work for sets or Isabelle/HOL's function type. |
789 of @{text "\<alpha> \<Rightarrow> bool"}.} There are functions and sets definable in |
787 There are functions and sets definable in Isabelle/HOL for which the finite |
790 Isabelle/HOL for which the finite support property does not hold. A simple |
788 support property does not hold. A simple example of a function with |
791 example of a function with infinite support is the function that returns the |
789 infinite support is the function that returns the natural number of an atom |
792 natural number of an atom |
790 |
793 |
791 @{text [display, indent=10] "nat_of (Atom s i) \<equiv> i"} |
794 @{text [display, indent=10] "nat_of (Atom s i) \<equiv> i"} |
792 |
795 |
793 \noindent |
796 \noindent |
794 This function's support is the set of \emph{all} atoms. To establish this we show @{term "\<not> a \<sharp> nat_of"}. |
797 This function's support is the set of \emph{all} atoms. To establish this we show @{term "\<not> a \<sharp> nat_of"}. |
795 This is equivalent to assuming the set @{term "{b. (a \<rightleftharpoons> b) \<bullet> nat_of \<noteq> nat_of}"} is finite |
798 This is equivalent to assuming the set @{term "{b. (a \<rightleftharpoons> b) \<bullet> nat_of \<noteq> nat_of}"} is finite |
805 & @{text "="} & @{term "((a \<rightleftharpoons> c) \<bullet> nat_of) ((a \<rightleftharpoons> c) \<bullet> a)"} & by \eqref{permutefunapp}\\ |
808 & @{text "="} & @{term "((a \<rightleftharpoons> c) \<bullet> nat_of) ((a \<rightleftharpoons> c) \<bullet> a)"} & by \eqref{permutefunapp}\\ |
806 & @{text "="} & @{term "nat_of c"} & by assumptions on @{text c}\\ |
809 & @{text "="} & @{term "nat_of c"} & by assumptions on @{text c}\\ |
807 \end{tabular} |
810 \end{tabular} |
808 \end{isabelle} |
811 \end{isabelle} |
809 |
812 |
810 |
|
811 \noindent |
813 \noindent |
812 But this means we have that @{term "nat_of a = nat_of c"} and @{term "sort_of a = sort_of c"}. |
814 But this means we have that @{term "nat_of a = nat_of c"} and @{term "sort_of a = sort_of c"}. |
813 This implies that atoms @{term a} and @{term c} must be equal, which clashes with our |
815 This implies that atoms @{term a} and @{term c} must be equal, which clashes with our |
814 assumption @{term "c \<noteq> a"} about how we chose @{text c}. |
816 assumption @{term "c \<noteq> a"} about how we chose @{text c}. |
815 Cheney \cite{Cheney06} gives similar examples for constructions that have infinite support. |
817 Cheney \cite{Cheney06} gives similar examples for constructions that have infinite support. |
816 *} |
818 *} |
817 |
819 |
818 section {* Support of Finite Sets *} |
820 section {* Support of Finite Sets *} |
819 |
821 |
820 text {* |
822 text {* |
821 Sets is one instance of a type that is not generally finitely supported. |
823 As shown above, sets is one instance of a type that is not generally finitely supported. |
822 However, it can be easily derived that finite sets of atoms are finitely |
824 However, we can easily show that finite sets of atoms are finitely |
823 supported, because their support can be characterised as: |
825 supported, because their support can be characterised as: |
824 |
826 |
825 \begin{lemma}\label{finatomsets} |
827 \begin{lemma}\label{finatomsets} |
826 If @{text S} is a finite set of atoms, then @{thm (concl) supp_finite_atom_set[no_vars]}. |
828 If @{text S} is a finite set of atoms, then @{thm (concl) supp_finite_atom_set[no_vars]}. |
827 \end{lemma} |
829 \end{lemma} |
828 |
830 |
829 \begin{proof} |
831 \begin{proof} |
830 finite-supp-unique |
832 finite-supp-unique |
831 \end{proof} |
833 \end{proof} |
832 |
834 |
833 More difficult is it to establish that finite sets of finitely |
835 \noindent |
|
836 More difficult, however, is it to establish that finite sets of finitely |
834 supported objects are finitely supported. |
837 supported objects are finitely supported. |
835 *} |
838 *} |
836 |
839 |
837 |
840 |
838 section {* Induction Principles *} |
841 section {* Induction Principles *} |
842 representation for permutations (for example @{term "(a \<rightleftharpoons> b)"} and |
845 representation for permutations (for example @{term "(a \<rightleftharpoons> b)"} and |
843 @{term "(b \<rightleftharpoons> a)"} are equal permutations), this representation has |
846 @{term "(b \<rightleftharpoons> a)"} are equal permutations), this representation has |
844 one draw back: it does not come readily with an induction principle. |
847 one draw back: it does not come readily with an induction principle. |
845 Such an induction principle is handy for deriving properties like |
848 Such an induction principle is handy for deriving properties like |
846 |
849 |
847 @{thm [display, indent=10] supp_perm_eq} |
850 @{thm [display, indent=10] supp_perm_eq[no_vars]} |
848 |
851 |
849 \noindent |
852 \noindent |
850 However, it is not too difficult to derive an induction principle, |
853 However, it is not too difficult to derive an induction principle, |
851 given the fact that we allow only permutations with a finite domain. |
854 given the fact that we allow only permutations with a finite domain. |
852 *} |
855 *} |