Quot/Nominal/Terms.thy
changeset 1111 ee276c9f12f0
parent 1109 86093c201bac
child 1117 8948319b190e
equal deleted inserted replaced
1110:1e5dee9e6ae2 1111:ee276c9f12f0
   927 
   927 
   928 
   928 
   929 (* example with a bn function defined over the type itself *)
   929 (* example with a bn function defined over the type itself *)
   930 datatype rtrm6 =
   930 datatype rtrm6 =
   931   rVr6 "name"
   931   rVr6 "name"
   932 | rAp6 "rtrm6" "rtrm6"
   932 | rLm6 "name" "rtrm6"
   933 | rFo6 "rtrm6" "rtrm6" --"bind (bv6 left) in (right)"
   933 | rLt6 "rtrm6" "rtrm6" --"bind (bv6 left) in (right)"
   934 
   934 
   935 primrec
   935 primrec
   936   rbv6
   936   rbv6
   937 where
   937 where
   938   "rbv6 (rVr6 x) = {atom x}"
   938   "rbv6 (rVr6 n) = {}"
   939 | "rbv6 (rAp6 l r) = rbv6 l \<union> rbv6 r"
   939 | "rbv6 (rLm6 n t) = {atom n}"
   940 | "rbv6 (rFo6 l r) = rbv6 r - rbv6 l"
   940 | "rbv6 (rLt6 l r) = rbv6 l \<union> rbv6 r"
   941 
   941 
   942 primrec
   942 primrec
   943   rfv_trm6
   943   rfv_trm6
   944 where
   944 where
   945   "rfv_trm6 (rVr6 n) = {atom n}"
   945   "rfv_trm6 (rVr6 n) = {atom n}"
   946 | "rfv_trm6 (rAp6 t s) = (rfv_trm6 t) \<union> (rfv_trm6 s)"
   946 | "rfv_trm6 (rLm6 n t) = (rfv_trm6 t) - {atom n}"
   947 | "rfv_trm6 (rFo6 l r) = (rfv_trm6 r - rbv6 l) \<union> (rfv_trm6 l)"
   947 | "rfv_trm6 (rLt6 l r) = (rfv_trm6 r - rbv6 l) \<union> rfv_trm6 r"
   948 
   948 
   949 instantiation
   949 instantiation
   950   rtrm6 :: pt
   950   rtrm6 :: pt
   951 begin
   951 begin
   952 
   952 
   953 primrec
   953 primrec
   954   permute_rtrm6
   954   permute_rtrm6
   955 where
   955 where
   956   "permute_rtrm6 pi (rVr6 a) = rVr6 (pi \<bullet> a)"
   956   "permute_rtrm6 pi (rVr6 a) = rVr6 (pi \<bullet> a)"
   957 | "permute_rtrm6 pi (rAp6 t1 t2) = rAp6 (permute_rtrm6 pi t1) (permute_rtrm6 pi t2)"
   957 | "permute_rtrm6 pi (rLm6 n t) = rLm6 (pi \<bullet> n) (permute_rtrm6 pi t)"
   958 | "permute_rtrm6 pi (rFo6 l r) = rFo6 (permute_rtrm6 pi l) (permute_rtrm6 pi r)"
   958 | "permute_rtrm6 pi (rLt6 l r) = rLt6 (permute_rtrm6 pi l) (permute_rtrm6 pi r)"
   959 
   959 
   960 lemma pt_rtrm6_zero:
   960 lemma pt_rtrm6_zero:
   961   fixes t::rtrm6
   961   fixes t::rtrm6
   962   shows "0 \<bullet> t = t"
   962   shows "0 \<bullet> t = t"
   963 apply(induct t)
   963 apply(induct t)
   980 
   980 
   981 inductive
   981 inductive
   982   alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [100, 100] 100)
   982   alpha6 :: "rtrm6 \<Rightarrow> rtrm6 \<Rightarrow> bool" ("_ \<approx>6 _" [100, 100] 100)
   983 where
   983 where
   984   a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
   984   a1: "a = b \<Longrightarrow> (rVr6 a) \<approx>6 (rVr6 b)"
   985 | a2: "\<lbrakk>t1 \<approx>6 t2; s1 \<approx>6 s2\<rbrakk> \<Longrightarrow> rAp6 t1 s1 \<approx>6 rAp6 t2 s2"
   985 | a2: "(\<exists>pi. (({atom a}, t) \<approx>gen alpha6 rfv_trm6 pi ({atom b}, s))) \<Longrightarrow> rLm6 a t \<approx>6 rLm6 b s"
   986 | a3: "\<lbrakk>\<exists>pi. ((rbv6 l1, r1) \<approx>gen alpha6 rfv_trm6 pi (rbv6 l2, r2))\<rbrakk>
   986 | a3: "(\<exists>pi. (((rbv6 t1), s1) \<approx>gen alpha6 rfv_trm6 pi ((rbv6 t2), s2))) \<Longrightarrow> rLt6 t1 s1 \<approx>6 rLt6 t2 s2"
   987         \<Longrightarrow> rFo6 l1 r1 \<approx>6 rFo6 l2 r2"
       
   988 
   987 
   989 lemma alpha6_equivps:
   988 lemma alpha6_equivps:
   990   shows "equivp alpha6"
   989   shows "equivp alpha6"
   991 sorry
   990 sorry
   992 
   991 
   998   "Vr6 :: name \<Rightarrow> trm6"
   997   "Vr6 :: name \<Rightarrow> trm6"
   999 as
   998 as
  1000   "rVr6"
   999   "rVr6"
  1001 
  1000 
  1002 quotient_definition
  1001 quotient_definition
  1003   "Ap6 :: trm6 \<Rightarrow> trm6 \<Rightarrow> trm6"
  1002   "Lm6 :: name \<Rightarrow> trm6 \<Rightarrow> trm6"
  1004 as
  1003 as
  1005   "rAp6"
  1004   "rLm6"
  1006 
  1005 
  1007 quotient_definition
  1006 quotient_definition
  1008   "Fo6 :: trm6 \<Rightarrow> trm6 \<Rightarrow> trm6"
  1007   "Lt6 :: trm6 \<Rightarrow> trm6 \<Rightarrow> trm6"
  1009 as
  1008 as
  1010   "rFo6"
  1009   "rLt6"
  1011 
  1010 
  1012 quotient_definition
  1011 quotient_definition
  1013    "fv_trm6 :: trm6 \<Rightarrow> atom set"
  1012    "fv_trm6 :: trm6 \<Rightarrow> atom set"
  1014 as
  1013 as
  1015   "rfv_trm6"
  1014   "rfv_trm6"
  1018    "bv6 :: trm6 \<Rightarrow> atom set"
  1017    "bv6 :: trm6 \<Rightarrow> atom set"
  1019 as
  1018 as
  1020   "rbv6"
  1019   "rbv6"
  1021 
  1020 
  1022 lemma [quot_respect]:
  1021 lemma [quot_respect]:
  1023   "(op = ===> alpha1 ===> alpha1) permute permute"
  1022   "(op = ===> alpha6 ===> alpha6) permute permute"
  1024 apply auto (* eqvt *)
  1023 apply auto (* will work with eqvt *)
  1025 sorry
  1024 sorry
       
  1025 
       
  1026 (* Definitely not true , see lemma below *)
  1026 
  1027 
  1027 lemma [quot_respect]:"(alpha6 ===> op =) rbv6 rbv6"
  1028 lemma [quot_respect]:"(alpha6 ===> op =) rbv6 rbv6"
  1028 apply simp apply clarify
  1029 apply simp apply clarify
  1029 apply (erule alpha6.induct)
  1030 apply (erule alpha6.induct)
       
  1031 oops
       
  1032 
       
  1033 lemma "(a :: name) \<noteq> b \<Longrightarrow> \<not> (alpha6 ===> op =) rbv6 rbv6"
  1030 apply simp
  1034 apply simp
       
  1035 apply (rule_tac x="rLm6 (a::name) (rVr6 (a :: name))" in  exI)
       
  1036 apply (rule_tac x="rLm6 (b::name) (rVr6 (b :: name))" in  exI)
  1031 apply simp
  1037 apply simp
  1032 apply (erule exE)
  1038 apply (rule a2)
  1033 apply (simp add: alpha_gen)
  1039 apply (rule_tac x="(a \<leftrightarrow> b)" in  exI)
  1034 oops
  1040 apply (simp add: alpha_gen fresh_star_def)
       
  1041 apply (rule a1)
       
  1042 apply (rule refl)
       
  1043 done
  1035 
  1044 
  1036 lemma [quot_respect]:"(alpha6 ===> op =) rfv_trm6 rfv_trm6"
  1045 lemma [quot_respect]:"(alpha6 ===> op =) rfv_trm6 rfv_trm6"
  1037 apply simp apply clarify
  1046 apply simp apply clarify
  1038 apply (induct_tac x y rule: alpha6.induct)
  1047 apply (induct_tac x y rule: alpha6.induct)
  1039 apply simp_all
  1048 apply simp_all
  1040 apply (erule exE)
  1049 apply (erule exE)
       
  1050 apply (simp_all add: alpha_gen)
       
  1051 apply (erule conjE)+
       
  1052 apply (erule exE)
       
  1053 apply (erule conjE)+
       
  1054 apply (simp)
       
  1055 oops
       
  1056 
       
  1057 
       
  1058 lemma [quot_respect]: "(op = ===> alpha6) rVr6 rVr6"
       
  1059 by (simp_all add: a1)
       
  1060 
       
  1061 lemma [quot_respect]:
       
  1062  "(op = ===> alpha6 ===> alpha6) rLm6 rLm6"
       
  1063  "(alpha6 ===> alpha6 ===> alpha6) rLt6 rLt6"
       
  1064 apply simp_all apply (clarify)
       
  1065 apply (rule a2)
       
  1066 apply (rule_tac x="0::perm" in exI)
  1041 apply (simp add: alpha_gen)
  1067 apply (simp add: alpha_gen)
  1042 apply (erule conjE)+
  1068 (* needs rfv6_rsp *) defer
  1043 oops
       
  1044 
       
  1045 lemma [quot_respect]:
       
  1046  "(op = ===> alpha6) rVr6 rVr6"
       
  1047  "(alpha6 ===> alpha6 ===> alpha6) rAp6 rAp6"
       
  1048  "(alpha6 ===> alpha6 ===> alpha6) rFo6 rFo6"
       
  1049 apply (simp_all add: a1 a2)
       
  1050 apply clarify
  1069 apply clarify
  1051 apply (rule a3)
  1070 apply (rule a3)
  1052 apply (rule_tac x="0::perm" in exI)
  1071 apply (rule_tac x="0::perm" in exI)
  1053 apply (simp add: alpha_gen)
  1072 apply (simp add: alpha_gen)
  1054 (* needs rbv6_rsp *)
  1073 (* needs rbv6_rsp *)
  1064 instance
  1083 instance
  1065 apply default
  1084 apply default
  1066 sorry
  1085 sorry
  1067 end
  1086 end
  1068 
  1087 
  1069 lemma 
  1088 lemma lifted_induct:
  1070 "\<lbrakk>x1 = x2; \<And>a b. a = b \<Longrightarrow> P (Vr6 a) (Vr6 b);
  1089 "\<lbrakk>x1 = x2; \<And>a b. a = b \<Longrightarrow> P (Vr6 a) (Vr6 b);
  1071   \<And>t1 t2 s1 s2. \<lbrakk>t1 = t2; P t1 t2; s1 = s2; P s1 s2\<rbrakk> \<Longrightarrow> P (Ap6 t1 s1) (Ap6 t2 s2);
  1090  \<And>a t b s.
  1072   \<And>l1 r1 l2 r2.
  1091    \<exists>pi. fv_trm6 t - {atom a} = fv_trm6 s - {atom b} \<and>
  1073      \<exists>pi. (bv6 l1, r1) \<approx>gen (\<lambda>x1 x2. x1 = x2 \<and> P x1 x2) fv_trm6 pi (bv6 l2, r2) \<Longrightarrow>
  1092         (fv_trm6 t - {atom a}) \<sharp>* pi \<and> pi \<bullet> t = s \<and> P (pi \<bullet> t) s \<Longrightarrow>
  1074      P (Fo6 l1 r1) (Fo6 l2 r2)\<rbrakk>
  1093    P (Lm6 a t) (Lm6 b s);
       
  1094  \<And>t1 s1 t2 s2.
       
  1095    \<exists>pi. fv_trm6 s1 - bv6 t1 = fv_trm6 s2 - bv6 t2 \<and>
       
  1096         (fv_trm6 s1 - bv6 t1) \<sharp>* pi \<and> pi \<bullet> s1 = s2 \<and> P (pi \<bullet> s1) s2 \<Longrightarrow>
       
  1097    P (Lt6 t1 s1) (Lt6 t2 s2)\<rbrakk>
  1075  \<Longrightarrow> P x1 x2"
  1098  \<Longrightarrow> P x1 x2"
  1076 unfolding alpha_gen
  1099 unfolding alpha_gen
  1077 apply (lifting alpha6.induct[unfolded alpha_gen])
  1100 apply (lifting alpha6.induct[unfolded alpha_gen])
  1078 apply(injection)
       
  1079 sorry
       
  1080 
       
  1081 lemma "\<lbrakk>\<exists>pi. ((bv6 l1, r1) \<approx>gen (op =) fv_trm6 pi (bv6 l2, r2))\<rbrakk>
       
  1082         \<Longrightarrow> Fo6 l1 r1 = Fo6 l2 r2"
       
  1083 apply (unfold alpha_gen)
       
  1084 apply (lifting a3[unfolded alpha_gen])
       
  1085 apply injection
  1101 apply injection
  1086 sorry
  1102 (* notice unsolvable goals: (alpha6 ===> op =) rbv6 rbv6 *)
       
  1103 oops
       
  1104 
       
  1105 lemma lifted_inject_a3:
       
  1106  "\<exists>pi. fv_trm6 s1 - bv6 t1 = fv_trm6 s2 - bv6 t2 \<and>
       
  1107     (fv_trm6 s1 - bv6 t1) \<sharp>* pi \<and> pi \<bullet> s1 = s2 \<Longrightarrow> Lt6 t1 s1 = Lt6 t2 s2"
       
  1108 apply(lifting a3[unfolded alpha_gen])
       
  1109 apply injection
       
  1110 (* notice unsolvable goals: (alpha6 ===> op =) rbv6 rbv6 *)
       
  1111 oops
       
  1112 
  1087 
  1113 
  1088 
  1114 
  1089 
  1115 
  1090 
  1116 
  1091 
  1117