LMCS-Paper/Paper.thy
changeset 3128 4bad521e3b9e
parent 3126 d3d5225f4f24
child 3129 8be3155c014f
equal deleted inserted replaced
3127:d13ac9f4e773 3128:4bad521e3b9e
   126   \noindent
   126   \noindent
   127   which relates a type-scheme with a list of variables and a type. The point of this
   127   which relates a type-scheme with a list of variables and a type. The point of this
   128   definition is to get access to the bound variables and the type-part of a type-scheme
   128   definition is to get access to the bound variables and the type-part of a type-scheme
   129   @{text S}, though in general 
   129   @{text S}, though in general 
   130   we will only get access to some variables and some type @{text T} that are  
   130   we will only get access to some variables and some type @{text T} that are  
   131   ``alpha-equivalent'' to @{text S}---it is an unbinding \emph{relation}. Still, with this 
   131   ``alpha-equivalent'' to @{text S}. This is because unbinding is a relation, not a function. 
       
   132   Still, with this 
   132   definition in place we can formally define when a type is an instance of a type-scheme as
   133   definition in place we can formally define when a type is an instance of a type-scheme as
   133 
   134 
   134   \[
   135   \[
   135   @{text "T \<prec> S \<equiv> \<exists>xs T' \<sigma>. S \<hookrightarrow> (xs, T') \<and> dom \<sigma> = set xs \<and> \<sigma>(T') = T"}
   136   @{text "T \<prec> S \<equiv> \<exists>xs T' \<sigma>. S \<hookrightarrow> (xs, T') \<and> dom \<sigma> = set xs \<and> \<sigma>(T') = T"}
   136   \]\smallskip
   137   \]\smallskip
   137   
   138   
   138   \noindent
   139   \noindent
   139   meaning there exists a list of variables @{text xs} and a type @{text T'} to which
   140   meaning there exists a list of variables @{text xs} and a type @{text T'} to which
   140   the type-scheme @{text S} unbinds, and there exists a substitution whose domain is
   141   the type-scheme @{text S} unbinds, and there exists a substitution whose domain is
   141   @{text xs} (seen as set) such that @{text "\<sigma>(T') = T"}.
   142   @{text xs} (seen as set) such that @{text "\<sigma>(T') = T"}.
   142   The pain with this definition is that we cannot follow the usual proofs 
   143   The problem with this definition is that we cannot follow the usual proofs 
   143   that are by induction on the type-part of the type-scheme (since it is under
   144   that are by induction on the type-part of the type-scheme (since it is under
   144   an existential quantifier). The representation of type-schemes by iterating single binders 
   145   an existential quantifier). The representation of type-schemes using iterations of single binders 
   145   prevents us from directly ``unbinding'' the bound variables and the type-part of 
   146   prevents us from directly ``unbinding'' the bound variables and the type-part of 
   146   a type-scheme. The purpose of this paper is to introduce general binders, which 
   147   a type-scheme. The purpose of this paper is to introduce general binders, which 
   147   allow us to represent type-schemes following closely informal practice and as 
   148   allow us to represent type-schemes so that they can bind multiple variables at once
   148   a result solve this problem.
   149   and as a result solve this problem.
   149   The need of iterating single binders is also one reason
   150   The need of iterating single binders is also one reason
   150   why Nominal Isabelle and similar theorem provers that only provide
   151   why Nominal Isabelle and similar theorem provers that only provide
   151   mechanisms for binding single variables have not fared extremely well with
   152   mechanisms for binding single variables have not fared extremely well with
   152   the more advanced tasks in the POPLmark challenge \cite{challenge05},
   153   the more advanced tasks in the POPLmark challenge \cite{challenge05},
   153   because also there one would like to bind multiple variables at once.
   154   because also there one would like to bind multiple variables at once.
   158   we would like to regard in \eqref{ex1} below  the first pair of type-schemes as alpha-equivalent,
   159   we would like to regard in \eqref{ex1} below  the first pair of type-schemes as alpha-equivalent,
   159   but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
   160   but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
   160   the second pair should \emph{not} be alpha-equivalent:
   161   the second pair should \emph{not} be alpha-equivalent:
   161 
   162 
   162   \begin{equation}\label{ex1}
   163   \begin{equation}\label{ex1}
   163   @{text "\<forall>{x, y}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{y, x}. y \<rightarrow> x"}\hspace{10mm}
   164   @{text "\<forall>{x, y}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{x, y}. y \<rightarrow> x"}\hspace{10mm}
   164   @{text "\<forall>{x, y}. x \<rightarrow> y  \<notapprox>\<^isub>\<alpha>  \<forall>{z}. z \<rightarrow> z"}
   165   @{text "\<forall>{x, y}. x \<rightarrow> y  \<notapprox>\<^isub>\<alpha>  \<forall>{z}. z \<rightarrow> z"}
   165   \end{equation}\smallskip
   166   \end{equation}\smallskip
   166 
   167 
   167   \noindent
   168   \noindent
   168   Moreover, we like to regard type-schemes as alpha-equivalent, if they differ
   169   Moreover, we like to regard type-schemes as alpha-equivalent, if they differ
   419   which includes multiple binders in type-schemes.\medskip
   420   which includes multiple binders in type-schemes.\medskip
   420 
   421 
   421   \noindent
   422   \noindent
   422   {\bf Contributions:} We provide three new definitions for when terms
   423   {\bf Contributions:} We provide three new definitions for when terms
   423   involving general binders are alpha-equivalent. These definitions are
   424   involving general binders are alpha-equivalent. These definitions are
   424   inspired by earlier work of Pitts \cite{Pitts04}. By means of automatically-generated
   425   inspired by earlier work of Pitts \cite{Pitts04}. By means of automati\-cally-generated
   425   proofs, we establish a reasoning infrastructure for alpha-equated terms,
   426   proofs, we establish a reasoning infrastructure for alpha-equated terms,
   426   including properties about support, freshness and equality conditions for
   427   including properties about support, freshness and equality conditions for
   427   alpha-equated terms. We are also able to automatically derive strong
   428   alpha-equated terms. We are also able to automatically derive strong
   428   induction principles that have the variable convention already built in.
   429   induction principles that have the variable convention already built in.
   429   For this we simplify the earlier automated proofs by using the proving tools
   430   For this we simplify the earlier automated proofs by using the proving tools
   517   @{thm permute_list.simps(1)[where p="\<pi>", no_vars, THEN eq_reflection]}\\
   518   @{thm permute_list.simps(1)[where p="\<pi>", no_vars, THEN eq_reflection]}\\
   518   @{thm permute_list.simps(2)[where p="\<pi>", no_vars, THEN eq_reflection]}\\
   519   @{thm permute_list.simps(2)[where p="\<pi>", no_vars, THEN eq_reflection]}\\
   519   \end{tabular} &
   520   \end{tabular} &
   520   \begin{tabular}{@ {}l@ {}}
   521   \begin{tabular}{@ {}l@ {}}
   521   @{thm permute_perm_def[where p="\<pi>" and q="\<pi>'", no_vars, THEN eq_reflection]}\\
   522   @{thm permute_perm_def[where p="\<pi>" and q="\<pi>'", no_vars, THEN eq_reflection]}\\
   522   @{thm permute_set_eq[where p="\<pi>", no_vars, THEN eq_reflection]}\\
   523   @{thm permute_set_def[where p="\<pi>", no_vars, THEN eq_reflection]}\\
   523   @{text "\<pi> \<bullet> f \<equiv> \<lambda>x. \<pi> \<bullet> (f (- \<pi> \<bullet> x))"}\\
   524   @{text "\<pi> \<bullet> f \<equiv> \<lambda>x. \<pi> \<bullet> (f (- \<pi> \<bullet> x))"}\\
   524   @{thm permute_bool_def[where p="\<pi>", no_vars, THEN eq_reflection]}
   525   @{thm permute_bool_def[where p="\<pi>", no_vars, THEN eq_reflection]}
   525   \end{tabular}
   526   \end{tabular}
   526   \end{tabular}}
   527   \end{tabular}}
   527   \end{equation}\smallskip
   528   \end{equation}\smallskip
   616   Another important notion in the nominal logic work is \emph{equivariance}.
   617   Another important notion in the nominal logic work is \emph{equivariance}.
   617   For a function @{text f} to be equivariant 
   618   For a function @{text f} to be equivariant 
   618   it is required that every permutation leaves @{text f} unchanged, that is
   619   it is required that every permutation leaves @{text f} unchanged, that is
   619   
   620   
   620   \begin{equation}\label{equivariancedef}
   621   \begin{equation}\label{equivariancedef}
   621   @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}
   622   @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}\;.
   622   \end{equation}\smallskip
   623   \end{equation}\smallskip
   623   
   624   
   624   \noindent
   625   \noindent
   625   If a function is of type @{text "\<alpha> \<Rightarrow> \<beta>"}, this definition is equivalent to 
   626   If a function is of type @{text "\<alpha> \<Rightarrow> \<beta>"}, this definition is equivalent to 
   626   the fact that a permutation applied to the application
   627   the fact that a permutation applied to the application
   627   @{text "f x"} can be moved to the argument @{text x}. That means for 
   628   @{text "f x"} can be moved to the argument @{text x}. That means for 
   628   functions @{text f} of type @{text "\<alpha> \<Rightarrow> \<beta>"}, we have for all permutations @{text "\<pi>"}:
   629   such functions, we have for all permutations @{text "\<pi>"}:
   629   
   630   
   630   \begin{equation}\label{equivariance}
   631   \begin{equation}\label{equivariance}
   631   @{text "\<pi> \<bullet> f = f"} \;\;\;\;\textit{if and only if}\;\;\;\;
   632   @{text "\<pi> \<bullet> f = f"} \;\;\;\;\textit{if and only if}\;\;\;\;
   632   @{text "\<forall>x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"}
   633   @{text "\<forall>x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"}\;.
   633   \end{equation}\smallskip
   634   \end{equation}\smallskip
   634    
   635    
   635   \noindent
   636   \noindent
   636   There is
   637   There is
   637   also a similar property for relations, which are in HOL functions of type @{text "\<alpha> \<Rightarrow> \<beta> \<Rightarrow> bool"}.
   638   also a similar property for relations, which are in HOL functions of type @{text "\<alpha> \<Rightarrow> \<beta> \<Rightarrow> bool"}.
   638   Suppose a relation @{text R}, then
   639   Suppose a relation @{text R}, then for all permutations @{text \<pi>}:
   639   that for all permutations @{text \<pi>}:
       
   640   
   640   
   641   \[
   641   \[
   642   @{text "\<pi> \<bullet> R = R"} \;\;\;\;\textit{if and only if}\;\;\;\;
   642   @{text "\<pi> \<bullet> R = R"} \;\;\;\;\textit{if and only if}\;\;\;\;
   643   @{text "\<forall>x y."}~~@{text "x R y"} \;\textit{implies}\; @{text "(\<pi> \<bullet> x) R (\<pi> \<bullet> y)"}
   643   @{text "\<forall>x y."}~~@{text "x R y"} \;\textit{implies}\; @{text "(\<pi> \<bullet> x) R (\<pi> \<bullet> y)"}\;.
   644   \]\smallskip
   644   \]\smallskip
   645 
   645 
   646   \noindent
   646   \noindent
   647   Note that from property \eqref{equivariancedef} and the definition of @{text supp}, we 
   647   Note that from property \eqref{equivariancedef} and the definition of @{text supp}, we 
   648   can easily deduce that equivariant functions have empty support.
   648   can easily deduce that for a function being equivariant is equivalent to having empty support.
   649 
   649 
   650   Using freshness, the nominal logic work provides us with general means for renaming 
   650   Using freshness, the nominal logic work provides us with general means for renaming 
   651   binders. 
   651   binders. 
   652   
   652   
   653   \noindent
   653   \noindent
  1041   \eqref{scheme}. In this case we will call the corresponding argument a
  1041   \eqref{scheme}. In this case we will call the corresponding argument a
  1042   \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such
  1042   \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such
  1043   recursive arguments need to satisfy a `positivity' restriction, which
  1043   recursive arguments need to satisfy a `positivity' restriction, which
  1044   ensures that the type has a set-theoretic semantics (see
  1044   ensures that the type has a set-theoretic semantics (see
  1045   \cite{Berghofer99}). If the types are polymorphic, we require the
  1045   \cite{Berghofer99}). If the types are polymorphic, we require the
  1046   type variables are of finitely supported type.
  1046   type variables stand for types that are finitely supported and over which 
  1047   The labels annotated on the types are optional. Their
  1047   a permutation operation is defined.
       
  1048   The labels @{text "label"}$_{1..l}$ annotated on the types are optional. Their
  1048   purpose is to be used in the (possibly empty) list of \emph{binding
  1049   purpose is to be used in the (possibly empty) list of \emph{binding
  1049   clauses}, which indicate the binders and their scope in a term-constructor.
  1050   clauses}, which indicate the binders and their scope in a term-constructor.
  1050   They come in three \emph{modes}:
  1051   They come in three \emph{modes}:
  1051 
  1052 
  1052 
  1053 
  1236   \noindent
  1237   \noindent
  1237   Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"}  pick 
  1238   Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"}  pick 
  1238   out different atoms to become bound, respectively be free, in @{text "p"}.
  1239   out different atoms to become bound, respectively be free, in @{text "p"}.
  1239   (Since the Ott-tool does not derive a reasoning infrastructure for 
  1240   (Since the Ott-tool does not derive a reasoning infrastructure for 
  1240   alpha-equated terms with deep binders, it can permit such specifications.)
  1241   alpha-equated terms with deep binders, it can permit such specifications.)
  1241   
  1242   For convenience we exlude such specifications even if @{text "bn\<^isub>1"} and 
       
  1243   @{text "bn\<^isub>2"} are the same binding functions, which would otherwise be harmless.
       
  1244 
  1242   We also need to restrict the form of the binding functions in order to
  1245   We also need to restrict the form of the binding functions in order to
  1243   ensure the @{text "bn"}-functions can be defined for alpha-equated
  1246   ensure the @{text "bn"}-functions can be defined for alpha-equated
  1244   terms. The main restriction is that we cannot return an atom in a binding
  1247   terms. The main restriction is that we cannot return an atom in a binding
  1245   function that is also bound in the corresponding term-constructor.
  1248   function that is also bound in the corresponding term-constructor.
  1246   Consider again the specification for @{text "trm"} and a contrived
  1249   Consider again the specification for @{text "trm"} and a contrived