src/ZF/Constructible/Datatype_absolute.thy
 author paulson Thu Jul 04 10:54:04 2002 +0200 (2002-07-04) changeset 13293 09276ee04361 parent 13269 3ba9be497c33 child 13306 6eebcddee32b permissions -rw-r--r--
tweaks
```     1 theory Datatype_absolute = Formula + WF_absolute:
```
```     2
```
```     3
```
```     4 subsection{*The lfp of a continuous function can be expressed as a union*}
```
```     5
```
```     6 constdefs
```
```     7   contin :: "[i=>i]=>o"
```
```     8    "contin(h) == (\<forall>A. A\<noteq>0 --> h(\<Union>A) = (\<Union>X\<in>A. h(X)))"
```
```     9
```
```    10 lemma bnd_mono_iterates_subset: "[|bnd_mono(D, h); n \<in> nat|] ==> h^n (0) <= D"
```
```    11 apply (induct_tac n)
```
```    12  apply (simp_all add: bnd_mono_def, blast)
```
```    13 done
```
```    14
```
```    15
```
```    16 lemma contin_iterates_eq:
```
```    17     "contin(h) \<Longrightarrow> h(\<Union>n\<in>nat. h^n (0)) = (\<Union>n\<in>nat. h^n (0))"
```
```    18 apply (simp add: contin_def)
```
```    19 apply (rule trans)
```
```    20 apply (rule equalityI)
```
```    21  apply (simp_all add: UN_subset_iff)
```
```    22  apply safe
```
```    23  apply (erule_tac [2] natE)
```
```    24   apply (rule_tac a="succ(x)" in UN_I)
```
```    25    apply simp_all
```
```    26 apply blast
```
```    27 done
```
```    28
```
```    29 lemma lfp_subset_Union:
```
```    30      "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) <= (\<Union>n\<in>nat. h^n(0))"
```
```    31 apply (rule lfp_lowerbound)
```
```    32  apply (simp add: contin_iterates_eq)
```
```    33 apply (simp add: contin_def bnd_mono_iterates_subset UN_subset_iff)
```
```    34 done
```
```    35
```
```    36 lemma Union_subset_lfp:
```
```    37      "bnd_mono(D,h) ==> (\<Union>n\<in>nat. h^n(0)) <= lfp(D,h)"
```
```    38 apply (simp add: UN_subset_iff)
```
```    39 apply (rule ballI)
```
```    40 apply (induct_tac x, simp_all)
```
```    41 apply (rule subset_trans [of _ "h(lfp(D,h))"])
```
```    42  apply (blast dest: bnd_monoD2 [OF _ _ lfp_subset] )
```
```    43 apply (erule lfp_lemma2)
```
```    44 done
```
```    45
```
```    46 lemma lfp_eq_Union:
```
```    47      "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) = (\<Union>n\<in>nat. h^n(0))"
```
```    48 by (blast del: subsetI
```
```    49           intro: lfp_subset_Union Union_subset_lfp)
```
```    50
```
```    51
```
```    52 subsection {*lists without univ*}
```
```    53
```
```    54 lemmas datatype_univs = A_into_univ Inl_in_univ Inr_in_univ
```
```    55                         Pair_in_univ zero_in_univ
```
```    56
```
```    57 lemma list_fun_bnd_mono: "bnd_mono(univ(A), \<lambda>X. {0} + A*X)"
```
```    58 apply (rule bnd_monoI)
```
```    59  apply (intro subset_refl zero_subset_univ A_subset_univ
```
```    60 	      sum_subset_univ Sigma_subset_univ)
```
```    61  apply (blast intro!: subset_refl sum_mono Sigma_mono del: subsetI)
```
```    62 done
```
```    63
```
```    64 lemma list_fun_contin: "contin(\<lambda>X. {0} + A*X)"
```
```    65 by (simp add: contin_def, blast)
```
```    66
```
```    67 text{*Re-expresses lists using sum and product*}
```
```    68 lemma list_eq_lfp2: "list(A) = lfp(univ(A), \<lambda>X. {0} + A*X)"
```
```    69 apply (simp add: list_def)
```
```    70 apply (rule equalityI)
```
```    71  apply (rule lfp_lowerbound)
```
```    72   prefer 2 apply (rule lfp_subset)
```
```    73  apply (clarify, subst lfp_unfold [OF list_fun_bnd_mono])
```
```    74  apply (simp add: Nil_def Cons_def)
```
```    75  apply blast
```
```    76 txt{*Opposite inclusion*}
```
```    77 apply (rule lfp_lowerbound)
```
```    78  prefer 2 apply (rule lfp_subset)
```
```    79 apply (clarify, subst lfp_unfold [OF list.bnd_mono])
```
```    80 apply (simp add: Nil_def Cons_def)
```
```    81 apply (blast intro: datatype_univs
```
```    82              dest: lfp_subset [THEN subsetD])
```
```    83 done
```
```    84
```
```    85 text{*Re-expresses lists using "iterates", no univ.*}
```
```    86 lemma list_eq_Union:
```
```    87      "list(A) = (\<Union>n\<in>nat. (\<lambda>X. {0} + A*X) ^ n (0))"
```
```    88 by (simp add: list_eq_lfp2 lfp_eq_Union list_fun_bnd_mono list_fun_contin)
```
```    89
```
```    90
```
```    91 subsection {*Absoluteness for "Iterates"*}
```
```    92
```
```    93 lemma (in M_trancl) iterates_relativize:
```
```    94   "[|n \<in> nat; M(v); \<forall>x[M]. M(F(x));
```
```    95      strong_replacement(M,
```
```    96        \<lambda>x z. \<exists>y[M]. \<exists>g[M]. pair(M, x, y, z) &
```
```    97               is_recfun (Memrel(succ(n)), x,
```
```    98                          \<lambda>n f. nat_case(v, \<lambda>m. F(f`m), n), g) &
```
```    99               y = nat_case(v, \<lambda>m. F(g`m), x))|]
```
```   100    ==> iterates(F,n,v) = z <->
```
```   101        (\<exists>g[M]. is_recfun(Memrel(succ(n)), n,
```
```   102                              \<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n), g) &
```
```   103             z = nat_case(v, \<lambda>m. F(g`m), n))"
```
```   104 by (simp add: iterates_nat_def recursor_def transrec_def
```
```   105               eclose_sing_Ord_eq trans_wfrec_relativize nat_into_M
```
```   106               wf_Memrel trans_Memrel relation_Memrel nat_case_closed)
```
```   107
```
```   108
```
```   109 lemma (in M_wfrank) iterates_closed [intro,simp]:
```
```   110   "[|n \<in> nat; M(v); \<forall>x[M]. M(F(x));
```
```   111      strong_replacement(M,
```
```   112        \<lambda>x z. \<exists>y[M]. \<exists>g[M]. pair(M, x, y, z) &
```
```   113               is_recfun (Memrel(succ(n)), x,
```
```   114                          \<lambda>n f. nat_case(v, \<lambda>m. F(f`m), n), g) &
```
```   115               y = nat_case(v, \<lambda>m. F(g`m), x))|]
```
```   116    ==> M(iterates(F,n,v))"
```
```   117 by (simp add: iterates_nat_def recursor_def transrec_def
```
```   118               eclose_sing_Ord_eq trans_wfrec_closed nat_into_M
```
```   119               wf_Memrel trans_Memrel relation_Memrel nat_case_closed)
```
```   120
```
```   121
```
```   122
```
```   123 locale M_datatypes = M_wfrank +
```
```   124 (*THEY NEED RELATIVIZATION*)
```
```   125   assumes list_replacement1:
```
```   126 	   "[|M(A); n \<in> nat|] ==>
```
```   127 	    strong_replacement(M,
```
```   128 	      \<lambda>x z. \<exists>y[M]. \<exists>g[M]. \<exists>sucn[M]. \<exists>memr[M].
```
```   129                      pair(M,x,y,z) & successor(M,n,sucn) &
```
```   130                      membership(M,sucn,memr) &
```
```   131 		     is_recfun (memr, x,
```
```   132 				\<lambda>n f. nat_case(0, \<lambda>m. {0} + A \<times> f`m, n), g) &
```
```   133 		     y = nat_case(0, \<lambda>m. {0} + A \<times> g`m, x))"
```
```   134       and list_replacement2':
```
```   135            "M(A) ==> strong_replacement(M, \<lambda>x y. y = (\<lambda>X. {0} + A \<times> X)^x (0))"
```
```   136
```
```   137
```
```   138 lemma (in M_datatypes) list_replacement1':
```
```   139   "[|M(A); n \<in> nat|]
```
```   140    ==> strong_replacement
```
```   141 	  (M, \<lambda>x y. \<exists>z[M]. y = \<langle>x,z\<rangle> &
```
```   142                (\<exists>g[M]. is_recfun (Memrel(succ(n)), x,
```
```   143 		          \<lambda>n f. nat_case(0, \<lambda>m. {0} + A \<times> f`m, n), g) &
```
```   144  	       z = nat_case(0, \<lambda>m. {0} + A \<times> g ` m, x)))"
```
```   145 by (insert list_replacement1, simp add: nat_into_M)
```
```   146
```
```   147
```
```   148 lemma (in M_datatypes) list_closed [intro,simp]:
```
```   149      "M(A) ==> M(list(A))"
```
```   150 by (simp add: list_eq_Union list_replacement1' list_replacement2')
```
```   151
```
```   152
```
```   153 end
```