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