920 preserving alpha-equivalence). The ``\isacommand{in}-part'' of a binding |
920 preserving alpha-equivalence). The ``\isacommand{in}-part'' of a binding |
921 clause will be called \emph{bodies} (there can be more than one); the |
921 clause will be called \emph{bodies} (there can be more than one); the |
922 ``\isacommand{bind}-part'' will be called \emph{binders}. |
922 ``\isacommand{bind}-part'' will be called \emph{binders}. |
923 |
923 |
924 In contrast to Ott, we allow multiple labels in binders and bodies. For example |
924 In contrast to Ott, we allow multiple labels in binders and bodies. For example |
925 we have binding clauses of the form: |
925 we allow binding clauses of the form: |
926 |
926 |
927 \begin{center} |
927 \begin{center} |
928 \begin{tabular}{ll} |
928 \begin{tabular}{@ {}ll@ {}} |
929 @{text "Foo x::name y::name t::lam s::lam"} & |
929 @{text "Foo\<^isub>1 x::name y::name t::lam s::lam"} & |
930 \isacommand{bind} @{text "x y"} \isacommand{in} @{text "t s"} |
930 \isacommand{bind} @{text "x y"} \isacommand{in} @{text "t s"}\\ |
931 \end{tabular} |
931 @{text "Foo\<^isub>2 x::name y::name t::lam s::lam"} & |
932 \end{center} |
932 \isacommand{bind} @{text "x y"} \isacommand{in} @{text "t"}, |
933 |
933 \isacommand{bind} @{text "x y"} \isacommand{in} @{text "s"}\\ |
934 \noindent |
934 \end{tabular} |
935 Similarly for the other binding modes. |
935 \end{center} |
936 |
936 |
937 |
937 \noindent |
938 There are a few restrictions we need to impose: First, a body can only occur in |
938 Similarly for the other binding modes. Interestingly, in case of \isacommand{bind\_set} |
939 \emph{one} binding clause of a term constructor. |
939 and \isacommand{bind\_res} the binding clauses will make a difference in |
940 For binders we distinguish between \emph{shallow} and \emph{deep} binders. |
940 terms of the corresponding alpha-equivalence. We will show this later with an example. |
941 Shallow binders are just labels. The |
941 |
942 restriction we need to impose on them is that in case of |
942 There are some restrictions we need to impose: First, a body can only occur |
943 \isacommand{bind\_set} and \isacommand{bind\_res} the labels must |
943 in \emph{one} binding clause of a term constructor. For binders we |
944 either refer to atom types or to sets of atom types; in case of |
944 distinguish between \emph{shallow} and \emph{deep} binders. Shallow binders |
945 \isacommand{bind} the labels must refer to atom types or lists of atom types. |
945 are just labels. The restriction we need to impose on them is that in case |
946 Two examples for the use of shallow binders are the specification of |
946 of \isacommand{bind\_set} and \isacommand{bind\_res} the labels must either |
947 lambda-terms, where a single name is bound, and type-schemes, where a finite |
947 refer to atom types or to sets of atom types; in case of \isacommand{bind} |
948 set of names is bound: |
948 the labels must refer to atom types or lists of atom types. Two examples for |
|
949 the use of shallow binders are the specification of lambda-terms, where a |
|
950 single name is bound, and type-schemes, where a finite set of names is |
|
951 bound: |
949 |
952 |
950 \begin{center} |
953 \begin{center} |
951 \begin{tabular}{@ {}cc@ {}} |
954 \begin{tabular}{@ {}cc@ {}} |
952 \begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
955 \begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
953 \isacommand{nominal\_datatype} @{text lam} =\\ |
956 \isacommand{nominal\_datatype} @{text lam} =\\ |
965 \end{tabular} |
968 \end{tabular} |
966 \end{tabular} |
969 \end{tabular} |
967 \end{center} |
970 \end{center} |
968 |
971 |
969 \noindent |
972 \noindent |
970 Note that for @{text lam} it does not matter which binding mode we use. The reason is that |
973 Note that for @{text lam} it does not matter which binding mode we use. The |
971 we bind only a single @{text name}. However, having \isacommand{bind\_set} or |
974 reason is that we bind only a single @{text name}. However, having |
972 \isacommand{bind} in the second |
975 \isacommand{bind\_set} or \isacommand{bind} in the second case again makes a |
973 case changes the semantics of the specification. |
976 difference to the underlying notion of alpha-equivalence. Note also that in |
974 Note also that in these specifications @{text "name"} refers to an atom type, and |
977 these specifications @{text "name"} refers to an atom type, and @{text |
975 @{text "fset"} to the type of finite sets. |
978 "fset"} to the type of finite sets. |
|
979 |
976 |
980 |
977 A \emph{deep} binder uses an auxiliary binding function that ``picks'' out |
981 A \emph{deep} binder uses an auxiliary binding function that ``picks'' out |
978 the atoms in one argument of the term-constructor, which can be bound in |
982 the atoms in one argument of the term-constructor, which can be bound in |
979 other arguments and also in the same argument (we will |
983 other arguments and also in the same argument (we will call such binders |
980 call such binders \emph{recursive}, see below). |
984 \emph{recursive}, see below). The corresponding binding functions are |
981 The corresponding binding functions are expected to return either a set of atoms |
985 expected to return either a set of atoms (for \isacommand{bind\_set} and |
982 (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms |
986 \isacommand{bind\_res}) or a list of atoms (for \isacommand{bind}). They can |
983 (for \isacommand{bind}). They can be defined by primitive recursion over the |
987 be defined by primitive recursion over the corresponding type; the equations |
984 corresponding type; the equations must be given in the binding function part of |
988 must be given in the binding function part of the scheme shown in |
985 the scheme shown in \eqref{scheme}. For example a term-calculus containing @{text "Let"}s |
989 \eqref{scheme}. For example a term-calculus containing @{text "Let"}s with |
986 with tuple patterns might be specified as: |
990 tuple patterns might be specified as: |
|
991 |
987 % |
992 % |
988 \begin{equation}\label{letpat} |
993 \begin{equation}\label{letpat} |
989 \mbox{% |
994 \mbox{% |
990 \begin{tabular}{l} |
995 \begin{tabular}{l} |
991 \isacommand{nominal\_datatype} @{text trm} =\\ |
996 \isacommand{nominal\_datatype} @{text trm} =\\ |
1063 \end{tabular} |
1068 \end{tabular} |
1064 \end{center} |
1069 \end{center} |
1065 |
1070 |
1066 \noindent |
1071 \noindent |
1067 The reason why we must exclude such specifications is that they cannot be |
1072 The reason why we must exclude such specifications is that they cannot be |
1068 represented by the general binders described in Section |
1073 represented by the general binders described in Section~\ref{sec:binders}. |
1069 \ref{sec:binders}. Unlike shallow binders, we restrict deep binders to occur |
|
1070 in only one binding clause. |
|
1071 |
1074 |
1072 We also need to restrict the form of the binding functions. As will shortly |
1075 We also need to restrict the form of the binding functions. As will shortly |
1073 become clear, we cannot return an atom in a binding function that is also |
1076 become clear, we cannot return an atom in a binding function that is also |
1074 bound in the corresponding term-constructor. That means in the example |
1077 bound in the corresponding term-constructor. That means in the example |
1075 \eqref{letpat} that the term-constructors @{text PVar} and @{text PTup} may |
1078 \eqref{letpat} that the term-constructors @{text PVar} and @{text PTup} may |
1082 (as in case @{text PNil}), a singleton set or singleton list containing an |
1085 (as in case @{text PNil}), a singleton set or singleton list containing an |
1083 atom (case @{text PVar}), or unions of atom sets or appended atom lists |
1086 atom (case @{text PVar}), or unions of atom sets or appended atom lists |
1084 (case @{text PTup}). This restriction will simplify some automatic proofs |
1087 (case @{text PTup}). This restriction will simplify some automatic proofs |
1085 later on. |
1088 later on. |
1086 |
1089 |
1087 In order to simplify later definitions, we shall assume specifications |
1090 In order to simplify our definitions, we shall assume specifications |
1088 of term-calculi are \emph{completed}. By this we mean that |
1091 of term-calculi are \emph{completed}. By this we mean that |
1089 for every argument of a term-constructor that is \emph{not} |
1092 for every argument of a term-constructor that is \emph{not} |
1090 already part of a binding clause, we add implicitly a special \emph{empty} binding |
1093 already part of a binding clause, we add implicitly a special \emph{empty} binding |
1091 clause, written \isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "label"}. In case |
1094 clause, written \isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "label"}. In case |
1092 of the lambda-calculus, the completion produces |
1095 of the lambda-calculus, the completion produces |