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