src/ZF/Constructible/Datatype_absolute.thy
 author paulson Fri Jul 12 16:41:39 2002 +0200 (2002-07-12) changeset 13353 1800e7134d2e parent 13352 3cd767f8d78b child 13363 c26eeb000470 permissions -rw-r--r--
towards relativization of "iterates" and "wfrec"
```     1 header {*Absoluteness Properties for Recursive Datatypes*}
```
```     2
```
```     3 theory Datatype_absolute = Formula + WF_absolute:
```
```     4
```
```     5
```
```     6 subsection{*The lfp of a continuous function can be expressed as a union*}
```
```     7
```
```     8 constdefs
```
```     9   contin :: "[i=>i]=>o"
```
```    10    "contin(h) == (\<forall>A. A\<noteq>0 --> h(\<Union>A) = (\<Union>X\<in>A. h(X)))"
```
```    11
```
```    12 lemma bnd_mono_iterates_subset: "[|bnd_mono(D, h); n \<in> nat|] ==> h^n (0) <= D"
```
```    13 apply (induct_tac n)
```
```    14  apply (simp_all add: bnd_mono_def, blast)
```
```    15 done
```
```    16
```
```    17
```
```    18 lemma contin_iterates_eq:
```
```    19     "contin(h) \<Longrightarrow> h(\<Union>n\<in>nat. h^n (0)) = (\<Union>n\<in>nat. h^n (0))"
```
```    20 apply (simp add: contin_def)
```
```    21 apply (rule trans)
```
```    22 apply (rule equalityI)
```
```    23  apply (simp_all add: UN_subset_iff)
```
```    24  apply safe
```
```    25  apply (erule_tac [2] natE)
```
```    26   apply (rule_tac a="succ(x)" in UN_I)
```
```    27    apply simp_all
```
```    28 apply blast
```
```    29 done
```
```    30
```
```    31 lemma lfp_subset_Union:
```
```    32      "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) <= (\<Union>n\<in>nat. h^n(0))"
```
```    33 apply (rule lfp_lowerbound)
```
```    34  apply (simp add: contin_iterates_eq)
```
```    35 apply (simp add: contin_def bnd_mono_iterates_subset UN_subset_iff)
```
```    36 done
```
```    37
```
```    38 lemma Union_subset_lfp:
```
```    39      "bnd_mono(D,h) ==> (\<Union>n\<in>nat. h^n(0)) <= lfp(D,h)"
```
```    40 apply (simp add: UN_subset_iff)
```
```    41 apply (rule ballI)
```
```    42 apply (induct_tac n, simp_all)
```
```    43 apply (rule subset_trans [of _ "h(lfp(D,h))"])
```
```    44  apply (blast dest: bnd_monoD2 [OF _ _ lfp_subset] )
```
```    45 apply (erule lfp_lemma2)
```
```    46 done
```
```    47
```
```    48 lemma lfp_eq_Union:
```
```    49      "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) = (\<Union>n\<in>nat. h^n(0))"
```
```    50 by (blast del: subsetI
```
```    51           intro: lfp_subset_Union Union_subset_lfp)
```
```    52
```
```    53
```
```    54 subsection {*lists without univ*}
```
```    55
```
```    56 lemmas datatype_univs = A_into_univ Inl_in_univ Inr_in_univ
```
```    57                         Pair_in_univ zero_in_univ
```
```    58
```
```    59 lemma list_fun_bnd_mono: "bnd_mono(univ(A), \<lambda>X. {0} + A*X)"
```
```    60 apply (rule bnd_monoI)
```
```    61  apply (intro subset_refl zero_subset_univ A_subset_univ
```
```    62 	      sum_subset_univ Sigma_subset_univ)
```
```    63  apply (blast intro!: subset_refl sum_mono Sigma_mono del: subsetI)
```
```    64 done
```
```    65
```
```    66 lemma list_fun_contin: "contin(\<lambda>X. {0} + A*X)"
```
```    67 by (simp add: contin_def, blast)
```
```    68
```
```    69 text{*Re-expresses lists using sum and product*}
```
```    70 lemma list_eq_lfp2: "list(A) = lfp(univ(A), \<lambda>X. {0} + A*X)"
```
```    71 apply (simp add: list_def)
```
```    72 apply (rule equalityI)
```
```    73  apply (rule lfp_lowerbound)
```
```    74   prefer 2 apply (rule lfp_subset)
```
```    75  apply (clarify, subst lfp_unfold [OF list_fun_bnd_mono])
```
```    76  apply (simp add: Nil_def Cons_def)
```
```    77  apply blast
```
```    78 txt{*Opposite inclusion*}
```
```    79 apply (rule lfp_lowerbound)
```
```    80  prefer 2 apply (rule lfp_subset)
```
```    81 apply (clarify, subst lfp_unfold [OF list.bnd_mono])
```
```    82 apply (simp add: Nil_def Cons_def)
```
```    83 apply (blast intro: datatype_univs
```
```    84              dest: lfp_subset [THEN subsetD])
```
```    85 done
```
```    86
```
```    87 text{*Re-expresses lists using "iterates", no univ.*}
```
```    88 lemma list_eq_Union:
```
```    89      "list(A) = (\<Union>n\<in>nat. (\<lambda>X. {0} + A*X) ^ n (0))"
```
```    90 by (simp add: list_eq_lfp2 lfp_eq_Union list_fun_bnd_mono list_fun_contin)
```
```    91
```
```    92
```
```    93 subsection {*Absoluteness for "Iterates"*}
```
```    94
```
```    95 constdefs
```
```    96
```
```    97   iterates_MH :: "[i=>o, [i,i]=>o, i, i, i, i] => o"
```
```    98    "iterates_MH(M,isF,v,n,g,z) ==
```
```    99         is_nat_case(M, v, \<lambda>m u. \<exists>gm[M]. fun_apply(M,g,m,gm) & isF(gm,u),
```
```   100                     n, z)"
```
```   101
```
```   102   iterates_replacement :: "[i=>o, [i,i]=>o, i] => o"
```
```   103    "iterates_replacement(M,isF,v) ==
```
```   104       \<forall>n[M]. n\<in>nat -->
```
```   105          wfrec_replacement(M, iterates_MH(M,isF,v), Memrel(succ(n)))"
```
```   106
```
```   107 lemma (in M_axioms) iterates_MH_abs:
```
```   108   "[| relativize1(M,isF,F); M(n); M(g); M(z) |]
```
```   109    ==> iterates_MH(M,isF,v,n,g,z) <-> z = nat_case(v, \<lambda>m. F(g`m), n)"
```
```   110 apply (simp add: iterates_MH_def)
```
```   111 apply (rule nat_case_abs)
```
```   112 apply (simp_all add: relativize1_def)
```
```   113 done
```
```   114
```
```   115
```
```   116 lemma (in M_axioms) iterates_imp_wfrec_replacement:
```
```   117   "[|relativize1(M,isF,F); n \<in> nat; iterates_replacement(M,isF,v)|]
```
```   118    ==> wfrec_replacement(M, \<lambda>n f z. z = nat_case(v, \<lambda>m. F(f`m), n),
```
```   119                        Memrel(succ(n)))"
```
```   120 by (simp add: iterates_replacement_def iterates_MH_abs)
```
```   121
```
```   122 theorem (in M_trancl) iterates_abs:
```
```   123   "[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
```
```   124       n \<in> nat; M(v); M(z); \<forall>x[M]. M(F(x)) |]
```
```   125    ==> is_wfrec(M, iterates_MH(M,isF,v), Memrel(succ(n)), n, z) <->
```
```   126        z = iterates(F,n,v)"
```
```   127 apply (frule iterates_imp_wfrec_replacement, assumption+)
```
```   128 apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
```
```   129                  relativize2_def iterates_MH_abs
```
```   130                  iterates_nat_def recursor_def transrec_def
```
```   131                  eclose_sing_Ord_eq nat_into_M
```
```   132          trans_wfrec_abs [of _ _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
```
```   133 done
```
```   134
```
```   135
```
```   136 lemma (in M_wfrank) iterates_closed [intro,simp]:
```
```   137   "[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
```
```   138       n \<in> nat; M(v); \<forall>x[M]. M(F(x)) |]
```
```   139    ==> M(iterates(F,n,v))"
```
```   140 apply (frule iterates_imp_wfrec_replacement, assumption+)
```
```   141 apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
```
```   142                  relativize2_def iterates_MH_abs
```
```   143                  iterates_nat_def recursor_def transrec_def
```
```   144                  eclose_sing_Ord_eq nat_into_M
```
```   145          trans_wfrec_closed [of _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
```
```   146 done
```
```   147
```
```   148
```
```   149 constdefs
```
```   150   is_list_functor :: "[i=>o,i,i,i] => o"
```
```   151     "is_list_functor(M,A,X,Z) ==
```
```   152         \<exists>n1[M]. \<exists>AX[M].
```
```   153          number1(M,n1) & cartprod(M,A,X,AX) & is_sum(M,n1,AX,Z)"
```
```   154
```
```   155 lemma (in M_axioms) list_functor_abs [simp]:
```
```   156      "[| M(A); M(X); M(Z) |] ==> is_list_functor(M,A,X,Z) <-> (Z = {0} + A*X)"
```
```   157 by (simp add: is_list_functor_def singleton_0 nat_into_M)
```
```   158
```
```   159
```
```   160 locale M_datatypes = M_wfrank +
```
```   161  assumes list_replacement1:
```
```   162    "M(A) ==> \<exists>zero[M]. empty(M,zero) &
```
```   163 		       iterates_replacement(M, is_list_functor(M,A), zero)"
```
```   164   and list_replacement2:
```
```   165    "M(A) ==>
```
```   166     \<exists>zero[M]. empty(M,zero) &
```
```   167 	      strong_replacement(M,
```
```   168          \<lambda>n y. n\<in>nat &
```
```   169                (\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
```
```   170                is_wfrec(M, iterates_MH(M,is_list_functor(M,A), zero),
```
```   171                         msn, n, y)))"
```
```   172
```
```   173 lemma (in M_datatypes) list_replacement1':
```
```   174    "M(A) ==> iterates_replacement(M, is_list_functor(M,A), 0)"
```
```   175 apply (insert list_replacement1, simp)
```
```   176 done
```
```   177
```
```   178 lemma (in M_datatypes) list_replacement2':
```
```   179   "M(A) ==> strong_replacement(M, \<lambda>n y. n\<in>nat & y = (\<lambda>X. {0} + A * X)^n (0))"
```
```   180 apply (insert list_replacement2 [of A])
```
```   181 apply (rule strong_replacement_cong [THEN iffD1])
```
```   182 apply (rule conj_cong [OF iff_refl iterates_abs [of "is_list_functor(M,A)"]])
```
```   183 apply (simp_all add: list_replacement1' relativize1_def)
```
```   184 done
```
```   185
```
```   186 lemma (in M_datatypes) list_closed [intro,simp]:
```
```   187      "M(A) ==> M(list(A))"
```
```   188 apply (insert list_replacement1)
```
```   189 by  (simp add: RepFun_closed2 list_eq_Union
```
```   190                list_replacement2' relativize1_def
```
```   191                iterates_closed [of "is_list_functor(M,A)"])
```
```   192
```
```   193
```
```   194 end
```