LMCS-Paper/Paper.thy
changeset 3162 95ff21cda33c
parent 3160 603a36f19bfe
equal deleted inserted replaced
3161:aa1ba91ed1ff 3162:95ff21cda33c
   127   \noindent
   127   \noindent
   128   Its purpose is to relate a type-scheme with a list of type-variables and a type. It is used to
   128   Its purpose is to relate a type-scheme with a list of type-variables and a type. It is used to
   129   address the following problem:
   129   address the following problem:
   130   Given a type-scheme, say @{text S}, how does one get access to the bound type-variables 
   130   Given a type-scheme, say @{text S}, how does one get access to the bound type-variables 
   131   and the type-part of @{text S}? The unbinding relation gives an answer to this problem, though 
   131   and the type-part of @{text S}? The unbinding relation gives an answer to this problem, though 
   132   in general it will only provide some list of type-variables together with a type that are  
   132   in general it will only provide \emph{a} list of type-variables together with \emph{a} type that are  
   133   ``alpha-equivalent'' to @{text S}. This is because unbinding is a relation; it cannot be a function
   133   ``alpha-equivalent'' to @{text S}. This is because unbinding is a relation; it cannot be a function
   134   for alpha-equated type-schemes. With this 
   134   for alpha-equated type-schemes. With the unbinding relation  
   135   definition in place we can formally define when a type is an instance of a type-scheme as follows:
   135   in place, we can define when a type @{text T} is an instance of a type-scheme @{text S} as follows:
   136 
   136 
   137   \[
   137   \[
   138   @{text "T \<prec> S \<equiv> \<exists>xs T' \<sigma>. S \<hookrightarrow> (xs, T') \<and> dom \<sigma> = set xs \<and> \<sigma>(T') = T"}
   138   @{text "T \<prec> S \<equiv> \<exists>xs T' \<sigma>. S \<hookrightarrow> (xs, T') \<and> dom \<sigma> = set xs \<and> \<sigma>(T') = T"}
   139   \]\smallskip
   139   \]\smallskip
   140   
   140   
   142   This means there exists a list of type-variables @{text xs} and a type @{text T'} to which
   142   This means there exists a list of type-variables @{text xs} and a type @{text T'} to which
   143   the type-scheme @{text S} unbinds, and there exists a substitution @{text "\<sigma>"} whose domain is
   143   the type-scheme @{text S} unbinds, and there exists a substitution @{text "\<sigma>"} whose domain is
   144   @{text xs} (seen as set) such that @{text "\<sigma>(T') = T"}.
   144   @{text xs} (seen as set) such that @{text "\<sigma>(T') = T"}.
   145   The problem with this definition is that we cannot follow the usual proofs 
   145   The problem with this definition is that we cannot follow the usual proofs 
   146   that are by induction on the type-part of the type-scheme (since it is under
   146   that are by induction on the type-part of the type-scheme (since it is under
   147   an existential quantifier and only an alpha-variant). The representation of 
   147   an existential quantifier and only an alpha-variant). The implementation of 
   148   type-schemes using iterations of single binders 
   148   type-schemes using iterations of single binders 
   149   prevents us from directly ``unbinding'' the bound type-variables and the type-part. 
   149   prevents us from directly ``unbinding'' the bound type-variables and the type-part. 
   150   Clearly, some more dignified approach to formalising algorithm W is desirable. 
   150   Clearly, a more dignified approach for formalising algorithm W is desirable. 
   151   The purpose of this paper is to introduce general binders, which 
   151   The purpose of this paper is to introduce general binders, which 
   152   allow us to represent type-schemes so that they can bind multiple variables at once
   152   allow us to represent type-schemes so that they can bind multiple variables at once
   153   and as a result solve this problem more straightforwardly.
   153   and as a result solve this problem more straightforwardly.
   154   The need of iterating single binders is also one reason
   154   The need of iterating single binders is also one reason
   155   why Nominal Isabelle and similar theorem provers that only provide
   155   why the existing Nominal Isabelle and similar theorem provers that only provide
   156   mechanisms for binding single variables have so far not fared very well with
   156   mechanisms for binding single variables have so far not fared very well with
   157   the more advanced tasks in the POPLmark challenge \cite{challenge05},
   157   the more advanced tasks in the POPLmark challenge \cite{challenge05},
   158   because also there one would like to bind multiple variables at once.
   158   because also there one would like to bind multiple variables at once.
   159 
   159 
   160   Binding multiple variables has interesting properties that cannot be captured
   160   Binding multiple variables has interesting properties that cannot be captured
  1288   unions of atom sets or appended atom lists (case @{text ACons'}). This
  1288   unions of atom sets or appended atom lists (case @{text ACons'}). This
  1289   restriction will simplify some automatic definitions and proofs later on.
  1289   restriction will simplify some automatic definitions and proofs later on.
  1290   
  1290   
  1291   To sum up this section, we introduced nominal datatype
  1291   To sum up this section, we introduced nominal datatype
  1292   specifications, which are like standard datatype specifications in
  1292   specifications, which are like standard datatype specifications in
  1293   Isabelle/HOL extended with specifications for binding
  1293   Isabelle/HOL but extended with binding clauses and specifications for binding
  1294   functions. Each constructor argument in our specification can also
  1294   functions. Each constructor argument in our specification can also
  1295   have an optional label. These labels are used in the binding clauses
  1295   have an optional label. These labels are used in the binding clauses
  1296   of a constructor; there can be several binding clauses for each
  1296   of a constructor; there can be several binding clauses for each
  1297   constructor, but bodies of binding clauses can only occur in a
  1297   constructor, but bodies of binding clauses can only occur in a
  1298   single one. Binding clauses come in three modes: \isacommand{binds},
  1298   single one. Binding clauses come in three modes: \isacommand{binds},
  1301   binders can occur in more than one binding clause and only have to
  1301   binders can occur in more than one binding clause and only have to
  1302   respect the binding mode (i.e.~be of the right type). Deep binders
  1302   respect the binding mode (i.e.~be of the right type). Deep binders
  1303   can also occur in more than one binding clause, unless they are
  1303   can also occur in more than one binding clause, unless they are
  1304   recursive in which case they can only occur once. Each of the deep
  1304   recursive in which case they can only occur once. Each of the deep
  1305   binders can only have a single binding function.  Binding functions
  1305   binders can only have a single binding function.  Binding functions
  1306   are defined by recursion over a nominal datatype.  They can only
  1306   are defined by recursion over a nominal datatype.  They can
  1307   return the empty set, singleton atoms and unions of sets of atoms
  1307   return the empty set, singleton atoms and unions of sets of atoms
  1308   (for binding modes \isacommand{binds (set)} and \isacommand{binds
  1308   (for binding modes \isacommand{binds (set)} and \isacommand{binds
  1309   (set+)}), and the empty list, singleton atoms and appended lists of
  1309   (set+)}), and the empty list, singleton atoms and appended lists of
  1310   atoms (for mode \isacommand{bind}). However, they can only return
  1310   atoms (for mode \isacommand{bind}). However, they can only return
  1311   atoms that are not mentioned in any binding clause.  In order to
  1311   atoms that are not mentioned in any binding clause.  
  1312   simplify our definitions of free atoms and alpha-equivalence, we
  1312 
       
  1313   In order to
       
  1314   simplify our definitions of free atoms and alpha-equivalence we define next, we
  1313   shall assume specifications of term-calculi are implicitly
  1315   shall assume specifications of term-calculi are implicitly
  1314   \emph{completed}. By this we mean that for every argument of a
  1316   \emph{completed}. By this we mean that for every argument of a
  1315   term-constructor that is \emph{not} already part of a binding clause
  1317   term-constructor that is \emph{not} already part of a binding clause
  1316   given by the user, we add implicitly a special \emph{empty} binding
  1318   given by the user, we add implicitly a special \emph{empty} binding
  1317   clause, written \isacommand{binds}~@{term
  1319   clause, written \isacommand{binds}~@{term
  1411   a raw term-constructor @{text "C"} of type @{text ty} and some associated
  1413   a raw term-constructor @{text "C"} of type @{text ty} and some associated
  1412   binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text
  1414   binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text
  1413   "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text
  1415   "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text
  1414   "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding
  1416   "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding
  1415   clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). 
  1417   clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). 
  1416   Suppose the binding clause @{text bc\<^isub>i} is of the form 
  1418   Suppose a binding clause @{text bc\<^isub>i} is of the form 
  1417   
  1419   
  1418   \[
  1420   \[
  1419   \mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}}
  1421   \mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}}
  1420   \]\smallskip
  1422   \]\smallskip
  1421   
  1423   
  1612   The alpha-equivalence relations are defined as inductive predicates
  1614   The alpha-equivalence relations are defined as inductive predicates
  1613   having a single clause for each term-constructor. Assuming a
  1615   having a single clause for each term-constructor. Assuming a
  1614   term-constructor @{text C} is of type @{text ty} and has the binding clauses
  1616   term-constructor @{text C} is of type @{text ty} and has the binding clauses
  1615   @{term "bc"}$_{1..k}$, then the alpha-equivalence clause has the form
  1617   @{term "bc"}$_{1..k}$, then the alpha-equivalence clause has the form
  1616   
  1618   
  1617   \[
  1619   \begin{equation}\label{gform}
  1618   \mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>n  \<approx>ty  C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>n"}}
  1620   \mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>n  \<approx>ty  C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>n"}}
  1619   {@{text "prems(bc\<^isub>1) \<dots> prems(bc\<^isub>k)"}}} 
  1621   {@{text "prems(bc\<^isub>1) \<dots> prems(bc\<^isub>k)"}}} 
  1620   \]\smallskip
  1622   \end{equation}\smallskip
  1621 
  1623 
  1622   \noindent
  1624   \noindent
  1623   The task below is to specify what the premises corresponding to a binding
  1625   The task below is to specify what the premises corresponding to a binding
  1624   clause are. To understand better what the general pattern is, let us first 
  1626   clause are. To understand better what the general pattern is, let us first 
  1625   treat the special instance where @{text "bc\<^isub>i"} is the empty binding clause 
  1627   treat the special instance where @{text "bc\<^isub>i"} is the empty binding clause 
  1632   \noindent
  1634   \noindent
  1633   In this binding clause no atom is bound and we only have to `alpha-relate'
  1635   In this binding clause no atom is bound and we only have to `alpha-relate'
  1634   the bodies. For this we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>,
  1636   the bodies. For this we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>,
  1635   d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"}
  1637   d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"}
  1636   whereby the labels @{text "d"}$_{1..q}$ refer to some of the arguments @{text
  1638   whereby the labels @{text "d"}$_{1..q}$ refer to some of the arguments @{text
  1637   "z"}$_{1..n}$ and respectively @{text "d\<PRIME>"}$_{1..q}$ to some of @{text
  1639   "z"}$_{1..n}$ and respectively @{text "d\<PRIME>"}$_{1..q}$ to some of the @{text
  1638   "z\<PRIME>"}$_{1..n}$ of the term-constructor. In order to relate two such
  1640   "z\<PRIME>"}$_{1..n}$ in \eqref{gform}. In order to relate two such
  1639   tuples we define the compound alpha-equivalence relation @{text "R"} as
  1641   tuples we define the compound alpha-equivalence relation @{text "R"} as
  1640   follows
  1642   follows
  1641 
  1643 
  1642   \begin{equation}\label{rempty}
  1644   \begin{equation}\label{rempty}
  1643   \mbox{@{text "R \<equiv> (R\<^isub>1,\<dots>, R\<^isub>q)"}}
  1645   \mbox{@{text "R \<equiv> (R\<^isub>1,\<dots>, R\<^isub>q)"}}
  1646   \noindent
  1648   \noindent
  1647   with @{text "R\<^isub>i"} being @{text "\<approx>ty\<^isub>i"} if the corresponding
  1649   with @{text "R\<^isub>i"} being @{text "\<approx>ty\<^isub>i"} if the corresponding
  1648   labels @{text "d\<^isub>i"} and @{text "d\<PRIME>\<^isub>i"} refer to a
  1650   labels @{text "d\<^isub>i"} and @{text "d\<PRIME>\<^isub>i"} refer to a
  1649   recursive argument of @{text C} and have type @{text "ty\<^isub>i"}; otherwise
  1651   recursive argument of @{text C} and have type @{text "ty\<^isub>i"}; otherwise
  1650   we take @{text "R\<^isub>i"} to be the equality @{text "="}. Again the
  1652   we take @{text "R\<^isub>i"} to be the equality @{text "="}. Again the
  1651   latter is because @{text "ty\<^isub>i"} is not part of the specified types
  1653   latter is because @{text "ty\<^isub>i"} is then not part of the specified types
  1652   and alpha-equivalence of any previously defined type is supposed to coincide
  1654   and alpha-equivalence of any previously defined type is supposed to coincide
  1653   with equality.  This lets us now define the premise for an empty binding
  1655   with equality.  This lets us now define the premise for an empty binding
  1654   clause succinctly as @{text "prems(bc\<^isub>i) \<equiv> D R D'"}, which can be
  1656   clause succinctly as @{text "prems(bc\<^isub>i) \<equiv> D R D'"}, which can be
  1655   unfolded to the series of premises
  1657   unfolded to the series of premises
  1656   
  1658   
  1982   We can also add to our infrastructure cases lemmas and a (mutual)
  1984   We can also add to our infrastructure cases lemmas and a (mutual)
  1983   induction principle for the types @{text "ty\<AL>"}$_{1..n}$. The cases
  1985   induction principle for the types @{text "ty\<AL>"}$_{1..n}$. The cases
  1984   lemmas allow the user to deduce a property @{text "P"} by exhaustively
  1986   lemmas allow the user to deduce a property @{text "P"} by exhaustively
  1985   analysing how an element of a type, say @{text "ty\<AL>"}$_i$, can be
  1987   analysing how an element of a type, say @{text "ty\<AL>"}$_i$, can be
  1986   constructed (that means one case for each of the term-constructors in @{text
  1988   constructed (that means one case for each of the term-constructors in @{text
  1987   "ty\<AL>"}$_i\,$). The lifted cases lemma for the type @{text
  1989   "ty\<AL>"}$_i\,$). The lifted cases lemma for a type @{text
  1988   "ty\<AL>"}$_i\,$ looks as follows
  1990   "ty\<AL>"}$_i\,$ looks as follows
  1989 
  1991 
  1990   \begin{equation}\label{cases}
  1992   \begin{equation}\label{cases}
  1991   \infer{P}
  1993   \infer{P}
  1992   {\begin{array}{l}
  1994   {\begin{array}{l}
  2229   line). In order to see how an instantiation for @{text "c"} in the
  2231   line). In order to see how an instantiation for @{text "c"} in the
  2230   conclusion `controls' the premises, one has to take into account that
  2232   conclusion `controls' the premises, one has to take into account that
  2231   Isabelle/HOL is a typed logic. That means if @{text "c"} is instantiated
  2233   Isabelle/HOL is a typed logic. That means if @{text "c"} is instantiated
  2232   with, for example, a pair, then this type-constraint will be propagated to
  2234   with, for example, a pair, then this type-constraint will be propagated to
  2233   the premises. The main point is that if @{text "c"} is instantiated
  2235   the premises. The main point is that if @{text "c"} is instantiated
  2234   appropriately, then the user can mimic the usual `pencil-and-paper'
  2236   appropriately, then the user can mimic the usual convenient `pencil-and-paper'
  2235   reasoning employing the variable convention about bound and free variables
  2237   reasoning employing the variable convention about bound and free variables
  2236   being distinct \cite{Urban08}.
  2238   being distinct \cite{Urban08}.
  2237 
  2239 
  2238   In what follows we will show that the weak induction principle in
  2240   In what follows we will show that the weak induction principle in
  2239   \eqref{inductex} implies the strong one \eqref{stronginduct}. This fact was established for
  2241   \eqref{inductex} implies the strong one \eqref{stronginduct}. This fact was established for
  2451 
  2453 
  2452   \noindent
  2454   \noindent
  2453   holds. This allows us to use the implication from the strong cases
  2455   holds. This allows us to use the implication from the strong cases
  2454   lemma, and we are done.
  2456   lemma, and we are done.
  2455 
  2457 
  2456   Consequently,  we can discharge all proof-obligations about having covered all
  2458   Consequently,  we can discharge all proof-obligations about having `covered all
  2457   cases. This completes the proof establishing that the weak induction principles imply 
  2459   cases'. This completes the proof establishing that the weak induction principles imply 
  2458   the strong induction principles. These strong induction principles have already proved 
  2460   the strong induction principles. These strong induction principles have already proved 
  2459   being very useful in practice, particularly for proving properties about 
  2461   being very useful in practice, particularly for proving properties about 
  2460   capture-avoiding substitution \cite{Urban08}. 
  2462   capture-avoiding substitution \cite{Urban08}. 
  2461 *}
  2463 *}
  2462 
  2464 
  2505   performed in older
  2507   performed in older
  2506   versions of Nominal Isabelle (one about Psi-calculi and one about algorithm W 
  2508   versions of Nominal Isabelle (one about Psi-calculi and one about algorithm W 
  2507   \cite{BengtsonParow09,UrbanNipkow09}).  Both
  2509   \cite{BengtsonParow09,UrbanNipkow09}).  Both
  2508   use the approach based on iterated single binders. Our experience with
  2510   use the approach based on iterated single binders. Our experience with
  2509   the latter formalisation has been disappointing. The major pain arose from
  2511   the latter formalisation has been disappointing. The major pain arose from
  2510   the need to `unbind' variables. This can be done in one step with our
  2512   the need to `unbind' bound variables and the resulting formal reasoning turned out to
  2511   general binders described in this paper, but needs a cumbersome
  2513   be rather unpleasant. In contrast, the unbinding can be 
  2512   iteration with single binders. The resulting formal reasoning turned out to
  2514   done in one step with our
  2513   be rather unpleasant. 
  2515   general binders described in this paper.
  2514  
  2516 
  2515   The most closely related work to the one presented here is the Ott-tool by
  2517   The most closely related work to the one presented here is the Ott-tool by
  2516   Sewell et al \cite{ott-jfp} and the C$\alpha$ml language by Pottier
  2518   Sewell et al \cite{ott-jfp} and the C$\alpha$ml language by Pottier
  2517   \cite{Pottier06}. Ott is a nifty front-end for creating \LaTeX{} documents
  2519   \cite{Pottier06}. Ott is a nifty front-end for creating \LaTeX{} documents
  2518   from specifications of term-calculi involving general binders. For a subset
  2520   from specifications of term-calculi involving general binders. For a subset
  2519   of the specifications Ott can also generate theorem prover code using a `raw'
  2521   of the specifications Ott can also generate theorem prover code using a `raw'
  2523   specified in Ott.  This definition is rather different from ours, not using
  2525   specified in Ott.  This definition is rather different from ours, not using
  2524   any nominal techniques.  To our knowledge there is no concrete mathematical
  2526   any nominal techniques.  To our knowledge there is no concrete mathematical
  2525   result concerning this notion of alpha-equivalence and free variables. We
  2527   result concerning this notion of alpha-equivalence and free variables. We
  2526   have proved that our definitions lead to alpha-equated terms, whose support
  2528   have proved that our definitions lead to alpha-equated terms, whose support
  2527   is as expected (that means bound atoms are removed from the support). We
  2529   is as expected (that means bound atoms are removed from the support). We
  2528   also showed that our specifications lift from `raw' types to types of
  2530   also showed that our specifications lift from `raw' terms to 
  2529   alpha-equivalence classes. For this we have established (automatically) that every
  2531   alpha-equivalence classes. For this we have established (automatically) that every
  2530   term-constructor and function defined for `raw' types 
  2532   term-constructor and function defined for `raw' terms 
  2531   is respectful w.r.t.~alpha-equivalence.
  2533   is respectful w.r.t.~alpha-equivalence.
  2532 
  2534 
  2533   Although we were heavily inspired by the syntax of Ott, its definition of
  2535   Although we were heavily inspired by the syntax of Ott, its definition of
  2534   alpha-equi\-valence is unsuitable for our extension of Nominal
  2536   alpha-equi\-valence is unsuitable for our extension of Nominal
  2535   Isabelle. First, it is far too complicated to be a basis for automated
  2537   Isabelle. First, it is far too complicated to be a basis for automated
  2580   @{text "Foo\<^isub>2 {a, b} (a, b) (b, a)"}\\
  2582   @{text "Foo\<^isub>2 {a, b} (a, b) (b, a)"}\\
  2581   \end{tabular}}
  2583   \end{tabular}}
  2582   \]\smallskip
  2584   \]\smallskip
  2583   
  2585   
  2584   \noindent
  2586   \noindent
  2585   and therefore need the extra generality to be able to distinguish between
  2587   and therefore need the extra generality to be able to distinguish
  2586   both specifications.  Because of how we set up our definitions, we also had
  2588   between both specifications.  Because of how we set up our
  2587   to impose some restrictions (like a single binding function for a deep
  2589   definitions, we also had to impose some restrictions (like a single
  2588   binder) that are not present in Ott. Our expectation is that we can still
  2590   binding function for a deep binder) that are not present in Ott. Our
  2589   cover many interesting term-calculi from programming language research, for
  2591   expectation is that we can still cover many interesting term-calculi
  2590   example the Core-Haskell language from the Introduction. With the work
  2592   from programming language research, for example the Core-Haskell
  2591   presented in this paper we can define it formally as shown in 
  2593   language from the Introduction. With the work presented in this
  2592   Figure~\ref{nominalcorehas} and then Nominal Isabelle derives automatically
  2594   paper we can define it formally as shown in
  2593   a corresponding reasoning infrastructure. However we have found out that 
  2595   Figure~\ref{nominalcorehas} and then Nominal Isabelle derives
  2594   telescopes seem to not easily representable in our framework. The reason is that
  2596   automatically a corresponding reasoning infrastructure. However we
  2595   we need to be able to lift our @{text bn}-function to alpha-equated lambda-terms.
  2597   have found out that telescopes seem to not easily be representable
  2596   This requires restrictions, which class with the `global' scope of binders in
  2598   in our framework.  The reason is that we need to be able to lift our
  2597   telescopes. They can
  2599   @{text bn}-functions to alpha-equated lambda-terms and therefore
  2598   be represented in the framework described in \cite{WeirichYorgeySheard11} using an extension of
  2600   need to restrict what these @{text bn}-functions can return.
  2599   the usual locally-nameless representation. 
  2601   Telescopes can be represented in the framework described in
       
  2602   \cite{WeirichYorgeySheard11} using an extension of the usual
       
  2603   locally-nameless representation. 
  2600 
  2604 
  2601   \begin{figure}[p]
  2605   \begin{figure}[p]
  2602   \begin{boxedminipage}{\linewidth}
  2606   \begin{boxedminipage}{\linewidth}
  2603   \small
  2607   \small
  2604   \begin{tabular}{l}
  2608   \begin{tabular}{l}
  2629   \isacommand{and}~@{text "pat ="}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
  2633   \isacommand{and}~@{text "pat ="}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
  2630   \isacommand{and}~@{text "vt_lst ="}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
  2634   \isacommand{and}~@{text "vt_lst ="}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
  2631   \isacommand{and}~@{text "tvtk_lst ="}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\
  2635   \isacommand{and}~@{text "tvtk_lst ="}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\
  2632   \isacommand{and}~@{text "tvck_lst ="}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\
  2636   \isacommand{and}~@{text "tvck_lst ="}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\
  2633   \isacommand{binder}\\
  2637   \isacommand{binder}\\
  2634   @{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}\\
  2638   \;@{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}\\
  2635   @{text "bv\<^isub>1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\
  2639   \;@{text "bv\<^isub>1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\
  2636   @{text "bv\<^isub>2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}\\
  2640   \;@{text "bv\<^isub>2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}\\
  2637   @{text "bv\<^isub>3 :: tvck_lst \<Rightarrow> atom list"}\\
  2641   \;@{text "bv\<^isub>3 :: tvck_lst \<Rightarrow> atom list"}\\
  2638   \isacommand{where}\\
  2642   \isacommand{where}\\
  2639   \phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv\<^isub>3 tvts) @ (bv\<^isub>2 tvcs) @ (bv\<^isub>1 vs)"}\\
  2643   \phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv\<^isub>3 tvts) @ (bv\<^isub>2 tvcs) @ (bv\<^isub>1 vs)"}\\
  2640   $|$~@{text "bv\<^isub>1 VTNil = []"}\\
  2644   $|$~@{text "bv\<^isub>1 VTNil = []"}\\
  2641   $|$~@{text "bv\<^isub>1 (VTCons x ty tl) = (atom x)::(bv\<^isub>1 tl)"}\\
  2645   $|$~@{text "bv\<^isub>1 (VTCons x ty tl) = (atom x)::(bv\<^isub>1 tl)"}\\
  2642   $|$~@{text "bv\<^isub>2 TVTKNil = []"}\\
  2646   $|$~@{text "bv\<^isub>2 TVTKNil = []"}\\
  2704   this time by using the function package \cite{Krauss09} that has recently
  2708   this time by using the function package \cite{Krauss09} that has recently
  2705   been implemented in Isabelle/HOL and also by restricting function
  2709   been implemented in Isabelle/HOL and also by restricting function
  2706   definitions to equivariant functions (for them we can provide more
  2710   definitions to equivariant functions (for them we can provide more
  2707   automation).
  2711   automation).
  2708 
  2712 
  2709   There are some restrictions we imposed in this paper that can be lifted using 
  2713   There are some restrictions we had
       
  2714   to impose in this paper that can be lifted using 
  2710   a recent reimplementation \cite{Traytel12} of the datatype package for Isabelle/HOL, which
  2715   a recent reimplementation \cite{Traytel12} of the datatype package for Isabelle/HOL, which
  2711   is however not yet part of the stable distribution.
  2716   however is not yet part of the stable distribution.
  2712   This reimplementation allows nested
  2717   This reimplementation allows nested
  2713   datatype definitions would allow one to specify, for instance, the function kinds
  2718   datatype definitions and would allow one to specify, for instance, the function kinds
  2714   in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded
  2719   in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded
  2715   version @{text "TFun string ty_list"} (see Figure~\ref{nominalcorehas}). We can 
  2720   version @{text "TFun string ty_list"} (see Figure~\ref{nominalcorehas}). We can 
  2716   also use it to represent the @{text "Let"}-terms from the Introduction where
  2721   also use it to represent the @{text "Let"}-terms from the Introduction where
  2717   the order of @{text "let"}-assignments does not matter. This means we can represent @{text "Let"}s
  2722   the order of @{text "let"}-assignments does not matter. This means we can represent @{text "Let"}s
  2718   such that the following two terms are equal
  2723   such that the following two terms are equal
  2721   @{text "Let x\<^isub>1 = t\<^isub>1 and x\<^isub>2 = t\<^isub>2 in s"} \;\;=\;\;
  2726   @{text "Let x\<^isub>1 = t\<^isub>1 and x\<^isub>2 = t\<^isub>2 in s"} \;\;=\;\;
  2722   @{text "Let x\<^isub>2 = t\<^isub>2 and x\<^isub>1 = t\<^isub>1 in s"} 
  2727   @{text "Let x\<^isub>2 = t\<^isub>2 and x\<^isub>1 = t\<^isub>1 in s"} 
  2723   \]\smallskip
  2728   \]\smallskip
  2724 
  2729 
  2725   \noindent
  2730   \noindent
  2726   For this we have to represent the @{text "let"}-assignments as finite sets
  2731   For this we have to represent the @{text "Let"}-assignments as finite sets
  2727   of pair and a binding function that picks out the left components to be bound in @{text s}.
  2732   of pair and a binding function that picks out the left components to be bound in @{text s}.
  2728 
  2733 
  2729   One line of investigation is whether we can go beyond the 
  2734   One line of future investigation is whether we can go beyond the 
  2730   simple-minded form of binding functions that we adopted from Ott. At the moment, binding
  2735   simple-minded form of binding functions that we adopted from Ott. At the moment, binding
  2731   functions can only return the empty set, a singleton atom set or unions
  2736   functions can only return the empty set, a singleton atom set or unions
  2732   of atom sets (similarly for lists). It remains to be seen whether 
  2737   of atom sets (similarly for lists). It remains to be seen whether 
  2733   properties like
  2738   properties like
  2734   
  2739