--- a/Nominal/Ex/TypeSchemes.thy Wed Jun 08 21:44:03 2011 +0900
+++ b/Nominal/Ex/TypeSchemes.thy Thu Jun 09 09:44:51 2011 +0900
@@ -71,10 +71,18 @@
using assms
by blast
---"The following two terms have the same type, however the first one is a valid default, but the second one no"
definition "MYUNDEFINED \<equiv> undefined"
-term "\<lambda>(x :: (name \<times> ty) list \<times> ty + (name \<times> ty) list \<times> tys). MYUNDEFINED :: ty + tys"
-term "\<lambda>(x :: (name \<times> ty) list \<times> ty + (name \<times> ty) list \<times> tys). sum_case (\<lambda>x. Inl (undefined :: ty)) (\<lambda>x. Inr (undefined :: tys)) x"
+
+--"The following is accepted by 'function' but not by 'nominal_primrec'"
+
+function (default "\<lambda>(x :: (name \<times> ty) list \<times> ty + (name \<times> ty) list \<times> tys). sum_case (\<lambda>x. Inl (undefined :: ty)) (\<lambda>x. Inr (undefined :: tys)) x")
+ subst :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty"
+and substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys"
+where
+ "subst \<theta> (Var X) = lookup \<theta> X"
+| "subst \<theta> (Fun T1 T2) = Fun (subst \<theta> T1) (subst \<theta> T2)"
+| "fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All xs T) = All xs (subst \<theta> T)"
+oops
nominal_primrec (default "\<lambda>(x :: (name \<times> ty) list \<times> ty + (name \<times> ty) list \<times> tys). MYUNDEFINED :: ty + tys")
subst :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty"