1002 coerces a name into the generic atom type of Nominal Isabelle. This allows |
1002 coerces a name into the generic atom type of Nominal Isabelle. This allows |
1003 us to treat binders of different atom type uniformly. |
1003 us to treat binders of different atom type uniformly. |
1004 |
1004 |
1005 As will shortly become clear, we cannot return an atom in a binding function |
1005 As will shortly become clear, we cannot return an atom in a binding function |
1006 that is also bound in the corresponding term-constructor. That means in the |
1006 that is also bound in the corresponding term-constructor. That means in the |
1007 example above that the term-constructors PVar and PTup must not have a |
1007 example above that the term-constructors @{text PVar} and @{text PTup} must not have a |
1008 binding clause. In the present version of Nominal Isabelle, we also adopted |
1008 binding clause. In the present version of Nominal Isabelle, we also adopted |
1009 the restriction from the Ott-tool that binding functions can only return: |
1009 the restriction from the Ott-tool that binding functions can only return: |
1010 the empty set or empty list (as in case PNil), a singleton set or singleton |
1010 the empty set or empty list (as in case @{text PNil}), a singleton set or singleton |
1011 list containing an atom (case PVar), or unions of atom sets or appended atom |
1011 list containing an atom (case @{text PVar}), or unions of atom sets or appended atom |
1012 lists (case PTup). This restriction will simplify proofs later on. |
1012 lists (case @{text PTup}). This restriction will simplify proofs later on. |
1013 |
1013 |
1014 The most drastic restriction we have to impose on deep binders is that |
1014 The most drastic restriction we have to impose on deep binders is that |
1015 we cannot have ``overlapping'' deep binders. Consider for example the |
1015 we cannot have ``overlapping'' deep binders. Consider for example the |
1016 term-constructors: |
1016 term-constructors: |
1017 |
1017 |
1121 %From this definition we can easily show that the raw datatypes are |
1121 %From this definition we can easily show that the raw datatypes are |
1122 %all permutation types (Def ??) by a simple structural induction over |
1122 %all permutation types (Def ??) by a simple structural induction over |
1123 %the @{text "ty"}s. |
1123 %the @{text "ty"}s. |
1124 |
1124 |
1125 The first non-trivial step we have to perform is the generation free-variable |
1125 The first non-trivial step we have to perform is the generation free-variable |
1126 functions from the specifications. Given types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} |
1126 functions from the specifications. Given the raw types @{text "ty\<^isub>1 \<dots> ty\<^isub>n"} |
1127 we need to define the free-variable functions |
1127 we need to define free-variable functions |
1128 |
1128 |
1129 \begin{center} |
1129 \begin{center} |
1130 @{text "fv_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_ty\<^isub>n :: ty\<^isub>n \<Rightarrow> atom set"} |
1130 @{text "fv_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_ty\<^isub>n :: ty\<^isub>n \<Rightarrow> atom set"} |
1131 \end{center} |
1131 \end{center} |
1132 |
1132 |
1133 \noindent |
1133 \noindent |
1134 We define them together with the auxiliary free variable functions for |
1134 We define them together with the auxiliary free variable functions for |
1135 binding functions. Given binding functions of types |
1135 binding functions. Given binding functions for raw types |
1136 @{text "bn\<^isub>1 :: ty\<^isub>i\<^isub>1 \<Rightarrow> \<dots> \<dots> bn\<^isub>m :: ty\<^isub>i\<^isub>m \<Rightarrow> \<dots>"} we need to define |
1136 @{text "bn_ty\<^isub>1 \<dots> bn_ty\<^isub>m"} we need to define |
1137 |
1137 |
1138 \begin{center} |
1138 \begin{center} |
1139 @{text "fv_bn\<^isub>1 :: ty\<^isub>i\<^isub>1 \<Rightarrow> atom set \<dots> fv_bn\<^isub>m :: ty\<^isub>i\<^isub>m \<Rightarrow> atom set"} |
1139 @{text "fv_bn_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_bn_ty\<^isub>m :: ty\<^isub>m \<Rightarrow> atom set"} |
1140 \end{center} |
1140 \end{center} |
1141 |
1141 |
1142 \noindent |
1142 \noindent |
1143 The basic idea behind these free-variable functions is to collect all atoms |
1143 The basic idea behind these free-variable functions is to collect all atoms |
1144 that are not bound in a term constructor, but because of the rather |
1144 that are not bound in a term constructor, but because of the rather |
1145 complicated binding mechanisms the details are somewhat involved. |
1145 complicated binding mechanisms the details are somewhat involved. |
1146 |
1146 |
1147 Given a term-constructor @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"}, of type @{text ty} together with |
1147 Given a term-constructor @{text "C"} of type @{text ty} with argument types |
1148 some binding clauses, the function @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be |
1148 @{text "ty\<^isub>1 \<dots> ty\<^isub>n"} and some binding clauses, the function |
1149 the union of the values defined below for each argument, say @{text "x\<^isub>i"} with type @{text "ty\<^isub>i"}. |
1149 @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values |
1150 From the binding clause of this term constructor, we can determine whether the |
1150 defined below for each argument. From the binding clause of this term |
1151 argument @{text "x\<^isub>i"} is a shallow or deep binder, and in the latter case also |
1151 constructor, we can determine whether the argument is a shallow or deep |
1152 whether it is a recursive or non-recursive of a binder. In these cases the value is: |
1152 binder, and in the latter case also whether it is a recursive or |
|
1153 non-recursive binder. In case the argument, say @{text "x\<^isub>i"} with |
|
1154 type @{text "ty\<^isub>i"}, is a binder, the value is: |
1153 |
1155 |
1154 \begin{center} |
1156 \begin{center} |
1155 \begin{tabular}{cp{7cm}} |
1157 \begin{tabular}{cp{7cm}} |
1156 $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1158 $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1157 $\bullet$ & @{text "fv_bn\<^isub>j x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep |
1159 $\bullet$ & @{text "fv_bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep |
1158 non-recursive binder with the auxiliary function @{text "bn\<^isub>j"}\\ |
1160 non-recursive binder with the auxiliary function @{text "bn_ty\<^isub>i"}\\ |
1159 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn\<^isub>j x\<^isub>i"} provided @{text "x\<^isub>i"} is |
1161 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is |
1160 a deep recursive binder with the auxiliary function @{text "bn\<^isub>j"} |
1162 a deep recursive binder with the auxiliary function @{text "bn_ty\<^isub>i"} |
1161 \end{tabular} |
1163 \end{tabular} |
1162 \end{center} |
1164 \end{center} |
1163 |
1165 |
1164 \noindent |
1166 \noindent |
1165 In case the argument @{text "x\<^isub>i"} is not a binder, it might be a body of |
1167 In case the argument @{text "x\<^isub>i"} is not a binder, it might be a body of |
1166 one or more abstractions. Let @{text "bnds"} be the bound atoms computed |
1168 one or more abstractions. Let @{text "bnds"} be the set of bound atoms calculated |
1167 as follows: If @{text "x\<^isub>i"} is not a body of an abstraction @{term "{}"}. |
1169 as follows: If @{text "x\<^isub>i"} is not a body of an abstraction @{term "{}"}. |
1168 Otherwise there are two cases: either the |
1170 Otherwise there are two cases: either the |
1169 corresponding binders are all shallow or there is a single deep binder. |
1171 corresponding binders are all shallow or there is a single deep binder. |
1170 In the former case we build the union of all shallow binders; in the |
1172 In the former case we build the union of all shallow binders; in the |
1171 later case we just take set or list of atoms the specified binding |
1173 later case we just take the set of atoms specified binding |
1172 function returns. With @{text "bnds"} computed as above the value of |
1174 function returns. With @{text "bnds"} computed as above the value of |
1173 for @{text "x\<^isub>i"} is given by: |
1175 for @{text "x\<^isub>i"} is given by: |
1174 |
1176 |
1175 \begin{center} |
1177 \begin{center} |
1176 \begin{tabular}{cp{7cm}} |
1178 \begin{tabular}{cp{7cm}} |
1177 $\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\ |
1179 $\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\ |
1178 $\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\ |
1180 $\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\ |
1179 $\bullet$ & @{text "(atoms (set x\<^isub>i)) - bnds"} provided @{term "x\<^isub>i"} is a list of atoms\\ |
1181 $\bullet$ & @{text "(atoms (set x\<^isub>i)) - bnds"} provided @{term "x\<^isub>i"} is a list of atoms\\ |
1180 $\bullet$ & @{text "(fv_ty\<^isub>m x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is one of the datatypes |
1182 $\bullet$ & @{text "(fv_ty\<^isub>i x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is one of the datatypes |
1181 we are defining, with the free variable function @{text "fv_ty\<^isub>m"}\\ |
1183 we are defining with the free variable function @{text "fv_ty\<^isub>i"}\\ |
1182 % $\bullet$ & @{text "(fv\<^isup>\<alpha> x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a defined nominal datatype |
1184 % $\bullet$ & @{text "(fv\<^isup>\<alpha> x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a defined nominal datatype |
1183 % with a free variable function @{text "fv\<^isup>\<alpha>"}\\ |
1185 % with a free variable function @{text "fv\<^isup>\<alpha>"}\\ |
1184 $\bullet$ & @{term "{}"} otherwise |
1186 $\bullet$ & @{term "{}"} otherwise |
1185 \end{tabular} |
1187 \end{tabular} |
1186 \end{center} |
1188 \end{center} |
1187 |
1189 |
1188 \noindent Next, for each binding function @{text "bn"} we define a |
1190 \noindent |
1189 free variable function @{text "fv_bn"}. The basic idea behind this |
1191 Next, for each binding function @{text "bn_ty"} we define a |
1190 function is to compute all the free atoms under this binding |
1192 free variable function @{text "fv_bn_ty"}. The basic idea behind this |
|
1193 function is to compute all the free atoms that are not bound by the binding |
1191 function. So given that @{text "bn"} is a binding function for type |
1194 function. So given that @{text "bn"} is a binding function for type |
1192 @{text "ty\<^isub>i"} it will be the same as @{text "fv_ty\<^isub>i"} with the |
1195 @{text "ty\<^isub>i"} it will be the same as @{text "fv_ty\<^isub>i"} with the |
1193 omission of the arguments present in @{text "bn"}. |
1196 omission of the arguments present in @{text "bn"}. |
1194 |
1197 |
1195 For a binding function clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, |
1198 For a binding function clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, |