260 identity on all atoms, except a finite number of them; and @{text "iii)"} map |
260 identity on all atoms, except a finite number of them; and @{text "iii)"} map |
261 each atom to one of the same sort. These properties can be conveniently stated |
261 each atom to one of the same sort. These properties can be conveniently stated |
262 for a function @{text \<pi>} as follows: |
262 for a function @{text \<pi>} as follows: |
263 |
263 |
264 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
264 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
265 \begin{tabular}{@ {}r@ {\hspace{4mm}}p{10cm}} |
265 i)~~~@{term "bij \<pi>"}\hspace{5mm} |
266 i) & @{term "bij \<pi>"}\\ |
266 ii)~~~@{term "finite {a. \<pi> a \<noteq> a}"}\hspace{5mm} |
267 ii) & @{term "finite {a. \<pi> a \<noteq> a}"}\\ |
267 iii)~~~@{term "\<forall>a. sort (\<pi> a) = sort a"}\hfill\numbered{permtype} |
268 iii) & @{term "\<forall>a. sort (\<pi> a) = sort a"} |
|
269 \end{tabular}\hfill\numbered{permtype} |
|
270 \end{isabelle} |
268 \end{isabelle} |
271 |
269 |
272 \noindent |
270 \noindent |
273 Like all HOL-based theorem provers, Isabelle/HOL allows us to |
271 Like all HOL-based theorem provers, Isabelle/HOL allows us to |
274 introduce a new type @{typ perm} that includes just those functions |
272 introduce a new type @{typ perm} that includes just those functions |
337 |
335 |
338 \noindent |
336 \noindent |
339 are \emph{equal}. We do not have to use the equivalence relation shown |
337 are \emph{equal}. We do not have to use the equivalence relation shown |
340 in~\eqref{permequ} to identify them, as we would if they had been represented |
338 in~\eqref{permequ} to identify them, as we would if they had been represented |
341 as lists of pairs. Another advantage of the function representation is that |
339 as lists of pairs. Another advantage of the function representation is that |
342 they form an (additive) group provided we define |
340 they form an (additive non-commutative) group provided we define |
343 |
341 |
344 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
342 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
345 \begin{tabular}{@ {}l} |
343 \begin{tabular}{@ {}l} |
346 @{thm zero_perm_def[no_vars, THEN eq_reflection]} \hspace{4mm} |
344 @{thm zero_perm_def[no_vars, THEN eq_reflection]} \hspace{4mm} |
347 @{thm plus_perm_def[where p="\<pi>\<^isub>1" and q="\<pi>\<^isub>2", THEN eq_reflection]} \hspace{4mm} |
345 @{thm plus_perm_def[where p="\<pi>\<^isub>1" and q="\<pi>\<^isub>2", THEN eq_reflection]} \hspace{4mm} |
362 \end{tabular} |
360 \end{tabular} |
363 \end{isabelle} |
361 \end{isabelle} |
364 |
362 |
365 \noindent |
363 \noindent |
366 Again this is in contrast to the list-of-pairs representation which does not |
364 Again this is in contrast to the list-of-pairs representation which does not |
367 form a group. The technical importance of this fact is that for groups we can |
365 form a group. The technical importance of this fact is that for groups we |
368 rely on Isabelle/HOL's rich simplification infrastructure. This will come in |
366 can rely on Isabelle/HOL's rich simplification infrastructure. This will |
369 handy when we have to do calculations with permutations. |
367 come in handy when we have to do calculations with permutations. However, |
|
368 note that in this case Isabelle/HOL neglects well-entrenched mathematical |
|
369 terminology that associates with an additive group a commutative |
|
370 operation. Obviously, permutations are not commutative in general---@{text |
|
371 "p + q \<noteq> q + p"}. However, it is quite difficult to work around this |
|
372 idiosyncrasy of Isabelle/HOL, unless we develop our own algebraic hierarchy |
|
373 and infrastructure. But since the point of this paper is to implement the |
|
374 nominal theory as smoothly as possible in Isabelle/HOL, we will follow its |
|
375 characterisation of additive groups. |
370 |
376 |
371 By formalising permutations abstractly as functions, and using a single type |
377 By formalising permutations abstractly as functions, and using a single type |
372 for all atoms, we can now restate the \emph{permutation properties} from |
378 for all atoms, we can now restate the \emph{permutation properties} from |
373 \eqref{permprops} as just the two equations |
379 \eqref{permprops} as just the two equations |
374 |
380 |
384 have only a single type parameter. Consequently, these properties are |
390 have only a single type parameter. Consequently, these properties are |
385 compatible with the one-parameter restriction of Isabelle/HOL's type classes. |
391 compatible with the one-parameter restriction of Isabelle/HOL's type classes. |
386 There is no need to introduce a separate type class instantiated for each |
392 There is no need to introduce a separate type class instantiated for each |
387 sort, like in the old approach. |
393 sort, like in the old approach. |
388 |
394 |
389 We call type @{text "\<beta>"} a \emph{permutation type} if the permutation |
395 The next notion allows us to establish generic lemmas involving the |
|
396 permutation operation. |
|
397 |
|
398 \begin{definition} |
|
399 A type @{text "\<beta>"} is a \emph{permutation type} if the permutation |
390 properties in \eqref{newpermprops} are satisfied for every @{text "x"} of type |
400 properties in \eqref{newpermprops} are satisfied for every @{text "x"} of type |
391 @{text "\<beta>"}. This notion allows us to establish generic lemmas, which are |
401 @{text "\<beta>"}. |
392 applicable to any permutation type. First, it follows from the laws governing |
402 \end{definition} |
|
403 |
|
404 \noindent |
|
405 First, it follows from the laws governing |
393 groups that a permutation and its inverse cancel each other. That is, for any |
406 groups that a permutation and its inverse cancel each other. That is, for any |
394 @{text "x"} of a permutation type: |
407 @{text "x"} of a permutation type: |
395 |
408 |
396 |
409 |
397 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
410 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
487 %section { * Equivariance * } |
500 %section { * Equivariance * } |
488 % |
501 % |
489 %text { * |
502 %text { * |
490 |
503 |
491 One huge advantage of using bijective permutation functions (as opposed to |
504 One huge advantage of using bijective permutation functions (as opposed to |
492 non-bijective renaming substitutions) is the property of \emph{equivariance} |
505 non-bijective renaming substitutions employed in traditional works syntax) is |
|
506 the property of \emph{equivariance} |
493 and the fact that most HOL-functions (this includes constants) whose argument |
507 and the fact that most HOL-functions (this includes constants) whose argument |
494 and result types are permutation types satisfy this property: |
508 and result types are permutation types satisfy this property: |
495 |
509 |
496 \begin{definition}\label{equivariance} |
510 \begin{definition}\label{equivariance} |
497 A function @{text f} is \emph{equivariant} if @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}. |
511 A function @{text f} is \emph{equivariant} if @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}. |
1007 @{text "\<lambda>x\<^isub>\<alpha>. x\<^isub>\<alpha> x\<^isub>\<beta>"} |
1021 @{text "\<lambda>x\<^isub>\<alpha>. x\<^isub>\<alpha> x\<^isub>\<beta>"} |
1008 \end{tabular}\hfill\numbered{church} |
1022 \end{tabular}\hfill\numbered{church} |
1009 \end{isabelle} |
1023 \end{isabelle} |
1010 |
1024 |
1011 \noindent |
1025 \noindent |
1012 both variables and binders include typing information indicated by @{text |
1026 both variables and binders include typing information indicated by @{text \<alpha>} |
1013 \<alpha>} and @{text \<beta>}. In this setting, we treat @{text |
1027 and @{text \<beta>}. In this setting, we treat @{text "x\<^isub>\<alpha>"} and @{text |
1014 "x\<^isub>\<alpha>"} and @{text "x\<^isub>\<beta>"} as distinct variables |
1028 "x\<^isub>\<beta>"} as distinct variables (assuming @{term "\<alpha>\<noteq>\<beta>"}) so that the |
1015 (assuming @{term "\<alpha>\<noteq>\<beta>"}) so that the variable @{text |
1029 variable @{text "x\<^isub>\<alpha>"} is bound by the lambda-abstraction, but not |
1016 "x\<^isub>\<alpha>"} is bound by the lambda-abstraction, but not @{text |
1030 @{text "x\<^isub>\<beta>"}. |
1017 "x\<^isub>\<beta>"}. |
|
1018 |
1031 |
1019 To illustrate how we can deal with this phenomenon, let us represent object |
1032 To illustrate how we can deal with this phenomenon, let us represent object |
1020 types like @{text \<alpha>} and @{text \<beta>} by the datatype |
1033 types like @{text \<alpha>} and @{text \<beta>} by the datatype |
1021 |
1034 |
1022 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
1035 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
1025 \end{tabular} |
1038 \end{tabular} |
1026 \end{isabelle} |
1039 \end{isabelle} |
1027 |
1040 |
1028 \noindent |
1041 \noindent |
1029 If we attempt to encode a variable naively as a pair of a @{text name} and a @{text ty}, we have the |
1042 If we attempt to encode a variable naively as a pair of a @{text name} and a @{text ty}, we have the |
1030 problem that a swapping, say @{term "(x \<leftrightarrow> y)"}, applied to the pair |
1043 problem that a swapping, say @{term "(x \<leftrightarrow> y)"}, applied to the pair @{text "((x, \<alpha>), (x, \<beta>))"} |
1031 |
|
1032 @{text [display,indent=10] "((x, \<alpha>), (x, \<beta>))"} |
|
1033 |
|
1034 \noindent |
|
1035 will always permute \emph{both} occurrences of @{text x}, even if the types |
1044 will always permute \emph{both} occurrences of @{text x}, even if the types |
1036 @{text "\<alpha>"} and @{text "\<beta>"} are different. This is unwanted, because it will |
1045 @{text "\<alpha>"} and @{text "\<beta>"} are different. This is unwanted, because it will |
1037 eventually mean that both occurrences of @{text x} will become bound by a |
1046 eventually mean that both occurrences of @{text x} will become bound by a |
1038 corresponding binder. |
1047 corresponding binder. |
1039 |
1048 |
1139 \noindent |
1148 \noindent |
1140 As we expect, the atom @{term "Var x \<beta>"} is left unchanged by the |
1149 As we expect, the atom @{term "Var x \<beta>"} is left unchanged by the |
1141 swapping. With this we can faithfully represent bindings in languages |
1150 swapping. With this we can faithfully represent bindings in languages |
1142 involving ``Church-style'' terms and bindings as shown in \eqref{church}. We |
1151 involving ``Church-style'' terms and bindings as shown in \eqref{church}. We |
1143 expect that the creation of such atoms can be easily automated so that the |
1152 expect that the creation of such atoms can be easily automated so that the |
1144 user just needs to specify |
1153 user just needs to specify \isacommand{atom\_decl}~~@{text "var (ty)"} |
1145 |
|
1146 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
1147 \begin{tabular}{@ {}l} |
|
1148 \isacommand{atom\_decl}~~@{text "var (ty)"} |
|
1149 \end{tabular} |
|
1150 \end{isabelle} |
|
1151 |
|
1152 \noindent |
|
1153 where the argument, or arguments, are datatypes for which we can automatically |
1154 where the argument, or arguments, are datatypes for which we can automatically |
1154 define an injective function like @{text "sort_ty"} (see \eqref{sortty}). |
1155 define an injective function like @{text "sort_ty"} (see \eqref{sortty}). |
1155 Our hope is that with this approach Benzmueller and Paulson the authors of |
1156 Our hope is that with this approach Benzmueller and Paulson the authors of |
1156 \cite{PaulsonBenzmueller} can make headway with formalising their results |
1157 \cite{PaulsonBenzmueller} can make headway with formalising their results |
1157 about simple type theory. |
1158 about simple type theory. |
1193 An interesting point is that we defined the swapping operation so that a |
1194 An interesting point is that we defined the swapping operation so that a |
1194 swapping of two atoms with different sorts is \emph{not} excluded, like |
1195 swapping of two atoms with different sorts is \emph{not} excluded, like |
1195 in our older work on Nominal Isabelle, but there is no ``effect'' of such |
1196 in our older work on Nominal Isabelle, but there is no ``effect'' of such |
1196 a swapping (it is defined as the identity). This is a crucial insight |
1197 a swapping (it is defined as the identity). This is a crucial insight |
1197 in order to make the approach based on a single type of sorted atoms to work. |
1198 in order to make the approach based on a single type of sorted atoms to work. |
|
1199 But of course it is analogous to the well-known trick of defining division by |
|
1200 zero to return zero. |
1198 |
1201 |
1199 We noticed only one disadvantage of the permutations-as-functions: Over |
1202 We noticed only one disadvantage of the permutations-as-functions: Over |
1200 lists we can easily perform inductions. For permutation made up from |
1203 lists we can easily perform inductions. For permutation made up from |
1201 functions, we have to manually derive an appropriate induction principle. We |
1204 functions, we have to manually derive an appropriate induction principle. We |
1202 can establish such a principle, but we have no experience yet whether ours |
1205 can establish such a principle, but we have no real experience yet whether ours |
1203 is the most useful principle: such an induction principle was not needed in |
1206 is the most useful principle: such an induction principle was not needed in |
1204 any of the reasoning we ported from the old Nominal Isabelle. |
1207 any of the reasoning we ported from the old Nominal Isabelle, except |
|
1208 when showing that if @{term "\<forall>a \<in> supp x. a \<sharp> p"} implies @{term "p \<bullet> x = x"}. |
1205 |
1209 |
1206 Finally, our implementation of sorted atoms turned out powerful enough to |
1210 Finally, our implementation of sorted atoms turned out powerful enough to |
1207 use it for representing variables that carry additional information, for |
1211 use it for representing variables that carry on additional information, for |
1208 example typing annotations. This information is encoded into the sorts. With |
1212 example typing annotations. This information is encoded into the sorts. With |
1209 this we can represent conveniently binding in ``Church-style'' lambda-terms |
1213 this we can represent conveniently binding in ``Church-style'' lambda-terms |
1210 and HOL-based languages. We are not aware of any other approach proposed for |
1214 and HOL-based languages. While dealing with such additional information in |
1211 language formalisations that can deal conveniently with such binders. |
1215 dependent type-theories, such as LF or Coq, is straightforward, we are not |
|
1216 aware of any other approach in a non-dependent HOL-setting that can deal |
|
1217 conveniently with such binders. |
1212 |
1218 |
1213 The formalisation presented here will eventually become part of the Isabelle |
1219 The formalisation presented here will eventually become part of the Isabelle |
1214 distribution, but for the moment it can be downloaded from the |
1220 distribution, but for the moment it can be downloaded from the |
1215 Mercurial repository linked at |
1221 Mercurial repository linked at |
1216 \href{http://isabelle.in.tum.de/nominal/download} |
1222 \href{http://isabelle.in.tum.de/nominal/download} |
1217 {http://isabelle.in.tum.de/nominal/download}.\medskip |
1223 {http://isabelle.in.tum.de/nominal/download}.\smallskip |
1218 |
1224 |
1219 \noindent |
1225 \noindent |
1220 {\bf Acknowledgements:} We are very grateful to Jesper Bengtson, Stefan |
1226 {\bf Acknowledgements:} We are very grateful to Jesper Bengtson, Stefan |
1221 Berghofer and Cezary Kaliszyk for their comments on earlier versions |
1227 Berghofer and Cezary Kaliszyk for their comments on earlier versions |
1222 of this paper. We are also grateful to the anonymous referee who helped us to |
1228 of this paper. We are also grateful to the anonymous referee who helped us to |